Java Code Examples for android.preference.Preference#setTitle()

The following examples show how to use android.preference.Preference#setTitle() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FiltersPrefFragment.java    From Onosendai with Apache License 2.0 6 votes vote down vote up
protected void refreshFiltersList () {
	getPreferenceScreen().removeAll();

	final CheckBoxPreference showFiltered = new CheckBoxPreference(getActivity());
	showFiltered.setKey(KEY_SHOW_FILTERED);
	showFiltered.setTitle("Show filtered"); //ES
	showFiltered.setSummary("For testing filters.  Does not work on seamless columns."); //ES
	getPreferenceScreen().addPreference(showFiltered);

	final Preference reapplyFilters = new Preference(getActivity());
	reapplyFilters.setTitle("Reapply Filters"); //ES
	reapplyFilters.setSummary("Apply filter rules to already downloaded tweets"); //ES
	reapplyFilters.setOnPreferenceClickListener(this.reapplyFiltersListener);
	getPreferenceScreen().addPreference(reapplyFilters);

	final Preference addFilter = new Preference(getActivity());
	addFilter.setTitle("Add Filter"); //ES
	addFilter.setSummary("Plain string or regex"); //ES
	addFilter.setOnPreferenceClickListener(new AddFilterClickListener(this));
	getPreferenceScreen().addPreference(addFilter);

	for (final String filterId : getPrefs().readFilterIds()) {
		final String filter = getPrefs().readFilter(filterId);
		getPreferenceScreen().addPreference(new FilterDialogPref(getActivity(), filterId, filter, this));
	}
}
 
Example 2
Source File: AutofillPreferences.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
private void rebuildProfileList() {
    // Add an edit preference for each current Chrome profile.
    PreferenceGroup profileCategory = (PreferenceGroup) findPreference(PREF_AUTOFILL_PROFILES);
    profileCategory.removeAll();
    for (AutofillProfile profile : PersonalDataManager.getInstance().getProfilesForSettings()) {
        // Add an item on the current page...
        Preference pref = new Preference(getActivity());
        pref.setTitle(profile.getFullName());
        pref.setSummary(profile.getLabel());

        if (profile.getIsLocal()) {
            pref.setFragment(AutofillProfileEditor.class.getName());
        } else {
            pref.setWidgetLayoutResource(R.layout.autofill_server_data_label);
            pref.setFragment(AutofillServerProfilePreferences.class.getName());
        }

        Bundle args = pref.getExtras();
        args.putString(AUTOFILL_GUID, profile.getGUID());
        profileCategory.addPreference(pref);
    }
}
 
Example 3
Source File: MobileMainActivity.java    From android-wear-gopro-remote with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.settings);
    bindPreferencesSummaryToValue(getPreferenceScreen());
    mPrefCategoryWatch = (PreferenceCategory)findPreference(getString(R.string.preference_category_watch_key));
    fCurrentWearSettings = new WearSettings();
    fCurrentWearSettings.loadFromPreferences(this, PreferenceManager.getDefaultSharedPreferences(this));

    mWifiNamePref = ((EditTextPreference)findPreference(getString(R.string.preference_wifi_name_key)));
    mWifiPassPref = ((EditTextPreference)findPreference(getString(R.string.preference_wifi_password_key)));

    Preference version = findPreference("preference_version_number");
    version.setTitle(BuildConfig.VERSION_NAME);
    version.setSummary(BuildConfig.FLAVOR + " " + BuildConfig.BUILD_TYPE);
}
 
Example 4
Source File: UsbChooserPreferences.java    From 365browser with Apache License 2.0 6 votes vote down vote up
private void resetList() {
    getPreferenceScreen().removeAll();
    addPreferencesFromResource(R.xml.usb_chooser_preferences);

    if (mPermissionsByObject.isEmpty() && mSearch.isEmpty() && mEmptyView != null) {
        mEmptyView.setText(R.string.website_settings_usb_no_devices);
    }

    for (Pair<ArrayList<UsbInfo>, ArrayList<Website>> entry : mPermissionsByObject.values()) {
        Preference preference = new Preference(getActivity());
        Bundle extras = preference.getExtras();
        extras.putInt(UsbDevicePreferences.EXTRA_CATEGORY, mCategory.toContentSettingsType());
        extras.putString(
                SingleCategoryPreferences.EXTRA_TITLE, getActivity().getTitle().toString());
        extras.putSerializable(UsbDevicePreferences.EXTRA_USB_INFOS, entry.first);
        extras.putSerializable(UsbDevicePreferences.EXTRA_SITES, entry.second);
        preference.setIcon(R.drawable.settings_usb);
        preference.setTitle(entry.first.get(0).getName());
        preference.setFragment(UsbDevicePreferences.class.getCanonicalName());
        getPreferenceScreen().addPreference(preference);
    }
}
 
