android.preference.ListPreference Java Examples

The following examples show how to use android.preference.ListPreference. 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: Utils.java    From VIA-AI with MIT License 7 votes vote down vote up
@Override
public boolean onPreferenceChange(Preference preference, Object value) {
    String stringValue = value.toString();

    if (preference instanceof ListPreference) {
        // For list preferences, look up the correct display value in
        // the preference's 'entries' list.
        ListPreference listPreference = (ListPreference) preference;
        int index = listPreference.findIndexOfValue(stringValue);

        // Set the summary to reflect the new value.
        preference.setSummary(index >= 0? listPreference.getEntries()[index] : null);
    } else {
        // For all other preferences, set the summary to the value's
        // simple string representation.
        preference.setSummary("    " + stringValue);
    }
    return true;
}
 
Example #2
Source File: SettingsActivity.java    From your-local-weather with GNU General Public License v3.0 6 votes vote down vote up
private void entrySummary(String key) {
    ListPreference preference = (ListPreference) findPreference(key);
    if (preference == null) {
        return;
    }
    preference.setSummary(preference.getEntry());
    if (Constants.KEY_PREF_LOCATION_AUTO_UPDATE_PERIOD.equals(key)) {
        if ("0".equals(preference.getValue())) {
            AppPreference.setNotificationEnabled(getActivity(), true);
            AppPreference.setNotificationPresence(getActivity(), "permanent");
            AppPreference.setRegularOnlyInterval(getActivity());
        } else {
            AppPreference.setNotificationEnabled(getActivity(), false);
            AppPreference.setNotificationPresence(getActivity(), "when_updated");
            NotificationManager notificationManager =
                (NotificationManager) getActivity().getSystemService(Context.NOTIFICATION_SERVICE);
                notificationManager.cancelAll();
        }
    }
}
 
Example #3
Source File: SettingsActivity.java    From privacy-friendly-food-tracker with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean onPreferenceChange(Preference preference, Object value) {
    String stringValue = value.toString();

    if (preference instanceof ListPreference) {
        // For list preferences, look up the correct display value in
        // the preference's 'entries' list.
        ListPreference listPreference = (ListPreference) preference;
        int index = listPreference.findIndexOfValue(stringValue);

        // Set the summary to reflect the new value.
        preference.setSummary(
                index >= 0
                        ? listPreference.getEntries()[index]
                        : null);
    } else {
        // For all other preferences, set the summary to the value's
        // simple string representation.
        preference.setSummary(stringValue);
    }
    return true;
}
 
Example #4
Source File: ColorSettingsActivity.java    From LaunchTime with GNU General Public License v3.0 6 votes vote down vote up
@Override
        public void onResume() {
            super.onResume();

            IconsHandler iph = GlobState.getIconsHandler(this.getActivity());
            findPreference(getString(R.string.pref_key_icon_tint)).setEnabled(iph.isIconTintable());

            ListPreference iconsPack = (ListPreference)findPreference(getString(R.string.pref_key_icons_pack));

            setListPreferenceIconsPacksData(iconsPack, this.getActivity());
//            iconsPack.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
//                @Override
//                public boolean onPreferenceChange(Preference preference, Object newValue) {
//                    getActivity().finish();
//                    return true;
//                }
//            });

            prefs.registerOnSharedPreferenceChangeListener(this);

        }
 
Example #5
Source File: SensorSettingsActivity.java    From mytracks with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("deprecation")
private void configSensorType(boolean hasAntSupport) {
  ListPreference preference = (ListPreference) findPreference(
      getString(R.string.sensor_type_key));
  String value = PreferencesUtils.getString(
      this, R.string.sensor_type_key, PreferencesUtils.SENSOR_TYPE_DEFAULT);
  String[] options = getResources().getStringArray(
      hasAntSupport ? R.array.sensor_type_all_options : R.array.sensor_type_bluetooth_options);
  String[] values = getResources().getStringArray(
      hasAntSupport ? R.array.sensor_type_all_values : R.array.sensor_type_bluetooth_values);

  if (!hasAntSupport && value.equals(R.string.sensor_type_value_ant)) {
    value = PreferencesUtils.SENSOR_TYPE_DEFAULT;
    PreferencesUtils.setString(this, R.string.sensor_type_key, value);
  }

  OnPreferenceChangeListener listener = new OnPreferenceChangeListener() {
      @Override
    public boolean onPreferenceChange(Preference pref, Object newValue) {
      updateUiBySensorType((String) newValue);
      return true;
    }
  };
  configureListPreference(preference, options, options, values, value, listener);
}
 
