android.preference.MultiSelectListPreference Java Examples

The following examples show how to use android.preference.MultiSelectListPreference. 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: SettingsFragment.java    From JPPF with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
  try {
    super.onCreate(savedInstanceState);
    // Load the preferences screen from an XML resource
    addPreferencesFromResource(R.xml.preferences);
    String[] pickerKeys = { PreferenceUtils.TRUST_STORE_LOCATION_KEY, PreferenceUtils.KEY_STORE_LOCATION_KEY };
    for (String key: pickerKeys) {
      FilechoserEditTextPreference picker = (FilechoserEditTextPreference) findPreference(key);
      picker.setFragment(this);
    }
    PreferenceScreen pref = (PreferenceScreen) findPreference("pref_security");
    if (SUPPORTED_CIPHER_SUITES.isEmpty()) {
      SSLSocketFactory ssf = (SSLSocketFactory) SSLSocketFactory.getDefault();
      ENABLED_CIPHER_SUITES.addAll(Arrays.asList(ssf.getDefaultCipherSuites()));
      SUPPORTED_CIPHER_SUITES.addAll(Arrays.asList(ssf.getSupportedCipherSuites()));
    }
    MultiSelectListPreference ciphersPref = (MultiSelectListPreference) findPreference(PreferenceUtils.ENABLED_CIPHER_SUITES_KEY);
    ciphersPref.setDefaultValue(ENABLED_CIPHER_SUITES.toArray(new String[ENABLED_CIPHER_SUITES.size()]));
    ciphersPref.setEntryValues(SUPPORTED_CIPHER_SUITES.toArray(new String[SUPPORTED_CIPHER_SUITES.size()]));
    ciphersPref.setEntries(SUPPORTED_CIPHER_SUITES.toArray(new String[SUPPORTED_CIPHER_SUITES.size()]));
  } catch(Throwable t) {
    t.printStackTrace();
  }
}
 
Example #2
Source File: SettingsActivity.java    From Equate with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Helper Class to setup the default Unit Type preference list in code
 */
private void setUpUnitTypePrefs() {
   PreferenceScreen screen = getPreferenceScreen();
   MultiSelectListPreference listPref = new MultiSelectListPreference(super.getActivity());
   listPref.setOrder(0);
   listPref.setDialogTitle(R.string.unit_select_title);
   listPref.setKey(UNIT_TYPE_PREF_KEY);
   listPref.setSummary(R.string.unit_select_summary);
   listPref.setTitle(R.string.unit_select_title);
   listPref.setEntries(getUnitTypeNameArray(getResources()));

   String[] keyArray = getUnitTypeKeyArray(getResources());
   listPref.setEntryValues(keyArray);

   final Set<String> result = new HashSet<>();
   Collections.addAll(result, keyArray);

   listPref.setDefaultValue(result);

   screen.addPreference(listPref);
}
 
Example #3
Source File: Preferences.java    From XInternalSD with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
protected void onPostExecute(Void result) {
    CharSequence[] appNamesList = appNames
            .toArray(new CharSequence[appNames.size()]);
    CharSequence[] packageNamesList = packageNames
            .toArray(new CharSequence[packageNames.size()]);

    enabledApps.setEntries(appNamesList);
    enabledApps.setEntryValues(packageNamesList);
    enabledApps.setEnabled(true);
    disabledApps.setEntries(appNamesList);
    disabledApps.setEntryValues(packageNamesList);
    disabledApps.setEnabled(true);

    Preference.OnPreferenceClickListener listener = new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            ((MultiSelectListPreference) preference).getDialog().getWindow().setLayout(WindowManager.LayoutParams.FILL_PARENT, WindowManager.LayoutParams.FILL_PARENT);
            return false;
        }
    };

    enabledApps.setOnPreferenceClickListener(listener);
    disabledApps.setOnPreferenceClickListener(listener);
}
 
Example #4
Source File: PreferenceFragment.java    From AcDisplay with GNU General Public License v2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void setValue(@NonNull Preference preference,
                     @NonNull ConfigBase.Option option,
                     @NonNull Object value) {
    int mode = (int) value;
    String[] values = new String[Integer.bitCount(mode)];
    for (int i = 1, j = 0; j < values.length; i <<= 1) {
        if (Operator.bitAnd(mode, i)) {
            values[j++] = Integer.toString(i);
        }
    }

    Set<String> valuesSet = new HashSet<>();
    Collections.addAll(valuesSet, values);

    MultiSelectListPreference mslp = (MultiSelectListPreference) preference;
    mslp.setValues(valuesSet);
}
 