Example 5
Source File: Preferences.java    From Androzic with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState)
{
	super.onCreate(savedInstanceState);

	PreferenceScreen root = getPreferenceManager().createPreferenceScreen(getActivity());
	root.setTitle(R.string.pref_plugins_title);
	setPreferenceScreen(root);

	Androzic application = (Androzic) getActivity().getApplication();
	Map<String, Intent> plugins = application.getPluginsPreferences();

	for (String plugin : plugins.keySet())
	{
		Preference preference = new Preference(getActivity());
		preference.setTitle(plugin);
		preference.setIntent(plugins.get(plugin));
		root.addPreference(preference);
	}
}
 
Example 6
Source File: DeveloperPreferences.java    From narrate-android with Apache License 2.0 6 votes vote down vote up
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        addPreferencesFromResource(R.xml.developer_preferences);

        findPreference("disable").setOnPreferenceClickListener(this);

//        mLogging = (CheckBoxPreference) findPreference("logging_enabled");
//        mLogging.setChecked(GlobalApplication.getUser().loggingEnabled);

        if (BuildConfig.DEBUG) {
            Preference pref = new Preference(this);
            pref.setTitle("Prepare for screenshots");
            pref.setSummary("Clears all data and adds entries for screenshots");
            pref.setKey("screenshots");
            pref.setOnPreferenceClickListener(this);
            getPreferenceScreen().addPreference(pref);
        }
    }
 
Example 7
Source File: AutofillAndPaymentsPreferences.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    PreferenceUtils.addPreferencesFromResource(this, R.xml.autofill_and_payments_preferences);
    getActivity().setTitle(R.string.prefs_autofill_and_payments);

    ChromeSwitchPreference autofillSwitch =
            (ChromeSwitchPreference) findPreference(PREF_AUTOFILL_SWITCH);
    autofillSwitch.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            PersonalDataManager.setAutofillEnabled((boolean) newValue);
            return true;
        }
    });

    if (ChromeFeatureList.isEnabled(ChromeFeatureList.ANDROID_PAYMENT_APPS)) {
        Preference pref = new Preference(getActivity());
        pref.setTitle(getActivity().getString(R.string.payment_apps_title));
        pref.setFragment(AndroidPaymentAppsFragment.class.getCanonicalName());
        pref.setShouldDisableView(true);
        pref.setKey(PREF_ANDROID_PAYMENT_APPS);
        getPreferenceScreen().addPreference(pref);
    }
}
 
Example 8
Source File: UsbChooserPreferences.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
private void resetList() {
    getPreferenceScreen().removeAll();
    addPreferencesFromResource(R.xml.usb_chooser_preferences);

    if (mPermissionsByObject.isEmpty() && mSearch.isEmpty() && mEmptyView != null) {
        mEmptyView.setText(R.string.website_settings_usb_no_devices);
    }

    for (Pair<ArrayList<UsbInfo>, ArrayList<Website>> entry : mPermissionsByObject.values()) {
        Preference preference = new Preference(getActivity());
        Bundle extras = preference.getExtras();
        extras.putInt(UsbDevicePreferences.EXTRA_CATEGORY, mCategory.toContentSettingsType());
        extras.putString(
                SingleCategoryPreferences.EXTRA_TITLE, getActivity().getTitle().toString());
        extras.putSerializable(UsbDevicePreferences.EXTRA_USB_INFOS, entry.first);
        extras.putSerializable(UsbDevicePreferences.EXTRA_SITES, entry.second);
        preference.setIcon(R.drawable.settings_usb);
        preference.setTitle(entry.first.get(0).getName());
        preference.setFragment(UsbDevicePreferences.class.getCanonicalName());
        getPreferenceScreen().addPreference(preference);
    }
}
 
Example 9
Source File: UserDictionaryList.java    From Indic-Keyboard with Apache License 2.0 6 votes vote down vote up
/**
 * Create a single User Dictionary Preference object, with its parameters set.
 * @param localeString The locale for which this user dictionary is for.
 * @return The corresponding preference.
 */
