Search in sources :

Example 36 with PreferenceCategory

use of android.preference.PreferenceCategory in project android by nextcloud.

the class SettingsActivity method setupAutoUploadCategory.

private void setupAutoUploadCategory(int accentColor, PreferenceScreen preferenceScreen) {
    PreferenceCategory preferenceCategorySyncedFolders = (PreferenceCategory) findPreference("synced_folders_category");
    preferenceCategorySyncedFolders.setTitle(ThemeTextUtils.getColoredTitle(getString(R.string.drawer_synced_folders), accentColor));
    if (!getResources().getBoolean(R.bool.syncedFolder_light)) {
        preferenceScreen.removePreference(preferenceCategorySyncedFolders);
    } else {
        // Upload on WiFi
        final ArbitraryDataProvider arbitraryDataProvider = new ArbitraryDataProvider(getContentResolver());
        final SwitchPreference pUploadOnWifiCheckbox = (SwitchPreference) findPreference("synced_folder_on_wifi");
        pUploadOnWifiCheckbox.setChecked(arbitraryDataProvider.getBooleanValue(user, SYNCED_FOLDER_LIGHT_UPLOAD_ON_WIFI));
        pUploadOnWifiCheckbox.setOnPreferenceClickListener(preference -> {
            arbitraryDataProvider.storeOrUpdateKeyValue(user.getAccountName(), SYNCED_FOLDER_LIGHT_UPLOAD_ON_WIFI, String.valueOf(pUploadOnWifiCheckbox.isChecked()));
            return true;
        });
        Preference pSyncedFolder = findPreference("synced_folders_configure_folders");
        if (pSyncedFolder != null) {
            if (getResources().getBoolean(R.bool.syncedFolder_light)) {
                pSyncedFolder.setOnPreferenceClickListener(preference -> {
                    Intent intent = new Intent(this, SyncedFoldersActivity.class);
                    startActivity(intent);
                    return true;
                });
            } else {
                preferenceCategorySyncedFolders.removePreference(pSyncedFolder);
            }
        }
    }
}
Also used : PreferenceCategory(android.preference.PreferenceCategory) SwitchPreference(android.preference.SwitchPreference) ListPreference(android.preference.ListPreference) Preference(android.preference.Preference) SwitchPreference(android.preference.SwitchPreference) ArbitraryDataProvider(com.owncloud.android.datamodel.ArbitraryDataProvider) Intent(android.content.Intent)

Example 37 with PreferenceCategory

use of android.preference.PreferenceCategory in project android by nextcloud.

the class SettingsActivity method setupAboutCategory.