Example #5
Source File: GroupPreferenceFragment.java    From tickmate with GNU General Public License v3.0 6 votes vote down vote up
private void loadGroup() {
    // Consider adding more features here, such as those in Track and TrackPreferenceFragment
    name = (EditTextPreference) findPreference("name");
    name.setText(group.getName());
    name.setSummary(group.getName());

    description = (EditTextPreference) findPreference("description");
    description.setText(group.getDescription());
    description.setSummary(group.getDescription());

    mTracksPref = (MultiSelectListPreference) findPreference("tracks");
    mTracksPref.setValues(getTrackIdsForGroupAsSet(group.getId()));

    mTracksPref.setEntries(getAllTrackNamesAsCharSeq());
    mTracksPref.setEntryValues(getAllTrackIdsAsCharSeq());
    mTracksPref.setSummary(getTrackNamesForSummary());

}
 
Example #6
Source File: SettingsActivity.java    From AndrOBD with GNU General Public License v3.0 6 votes vote down vote up
/**
 * set up protocol selection
 */
void setupElmCmdSelection()
{
	MultiSelectListPreference pref =
		(MultiSelectListPreference) findPreference(ELM_CMD_DISABLE);
	ElmProt.CMD[] values = ElmProt.CMD.values();
	HashSet<String> selections = new HashSet<>();
	CharSequence[] titles = new CharSequence[values.length];
	CharSequence[] keys = new CharSequence[values.length];
	int i = 0;
	for (ElmProt.CMD cmd : values)
	{
		titles[i] = cmd.toString();
		keys[i] = cmd.toString();
		if(!cmd.isEnabled()) selections.add(cmd.toString());
		i++;
	}
	// set enries and keys
	pref.setEntries(titles);
	pref.setEntryValues(keys);
	pref.setValues(selections);
}
 
Example #7
Source File: CustomRestrictionsFragment.java    From android-AppRestrictions with Apache License 2.0 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 #8
Source File: PreferenceFragment.java    From HeadsUp with GNU General Public License v2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void setValue(@NonNull Preference preference,
                     @NonNull ConfigBase.Option option,
                     @NonNull Object value) {
    int mode = (int) value;
    String[] values = new String[Integer.bitCount(mode)];
    for (int i = 1, j = 0; j < values.length; i <<= 1) {
        if (Operator.bitAnd(mode, i)) {
            values[j++] = Integer.toString(i);
        }
    }

    Set<String> valuesSet = new HashSet<>();
    Collections.addAll(valuesSet, values);

    MultiSelectListPreference mslp = (MultiSelectListPreference) preference;
    mslp.setValues(valuesSet);
}
 
Example #9
Source File: SettingsActivity.java    From android with MIT License 6 votes vote down vote up
private void updateReminderDaysSummary(MultiSelectListPreference daysPreference,
                                       Set<String> savedValues) {
    if (savedValues == null || savedValues.size() == 0) {
        daysPreference.setSummary(getActivity().getResources().getString(
                R.string.no_days_selected));
        return;
    }
    List<String> daysEntries = Arrays.asList(getActivity().getResources()
            .getStringArray(R.array.reminder_days_titles));
    List<String> daysEntriesValues = Arrays.asList(getActivity().getResources()
            .getStringArray(R.array.reminder_days_values));
    String summary = "";
    for (int i = 0; i < daysEntriesValues.size(); i++) {
        if (savedValues.contains(daysEntriesValues.get(i))) {
            if (!TextUtils.isEmpty(summary)) {
                summary += ", ";
            }
            summary += daysEntries.get(i);
        }
    }
    daysPreference.setSummary(summary);
}
 
Example #10
Source File: SettingsActivity.java    From android with MIT License 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.settings);

    boolean hasReminders = accountManager.getAllowReminders(getActivity());
    ((SwitchPreference) findPreference(AccountManager.KEY_ALLOW_REMINDERS))
            .setChecked(hasReminders);

    Set<String> reminderDays = accountManager.getReminderDays(getActivity());
    MultiSelectListPreference daysPreference =
            (MultiSelectListPreference) findPreference(AccountManager.KEY_REMINDER_DAYS);
    daysPreference.setValues(reminderDays);
    updateReminderDaysSummary(daysPreference, reminderDays);

    String notificationSetting = accountManager.getNotificationPreference(getActivity());
    ListPreference notificationPref =
            (ListPreference) findPreference(AccountManager.KEY_NOTIFICATIONS);
    notificationPref.setValue(notificationSetting);
}
 
