Java Code Examples for android.preference.ListPreference

The following are top voted examples for showing how to use android.preference.ListPreference. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: android-mrz-reader   File: PreferencesActivity.java   View source code 6 votes vote down vote up
/**
 * Set the default preference values.
 *
 * @param savedInstanceState the current Activity's state, as passed by
 *            Android
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  addPreferencesFromResource(R.xml.preferences);
  
  sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
  
  listPreferenceSourceLanguage = (ListPreference) getPreferenceScreen().findPreference(KEY_SOURCE_LANGUAGE_PREFERENCE);
  listPreferenceTargetLanguage = (ListPreference) getPreferenceScreen().findPreference(KEY_TARGET_LANGUAGE_PREFERENCE);
  listPreferenceTranslator = (ListPreference) getPreferenceScreen().findPreference(KEY_TRANSLATOR);    
  listPreferenceOcrEngineMode = (ListPreference) getPreferenceScreen().findPreference(KEY_OCR_ENGINE_MODE);
  editTextPreferenceCharacterBlacklist = (EditTextPreference) getPreferenceScreen().findPreference(KEY_CHARACTER_BLACKLIST);
  editTextPreferenceCharacterWhitelist = (EditTextPreference) getPreferenceScreen().findPreference(KEY_CHARACTER_WHITELIST);
  listPreferencePageSegmentationMode = (ListPreference) getPreferenceScreen().findPreference(KEY_PAGE_SEGMENTATION_MODE);
  
  // Create the entries/entryvalues for the translation target language list.
  initTranslationTargetList();
  
}
 
Example 2
Project: q-mail   File: AccountSettings.java   View source code 6 votes vote down vote up
@Override
protected void onPreExecute() {
    autoExpandFolder = (ListPreference) findPreference(PREFERENCE_AUTO_EXPAND_FOLDER);
    autoExpandFolder.setEnabled(false);
    archiveFolder = (ListPreference) findPreference(PREFERENCE_ARCHIVE_FOLDER);
    archiveFolder.setEnabled(false);
    draftsFolder = (ListPreference) findPreference(PREFERENCE_DRAFTS_FOLDER);
    draftsFolder.setEnabled(false);
    sentFolder = (ListPreference) findPreference(PREFERENCE_SENT_FOLDER);
    sentFolder.setEnabled(false);
    spamFolder = (ListPreference) findPreference(PREFERENCE_SPAM_FOLDER);
    spamFolder.setEnabled(false);
    trashFolder = (ListPreference) findPreference(PREFERENCE_TRASH_FOLDER);
    trashFolder.setEnabled(false);

    if (!isMoveCapable) {
        PreferenceScreen foldersCategory =
                (PreferenceScreen) findPreference(PREFERENCE_CATEGORY_FOLDERS);
        foldersCategory.removePreference(archiveFolder);
        foldersCategory.removePreference(spamFolder);
        foldersCategory.removePreference(draftsFolder);
        foldersCategory.removePreference(sentFolder);
        foldersCategory.removePreference(trashFolder);
    }
}
 
Example 3
Project: Treebolic   File: SettingsActivity.java   View source code 6 votes vote down vote up
@Override
public void onCreate(final Bundle savedInstanceState)
{
	super.onCreate(savedInstanceState);

	// inflate
	addPreferencesFromResource(R.xml.pref_service);

	// preference
	final ListPreference listPreference = (ListPreference) findPreference(Settings.PREF_SERVICE);

	// activity
	final SettingsActivity activity = (SettingsActivity) getActivity();

	// connect to data
	activity.fillWithServiceData(listPreference);

	// bind
	activity.bind(listPreference, Settings.getStringPref(activity, listPreference.getKey()), activity.listener);
}
 
Example 4
Project: Cable-Android   File: ChatsPreferenceFragment.java   View source code 6 votes vote down vote up
@Override
public void onCreate(Bundle paramBundle) {
  super.onCreate(paramBundle);
  addPreferencesFromResource(R.xml.preferences_chats);

  findPreference(TextSecurePreferences.MEDIA_DOWNLOAD_MOBILE_PREF)
      .setOnPreferenceChangeListener(new MediaDownloadChangeListener());
  findPreference(TextSecurePreferences.MEDIA_DOWNLOAD_WIFI_PREF)
      .setOnPreferenceChangeListener(new MediaDownloadChangeListener());
  findPreference(TextSecurePreferences.MEDIA_DOWNLOAD_ROAMING_PREF)
      .setOnPreferenceChangeListener(new MediaDownloadChangeListener());
  findPreference(TextSecurePreferences.MESSAGE_BODY_TEXT_SIZE_PREF)
      .setOnPreferenceChangeListener(new ListSummaryListener());

  findPreference(TextSecurePreferences.THREAD_TRIM_NOW)
      .setOnPreferenceClickListener(new TrimNowClickListener());
  findPreference(TextSecurePreferences.THREAD_TRIM_LENGTH)
      .setOnPreferenceChangeListener(new TrimLengthValidationListener());

  initializeListSummary((ListPreference) findPreference(TextSecurePreferences.MESSAGE_BODY_TEXT_SIZE_PREF));
}
 
Example 5
Project: android-slideshow   File: SettingsActivity.java   View source code 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 6
Project: PeSanKita-android   File: NotificationsPreferenceFragment.java   View source code 6 votes vote down vote up
@Override
public void onCreate(Bundle paramBundle) {
  super.onCreate(paramBundle);
  masterSecret = getArguments().getParcelable("master_secret");
  addPreferencesFromResource(R.xml.preferences_notifications);

  this.findPreference(TextSecurePreferences.LED_COLOR_PREF)
      .setOnPreferenceChangeListener(new ListSummaryListener());
  this.findPreference(TextSecurePreferences.LED_BLINK_PREF)
      .setOnPreferenceChangeListener(new ListSummaryListener());
  this.findPreference(TextSecurePreferences.RINGTONE_PREF)
      .setOnPreferenceChangeListener(new RingtoneSummaryListener());
  this.findPreference(TextSecurePreferences.REPEAT_ALERTS_PREF)
      .setOnPreferenceChangeListener(new ListSummaryListener());
  this.findPreference(TextSecurePreferences.NOTIFICATION_PRIVACY_PREF)
      .setOnPreferenceChangeListener(new NotificationPrivacyListener());

  initializeListSummary((ListPreference) findPreference(TextSecurePreferences.LED_COLOR_PREF));
  initializeListSummary((ListPreference) findPreference(TextSecurePreferences.LED_BLINK_PREF));
  initializeListSummary((ListPreference) findPreference(TextSecurePreferences.REPEAT_ALERTS_PREF));
  initializeListSummary((ListPreference) findPreference(TextSecurePreferences.NOTIFICATION_PRIVACY_PREF));
  initializeRingtoneSummary((RingtonePreference) findPreference(TextSecurePreferences.RINGTONE_PREF));
}
 
Example 7
Project: Treebolic   File: SettingsActivity.java   View source code 6 votes vote down vote up
/**
 * Connect list preference to service data
 *
 * @param listPreference list preference
 */