Example #6
Source File: ColorSettingsActivity.java    From LaunchTime with GNU General Public License v3.0 6 votes vote down vote up
private static void setListPreferenceIconsPacksData(ListPreference lp, Context context) {
    IconsHandler iph = GlobState.getIconsHandler(context);

    iph.loadAvailableIconsPacks();

    Map<String, String> iconsPacks = iph.getAllIconsThemes();

    CharSequence[] entries = new CharSequence[iconsPacks.size()];
    CharSequence[] entryValues = new CharSequence[iconsPacks.size()];

    int i = 0;
    for (String packageIconsPack : iconsPacks.keySet()) {
        entries[i] = iconsPacks.get(packageIconsPack);
        entryValues[i] = packageIconsPack;
        i++;
    }

    lp.setEntries(entries);
    lp.setDefaultValue(IconsHandler.DEFAULT_PACK);
    lp.setEntryValues(entryValues);
}
 
Example #7
Source File: SettingsActivity.java    From JayPS-AndroidApp with MIT License 6 votes vote down vote up
private void setRefreshSummary(String p_refreshInterval) {
    ListPreference refreshPref = (ListPreference) findPreference("REFRESH_INTERVAL");
    if (refreshPref.findIndexOfValue(p_refreshInterval) >= 0) {
        CharSequence listDesc = refreshPref.getEntries()[refreshPref.findIndexOfValue(p_refreshInterval)];
        refreshPref.setSummary(listDesc);
    } else {
        // not in the list (old value?)
        int refresh_interval = 0;
        try {
            refresh_interval = Integer.valueOf(_sharedPreferences.getString("REFRESH_INTERVAL", "500"));
        } catch (NumberFormatException nfe) {
            refresh_interval = Constants.REFRESH_INTERVAL_DEFAULT;
        }
        refresh_interval = refresh_interval % 100000;
        if (refresh_interval < 1000) {
            refreshPref.setSummary(refresh_interval + " ms");
        } else {
            refreshPref.setSummary(refresh_interval/1000 + " s");
        }
    }

}
 
Example #8
Source File: SettingsActivity.java    From M365-Power with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.pref_general);
    setHasOptionsMenu(true);
    ListPreference speedListPreference = (ListPreference) findPreference("min_speed");
    ListPreference effListPreference = (ListPreference) findPreference("default_efficiency");


    //Statistics.setDefault_efficiency(Integer.valueOf(String.valueOf(effListPreference.getValue())));
    //Statistics.setMin_speed(Integer.valueOf(String.valueOf(speedListPreference.getValue())));

    speedListPreference.setValueIndex(3);
    speedListPreference.setValue("4");
    effListPreference.setValueIndex(7);
    effListPreference.setValue("600");
    // Bind the summaries of EditText/List/Dialog/Ringtone preferences
    // to their values. When their values change, their summaries are
    // updated to reflect the new value, per the Android Design
    // guidelines.
    bindPreferenceSummaryToValue(findPreference("min_speed"));
    bindPreferenceSummaryToValue(findPreference("default_efficiency"));
}
 
Example #9
Source File: MainActivity.java    From buildprop with Apache License 2.0 6 votes vote down vote up
@Override
        public boolean onPreferenceChange(Preference preference, Object value) {

            if (preference instanceof ListPreference) {
                String stringValue = value.toString();
                // For list preferences, look up the correct display value in
                // the preference's 'entries' list.
                ListPreference listPreference = (ListPreference) preference;
                int index = listPreference.findIndexOfValue(stringValue);

                // Set the summary to reflect the new value.
                preference.setSummary(
                        index >= 0
                                ? listPreference.getEntries()[index]
                                : null);
            }
//            else {
//                // For all other preferences, set the summary to the value's
//                // simple string representation.
//                preference.setSummary(stringValue);
//            }
            return true;
        }
 