private void setupAboutCategory(int accentColor, String appVersion) {
    PreferenceCategory preferenceCategoryAbout = (PreferenceCategory) findPreference("about");
    preferenceCategoryAbout.setTitle(ThemeTextUtils.getColoredTitle(getString(R.string.prefs_category_about), accentColor));
    /* About App */
    Preference pAboutApp = findPreference("about_app");
    if (pAboutApp != null) {
        pAboutApp.setTitle(String.format(getString(R.string.about_android), getString(R.string.app_name)));
        String buildNumber = getResources().getString(R.string.buildNumber);
        if (TextUtils.isEmpty(buildNumber)) {
            pAboutApp.setSummary(String.format(getString(R.string.about_version), appVersion));
        } else {
            pAboutApp.setSummary(String.format(getString(R.string.about_version_with_build), appVersion, buildNumber));
        }
    }
    // license
    boolean licenseEnabled = getResources().getBoolean(R.bool.license_enabled);
    Preference licensePreference = findPreference("license");
    if (licensePreference != null) {
        if (licenseEnabled) {
            licensePreference.setSummary(R.string.prefs_gpl_v2);
            licensePreference.setOnPreferenceClickListener(preference -> {
                DisplayUtils.startLinkIntent(this, R.string.license_url);
                return true;
            });
        } else {
            preferenceCategoryAbout.removePreference(licensePreference);
        }
    }
    // privacy
    boolean privacyEnabled = getResources().getBoolean(R.bool.privacy_enabled);
    Preference privacyPreference = findPreference("privacy");
    if (privacyPreference != null) {
        if (privacyEnabled && URLUtil.isValidUrl(getString(R.string.privacy_url))) {
            privacyPreference.setOnPreferenceClickListener(preference -> {
                try {
                    Uri privacyUrl = Uri.parse(getString(R.string.privacy_url));
                    String mimeType = MimeTypeUtil.getBestMimeTypeByFilename(privacyUrl.getLastPathSegment());
                    Intent intent;
                    if ("application/pdf".equals(mimeType)) {
                        intent = new Intent(Intent.ACTION_VIEW, privacyUrl);
                        DisplayUtils.startIntentIfAppAvailable(intent, this, R.string.no_pdf_app_available);
                    } else {
                        intent = new Intent(getApplicationContext(), ExternalSiteWebView.class);
                        intent.putExtra(ExternalSiteWebView.EXTRA_TITLE, getResources().getString(R.string.privacy));
                        intent.putExtra(ExternalSiteWebView.EXTRA_URL, privacyUrl.toString());
                        intent.putExtra(ExternalSiteWebView.EXTRA_SHOW_SIDEBAR, false);
                        intent.putExtra(ExternalSiteWebView.EXTRA_MENU_ITEM_ID, -1);
                    }
                    startActivity(intent);
                } catch (Exception e) {
                    Log_OC.e(TAG, "Could not parse privacy url");
                    preferenceCategoryAbout.removePreference(privacyPreference);
                }
                return true;
            });
        } else {
            preferenceCategoryAbout.removePreference(privacyPreference);
        }
    }
    // source code
    boolean sourcecodeEnabled = getResources().getBoolean(R.bool.sourcecode_enabled);
    Preference sourcecodePreference = findPreference("sourcecode");
    if (sourcecodePreference != null) {
        if (sourcecodeEnabled) {
            sourcecodePreference.setOnPreferenceClickListener(preference -> {
                DisplayUtils.startLinkIntent(this, R.string.sourcecode_url);
                return true;
            });
        } else {
            preferenceCategoryAbout.removePreference(sourcecodePreference);
        }
    }
}
Also used : PreferenceCategory(android.preference.PreferenceCategory) ListPreference(android.preference.ListPreference) Preference(android.preference.Preference) SwitchPreference(android.preference.SwitchPreference) Intent(android.content.Intent) Uri(android.net.Uri) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException)

Example 38 with PreferenceCategory

use of android.preference.PreferenceCategory in project Taskbar by farmerbb.

the class DesktopModeFragment method loadPrefs.

@Override
protected void loadPrefs() {
    // Add preferences
    addPreferencesFromResource(R.xml.tb_pref_desktop_mode);
    // Set OnClickListeners for certain preferences
    findPreference(PREF_DESKTOP_MODE).setOnPreferenceClickListener(this);
    findPreference(PREF_SET_LAUNCHER_DEFAULT).setOnPreferenceClickListener(this);
    findPreference(PREF_PRIMARY_LAUNCHER).setOnPreferenceClickListener(this);
    findPreference(PREF_DIM_SCREEN).setOnPreferenceClickListener(this);
    findPreference(PREF_ENABLE_ADDITIONAL_SETTINGS).setOnPreferenceClickListener(this);
    if (!U.isShowHideNavbarSupported()) {
        PreferenceCategory category = (PreferenceCategory) findPreference(PREF_ADDITIONAL_SETTINGS);
        category.removePreference(findPreference(PREF_AUTO_HIDE_NAVBAR_DESKTOP_MODE));
    }
    if (U.getCurrentApiVersion() > 29.0)
        findPreference(PREF_DESKTOP_MODE_IME_FIX).setOnPreferenceClickListener(this);
    else
        getPreferenceScreen().removePreference(findPreference(PREF_DESKTOP_MODE_IME_FIX));
    SharedPreferences pref = U.getSharedPreferences(getActivity());
    if (pref.getBoolean(PREF_LAUNCHER, false)) {
        findPreference(PREF_DESKTOP_MODE).setEnabled(false);
        U.showToastLong(getActivity(), R.string.tb_disable_home_setting);
    } else
        bindPreferenceSummaryToValue(findPreference(PREF_DESKTOP_MODE));
    bindPreferenceSummaryToValue(findPreference(PREF_DISPLAY_DENSITY));
    DisplayManager manager = (DisplayManager) getActivity().getSystemService(Context.DISPLAY_SERVICE);
    manager.registerDisplayListener(listener, null);
    updateAdditionalSettings();
}
Also used : PreferenceCategory(android.preference.PreferenceCategory) SharedPreferences(android.content.SharedPreferences) DisplayManager(android.hardware.display.DisplayManager)