private void fillWithServiceData(@NonNull final ListPreference listPreference)
{
	final List<HashMap<String, Object>> services = Services.getServices(this, true);
	if (services != null)
	{
		final int n = services.size();
		final String[] entries = new String[n];
		final String[] values = new String[n];
		for (int i = 0; i < n; i++)
		{
			final HashMap<String, Object> service = services.get(i);
			entries[i] = (String) service.get(Services.LABEL);
			values[i] = (String) service.get(Services.PACKAGE) + '/' + service.get(Services.NAME);
		}
		listPreference.setEntries(entries);
		listPreference.setEntryValues(values);
	}
}
 
Example 8
Project: BeaconMqtt   File: SettingsActivity.java   View source code 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 9
Project: C500Companion   File: SettingsActivity.java   View source code 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 10
Project: text_converter   File: PreferencesUtil.java   View source code 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 if (preference instanceof RingtonePreference) {
    } else if (preference instanceof EditTextPreference) {
        EditTextPreference editTextPreference = (EditTextPreference) preference;
        editTextPreference.setSummary(editTextPreference.getText());
    } else {
        // For all other preferences, set the summary to the value's
        // simple string representation.
        preference.setSummary(stringValue);
    }
    return true;
}
 
Example 11
Project: bananapeel   File: ServerPreferencesScreen.java   View source code 6 votes vote down vote up
private void setKeys(PreferenceScreen screen)
{
	for(int i = 0; i < screen.getPreferenceCount(); i++)
	{
		Preference preference = screen.getPreference(i);
		String key = server + ";" + preference.getKey();
		preference.setKey(key);
		if(preference instanceof EditIntPreference)
			((EditIntPreference)preference).setInt(preference.getSharedPreferences().getInt(key, -1));
		else if(preference instanceof EditTextPreference)
			((EditTextPreference)preference).setText(preference.getSharedPreferences().getString(key, null));
		else if(preference instanceof ListPreference)
			((ListPreference)preference).setValue(preference.getSharedPreferences().getString(key, null));
		else if(preference instanceof CheckBoxPreference)
			((CheckBoxPreference)preference).setChecked(preference.getSharedPreferences().getBoolean(key, false));
		if(preference instanceof PreferenceScreen)
			setKeys((PreferenceScreen)preference);
	}
}
 
