Search in sources :

Example 51 with ListPreference

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));
}
Also used : PreferenceScreen(android.support.v7.preference.PreferenceScreen)

Example 52 with ListPreference

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;
    });
}
Also used : ExtractionException(org.schabi.newpipe.extractor.exceptions.ExtractionException) FilePickerActivityHelper(org.schabi.newpipe.util.FilePickerActivityHelper) ListPreference(android.support.v7.preference.ListPreference) Preference(android.support.v7.preference.Preference) Intent(android.content.Intent) ListPreference(android.support.v7.preference.ListPreference) ZipFile(java.util.zip.ZipFile) File(java.io.File)

Example 53 with ListPreference

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();
    }
}
Also used : ListPreference(android.support.v7.preference.ListPreference)

Example 54 with ListPreference

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;
}
Also used : ListPreference(android.support.v7.preference.ListPreference)

Example 55 with ListPreference

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);
    }
}
Also used : PreferenceScreen(android.support.v7.preference.PreferenceScreen) ListPreference(android.support.v7.preference.ListPreference) Preference(android.support.v7.preference.Preference) SwitchPreference(android.support.v14.preference.SwitchPreference) ContentResolver(android.content.ContentResolver)

Aggregations

ListPreference (android.support.v7.preference.ListPreference)115 Preference (android.support.v7.preference.Preference)51 PreferenceScreen (android.support.v7.preference.PreferenceScreen)34 SwitchPreference (android.support.v14.preference.SwitchPreference)31 ContentResolver (android.content.ContentResolver)24 PreferenceCategory (android.support.v7.preference.PreferenceCategory)20 OnPreferenceChangeListener (android.support.v7.preference.Preference.OnPreferenceChangeListener)17 Intent (android.content.Intent)12 Resources (android.content.res.Resources)12 MultiSelectListPreference (android.support.v14.preference.MultiSelectListPreference)12 PackageInfo (android.content.pm.PackageInfo)11 CheckBoxPreference (android.support.v7.preference.CheckBoxPreference)11 RestrictionEntry (android.content.RestrictionEntry)10 OverlayInfo (android.content.om.OverlayInfo)10 ApplicationInfo (android.content.pm.ApplicationInfo)10 SmallTest (android.support.test.filters.SmallTest)10 HashSet (java.util.HashSet)10 Test (org.junit.Test)10 Matchers.anyString (org.mockito.Matchers.anyString)10 IBinder (android.os.IBinder)7