Example #10
Source File: Preferences.java    From Plumble with GNU General Public License v3.0 6 votes vote down vote up
private static void configureAudioPreferences(final PreferenceScreen screen) {
    ListPreference inputPreference = (ListPreference) screen.findPreference(Settings.PREF_INPUT_METHOD);
    inputPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            updateAudioDependents(screen, (String) newValue);
            return true;
        }
    });

    // Scan each bitrate and determine if the device supports it
    ListPreference inputQualityPreference = (ListPreference) screen.findPreference(Settings.PREF_INPUT_RATE);
    String[] bitrateNames = new String[inputQualityPreference.getEntryValues().length];
    for(int x=0;x<bitrateNames.length;x++) {
        int bitrate = Integer.parseInt(inputQualityPreference.getEntryValues()[x].toString());
        boolean supported = AudioRecord.getMinBufferSize(bitrate, AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT) > 0;
        bitrateNames[x] = bitrate+"Hz" + (supported ? "" : " (unsupported)");
    }
    inputQualityPreference.setEntries(bitrateNames);

    updateAudioDependents(screen, inputPreference.getValue());
}
 
Example #11
Source File: SettingsActivity.java    From scroball with MIT License 6 votes vote down vote up
@Override
public boolean onPreferenceChange(Preference preference, Object value) {
  String stringValue = value.toString();

  if (preference instanceof ListPreference) {
    // For list preferences, look up the correct display value in
    // the preference's 'entries' list.
    ListPreference listPreference = (ListPreference) preference;
    int index = listPreference.findIndexOfValue(stringValue);

    // Set the summary to reflect the new value.
    preference.setSummary(index >= 0 ? listPreference.getEntries()[index] : null);
  } else {
    // For all other preferences, set the summary to the value's
    // simple string representation.
    preference.setSummary(stringValue);
  }
  return true;
}
 
Example #12
Source File: SettingsActivity.java    From al-muazzin with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Activity activity = getActivity();
    sLocaleManager = LocaleManager.getInstance(activity, false);

    addPreferencesFromResource(R.xml.settings);
    PreferenceScreen root = getPreferenceScreen();
    // System time zone
    Preference timezonePref = root.findPreference("key_time_zone");
    timezonePref.setSummary(getGmtOffSet(activity));

    // Language settings
    ListPreference languagePref = (ListPreference) root.findPreference("key_locale");
    languagePref.setEntryValues(LocaleManager.LOCALES);
    languagePref.setValueIndex(sLocaleManager.getLanguageIndex());
    languagePref.setSummary(languagePref.getEntry());
    languagePref.setOnPreferenceChangeListener(this);
}
 
Example #13
Source File: CameraSettingsActivity.java    From Camera2 with Apache License 2.0 6 votes vote down vote up
/**
 * Set the entries for the given preference. The given preference needs
 * to be a {@link ListPreference}
 */
private void setEntries(Preference preference)
{
    if (!(preference instanceof ListPreference))
    {
        return;
    }

    ListPreference listPreference = (ListPreference) preference;
    if (listPreference.getKey().equals(Keys.KEY_PICTURE_SIZE_BACK))
    {
        setEntriesForSelection(mPictureSizes.backCameraSizes, listPreference);
    } else if (listPreference.getKey().equals(Keys.KEY_PICTURE_SIZE_FRONT))
    {
        setEntriesForSelection(mPictureSizes.frontCameraSizes, listPreference);
    } else if (listPreference.getKey().equals(Keys.KEY_VIDEO_QUALITY_BACK))
    {
        setEntriesForSelection(mPictureSizes.videoQualitiesBack.orNull(), listPreference);
    } else if (listPreference.getKey().equals(Keys.KEY_VIDEO_QUALITY_FRONT))
    {
        setEntriesForSelection(mPictureSizes.videoQualitiesFront.orNull(), listPreference);
    }
}
 
Example #14
Source File: SettingsActivity.java    From redgram-for-reddit with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean onPreferenceChange(Preference preference, Object value) {
    String stringValue = value.toString();
    // For all preferences, set the summary to the value's
    // simple string representation.
    if(preference.getKey().equalsIgnoreCase(pref_posts_min_score) || preference.getKey().equalsIgnoreCase(pref_comments_min_score)) {
        if (stringValue.isEmpty()) {
            stringValue = "Show all submissions";
        }
    }else if(preference.getKey().equalsIgnoreCase(pref_comments_num_display)){
        if(stringValue.isEmpty()){
            stringValue = "200";
        }else if(stringValue.equalsIgnoreCase("0")){
            stringValue = "1";
        }else if(Integer.parseInt(stringValue) > 500){
            stringValue = "500";
        }
    }else if(preference.getKey().equalsIgnoreCase(pref_sync_period)){
        stringValue = ((ListPreference)preference).getEntry().toString();
    }

    preference.setSummary(stringValue);

    return true;
}
 