Example #11
Source File: QuietHoursActivity.java    From GravityBox with Apache License 2.0 6 votes vote down vote up
private void setupWeekDaysPref() {
    mPrefWeekDays = (MultiSelectListPreference) findPreference(PREF_KEY_QH_WEEKDAYS);
    String[] days = new DateFormatSymbols(Locale.getDefault()).getWeekdays();
    CharSequence[] entries = new CharSequence[7];
    CharSequence[] entryValues = new CharSequence[7];
    for (int i = 1; i <= 7; i++) {
        entries[i - 1] = days[i];
        entryValues[i - 1] = String.valueOf(i);
    }
    mPrefWeekDays.setEntries(entries);
    mPrefWeekDays.setEntryValues(entryValues);
    if (mPrefs.getStringSet(PREF_KEY_QH_WEEKDAYS, null) == null) {
        Set<String> value = new HashSet<String>(Arrays.asList("2", "3", "4", "5", "6"));
        mPrefs.edit().putStringSet(PREF_KEY_QH_WEEKDAYS, value).commit();
        mPrefWeekDays.setValues(value);
    }
}
 
Example #12
Source File: CreateModulePreference.java    From GNSS_Compare with Apache License 2.0 6 votes vote down vote up
/**
 * defines a multiSelectList preference
 * @param preferenceKey Key of the preference
 * @param registeredObjectNames set containing possible values in the list preference
 * @param intentExtras intent passed to the fragment
 */
private void defineMultiSelectListPrefernece(String preferenceKey, Set<String> registeredObjectNames, Bundle intentExtras) {

    MultiSelectListPreference preference = (MultiSelectListPreference) findPreference(preferenceKey);
    CharSequence[] entries =
            registeredObjectNames.toArray(new CharSequence[registeredObjectNames.size()]);

    preference.setEntries(entries);
    preference.setEntryValues(entries);

    if(intentExtras != null){
        if(intentExtras.getStringArray(preferenceKey) == null){
            preference.setValues(null);
        } else {
            Set<String> selectedCorrections = new HashSet<>(Arrays.asList(intentExtras.getStringArray(preferenceKey)));
            preference.setValues(selectedCorrections);
        }
    } else {
        preference.setValues(new HashSet<String>());
    }
}
 
Example #13
Source File: SettingsActivityFragment.java    From geopaparazzi with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
    // get the preference that has been changed
    Preference pref = findPreference(key);
    // and if it's an instance of EditTextPreference class, update its summary
    if (pref instanceof EditTextPreference) {
        updateSummary((EditTextPreference) pref);
    } else if (pref instanceof ListPreference) {
        updateSummary((ListPreference) pref);
    } else if (pref instanceof MultiSelectListPreference) {
        updateSummary((MultiSelectListPreference) pref);
    }
}
 
Example #14
Source File: PreferencesFragment.java    From Bluefruit_LE_Connect_Android with MIT License 5 votes vote down vote up
private void updatePrefSummary(Preference p) {
    if (p instanceof ListPreference) {
        ListPreference listPref = (ListPreference) p;
        p.setSummary(listPref.getEntry());
    } else if (p instanceof EditTextPreference) {
        updateEditTextPreferenceSummary(p.getKey());
    } else if (p instanceof MultiSelectListPreference) {
        EditTextPreference editTextPref = (EditTextPreference) p;
        p.setSummary(editTextPref.getText());
    }
}
 
Example #15
Source File: AllPreferences.java    From YalpStore with GNU General Public License v2.0 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
private void drawBlackList() {
    Blacklist blacklistFragment = new Blacklist(activity);
    blacklistFragment.setBlackOrWhite((ListPreference) activity.findPreference(PreferenceUtil.PREFERENCE_UPDATE_LIST_WHITE_OR_BLACK));
    blacklistFragment.setAppList((MultiSelectListPreference) activity.findPreference(PreferenceUtil.PREFERENCE_UPDATE_LIST));
    blacklistFragment.setAutoWhitelist((CheckBoxPreference) activity.findPreference(PreferenceUtil.PREFERENCE_AUTO_WHITELIST));
    blacklistFragment.draw();
}
 