Example 12
Project: social-journal   File: SettingsActivity.java   View source code 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 13
Project: SecScanQR   File: SettingsActivity.java   View source code 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 14
Project: AndroidIRCLogViewer   File: SettingsActivity.java   View source code 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 15
Project: AndiCar   File: PreferenceActivity.java   View source code 6 votes vote down vote up
/**
 * Sets the summary of the preference according to its value
 *
 * @param preference
 * @param value
 */
private static void setPreferenceSummaryByValue(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);
    }
}
 
Example 16
Project: QuakeRepor   File: SettingActivity.java   View source code 6 votes vote down vote up
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
    String stringValue = newValue.toString();
    if (preference instanceof ListPreference) {
        ListPreference listPreference = (ListPreference) preference;
        int prefIndex = listPreference.findIndexOfValue(stringValue);
        if (prefIndex >= 0) {
            CharSequence[] labels  = listPreference.getEntries();
            preference.setSummary(labels[prefIndex]);
        }

    }else {
        preference.setSummary(stringValue);
    }
    return true;
}
 
Example 17
Project: proto-collecte   File: SettingsActivity.java   View source code 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 18
Project: javaide   File: PreferencesUtil.java   View source code 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 if (preference instanceof RingtonePreference) {
    } else if (preference instanceof EditTextPreference) {
        EditTextPreference editTextPreference = (EditTextPreference) preference;
        editTextPreference.setSummary(editTextPreference.getText());
    } else {
        // For all other preferences, set the summary to the value's
        // simple string representation.
        preference.setSummary(stringValue);
    }
    return true;
}
 
Example 19
Project: buildAPKsSamples   File: CustomRestrictionsFragment.java   View source code 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.custom_prefs);

    // This sample app uses shared preferences to maintain app restriction settings.  Your app
    // can use other methods to maintain the settings.
    mBooleanPref = (CheckBoxPreference) findPreference(KEY_BOOLEAN_PREF);
    mChoicePref = (ListPreference) findPreference(KEY_CHOICE_PREF);
    mMultiPref = (MultiSelectListPreference) findPreference(KEY_MULTI_PREF);

    mBooleanPref.setOnPreferenceChangeListener(this);
    mChoicePref.setOnPreferenceChangeListener(this);
    mMultiPref.setOnPreferenceChangeListener(this);

    setRetainInstance(true);
}
 