protected Preference createUserDictionaryPreference(@Nullable final String localeString) {
    final Preference newPref = new Preference(getActivity());
    final Intent intent = new Intent(USER_DICTIONARY_SETTINGS_INTENT_ACTION);
    if (null == localeString) {
        newPref.setTitle(Locale.getDefault().getDisplayName());
    } else {
        if (localeString.isEmpty()) {
            newPref.setTitle(getString(R.string.user_dict_settings_all_languages));
        } else {
            newPref.setTitle(
                    LocaleUtils.constructLocaleFromString(localeString).getDisplayName());
        }
        intent.putExtra("locale", localeString);
        newPref.getExtras().putString("locale", localeString);
    }
    newPref.setIntent(intent);
    newPref.setFragment(UserDictionarySettings.class.getName());
    return newPref;
}
 
Example 10
Source File: AdvancedPrefFragment.java    From Onosendai with Apache License 2.0 5 votes vote down vote up
private void addDumpLogPref () {
	final Preference pref = new Preference(getActivity());
	pref.setTitle("Dump log"); //ES
	pref.setSummary("Write app log to /sdcard/onosendai-<time>.log"); //ES
	pref.setOnPreferenceClickListener(this.dumpLogsClickListener);
	getPreferenceScreen().addPreference(pref);
}
 
Example 11
Source File: ActivitySettings.java    From FineGeotag with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
    Preference pref = findPreference(key);

    // Remove empty string settings
    if (pref instanceof EditTextPreference)
        if ("".equals(prefs.getString(key, null))) {
            SharedPreferences.Editor edit = prefs.edit();
            edit.remove(key);
            edit.apply();
        }

    if (PREF_ENABLED.equals(key))
        pref.setSummary(prefs.getBoolean(PREF_ENABLED, true) ? getString(R.string.summary_enabled) : null);

    else if (PREF_TOAST.equals(key))
        pref.setSummary(prefs.getBoolean(PREF_TOAST, true) ? getString(R.string.summary_toast) : null);

    else if (PREF_ALTITUDE.equals(key))
        pref.setSummary(prefs.getBoolean(PREF_ALTITUDE, true) ? getString(R.string.summary_altitude) : null);

    else if (PREF_ACCURACY.equals(key))
        pref.setTitle(getString(R.string.title_accuracy, prefs.getString(key, DEFAULT_ACCURACY)));

    else if (PREF_TIMEOUT.equals(key))
        pref.setTitle(getString(R.string.title_timeout, prefs.getString(key, DEFAULT_TIMEOUT)));

    else if (PREF_KNOWN.equals(key)) {
        ListPreference lpref = (ListPreference) pref;
        int index = lpref.findIndexOfValue(prefs.getString(key, DEFAULT_KNOWN));
        pref.setTitle(getString(R.string.title_known, lpref.getEntries()[index]));
    }
}
 
Example 12
Source File: InputMethodSettingsImpl.java    From Android-Keyboard with Apache License 2.0 5 votes vote down vote up
public void updateSubtypeEnabler() {
    final Preference pref = mSubtypeEnablerPreference;
    if (pref == null) {
        return;
    }
    final Context context = pref.getContext();
    final CharSequence title;
    if (mSubtypeEnablerTitleRes != 0) {
        title = context.getString(mSubtypeEnablerTitleRes);
    } else {
        title = mSubtypeEnablerTitle;
    }
    pref.setTitle(title);
    final Intent intent = pref.getIntent();
    if (intent != null) {
        intent.putExtra(Intent.EXTRA_TITLE, title);
    }
    final String summary = getEnabledSubtypesLabel(context, mImm, mImi);
    if (!TextUtils.isEmpty(summary)) {
        pref.setSummary(summary);
    }
    if (mSubtypeEnablerIconRes != 0) {
        pref.setIcon(mSubtypeEnablerIconRes);
    } else {
        pref.setIcon(mSubtypeEnablerIcon);
    }
}
 
Example 13
Source File: SettingsActivity.java    From bluetooth-spp-terminal with Apache License 2.0 5 votes vote down vote up
/**
 * Установка заголовка списка
 */
private void setPrefenceTitle(String TAG) {
    final Preference preference = findPreference(TAG);
    if (preference == null) return;
    if (preference instanceof ListPreference) {
        if (((ListPreference) preference).getEntry() == null) return;
        final String title = ((ListPreference) preference).getEntry().toString();
        preference.setTitle(title);
    }
}
 