Example #16
Source File: OthersPreferenceFragment.java    From SkyTube with GNU General Public License v3.0 5 votes vote down vote up
@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		addPreferencesFromResource(R.xml.preference_others);

		// Default tab
		defaultTabPref = (ListPreference)findPreference(getString(R.string.pref_key_default_tab_name));
		Set<String> hiddenFragments = SkyTubeApp.getPreferenceManager().getStringSet(getString(R.string.pref_key_hide_tabs), new HashSet<>());
		String[] tabListValues = SkyTubeApp.getStringArray(R.array.tab_list_values);
		if(hiddenFragments.size() == 0) {
			defaultTabPref.setEntries(SkyTubeApp.getStringArray(R.array.tab_list));
			defaultTabPref.setEntryValues(tabListValues);
		} else {
			List<String> defaultTabEntries = new ArrayList<>();
			List<String> defaultTabEntryValues = new ArrayList<>();
			for(int i=0;i<SkyTubeApp.getStringArray(R.array.tab_list).length;i++) {
				if(!hiddenFragments.contains(tabListValues[i])) {
					defaultTabEntries.add(SkyTubeApp.getStringArray(R.array.tab_list)[i]);
					defaultTabEntryValues.add(tabListValues[i]);

				}
			}
			defaultTabPref.setEntries(defaultTabEntries.toArray(new CharSequence[defaultTabEntries.size()]));
			defaultTabPref.setEntryValues(defaultTabEntryValues.toArray(new CharSequence[defaultTabEntryValues.size()]));
		}
		if (defaultTabPref.getValue() == null) {
			defaultTabPref.setValueIndex(0);
		}
		defaultTabPref.setSummary(String.format(getString(R.string.pref_summary_default_tab), defaultTabPref.getEntry()));

		MultiSelectListPreference hiddenTabsPref = (MultiSelectListPreference)findPreference(getString(R.string.pref_key_hide_tabs));
		hiddenTabsPref.setEntryValues(tabListValues);

//		ListPreference feedNotificationPref = (ListPreference) findPreference(getString(R.string.pref_feed_notification_key));
//		if(feedNotificationPref.getValue() == null) {
//			feedNotificationPref.setValueIndex(0);
//		}
//		feedNotificationPref.setSummary(String.format(getString(R.string.pref_summary_feed_notification), feedNotificationPref.getEntry()));
	}
 
Example #17
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));
}
 
Example #18
Source File: MySolarSettingsFragment.java    From AndroidApp with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);

    // Load the preferences from an XML resource
    addPreferencesFromResource(R.xml.ms_preferences);

    sp = PreferenceManager.getDefaultSharedPreferences(getActivity().getBaseContext());
    loadValues();
    powerFeedPreference = (MultiSelectListPreference) this.findPreference("mysolar_power_feeds");
    //kWhFeedPreference = (ListPreference) this.findPreference("mysolar_kwh_feed");
    updateFeedList();
}
 
Example #19
Source File: PBPreferenceFragment.java    From client-android with GNU General Public License v2.0 5 votes vote down vote up
private void fillBuckets() {
    this.bucketNames = PBApplication.getMediaStore().getBucketData();

    final CharSequence[] ids = this.bucketNames.values().toArray(new CharSequence[this.bucketNames.size()]);
    final CharSequence[] names = this.bucketNames.keySet().toArray(new CharSequence[this.bucketNames.size()]);

    final MultiSelectListPreference bucketListPreference = (MultiSelectListPreference) findPreference(PBConstants.PREF_PICTURE_FOLDER_LIST);
    bucketListPreference.setEntries(ids);
    bucketListPreference.setEnabled(true);
    bucketListPreference.setEntryValues(names);

    setSummaries();
}
 
Example #20
Source File: SettingsActivity.java    From AndrOBD with GNU General Public License v3.0 5 votes vote down vote up
/**
 * set up selection for PIDs
 */