Example 39 with PreferenceCategory

use of android.preference.PreferenceCategory in project android by owncloud.

the class Preferences method onCreate.

@SuppressWarnings("deprecation")
@Override
public void onCreate(Bundle savedInstanceState) {
    getDelegate().installViewFactory();
    getDelegate().onCreate(savedInstanceState);
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.preferences);
    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setTitle(R.string.actionbar_settings);
    // For adding content description tag to a title field in the action bar
    int actionBarTitleId = getResources().getIdentifier("action_bar_title", "id", "android");
    View actionBarTitleView = getWindow().getDecorView().findViewById(actionBarTitleId);
    if (actionBarTitleView != null) {
        // it's null in Android 2.x
        getWindow().getDecorView().findViewById(actionBarTitleId).setContentDescription(getString(R.string.actionbar_settings));
    }
    // Load package info
    String temp;
    try {
        PackageInfo pkg = getPackageManager().getPackageInfo(getPackageName(), 0);
        temp = pkg.versionName;
    } catch (NameNotFoundException e) {
        temp = "";
        Log_OC.e(TAG, "Error while showing about dialog", e);
    }
    final String appVersion = temp;
    // Register context menu for list of preferences.
    registerForContextMenu(getListView());
    pCode = (CheckBoxPreference) findPreference(PassCodeActivity.PREFERENCE_SET_PASSCODE);
    if (pCode != null) {
        pCode.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {

            @Override
            public boolean onPreferenceChange(Preference preference, Object newValue) {
                Intent i = new Intent(getApplicationContext(), PassCodeActivity.class);
                Boolean incoming = (Boolean) newValue;
                i.setAction(incoming ? PassCodeActivity.ACTION_REQUEST_WITH_RESULT : PassCodeActivity.ACTION_CHECK_WITH_RESULT);
                startActivityForResult(i, incoming ? ACTION_REQUEST_PASSCODE : ACTION_CONFIRM_PASSCODE);
                // Don't update just yet, we will decide on it in onActivityResult
                return false;
            }
        });
    }
    PreferenceCategory preferenceCategory = (PreferenceCategory) findPreference("more");
    boolean helpEnabled = getResources().getBoolean(R.bool.help_enabled);
    Preference pHelp = findPreference("help");
    if (pHelp != null) {
        if (helpEnabled) {
            pHelp.setOnPreferenceClickListener(new OnPreferenceClickListener() {

                @Override
                public boolean onPreferenceClick(Preference preference) {
                    String helpWeb = (String) getText(R.string.url_help);
                    if (helpWeb != null && helpWeb.length() > 0) {
                        Uri uriUrl = Uri.parse(helpWeb);
                        Intent intent = new Intent(Intent.ACTION_VIEW, uriUrl);
                        startActivity(intent);
                    }
                    return true;
                }
            });
        } else {
            preferenceCategory.removePreference(pHelp);
        }
    }
    boolean recommendEnabled = getResources().getBoolean(R.bool.recommend_enabled);
    Preference pRecommend = findPreference("recommend");
    if (pRecommend != null) {
        if (recommendEnabled) {
            pRecommend.setOnPreferenceClickListener(new OnPreferenceClickListener() {

                @Override
                public boolean onPreferenceClick(Preference preference) {
                    Intent intent = new Intent(Intent.ACTION_SENDTO);
                    intent.setType("text/plain");
                    intent.setData(Uri.parse(getString(R.string.mail_recommend)));
                    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    String appName = getString(R.string.app_name);
                    String downloadUrl = getString(R.string.url_app_download);
                    String recommendSubject = String.format(getString(R.string.recommend_subject), appName);
                    String recommendText = String.format(getString(R.string.recommend_text), appName, downloadUrl);
                    intent.putExtra(Intent.EXTRA_SUBJECT, recommendSubject);
                    intent.putExtra(Intent.EXTRA_TEXT, recommendText);
                    startActivity(intent);
                    return (true);
                }
            });
        } else {
            preferenceCategory.removePreference(pRecommend);
        }
    }
    boolean feedbackEnabled = getResources().getBoolean(R.bool.feedback_enabled);
    Preference pFeedback = findPreference("feedback");
    if (pFeedback != null) {
        if (feedbackEnabled) {
            pFeedback.setOnPreferenceClickListener(new OnPreferenceClickListener() {

                @Override
                public boolean onPreferenceClick(Preference preference) {
                    String feedbackMail = (String) getText(R.string.mail_feedback);
                    String feedback = (String) getText(R.string.prefs_feedback) + " - android v" + appVersion;
                    Intent intent = new Intent(Intent.ACTION_SENDTO);
                    intent.setType("text/plain");
                    intent.putExtra(Intent.EXTRA_SUBJECT, feedback);
                    intent.setData(Uri.parse(feedbackMail));
                    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    startActivity(intent);
                    return true;
                }
            });
        } else {
            preferenceCategory.removePreference(pFeedback);
        }
    }
    boolean privacyPolicyEnabled = getResources().getBoolean(R.bool.privacy_policy_enabled);
    Preference pPrivacyPolicy = findPreference("privacyPolicy");
    if (pPrivacyPolicy != null) {
        if (privacyPolicyEnabled) {
            pPrivacyPolicy.setOnPreferenceClickListener(new OnPreferenceClickListener() {

                @Override
                public boolean onPreferenceClick(Preference preference) {
                    Intent privacyPolicyIntent = new Intent(getApplicationContext(), PrivacyPolicyActivity.class);
                    startActivity(privacyPolicyIntent);
                    return true;
                }
            });
        } else {
            preferenceCategory.removePreference(pPrivacyPolicy);
        }
    }
    boolean loggerEnabled = getResources().getBoolean(R.bool.logger_enabled) || BuildConfig.DEBUG;
    Preference pLogger = findPreference("logger");
    if (pLogger != null) {
        if (loggerEnabled) {
            pLogger.setOnPreferenceClickListener(new OnPreferenceClickListener() {

                @Override
                public boolean onPreferenceClick(Preference preference) {
                    Intent loggerIntent = new Intent(getApplicationContext(), LogHistoryActivity.class);
                    startActivity(loggerIntent);
                    return true;
                }
            });
        } else {
            preferenceCategory.removePreference(pLogger);
        }
    }
    boolean imprintEnabled = getResources().getBoolean(R.bool.imprint_enabled);
    Preference pImprint = findPreference("imprint");
    if (pImprint != null) {
        if (imprintEnabled) {
            pImprint.setOnPreferenceClickListener(new OnPreferenceClickListener() {

                @Override
                public boolean onPreferenceClick(Preference preference) {
                    String imprintWeb = (String) getText(R.string.url_imprint);
                    if (imprintWeb != null && imprintWeb.length() > 0) {
                        Uri uriUrl = Uri.parse(imprintWeb);
                        Intent intent = new Intent(Intent.ACTION_VIEW, uriUrl);
                        startActivity(intent);
                    }
                    //ImprintDialog.newInstance(true).show(preference.get, "IMPRINT_DIALOG");
                    return true;
                }
            });
        } else {
            preferenceCategory.removePreference(pImprint);
        }
    }
    mPrefInstantUploadPath = findPreference("instant_upload_path");
    if (mPrefInstantUploadPath != null) {
        mPrefInstantUploadPath.setOnPreferenceClickListener(new OnPreferenceClickListener() {

            @Override
            public boolean onPreferenceClick(Preference preference) {
                if (!mUploadPath.endsWith(OCFile.PATH_SEPARATOR)) {
                    mUploadPath += OCFile.PATH_SEPARATOR;
                }
                Intent intent = new Intent(Preferences.this, UploadPathActivity.class);
                intent.putExtra(UploadPathActivity.KEY_INSTANT_UPLOAD_PATH, mUploadPath);
                startActivityForResult(intent, ACTION_SELECT_UPLOAD_PATH);
                return true;
            }
        });
    }
    mPrefInstantUploadCategory = (PreferenceCategory) findPreference("instant_uploading_category");
    mPrefInstantUploadWiFi = findPreference("instant_upload_on_wifi");
    mPrefInstantUpload = findPreference("instant_uploading");
    toggleInstantPictureOptions(((CheckBoxPreference) mPrefInstantUpload).isChecked());
    mPrefInstantUpload.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {

        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            boolean enableInstantPicture = (Boolean) newValue;
            toggleInstantPictureOptions(enableInstantPicture);
            toggleInstantUploadCommonOptions(((CheckBoxPreference) mPrefInstantVideoUpload).isChecked(), enableInstantPicture);
            return true;
        }
    });
    mPrefInstantVideoUploadPath = findPreference("instant_video_upload_path");
    if (mPrefInstantVideoUploadPath != null) {
        mPrefInstantVideoUploadPath.setOnPreferenceClickListener(new OnPreferenceClickListener() {

            @Override
            public boolean onPreferenceClick(Preference preference) {
                if (!mUploadVideoPath.endsWith(OCFile.PATH_SEPARATOR)) {
                    mUploadVideoPath += OCFile.PATH_SEPARATOR;
                }
                Intent intent = new Intent(Preferences.this, UploadPathActivity.class);
                intent.putExtra(UploadPathActivity.KEY_INSTANT_UPLOAD_PATH, mUploadVideoPath);
                startActivityForResult(intent, ACTION_SELECT_UPLOAD_VIDEO_PATH);
                return true;
            }
        });
    }
    mPrefInstantVideoUploadWiFi = findPreference("instant_video_upload_on_wifi");
    mPrefInstantVideoUpload = findPreference("instant_video_uploading");
    toggleInstantVideoOptions(((CheckBoxPreference) mPrefInstantVideoUpload).isChecked());
    mPrefInstantVideoUpload.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {

        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            toggleInstantVideoOptions((Boolean) newValue);
            toggleInstantUploadCommonOptions((Boolean) newValue, ((CheckBoxPreference) mPrefInstantUpload).isChecked());
            return true;
        }
    });
    mPrefInstantUploadSourcePath = findPreference("instant_upload_source_path");
    if (mPrefInstantUploadSourcePath != null) {
        mPrefInstantUploadSourcePath.setOnPreferenceClickListener(new OnPreferenceClickListener() {

            @Override
            public boolean onPreferenceClick(Preference preference) {
                if (!mSourcePath.endsWith(File.separator)) {
                    mSourcePath += File.separator;
                }
                LocalFolderPickerActivity.startLocalFolderPickerActivityForResult(Preferences.this, mSourcePath, ACTION_SELECT_SOURCE_PATH);
                return true;
            }
        });
    } else {
        Log_OC.e(TAG, "Lost preference instant_upload_source_path");
    }
    mPrefInstantUploadBehaviour = findPreference("prefs_instant_behaviour");
    toggleInstantUploadCommonOptions(((CheckBoxPreference) mPrefInstantVideoUpload).isChecked(), ((CheckBoxPreference) mPrefInstantUpload).isChecked());
    /* About App */
    pAboutApp = (Preference) findPreference("about_app");
    if (pAboutApp != null) {
        pAboutApp.setTitle(String.format(getString(R.string.about_android), getString(R.string.app_name)));
        pAboutApp.setSummary(String.format(getString(R.string.about_version), appVersion));
    }
    loadInstantUploadPath();
    loadInstantUploadVideoPath();
    loadInstantUploadSourcePath();
}
Also used : NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) CheckBoxPreference(android.preference.CheckBoxPreference) PackageInfo(android.content.pm.PackageInfo) Intent(android.content.Intent) OnPreferenceChangeListener(android.preference.Preference.OnPreferenceChangeListener) View(android.view.View) Uri(android.net.Uri) OnPreferenceClickListener(android.preference.Preference.OnPreferenceClickListener) CheckBoxPreference(android.preference.CheckBoxPreference) Preference(android.preference.Preference) PreferenceCategory(android.preference.PreferenceCategory) ActionBar(android.support.v7.app.ActionBar)