Example #15
Source File: PluggableCalibration.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
public static void setListPreferenceData(ListPreference p) {
    final Type[] types = Type.values();
    final CharSequence[] entries = new CharSequence[types.length];
    final CharSequence[] entryValues = new CharSequence[types.length];

    for (int i = 0; i < types.length; i++) {
        // Not sure exactly of what the overhead of this will be
        // perhaps we should save it to a cache...
        final CalibrationAbstract plugin = getCalibrationPlugin(types[i]);

        entries[i] = (plugin != null) ? plugin.getNiceNameAndDescription() : "None";
        entryValues[i] = types[i].toString();
    }
    p.setEntries(entries);
    p.setEntryValues(entryValues);
}
 
Example #16
Source File: SettingsActivity.java    From padland with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onPreferenceChange(Preference preference, Object value) {
    String stringValue = value.toString();

    if (preference instanceof ListPreference) {
        // For list pref_general, look up the correct display value in
        // the preference's 'entries' list.
        ListPreference listPreference = (ListPreference) preference;
        int index = listPreference.findIndexOfValue(stringValue);

        // Set the summary to reflect the new value.
        preference.setSummary(
                index >= 0
                        ? listPreference.getEntries()[index]
                        : null);

    } else {
        // For all other pref_general, set the summary to the value's
        // simple string representation.
        preference.setSummary(stringValue);
    }
    return true;
}
 
Example #17
Source File: PreferencesActivity.java    From AndroidAPS with GNU Affero General Public License v3.0 6 votes vote down vote up
private static void updatePrefSummary(Preference pref) {
    if (pref instanceof ListPreference) {
        ListPreference listPref = (ListPreference) pref;
        pref.setSummary(listPref.getEntry());
    }
    if (pref instanceof EditTextPreference) {
        EditTextPreference editTextPref = (EditTextPreference) pref;
        if (pref.getKey().contains("password") || pref.getKey().contains("secret")) {
            pref.setSummary("******");
        } else if (editTextPref.getText() != null) {
            ((EditTextPreference) pref).setDialogMessage(editTextPref.getDialogMessage());
            pref.setSummary(editTextPref.getText());
        } else {
            for (PluginBase plugin : MainApp.getPluginsList()) {
                plugin.updatePreferenceSummary(pref);
            }
        }
    }
    if (pref != null)
        adjustUnitDependentPrefs(pref);
}
 
Example #18
Source File: SettingFragment.java    From BetterWay with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
    if (preference instanceof ListPreference) {
        //把preference这个Preference强制转化为ListPreference类型
        ListPreference listPreference = (ListPreference) preference;
        //获取ListPreference中的实体内容
        CharSequence[] entries = listPreference.getEntries();
        //获取ListPreference中的实体内容的下标值
        int index = listPreference.findIndexOfValue((String) newValue);
        //把listPreference中的摘要显示为当前ListPreference的实体内容中选择的那个项目
        listPreference.setSummary(entries[index]);
        if (preference.getKey().equals("warning_time")) {
            int i = Integer.parseInt( listPreference.getEntryValues()[index].toString());
            postMessage(MyService.DURATION_CHANGE_KEY, MyService.DURATION_CHANGE, i);
        }
    }
    return true;
}
 
Example #19
Source File: SettingsActivity.java    From Acastus with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public boolean onPreferenceChange(Preference preference, Object value) {
    String stringValue = value.toString();

    if (preference instanceof ListPreference) {
        // For list preferences, look up the correct display value in
        // the preference's 'entries' list.
        ListPreference listPreference = (ListPreference) preference;
        int index = listPreference.findIndexOfValue(stringValue);

        // Set the summary to reflect the new value.
        preference.setSummary(
                index >= 0
                        ? listPreference.getEntries()[index]
                        : null);

    } else {
        // For all other preferences, set the summary to the value's
        // simple string representation.
        preference.setSummary(stringValue);
    }
    return true;
}
 
Example #20
Source File: AccountPreferencesFragment.java    From Linphone4Android with GNU General Public License v3.0 6 votes vote down vote up
private void initializeTransportPreference(ListPreference pref) {
	List<CharSequence> entries = new ArrayList<CharSequence>();
	List<CharSequence> values = new ArrayList<CharSequence>();
	entries.add(getString(R.string.pref_transport_udp));
	values.add(getString(R.string.pref_transport_udp_key));
	entries.add(getString(R.string.pref_transport_tcp));
	values.add(getString(R.string.pref_transport_tcp_key));

	if (!getResources().getBoolean(R.bool.disable_all_security_features_for_markets)) {
		entries.add(getString(R.string.pref_transport_tls));
		values.add(getString(R.string.pref_transport_tls_key));
	}
	setListPreferenceValues(pref, entries, values);

	if (! isNewAccount) {
		pref.setSummary(mPrefs.getAccountTransportString(n));
		pref.setDefaultValue(mPrefs.getAccountTransportKey(n));
		pref.setValueIndex(entries.indexOf(mPrefs.getAccountTransportString(n)));
	} else {

		pref.setSummary(getString(R.string.pref_transport_udp));
		pref.setDefaultValue(getString(R.string.pref_transport_udp));
		pref.setValueIndex(entries.indexOf(getString(R.string.pref_transport_udp)));
	}
}
 