Example 20
Project: LaunchTime   File: SettingsActivity.java   View source code 6 votes vote down vote up
protected 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 21
Project: q-mail   File: AccountSettings.java   View source code 5 votes vote down vote up
private void removeListEntry(ListPreference listPreference, String remove) {
    CharSequence[] entryValues = listPreference.getEntryValues();
    CharSequence[] entries = listPreference.getEntries();

    CharSequence[] newEntryValues = new String[entryValues.length - 1];
    CharSequence[] newEntries = new String[entryValues.length - 1];

    for (int i = 0, out = 0; i < entryValues.length; i++) {
        CharSequence value = entryValues[i];
        if (!value.equals(remove)) {
            newEntryValues[out] = value;
            newEntries[out] = entries[i];
            out++;
        }
    }

    listPreference.setEntryValues(newEntryValues);
    listPreference.setEntries(newEntries);
}
 
Example 22
Project: GitHub   File: SettingsActivity.java   View source code 5 votes vote down vote up
private void setSummary(Preference pref, boolean init) {
    if (pref instanceof EditTextPreference) {
        EditTextPreference editPref = (EditTextPreference) pref;
        pref.setSummary(editPref.getText());

        if (editPref.getKey().equals("env_dir") && !init) {
            editPref.setText(PrefStore.getEnvDir(this));
            pref.setSummary(editPref.getText());
        }

        if (editPref.getKey().equals("http_conf") &&
                editPref.getText().isEmpty()) {
            editPref.setText(PrefStore.getHttpConf(this));
            pref.setSummary(editPref.getText());
        }
    }

    if (pref instanceof ListPreference) {
        ListPreference listPref = (ListPreference) pref;
        pref.setSummary(listPref.getEntry());
    }

    if (pref instanceof CheckBoxPreference) {
        CheckBoxPreference checkPref = (CheckBoxPreference) pref;

        if (checkPref.getKey().equals("logger") && checkPref.isChecked() && init) {
            requestWritePermissions();
        }
    }
}
 
Example 23
Project: Linphone4Android   File: SettingsFragment.java   View source code 5 votes vote down vote up
private void initTunnelSettings() {
	if (!LinphoneManager.getLc().isTunnelAvailable()) {
		return;
	}

	setPreferenceDefaultValueAndSummary(R.string.pref_tunnel_host_key, mPrefs.getTunnelHost());
	setPreferenceDefaultValueAndSummary(R.string.pref_tunnel_port_key, String.valueOf(mPrefs.getTunnelPort()));
	ListPreference tunnelModePref = (ListPreference) findPreference(getString(R.string.pref_tunnel_mode_key));
	String tunnelMode = mPrefs.getTunnelMode();
	tunnelModePref.setSummary(tunnelMode);
	tunnelModePref.setValue(tunnelMode);
}
 
Example 24
Project: Rey-MusicPlayer   File: SettingsAppearanceFragment.java   View source code 5 votes vote down vote up
@Override
public void onCreate(Bundle onSavedInstanceState) {
    super.onCreate(onSavedInstanceState);
    addPreferencesFromResource(R.xml.settings_appearance);
    mPreferenceManager = this.getPreferenceManager();

    mStartUpScreenPreference = (ListPreference) mPreferenceManager.findPreference("preference_key_startup_screen");
    mStartUpScreenPreference.setOnPreferenceChangeListener((preference, o) -> {
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        builder.setTitle(R.string.restart_app);
        builder.setMessage(R.string.restart_app_des);
        builder.setPositiveButton(R.string.ok, (dialogInterface, i) -> {
            dialogInterface.dismiss();
            Intent intent = getActivity().getBaseContext().getPackageManager().getLaunchIntentForPackage(getActivity().getBaseContext().getPackageName());
            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
            intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
            getActivity().finish();
            startActivity(intent);
        });
        builder.setNegativeButton(R.string.cancel, (dialogInterface, i) -> dialogInterface.dismiss());
        builder.create().show();

        return true;
    });


}
 