void setupPidSelection()
{
	MultiSelectListPreference itemList =
		(MultiSelectListPreference) findPreference(KEY_DATA_ITEMS);

	// collect data items for selection
	items = ObdProt.dataItems.getSvcDataItems(ObdProt.OBD_SVC_DATA);
	HashSet<String> selections = new HashSet<>();
	CharSequence[] titles = new CharSequence[items.size()];
	CharSequence[] keys = new CharSequence[items.size()];
	// loop through data items
	int i = 0;
	for (EcuDataItem currItem : items)
	{
		titles[i] = currItem.label;
		keys[i] = currItem.toString();
		selections.add(currItem.toString());
		i++;
	}
	// set enries and keys
	itemList.setEntries(titles);
	itemList.setEntryValues(keys);

	// if there is no item selected, mark all as selected
	if (itemList.getValues().size() == 0)
	{
		itemList.setValues(selections);
	}
}
 
Example #21
Source File: GroupPreferenceFragment.java    From tickmate with GNU General Public License v3.0 5 votes vote down vote up
@Override
    public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
                                          String key) {
        Preference pref = findPreference(key);

        if (pref instanceof EditTextPreference) {
            EditTextPreference etp = (EditTextPreference) pref;
            if (pref.equals(name)) {
                group.setName(name.getText());
            }
            if (pref.equals(description)) {
                group.setDescription(description.getText());
            }
            pref.setSummary(etp.getText());

            DataSource.getInstance().storeGroup(group);
        } else if (pref instanceof MultiSelectListPreference) {
            MultiSelectListPreference mp = (MultiSelectListPreference) pref;
//            Log.d(TAG, "MultiSelectListPreference changed, with trackIds: " + TextUtils.join(",", mp.getValues()));
            // Convert the Set returned by getValues into a List, as expected by setTrackIdsUsingStrings:
            List<Integer> trackIds = new ArrayList<>();
            for (String value : mp.getValues()) {
                trackIds.add(Integer.valueOf(value));
            }
            mDataSource.linkManyTracksOneGroup(trackIds, group.getId());
//            Log.d(TAG, "\tUser selected: " + TextUtils.join(",", trackIds));

            mTracksPref.setSummary(getTrackNamesForSummary());
//                    + "  \n" + TextUtils.join("\n", mDataSource.getGroups())); // Leaving here for future debugging, until tests are written
//            Log.d(TAG, "Confirm that the group IDs are correct: " + TextUtils.join(",", track.getGroupIdsAsSet()));
//            Log.d(TAG, "Confirm that the group NAMES are correct: " + TextUtils.join(",", track.getGroupNamesAsSet()));

        }
        mDataSource.storeGroup(group);

        // If this was launched simply to edit the track list, then exit at this point.
        if (mOpenTrackList) {
            getActivity().onBackPressed();
        }
    }
 
Example #22
Source File: QuietHoursActivity.java    From GravityBox with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mPrefs = SharedPreferencesUtils.getSharedPreferences(getPreferenceManager(), "quiet_hours");
    addPreferencesFromResource(R.xml.led_control_quiet_hours_settings);
    setupWeekDaysPref();
    mPrefSystemSounds = (MultiSelectListPreference) findPreference(PREF_KEY_QH_MUTE_SYSTEM_SOUNDS);
}
 
Example #23
Source File: SettingsActivityFragment.java    From geopaparazzi with GNU General Public License v3.0 4 votes vote down vote up
private void updateSummary(MultiSelectListPreference pref) {
    pref.setSummary(Arrays.toString(pref.getValues().toArray()));
}
 
Example #24
Source File: MultiSelectListPreferenceAssert.java    From assertj-android with Apache License 2.0 4 votes vote down vote up
public MultiSelectListPreferenceAssert(MultiSelectListPreference actual) {
  super(actual, MultiSelectListPreferenceAssert.class);
}
 