Example 14
Source File: AccountsSettingsFragment.java    From Android-Keyboard with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(final Bundle icicle) {
    super.onCreate(icicle);
    addPreferencesFromResource(R.xml.prefs_screen_accounts);

    mAccountSwitcher = findPreference(PREF_ACCCOUNT_SWITCHER);
    mEnableSyncPreference = (TwoStatePreference) findPreference(PREF_ENABLE_SYNC_NOW);
    mSyncNowPreference = findPreference(PREF_SYNC_NOW);
    mClearSyncDataPreference = findPreference(PREF_CLEAR_SYNC_DATA);

    if (ProductionFlags.IS_METRICS_LOGGING_SUPPORTED) {
        final Preference enableMetricsLogging =
                findPreference(Settings.PREF_ENABLE_METRICS_LOGGING);
        final Resources res = getResources();
        if (enableMetricsLogging != null) {
            final String enableMetricsLoggingTitle = res.getString(
                    R.string.enable_metrics_logging, getApplicationName());
            enableMetricsLogging.setTitle(enableMetricsLoggingTitle);
        }
    } else {
        removePreference(Settings.PREF_ENABLE_METRICS_LOGGING);
    }

    if (!ProductionFlags.ENABLE_USER_HISTORY_DICTIONARY_SYNC) {
        removeSyncPreferences();
    } else {
        // Disable by default till we are sure we can enable this.
        disableSyncPreferences();
        new ManagedProfileCheckerTask(this).execute();
    }
}
 
Example 15
Source File: SettingFragment.java    From RxZhihuPager with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.preferences);

    Preference appVersion = findPreference(APP_VERSION);
    appVersion.setTitle("版本号:" + AppInfoUtils.getVersionName(getActivity()));

    Preference aboutDev = findPreference(ABOUT_DEV);
    aboutDev.setOnPreferenceClickListener(this);
}
 
Example 16
Source File: Preferences.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onPreferenceChange(Preference preference, Object value) {

    boolean do_update = false;
    // detect not first run
    if (preference.getTitle().toString().contains("(")) {
        do_update = true;
    }

    preference.setTitle(preference.getTitle().toString().replaceAll("  \\([a-z0-9A-Z.]+\\)$", "") + "  (" + value.toString() + ")");
    if (do_update) {
        preference.getEditor().putString(preference.getKey(), (String) value).apply(); // update prefs now
    }
    return true;
}
 
Example 17
Source File: OpenFitActivity.java    From OpenFit with MIT License 5 votes vote down vote up
public Preference createAppPreference(final String packageName, final String appName) {
    Preference app = new Preference(getActivity());
    app.setTitle(appName);
    app.setKey(packageName);
    app.setIcon(appManager.loadIcon(packageName));
    return app;
}
 
Example 18
Source File: NumberGroupEdit.java    From callmeter with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Reload numbers.
 */
@SuppressWarnings("deprecation")
private void reload() {
    Cursor c = getContentResolver().query(
            ContentUris.withAppendedId(DataProvider.NumbersGroup.CONTENT_URI, gid),
            DataProvider.NumbersGroup.PROJECTION, null, null, null);
    if (c.moveToFirst()) {
        CallMeter.setActivitySubtitle(this, c.getString(DataProvider.NumbersGroup.INDEX_NAME));
    }
    c.close();
    PreferenceScreen ps = (PreferenceScreen) findPreference("container");
    ps.removeAll();
    c = getContentResolver().query(
            ContentUris.withAppendedId(DataProvider.Numbers.GROUP_URI, gid),
            DataProvider.Numbers.PROJECTION, null, null, DataProvider.Numbers.NUMBER);
    if (c.moveToFirst()) {
        do {
            Preference p = new Preference(this);
            p.setPersistent(false);
            String number = c.getString(DataProvider.Numbers.INDEX_NUMBER);
            p.setTitle(number);
            p.setKey("item_" + c.getInt(DataProvider.Numbers.INDEX_ID));
            p.setOnPreferenceClickListener(this);
            ps.addPreference(p);

            if (number != null && !number.contains("%")
                    && CallMeter.hasPermission(this, Manifest.permission.READ_CONTACTS)) {
                String name = CWRAPPER.getNameForNumber(getContentResolver(), number);
                if (!TextUtils.isEmpty(name)) {
                    p.setSummary(name);
                }
            }
        } while (c.moveToNext());
    }
    c.close();
}
 