Example 25
Project: Linphone4Android   File: SettingsFragment.java   View source code 5 votes vote down vote up
private void initializePreferredVideoSizePreferences(ListPreference pref) {
	List<CharSequence> entries = new ArrayList<CharSequence>();
	List<CharSequence> values = new ArrayList<CharSequence>();
	for (String name : LinphoneManager.getLc().getSupportedVideoSizes()) {
		entries.add(name);
		values.add(name);
	}

	setListPreferenceValues(pref, entries, values);

	String value = mPrefs.getPreferredVideoSize();
	pref.setSummary(value);
	pref.setValue(value);
}
 
Example 26
Project: WeatherAlarmClock   File: SettingsActivity.java   View source code 5 votes vote down vote up
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
    String stringValue = newValue.toString();
    if (preference instanceof ListPreference) {
        ListPreference listPreference = (ListPreference) preference;
        int prefIndex = listPreference.findIndexOfValue(stringValue);
        if (prefIndex >= 0) {
            preference.setSummary(listPreference.getEntries()[prefIndex]);
        }
    } else {
        preference.setSummary(stringValue);
    }
    return true;
}
 
Example 27
Project: Linphone4Android   File: SettingsFragment.java   View source code 5 votes vote down vote up
private void initLimeEncryptionPreference(ListPreference pref) {
	List<CharSequence> entries = new ArrayList<CharSequence>();
	List<CharSequence> values = new ArrayList<CharSequence>();
	entries.add(getString(R.string.lime_encryption_entry_disabled));
	values.add(LinphoneLimeState.Disabled.toString());

	LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
	if (lc == null || !lc.isLimeEncryptionAvailable()) {
		setListPreferenceValues(pref, entries, values);
		pref.setEnabled(false);
		return;
	}

	entries.add(getString(R.string.lime_encryption_entry_mandatory));
	values.add(LinphoneLimeState.Mandatory.toString());
	entries.add(getString(R.string.lime_encryption_entry_preferred));
	values.add(LinphoneLimeState.Preferred.toString());
	setListPreferenceValues(pref, entries, values);

	LinphoneLimeState lime = mPrefs.getLimeEncryption();
	if (lime == LinphoneLimeState.Disabled) {
		pref.setSummary(getString(R.string.lime_encryption_entry_disabled));
	} else if (lime == LinphoneLimeState.Mandatory) {
		pref.setSummary(getString(R.string.lime_encryption_entry_mandatory));
	} else if (lime == LinphoneLimeState.Preferred) {
		pref.setSummary(getString(R.string.lime_encryption_entry_preferred));
	}
	pref.setValue(lime.toString());
}
 
Example 28
Project: Linphone4Android   File: AccountPreferencesFragment.java   View source code 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 29
Project: Cable-Android   File: ListSummaryPreferenceFragment.java   View source code 5 votes vote down vote up
@Override
public boolean onPreferenceChange(Preference preference, Object value) {
  ListPreference listPref   = (ListPreference) preference;
  int            entryIndex = Arrays.asList(listPref.getEntryValues()).indexOf(value);

  listPref.setSummary(entryIndex >= 0 && entryIndex < listPref.getEntries().length
                      ? listPref.getEntries()[entryIndex]
                      : getString(R.string.preferences__led_color_unknown));
  return true;
}
 
Example 30
Project: SampleAppArch   File: SettingsActivity.java   View source code 5 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 if (preference instanceof RingtonePreference) {
    // For ringtone preferences, look up the correct display value
    // using RingtoneManager.
    if (TextUtils.isEmpty(stringValue)) {
      // Empty values correspond to 'silent' (no ringtone).
      preference.setSummary(R.string.pref_ringtone_silent);

    } else {
      Ringtone ringtone = RingtoneManager.getRingtone(
          preference.getContext(), Uri.parse(stringValue));

      if (ringtone == null) {
        // Clear the summary if there was a lookup error.
        preference.setSummary(null);
      } else {
        // Set the summary to reflect the new ringtone display
        // name.
        String name = ringtone.getTitle(preference.getContext());
        preference.setSummary(name);
      }
    }

  } else {
    // For all other preferences, set the summary to the value's
    // simple string representation.
    preference.setSummary(stringValue);
  }
  return true;
}
 