Example #25
Source File: PBPreferenceFragment.java    From client-android with GNU General Public License v2.0 4 votes vote down vote up
private void setSummaries() {
    final String wifiOnly = preferences.getString(PBConstants.PREF_WIFI_ONLY,
            getResources().getString(R.string.only_wifi_default)); // default
    final ListPreference wifiPreference = (ListPreference) findPreference(PBConstants.PREF_WIFI_ONLY);
    wifiPreference.setSummary(wifiOnly);

    final String recentUploadOnly = preferences.getString(PBConstants.PREF_RECENT_UPLOAD_ONLY,
            getResources().getString(R.string.only_recent_upload_default)); // default
    final ListPreference recentUploadPreference = (ListPreference) findPreference(PBConstants.PREF_RECENT_UPLOAD_ONLY);
    recentUploadPreference.setSummary(recentUploadOnly);

    final String serverUrl = preferences.getString(PBServerPreferenceFragment.PREF_SERVER_URL, null);
    if (serverUrl != null) {
        final String serverName = preferences.getString(PBConstants.PREF_SERVER, null);
        if (serverName != null) {
            final PBServerListPreference serverPreference = (PBServerListPreference) findPreference(PBConstants.PREF_SERVER);
            serverPreference.setSummary(serverName + " @ " + serverUrl);

            // bonus: left icon of the server
            final int serverNamesId = getResources().getIdentifier("pref_server_names", "array", getActivity().getPackageName());
            final String[] serverNames = getResources().getStringArray(serverNamesId);
            final int serverPosition = Arrays.asList(serverNames).indexOf(serverName);
            final int serverIconsId = getResources().getIdentifier("pref_server_icons", "array", getActivity().getPackageName());
            final String[] serverIcons = getResources().getStringArray(serverIconsId);
            final String serverIcon = serverIcons[serverPosition];
            final String[] parts = serverIcon.split("\\.");
            final String drawableName = parts[parts.length - 1];
            final int id = getResources().getIdentifier(drawableName, "drawable", getActivity().getPackageName());
            if (id != 0) {
                serverPreference.setIcon(id);
            }
        }
    }

    String bucketSummary = "";
    final Set<String> selectedBuckets = preferences.getStringSet(PBConstants.PREF_PICTURE_FOLDER_LIST, null);
    if (selectedBuckets != null && bucketNames != null) {
        final ArrayList<String> selectedBucketNames = new ArrayList<>();
        for (String entry : selectedBuckets) {
            String oneName = bucketNames.get(entry);
            if (oneName != null) {
                oneName = oneName.substring(0, oneName.lastIndexOf('(') - 1);
                selectedBucketNames.add(oneName);
            }
        }
        bucketSummary = TextUtils.join(", ", selectedBucketNames);
    }
    final MultiSelectListPreference bucketListPreference = (MultiSelectListPreference) findPreference(PBConstants.PREF_PICTURE_FOLDER_LIST);
    bucketListPreference.setSummary(bucketSummary);
}
 
Example #26
Source File: Blacklist.java    From YalpStore with GNU General Public License v2.0 4 votes vote down vote up
public AppListTask(MultiSelectListPreference appList) {
    this.appList = appList;
    setContext(appList.getContext());
}
 
Example #27
Source File: Blacklist.java    From YalpStore with GNU General Public License v2.0 4 votes vote down vote up
public BlackListOnPreferenceChangeListener(MultiSelectListPreference appList, CheckBoxPreference autoWhitelist) {
    this.appList = appList;
    this.autoWhitelist = autoWhitelist;
}
 
Example #28
Source File: Blacklist.java    From YalpStore with GNU General Public License v2.0 4 votes vote down vote up
public void setAppList(MultiSelectListPreference appList) {
    this.appList = appList;
}
 