Example 19
Source File: MaxLockPreferenceFragment.java    From MaxLock with GNU General Public License v3.0 4 votes vote down vote up
@SuppressLint("WorldReadableFiles")
@SuppressWarnings("deprecation")
@Override
public void onCreate(Bundle paramBundle) {
    super.onCreate(paramBundle);
    if (getArguments() != null) {
        screen = Screen.valueOf(getArguments().getString(Screen.KEY, Screen.MAIN.toString()));
    } else {
        screen = Screen.MAIN;
    }
    prefs = MLPreferences.getPreferences(getActivity());
    setTitle();
    if (screen == Screen.IMOD) {
        getPreferenceManager().setSharedPreferencesName(Common.PREFS_APPS);
    }
    addPreferencesFromResource(screen.preferenceXML);
    switch (screen) {
        case MAIN:
            updateImplementationStatus();
            PreferenceCategory catAppUI = (PreferenceCategory) findPreference(Common.CATEGORY_APPLICATION_UI);
            CheckBoxPreference useDark = (CheckBoxPreference) findPreference(Common.USE_DARK_STYLE);
            if (!useDark.isChecked()) {
                catAppUI.removePreference(findPreference(Common.USE_AMOLED_BLACK));
            }
            if (SDK_INT >= Build.VERSION_CODES.O) {
                catAppUI.removePreference(findPreference(Common.NEW_APP_NOTIFICATION));
            }
            break;
        case TYPE:
            FingerprintManagerCompat fpm = FingerprintManagerCompat.from(getActivity());
            if (!fpm.isHardwareDetected()) {
                getPreferenceScreen().removePreference(findPreference(Common.SHADOW_FINGERPRINT));
                getPreferenceScreen().removePreference(findPreference(Common.CATEGORY_FINGERPRINT));
            } else {
                CheckBoxPreference disableFP = (CheckBoxPreference) findPreference(Common.DISABLE_FINGERPRINT);
                if (!fpm.hasEnrolledFingerprints() && !disableFP.isChecked()) {
                    disableFP.setSummary(disableFP.getSummary() + getResources().getString(R.string.pref_fingerprint_summary_non_enrolled));
                }
            }
            break;
        case UI:
            ListPreference lp = (ListPreference) findPreference(Common.BACKGROUND);
            findPreference(Common.BACKGROUND_COLOR).setEnabled(lp.getValue().equals("color"));
            lp.setOnPreferenceChangeListener((preference, newValue) -> {
                if (preference.getKey().equals(Common.BACKGROUND)) {
                    if (newValue.toString().equals("custom")) {
                        Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
                        intent.setType("image/*");
                        startActivityForResult(intent, WALLPAPER_REQUEST_CODE);
                    } else
                        FileUtils.deleteQuietly(new File(getActivity().getFilesDir(), "background"));
                    findPreference(Common.BACKGROUND_COLOR).setEnabled(newValue.toString().equals("color"));
                }
                return true;
            });
            break;
        case OPTIONS:
            Preference el = findPreference(Common.ENABLE_LOGGING);
            el.setEnabled(prefs.getBoolean(Common.ENABLE_PRO, false));
            if (!prefs.getBoolean(Common.ENABLE_PRO, false)) {
                el.setSummary(R.string.toast_pro_required);
            }
            if (MLImplementation.getImplementation(prefs) != MLImplementation.DEFAULT) {
                PreferenceCategory catOther = (PreferenceCategory) findPreference(Common.CATEGORY_OTHER);
                catOther.removePreference(findPreference(Common.HIDE_RECENTS_THUMBNAILS));
            }
            break;
        case IMOD:
            // I.Mod - Pro setup
            Preference iModDelayGlobal = findPreference(Common.ENABLE_DELAY_GENERAL);
            Preference iModDelayPerApp = findPreference(Common.ENABLE_DELAY_PER_APP);
            iModDelayGlobal.setEnabled(prefs.getBoolean(Common.ENABLE_PRO, false));
            iModDelayPerApp.setEnabled(prefs.getBoolean(Common.ENABLE_PRO, false));
            if (!prefs.getBoolean(Common.ENABLE_PRO, false)) {
                iModDelayGlobal.setTitle(R.string.pref_delay_needpro);
                iModDelayPerApp.setTitle(R.string.pref_delay_needpro);
            }
            break;
    }
}
 
Example 20
Source File: SettingsActivity.java    From JayPS-AndroidApp with MIT License 4 votes vote down vote up
private void setBleTitle(String title, String key) {
    Preference blePref = findPreference(key);
    blePref.setTitle(title);
}