Example 31
Project: AC2RD   File: Preferences.java   View source code 5 votes vote down vote up
private void onSharedPreferenceAudioFormatChanged()
{
	try
	{
		Preference preferencesAudioFormat = findPreference("preferences_audio_format");
		if (preferencesAudioFormat instanceof ListPreference)
		{
			ListPreference listPreferencesAudioFormat = (ListPreference) preferencesAudioFormat;
			preferencesAudioFormatValue = (String) listPreferencesAudioFormat.getEntry();
			preferencesAudioFormat.setSummary(getString(R.string.preferences_audio_format_summary) + " " + listPreferencesAudioFormat.getEntry());
			
			Log.d("Preferences", "onSharedPreferenceAudioFormatChanged : " + getApplicationContext().getString(R.string.log_preferences_audio_format_changed) + " : " + listPreferencesAudioFormat.getEntry());
			
			if(isInit == true)
			{
				databaseManager.insertLog(getApplicationContext(), "" + getApplicationContext().getString(R.string.log_preferences_audio_format_changed) + " : " + listPreferencesAudioFormat.getEntry(), new Date().getTime(), 3, false);
			}
		}
	}
	catch (Exception e)
	{
		Log.w("Preferences", "onSharedPreferenceAudioFormatChanged : " + getApplicationContext().getString(R.string.log_preferences_error_audio_format_changed) + " : " + e);
		
		if(isInit == true)
		{
			databaseManager.insertLog(getApplicationContext(), "" + getApplicationContext().getString(R.string.log_preferences_error_audio_format_changed), new Date().getTime(), 2, false);
		}
	}
}
 
Example 32
Project: ultrasonic   File: SettingsFragment.java   View source code 5 votes vote down vote up
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    theme = (ListPreference) findPreference(Constants.PREFERENCES_KEY_THEME);
    videoPlayer = (ListPreference) findPreference(Constants.PREFERENCES_KEY_VIDEO_PLAYER);
    maxBitrateWifi = (ListPreference) findPreference(Constants.PREFERENCES_KEY_MAX_BITRATE_WIFI);
    maxBitrateMobile = (ListPreference) findPreference(Constants.PREFERENCES_KEY_MAX_BITRATE_MOBILE);
    cacheSize = (ListPreference) findPreference(Constants.PREFERENCES_KEY_CACHE_SIZE);
    cacheLocation = (EditTextPreference) findPreference(Constants.PREFERENCES_KEY_CACHE_LOCATION);
    preloadCount = (ListPreference) findPreference(Constants.PREFERENCES_KEY_PRELOAD_COUNT);
    bufferLength = (ListPreference) findPreference(Constants.PREFERENCES_KEY_BUFFER_LENGTH);
    incrementTime = (ListPreference) findPreference(Constants.PREFERENCES_KEY_INCREMENT_TIME);
    networkTimeout = (ListPreference) findPreference(Constants.PREFERENCES_KEY_NETWORK_TIMEOUT);
    maxAlbums = (ListPreference) findPreference(Constants.PREFERENCES_KEY_MAX_ALBUMS);
    maxSongs = (ListPreference) findPreference(Constants.PREFERENCES_KEY_MAX_SONGS);
    maxArtists = (ListPreference) findPreference(Constants.PREFERENCES_KEY_MAX_ARTISTS);
    defaultArtists = (ListPreference) findPreference(Constants.PREFERENCES_KEY_DEFAULT_ARTISTS);
    defaultSongs = (ListPreference) findPreference(Constants.PREFERENCES_KEY_DEFAULT_SONGS);
    defaultAlbums = (ListPreference) findPreference(Constants.PREFERENCES_KEY_DEFAULT_ALBUMS);
    chatRefreshInterval = (ListPreference) findPreference(Constants.PREFERENCES_KEY_CHAT_REFRESH_INTERVAL);
    directoryCacheTime = (ListPreference) findPreference(Constants.PREFERENCES_KEY_DIRECTORY_CACHE_TIME);
    mediaButtonsEnabled = (CheckBoxPreference) findPreference(Constants.PREFERENCES_KEY_MEDIA_BUTTONS);
    lockScreenEnabled = (CheckBoxPreference) findPreference(Constants.PREFERENCES_KEY_SHOW_LOCK_SCREEN_CONTROLS);
    sendBluetoothAlbumArt = (CheckBoxPreference) findPreference(Constants.PREFERENCES_KEY_SEND_BLUETOOTH_ALBUM_ART);
    sendBluetoothNotifications = (CheckBoxPreference) findPreference(Constants.PREFERENCES_KEY_SEND_BLUETOOTH_NOTIFICATIONS);
    viewRefresh = (ListPreference) findPreference(Constants.PREFERENCES_KEY_VIEW_REFRESH);
    imageLoaderConcurrency = (ListPreference) findPreference(Constants.PREFERENCES_KEY_IMAGE_LOADER_CONCURRENCY);
    sharingDefaultDescription = (EditTextPreference) findPreference(Constants.PREFERENCES_KEY_DEFAULT_SHARE_DESCRIPTION);
    sharingDefaultGreeting = (EditTextPreference) findPreference(Constants.PREFERENCES_KEY_DEFAULT_SHARE_GREETING);
    sharingDefaultExpiration = (TimeSpanPreference) findPreference(Constants.PREFERENCES_KEY_DEFAULT_SHARE_EXPIRATION);
    serversCategory = (PreferenceCategory) findPreference(Constants.PREFERENCES_KEY_SERVERS_KEY);

    sharingDefaultGreeting.setText(Util.getShareGreeting(getActivity()));
    setupClearSearchPreference();
    setupGaplessControlSettingsV14();
}
 
