use of android.support.v7.preference.ListPreference in project android_packages_apps_CMParts by LineageOS.
the class WeatherServiceSettings method onActivityCreated.
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
addPreferencesFromResource(R.xml.weather_settings);
final PreferenceScreen ps = getPreferenceScreen();
mGeneralSettingsCategory = (PreferenceCategory) ps.findPreference(PREFERENCE_GENERAL);
mProvidersCategory = (PreferenceCategory) ps.findPreference(PREFERENCE_PROVIDERS);
mTemperatureUnit = (ListPreference) ps.findPreference(PREFERENCE_TEMP_UNIT);
mTemperatureUnit.setOnPreferenceChangeListener(this);
watch(CMSettings.Secure.getUriFor(CMSettings.Secure.WEATHER_PROVIDER_SERVICE));
}
use of android.support.v7.preference.ListPreference in project NewPipe by TeamNewPipe.
the class ContentSettingsFragment method onCreatePreferences.
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
homeDir = getActivity().getApplicationInfo().dataDir;
databasesDir = new File(homeDir + "/databases");
newpipe_db = new File(homeDir + "/databases/newpipe.db");
newpipe_db_journal = new File(homeDir + "/databases/newpipe.db-journal");
addPreferencesFromResource(R.xml.content_settings);
final ListPreference mainPageContentPref = (ListPreference) findPreference(getString(R.string.main_page_content_key));
mainPageContentPref.setOnPreferenceChangeListener((Preference preference, Object newValueO) -> {
final String newValue = newValueO.toString();
final String mainPrefOldValue = defaultPreferences.getString(getString(R.string.main_page_content_key), "blank_page");
final String mainPrefOldSummary = getMainPagePrefSummery(mainPrefOldValue, mainPageContentPref);
if (newValue.equals(getString(R.string.kiosk_page_key))) {
SelectKioskFragment selectKioskFragment = new SelectKioskFragment();
selectKioskFragment.setOnSelectedLisener((String kioskId, int service_id) -> {
defaultPreferences.edit().putInt(getString(R.string.main_page_selected_service), service_id).apply();
defaultPreferences.edit().putString(getString(R.string.main_page_selectd_kiosk_id), kioskId).apply();
String serviceName = "";
try {
serviceName = NewPipe.getService(service_id).getServiceInfo().getName();
} catch (ExtractionException e) {
onError(e);
}
String kioskName = KioskTranslator.getTranslatedKioskName(kioskId, getContext());
String summary = String.format(getString(R.string.service_kiosk_string), serviceName, kioskName);
mainPageContentPref.setSummary(summary);
});
selectKioskFragment.setOnCancelListener(() -> {
mainPageContentPref.setSummary(mainPrefOldSummary);
mainPageContentPref.setValue(mainPrefOldValue);
});
selectKioskFragment.show(getFragmentManager(), "select_kiosk");
} else if (newValue.equals(getString(R.string.channel_page_key))) {
SelectChannelFragment selectChannelFragment = new SelectChannelFragment();
selectChannelFragment.setOnSelectedLisener((String url, String name, int service) -> {
defaultPreferences.edit().putInt(getString(R.string.main_page_selected_service), service).apply();
defaultPreferences.edit().putString(getString(R.string.main_page_selected_channel_url), url).apply();
defaultPreferences.edit().putString(getString(R.string.main_page_selected_channel_name), name).apply();
mainPageContentPref.setSummary(name);
});
selectChannelFragment.setOnCancelListener(() -> {
mainPageContentPref.setSummary(mainPrefOldSummary);
mainPageContentPref.setValue(mainPrefOldValue);
});
selectChannelFragment.show(getFragmentManager(), "select_channel");
} else {
mainPageContentPref.setSummary(getMainPageSummeryByKey(newValue));
}
defaultPreferences.edit().putBoolean(Constants.KEY_MAIN_PAGE_CHANGE, true).apply();
return true;
});
Preference importDataPreference = findPreference(getString(R.string.import_data));
importDataPreference.setOnPreferenceClickListener((Preference p) -> {
Intent i = new Intent(getActivity(), FilePickerActivityHelper.class).putExtra(FilePickerActivityHelper.EXTRA_ALLOW_MULTIPLE, false).putExtra(FilePickerActivityHelper.EXTRA_ALLOW_CREATE_DIR, false).putExtra(FilePickerActivityHelper.EXTRA_MODE, FilePickerActivityHelper.MODE_FILE);
startActivityForResult(i, REQUEST_IMPORT_PATH);
return true;
});
Preference exportDataPreference = findPreference(getString(R.string.export_data));
exportDataPreference.setOnPreferenceClickListener((Preference p) -> {
Intent i = new Intent(getActivity(), FilePickerActivityHelper.class).putExtra(FilePickerActivityHelper.EXTRA_ALLOW_MULTIPLE, false).putExtra(FilePickerActivityHelper.EXTRA_ALLOW_CREATE_DIR, true).putExtra(FilePickerActivityHelper.EXTRA_MODE, FilePickerActivityHelper.MODE_DIR);
startActivityForResult(i, REQUEST_EXPORT_PATH);
return true;
});
}
use of android.support.v7.preference.ListPreference in project AndelaMedManager by jumaallan.
the class SettingsFragment method loadSummaries.
private void loadSummaries(String key) {
ListPreference preference = (ListPreference) findPreference("THEME");
preference.setSummary(preference.getEntry());
if (ObjectsCompat.equals(key, "THEME")) {
getActivity().recreate();
}
}
use of android.support.v7.preference.ListPreference in project android_packages_apps_Settings by DirtyUnicorns.
the class DevelopmentSettings method addListPreference.
private ListPreference addListPreference(String prefKey) {
ListPreference pref = (ListPreference) findPreference(prefKey);
mAllPrefs.add(pref);
pref.setOnPreferenceChangeListener(this);
return pref;
}
use of android.support.v7.preference.ListPreference in project android_packages_apps_DU-Tweaks by DirtyUnicorns.
the class LockscreenItems method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.lockscreen_items);
ContentResolver resolver = getActivity().getContentResolver();
final PreferenceScreen prefScreen = getPreferenceScreen();
mFooterPreferenceMixin.createFooterPreference().setTitle(R.string.lockscreen_torch_warning_text);
if (!DUActionUtils.deviceSupportsFlashLight(getContext())) {
Preference toRemove = prefScreen.findPreference(TORCH_POWER_BUTTON_GESTURE);
if (toRemove != null) {
prefScreen.removePreference(toRemove);
}
} else {
mTorchPowerButton = (ListPreference) findPreference(TORCH_POWER_BUTTON_GESTURE);
int mTorchPowerButtonValue = Settings.Secure.getInt(resolver, Settings.Secure.TORCH_POWER_BUTTON_GESTURE, 0);
mTorchPowerButton.setValue(Integer.toString(mTorchPowerButtonValue));
mTorchPowerButton.setSummary(mTorchPowerButton.getEntry());
mTorchPowerButton.setOnPreferenceChangeListener(this);
}
}
Aggregations