Example #29
Source File: LedSettingsFragment.java    From GravityBox with Apache License 2.0 4 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.led_control_settings);

    mColorPref = (ColorPickerPreference) findPreference(PREF_KEY_LED_COLOR);
    mLedOnMsPref = (SeekBarPreference) findPreference(PREF_KEY_LED_TIME_ON);
    mLedOffMsPref = (SeekBarPreference) findPreference(PREF_KEY_LED_TIME_OFF);
    mOngoingPref = (CheckBoxPreference) findPreference(PREF_KEY_ONGOING);
    mNotifSoundOverridePref = (CheckBoxPreference) findPreference(PREF_KEY_NOTIF_SOUND_OVERRIDE);
    mNotifSoundPref = findPreference(PREF_KEY_NOTIF_SOUND);
    mSoundReplacePref = (CheckBoxPreference) findPreference(PREF_KEY_NOTIF_SOUND_REPLACE);
    mNotifSoundOnlyOncePref = (CheckBoxPreference) findPreference(PREF_KEY_NOTIF_SOUND_ONLY_ONCE);
    mNotifSoundOnlyOnceTimeoutPref = (SeekBarPreference) findPreference(PREF_KEY_NOTIF_SOUND_ONLY_ONCE_TIMEOUT);
    mNotifInsistentPref = (CheckBoxPreference) findPreference(PREF_KEY_NOTIF_INSISTENT);
    mVibratePatternOverridePref = (CheckBoxPreference) findPreference(PREF_KEY_VIBRATE_OVERRIDE);
    mVibratePatternPref = (EditTextPreference) findPreference(PREF_KEY_VIBRATE_PATTERN);
    mVibratePatternPref.setOnPreferenceChangeListener(this);
    mVibrateReplacePref = (CheckBoxPreference) findPreference(PREF_KEY_VIBRATE_REPLACE);
    mDefaultSettingsPref = (SwitchPreference) findPreference(PREF_KEY_DEFAULT_SETTINGS);
    mActiveScreenCat = (PreferenceCategory) findPreference(PREF_CAT_KEY_ACTIVE_SCREEN);
    mActiveScreenModePref = (ListPreference) findPreference(PREF_KEY_ACTIVE_SCREEN_MODE);
    mActiveScreenModePref.setOnPreferenceChangeListener(this);
    mActiveScreenIgnoreUpdatePref = (CheckBoxPreference) findPreference(PREF_KEY_ACTIVE_SCREEN_IGNORE_UPDATE);
    mLedModePref = (ListPreference) findPreference(PREF_KEY_LED_MODE);
    mLedModePref.setOnPreferenceChangeListener(this);
    mQhCat = (PreferenceCategory) findPreference(PREF_CAT_KEY_QH);
    mQhIgnorePref = (CheckBoxPreference) findPreference(PREF_KEY_QH_IGNORE);
    mQhIgnoreListPref = (EditTextPreference) findPreference(PREF_KEY_QH_IGNORE_LIST);
    mHeadsUpCat = (PreferenceCategory) findPreference(PREF_CAT_KEY_HEADS_UP);
    mHeadsUpModePref = (ListPreference) findPreference(PREF_KEY_HEADS_UP_MODE);
    mHeadsUpModePref.setOnPreferenceChangeListener(this);
    mHeadsUpDndPref = (CheckBoxPreference) findPreference(PREF_KEY_HEADS_UP_DND);
    mHeadsUpTimeoutPref = (SeekBarPreference) findPreference(PREF_KEY_HEADS_UP_TIMEOUT);
    mOtherCat = (PreferenceCategory) findPreference(PREF_CAT_KEY_OTHER);
    mProgressTrackingPref = (CheckBoxPreference) findPreference(PREF_KEY_PROGRESS_TRACKING);
    mVisibilityPref = (ListPreference) findPreference(PREF_KEY_VISIBILITY);
    mVisibilityPref.setOnPreferenceChangeListener(this);
    mVisibilityLsPref = (ListPreference) findPreference(PREF_KEY_VISIBILITY_LS);
    mVisibilityLsPref.setOnPreferenceChangeListener(this);
    mDisableSoundToVibratePref = (CheckBoxPreference) findPreference(PREF_KEY_DISABLE_SOUND_TO_VIBRATE);
    mHidePersistentPref = (CheckBoxPreference) findPreference(PREF_KEY_HIDE_PERSISTENT);
    mLedDndPref = (MultiSelectListPreference) findPreference(PREF_KEY_LED_DND);
    mLedIgnoreUpdatePref = (CheckBoxPreference) findPreference(PREF_KEY_LED_IGNORE_UPDATE);
}
 
Example #30
Source File: PrefsActivity.java    From ETSMobile-Android2 with Apache License 2.0 3 votes vote down vote up
@Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);

            addPreferencesFromResource(R.xml.preferences);
            
            String[] selections = getResources().getStringArray(R.array.sources_news_values);
            Set<String> selectionSet = new HashSet<String>();
            selectionSet.addAll(Arrays.asList(selections));

            MultiSelectListPreference multiSelectPref = new MultiSelectListPreference(getActivity());
            multiSelectPref.setKey("multi_pref");
            multiSelectPref.setTitle(CHOIX_DES_SOURCES);
            multiSelectPref.setEntries(R.array.sources_news);
            multiSelectPref.setEntryValues(R.array.sources_news_values);
            multiSelectPref.setDefaultValue(selectionSet);
            getPreferenceScreen().addPreference(multiSelectPref);





            // Make sure default values are applied.  In a real app, you would
            // want this in a shared function that is used to retrieve the
            // SharedPreferences wherever they are needed.
//            PreferenceManager.setDefaultValues(getActivity(),R.xml.advanced_preferences, false);

            // Load the preferences from an XML resource

        }