Example 33
Project: keepass2android   File: LatinIMESettings.java   View source code 5 votes vote down vote up
@Override
protected void onCreate(Bundle icicle) {
	SharedPreferences prefs =
			PreferenceManager.getDefaultSharedPreferences(this);
	Design.updateTheme(this, prefs);

    super.onCreate(icicle);
    addPreferencesFromResource(R.xml.prefs);
    mQuickFixes = (CheckBoxPreference) findPreference(QUICK_FIXES_KEY);
    mSettingsKeyPreference = (ListPreference) findPreference(PREF_SETTINGS_KEY);
    prefs.registerOnSharedPreferenceChangeListener(this);

    
}
 
Example 34
Project: AC2RD   File: Preferences.java   View source code 5 votes vote down vote up
private void onSharedPreferenceAudioSourceChanged()
{
	try
	{
		Preference preferencesAudioSource = findPreference("preferences_audio_source");
		if (preferencesAudioSource instanceof ListPreference)
		{
			ListPreference listPreferencesAudioSource = (ListPreference) preferencesAudioSource;
			preferencesAudioSourceValue = (String) listPreferencesAudioSource.getEntry();
			preferencesAudioSource.setSummary(getString(R.string.preferences_audio_source_summary) + " " + listPreferencesAudioSource.getEntry());
			
			Log.d("Preferences", "onSharedPreferenceAudioSourceChanged : " + getApplicationContext().getString(R.string.log_preferences_audio_source_changed) + " : " + listPreferencesAudioSource.getEntry());
			
			if(isInit == true)
			{	
				databaseManager.insertLog(getApplicationContext(), "" + getApplicationContext().getString(R.string.log_preferences_audio_source_changed) + " : " + listPreferencesAudioSource.getEntry(), new Date().getTime(), 3, false);
			}
		}
	}
	catch (Exception e)
	{
		Log.w("Preferences", "onSharedPreferenceAudioSourceChanged : " + getApplicationContext().getString(R.string.log_preferences_error_audio_source_changed) + " : " + e);
		
		if(isInit == true)
		{
			databaseManager.insertLog(getApplicationContext(), "" + getApplicationContext().getString(R.string.log_preferences_error_audio_source_changed), new Date().getTime(), 2, false);
		}
	}
}
 