Example 40 with PreferenceCategory

use of android.preference.PreferenceCategory in project qksms by moezbhatti.

the class SettingsFragment method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Bundle args = getArguments();
    setHasOptionsMenu(true);
    mContext = (QKActivity) getActivity();
    mPrefs = mContext.getPrefs();
    mRes = mContext.getResources();
    mContext.setTitle(R.string.title_settings);
    mResource = args.getInt("category", R.xml.settings);
    addPreferencesFromResource(mResource);
    // Set `this` to be the preferences click/change listener for all the preferences.
    PreferenceScreen screen = getPreferenceScreen();
    for (int i = 0; i < screen.getPreferenceCount(); i++) {
        Preference pref = screen.getPreference(i);
        pref.setOnPreferenceClickListener(this);
        pref.setOnPreferenceChangeListener(this);
        // well.
        if (pref instanceof PreferenceCategory) {
            Stack<PreferenceCategory> stack = new Stack<>();
            stack.push((PreferenceCategory) pref);
            do {
                PreferenceCategory category = stack.pop();
                for (int j = 0; j < category.getPreferenceCount(); j++) {
                    Preference subPref = category.getPreference(j);
                    subPref.setOnPreferenceClickListener(this);
                    subPref.setOnPreferenceChangeListener(this);
                    if (subPref instanceof PreferenceCategory) {
                        stack.push((PreferenceCategory) subPref);
                    }
                }
            } while (!stack.isEmpty());
        }
    }
    Preference icon = findPreference(ICON);
    if (icon != null) {
        icon.setOnPreferenceClickListener(this);
    }
    mThemeLed = findPreference(NOTIFICATION_LED_COLOR);
    if (mThemeLed != null) {
        mLedColors = new int[] { mRes.getColor(R.color.blue_light), mRes.getColor(R.color.purple_light), mRes.getColor(R.color.green_light), mRes.getColor(R.color.yellow_light), mRes.getColor(R.color.red_light), mRes.getColor(R.color.white_pure) };
        mLedColorPickerDialog = new ColorPickerDialog();
        mLedColorPickerDialog.initialize(R.string.pref_theme_led, mLedColors, Integer.parseInt(mPrefs.getString(NOTIFICATION_LED_COLOR, "-48060")), 3, 2);
        mLedColorPickerDialog.setOnColorSelectedListener(new ColorPickerSwatch.OnColorSelectedListener() {

            @Override
            public void onColorSelected(int color) {
                mPrefs.edit().putString(mThemeLed.getKey(), "" + color).apply();
                onPreferenceChange(findPreference(mThemeLed.getKey()), color);
            }
        });
    }
    ListPreference font_family = (ListPreference) findPreference(FONT_FAMILY);
    if (font_family != null) {
        mFontFamilies = mRes.getStringArray(R.array.font_families);
        font_family.setSummary(mFontFamilies[Integer.parseInt(font_family.getValue())]);
    }
    ListPreference font_size = (ListPreference) findPreference(FONT_SIZE);
    if (font_size != null) {
        mFontSizes = mRes.getStringArray(R.array.font_sizes);
        font_size.setSummary(mFontSizes[Integer.parseInt(font_size.getValue())]);
    }
    ListPreference font_weight = (ListPreference) findPreference(FONT_WEIGHT);
    if (font_weight != null) {
        mFontWeights = mRes.getStringArray(R.array.font_weights);
        int i = Integer.parseInt(font_weight.getValue());
        font_weight.setSummary(mFontWeights[i == 2 ? 0 : 1]);
    }
    EditTextPreference deleteUnread = (EditTextPreference) findPreference(DELETE_UNREAD_MESSAGES);
    if (deleteUnread != null) {
        deleteUnread.setSummary(mContext.getString(R.string.pref_delete_old_messages_unread_summary, QKPreferences.getString(QKPreference.AUTO_DELETE_UNREAD)));
    }
    EditTextPreference deleteRead = (EditTextPreference) findPreference(DELETE_READ_MESSAGES);
    if (deleteRead != null) {
        deleteRead.setSummary(mContext.getString(R.string.pref_delete_old_messages_read_summary, QKPreferences.getString(QKPreference.AUTO_DELETE_READ)));
    }
    Preference day_start = findPreference(DAY_START);
    if (day_start != null) {
        day_start.setSummary(DateFormatter.getSummaryTimestamp(mContext, mPrefs.getString(DAY_START, "6:00")));
    }
    Preference night_start = findPreference(NIGHT_START);
    if (night_start != null) {
        night_start.setSummary(DateFormatter.getSummaryTimestamp(mContext, mPrefs.getString(NIGHT_START, "21:00")));
    }
    mMmscUrl = (EditTextPreference) findPreference(MMSC_URL);
    if (mMmscUrl != null) {
        mMmscUrl.setSummary(mMmscUrl.getText());
    }
    mMmsProxy = (EditTextPreference) findPreference(MMS_PROXY);
    if (mMmsProxy != null) {
        mMmsProxy.setSummary(mMmsProxy.getText());
    }
    mMmsPort = (EditTextPreference) findPreference(MMS_PORT);
    if (mMmsPort != null) {
        mMmsPort.setSummary(mMmsPort.getText());
    }
    mMaxMmsAttachmentSize = (ListPreference) findPreference(MAX_MMS_ATTACHMENT_SIZE);
    if (mMaxMmsAttachmentSize != null) {
        mMaxMmsAttachmentSizes = mRes.getStringArray(R.array.max_mms_attachment_sizes);
        String value = mMaxMmsAttachmentSize.getValue();
        String summary = mMaxMmsAttachmentSizes[mMaxMmsAttachmentSize.findIndexOfValue(value)];
        mMaxMmsAttachmentSize.setSummary(summary);
    }
    Preference version = findPreference(VERSION);
    if (version != null) {
        String v = "unknown";
        try {
            PackageInfo info = mContext.getPackageManager().getPackageInfo(mContext.getPackageName(), 0);
            v = info.versionName;
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
        version.setSummary(v);
    }
    // Status and nav bar tinting are only supported on kit kat or above.
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        removePreference(CATEGORY_APPEARANCE_SYSTEM_BARS);
    }
}
Also used : PreferenceScreen(android.preference.PreferenceScreen) Bundle(android.os.Bundle) PackageInfo(android.content.pm.PackageInfo) ListPreference(android.preference.ListPreference) EditTextPreference(android.preference.EditTextPreference) Stack(java.util.Stack) ColorPickerDialog(com.moez.QKSMS.ui.view.colorpicker.ColorPickerDialog) PackageManager(android.content.pm.PackageManager) EditTextPreference(android.preference.EditTextPreference) ListPreference(android.preference.ListPreference) QKPreference(com.moez.QKSMS.enums.QKPreference) CheckBoxPreference(android.preference.CheckBoxPreference) Preference(android.preference.Preference) PreferenceCategory(android.preference.PreferenceCategory) ColorPickerSwatch(com.moez.QKSMS.ui.view.colorpicker.ColorPickerSwatch)

Aggregations

PreferenceCategory (android.preference.PreferenceCategory)81 Preference (android.preference.Preference)49 PreferenceScreen (android.preference.PreferenceScreen)31 ListPreference (android.preference.ListPreference)30 CheckBoxPreference (android.preference.CheckBoxPreference)26 Intent (android.content.Intent)19 EditTextPreference (android.preference.EditTextPreference)8 OnPreferenceClickListener (android.preference.Preference.OnPreferenceClickListener)8 SwitchPreference (android.preference.SwitchPreference)8 ArrayList (java.util.ArrayList)7 Uri (android.net.Uri)6 SharedPreferences (android.content.SharedPreferences)5 Bundle (android.os.Bundle)5 View (android.view.View)4 OsmandApplication (net.osmand.plus.OsmandApplication)4 Context (android.content.Context)3 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)3 OnPreferenceChangeListener (android.preference.Preference.OnPreferenceChangeListener)3 RingtonePreference (android.preference.RingtonePreference)3 ListView (android.widget.ListView)3