Example #21
Source File: SettingsFragment.java    From Linphone4Android with GNU General Public License v3.0 6 votes vote down vote up
private void initializePreferredVideoFpsPreferences(ListPreference pref) {
	List<CharSequence> entries = new ArrayList<CharSequence>();
	List<CharSequence> values = new ArrayList<CharSequence>();
	entries.add(getString(R.string.pref_none));
	values.add("0");
	for (int i = 5; i <= 30; i += 5) {
		String str = Integer.toString(i);
		entries.add(str);
		values.add(str);
	}
	setListPreferenceValues(pref, entries, values);
	String value = Integer.toString(mPrefs.getPreferredVideoFps());
	if (value.equals("0")) {
		value = getString(R.string.pref_none);
	}
	pref.setSummary(value);
	pref.setValue(value);
}
 
Example #22
Source File: MapSettingsActivity.java    From mytracks with Apache License 2.0 6 votes vote down vote up
/**
 * Configures the track color mode preference.
 */
@SuppressWarnings("deprecation")
private void configTrackColorModePerference() {
  ListPreference preference = (ListPreference) findPreference(
      getString(R.string.track_color_mode_key));
  OnPreferenceChangeListener listener = new OnPreferenceChangeListener() {
      @Override
    public boolean onPreferenceChange(Preference pref, Object newValue) {
      updateUiByTrackColorMode((String) newValue);
      return true;
    }
  };
  String value = PreferencesUtils.getString(
      this, R.string.track_color_mode_key, PreferencesUtils.TRACK_COLOR_MODE_DEFAULT);
  String[] values = getResources().getStringArray(R.array.track_color_mode_values);
  String[] options = getResources().getStringArray(R.array.track_color_mode_options);
  String[] summary = getResources().getStringArray(R.array.track_color_mode_summary);
  configureListPreference(preference, summary, options, values, value, listener);
}
 
Example #23
Source File: StatsSettingsActivity.java    From mytracks with Apache License 2.0 6 votes vote down vote up
/**
 * Configures the preferred units list preference.
 */
private void configUnitsListPreference() {
  @SuppressWarnings("deprecation")
  ListPreference listPreference = (ListPreference) findPreference(
      getString(R.string.stats_units_key));
  OnPreferenceChangeListener listener = new OnPreferenceChangeListener() {

      @Override
    public boolean onPreferenceChange(Preference pref, Object newValue) {
      boolean metricUnits = PreferencesUtils.STATS_UNITS_DEFAULT.equals((String) newValue);
      configRateListPreference(metricUnits);
      return true;
    }
  };
  String value = PreferencesUtils.getString(
      this, R.string.stats_units_key, PreferencesUtils.STATS_UNITS_DEFAULT);
  String[] values = getResources().getStringArray(R.array.stats_units_values);
  String[] options = getResources().getStringArray(R.array.stats_units_options);
  configureListPreference(listPreference, options, options, values, value, listener);
}
 
Example #24
Source File: SettingsActivity.java    From PKUCourses with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean onPreferenceChange(Preference preference, Object value) {
    String stringValue = value.toString();

    if (preference instanceof ListPreference) {
        // For list preferences, look up the correct display value in the preference's 'entries' list.
        ListPreference listPreference = (ListPreference) preference;
        int index = listPreference.findIndexOfValue(stringValue);

        // Set the summary to reflect the new value.
        preference.setSummary(index >= 0 ? listPreference.getEntries()[index] : null);

    } else {
        // For all other preferences, set the summary to the value's simple string representation.
        preference.setSummary(stringValue);
    }
    return true;
}
 