Example 35
Project: order-by-android   File: SettingsActivity.java   View source code 5 votes vote down vote up
private void updatePreference(Preference preference) {
    //Mostra corretamente os objetos
    if (preference instanceof ListPreference) {
        ListPreference listPreference = (ListPreference) preference;
        listPreference.setSummary(listPreference.getEntry());
    }
    else if(preference instanceof EditTextPreference)
    {
        EditTextPreference editTextPreference = (EditTextPreference) preference;
        editTextPreference.setSummary(editTextPreference.getText());
    }
}
 
Example 36
Project: Botanist   File: SettingsActivity.java   View source code 5 votes vote down vote up
/**
 * Update a preference
 * @param key - which preference
 */
private void updatePref(String key){
    ListPreference preference = (ListPreference) findPreference(key);
    CharSequence entry = preference.getEntry();
    String value = preference.getValue();
    preference.setSummary(entry);
    SharedPreferences.Editor editor = mPreferences.edit();
    // Fucking strangely, a string cannot be parsed to an integer
    editor.putString(key, value);
    editor.apply();
}
 
Example 37
Project: PeSanKita-android   File: ListSummaryPreferenceFragment.java   View source code 5 votes vote down vote up
@Override
public boolean onPreferenceChange(Preference preference, Object value) {
  ListPreference listPref   = (ListPreference) preference;
  int            entryIndex = Arrays.asList(listPref.getEntryValues()).indexOf(value);

  listPref.setSummary(entryIndex >= 0 && entryIndex < listPref.getEntries().length
                      ? listPref.getEntries()[entryIndex]
                      : getString(R.string.preferences__led_color_unknown));
  return true;
}
 
Example 38
Project: PeSanKita-android   File: AppearancePreferenceFragment.java   View source code 5 votes vote down vote up
@Override
public void onCreate(Bundle paramBundle) {
  super.onCreate(paramBundle);
  addPreferencesFromResource(R.xml.preferences_appearance);

  this.findPreference(TextSecurePreferences.THEME_PREF).setOnPreferenceChangeListener(new ListSummaryListener());
  this.findPreference(TextSecurePreferences.LANGUAGE_PREF).setOnPreferenceChangeListener(new ListSummaryListener());
  initializeListSummary((ListPreference)findPreference(TextSecurePreferences.THEME_PREF));
  initializeListSummary((ListPreference)findPreference(TextSecurePreferences.LANGUAGE_PREF));
}
 
Example 39
Project: decoy   File: AVChatSettingsFragment.java   View source code 5 votes vote down vote up
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
    String stringValue = newValue.toString();

    if (preference instanceof ListPreference) {
        ListPreference listPreference = (ListPreference) preference;
        int prefIndex = listPreference.findIndexOfValue(stringValue);
        if (prefIndex >= 0) {
            preference.setSummary(listPreference.getEntries()[prefIndex]);
        }
    } else {
        preference.setSummary(stringValue);
    }
    return true;
}
 
Example 40
Project: CSipSimple   File: GenericPrefs.java   View source code 5 votes vote down vote up
/**
 * Set summary of a list field If empty will display default summary If one
 * item selected will display item name
 * 
 * @param fieldName the preference key name
 */
public void setListFieldSummary(String fieldName) {
    PreferenceScreen pfs = getPreferenceScreen();
    ListPreference pref = (ListPreference) pfs.findPreference(fieldName);
    if (pref == null) {
        Log.w(THIS_FILE, "Unable to find preference " + fieldName);
        return;
    }

    CharSequence val = pref.getEntry();
    if (TextUtils.isEmpty(val)) {
        val = getDefaultFieldSummary(fieldName);
    }
    setPreferenceSummary(pref, val);
}