Example #25
Source File: CBIActvitySettings.java    From CarBusInterface with MIT License 6 votes vote down vote up
@Override
public boolean onPreferenceChange(final Preference preference, final Object value) {
    if (D) Log.d(TAG, "onPreferenceChange()");

    final String stringValue = value.toString();

    if (preference instanceof ListPreference) {
        final ListPreference listPreference = (ListPreference) preference;
        final int index = listPreference.findIndexOfValue(stringValue);
        preference.setSummary(index >= 0 ? listPreference.getEntries()[index] : null);
    } else {
        preference.setSummary(stringValue);
    }

    return true;
}
 
Example #26
Source File: UiPrefFragment.java    From Onosendai with Apache License 2.0 5 votes vote down vote up
private void addColumnsCount (final String key, final String title) {
	final ListPreference pref = new ComboPreference(getActivity());
	pref.setKey(key);
	pref.setTitle(title);
	pref.setEntries(COUNTS);
	pref.setEntryValues(COUNTS);
	pref.setDefaultValue(DEFAULT_COUNT);
	getPreferenceScreen().addPreference(pref);
}
 
Example #27
Source File: AccountPreferencesFragment.java    From Linphone4Android with GNU General Public License v3.0 5 votes vote down vote up
private static void setListPreferenceValues(ListPreference pref, List<CharSequence> entries, List<CharSequence> values) {
	CharSequence[] contents = new CharSequence[entries.size()];
	entries.toArray(contents);
	pref.setEntries(contents);
	contents = new CharSequence[values.size()];
	values.toArray(contents);
	pref.setEntryValues(contents);
}
 
Example #28
Source File: SettingsFragment.java    From Document-Scanner with GNU General Public License v3.0 5 votes vote down vote up
private void updatePreference(Preference preference, String key) {
    if (preference == null) return;
    if (preference instanceof ListPreference) {
        ListPreference listPreference = (ListPreference) preference;
        listPreference.setSummary(listPreference.getEntry());
        return;
    } if (preference instanceof EditTextPreference) {
        SharedPreferences sharedPrefs = getPreferenceManager().getSharedPreferences();
        preference.setSummary(sharedPrefs.getString(key, "Default"));
    } if (preference instanceof PreferenceScreen) {
        updatePreferenceScreen((PreferenceScreen) preference);
    }
}
 
Example #29
Source File: CameraPrefsActivity.java    From evercam-android with GNU Affero General Public License v3.0 5 votes vote down vote up
private void setCameraNumbersForScreen(int screenWidth) {
    int maxCamerasPerRow = 3;
    if (screenWidth != 0) {
        maxCamerasPerRow = screenWidth / 350;
    }
    if (maxCamerasPerRow == 0) {
        maxCamerasPerRow = 1;
    }
    ArrayList<String> cameraNumberArrayList = new ArrayList<String>();
    for (int index = 1; index <= maxCamerasPerRow; index++) {
        cameraNumberArrayList.add(String.valueOf(index));
    }
    CharSequence[] charNumberValues = cameraNumberArrayList.toArray(new
            CharSequence[cameraNumberArrayList.size()]);
    final ListPreference interfaceList = (ListPreference)
            getPreferenceManager().findPreference(PrefsManager.KEY_CAMERA_PER_ROW);
    interfaceList.setEntries(charNumberValues);
    interfaceList.setEntryValues(charNumberValues);
    interfaceList.setSummary(interfaceList.getValue());
    interfaceList.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            interfaceList.setSummary(newValue.toString());
            return true;
        }
    });
}
 
Example #30
Source File: SettingsFragment.java    From Capstone-Project with MIT License 5 votes vote down vote up
private void bindPreferences() {
    mListPreferenceManageThemes = (ListPreference) findPreference(getString(R.string.settings_manage_themes_key));
    mPredatorDialogPreferenceClearCache = (PredatorDialogPreference) findPreference(getString(R.string.settings_clear_cache_key));
    //mSwitchPreferenceEnableExperimentalFeatures = (SwitchPreference) findPreference(getString(R.string.settings_enable_experimental_features_key));
    mListPreferenceChangeFont = (ListPreference) findPreference(getString(R.string.settings_change_font_key));
    mSwitchPreferenceBackgroundSync = (SwitchPreference) findPreference(getString(R.string.settings_background_sync_key));
    mListPreferenceSyncInterval = (ListPreference) findPreference(getString(R.string.settings_sync_interval_key));
    mSwitchPreferenceNotifications = (SwitchPreference) findPreference(getString(R.string.settings_notifications_key));
    mMultiSelectListPreferenceNotificationSettings = (MultiSelectListPreference) findPreference(getString(R.string.settings_notification_settings_key));
}