Search in sources :

Example 96 with ListPreference

use of androidx.preference.ListPreference in project kcanotify by antest1.

the class MainPreferenceFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    isActivitySet = true;
    Activity activity = getActivity();
    if (activity instanceof Callback)
        mCallback = (Callback) activity;
    Map<String, ?> allEntries = sharedPref.getAll();
    for (String key : allEntries.keySet()) {
        Preference preference = findPreference(key);
        if (preference == null)
            continue;
        if (preference instanceof ListPreference) {
            ListPreference etp = (ListPreference) preference;
            preference.setSummary(etp.getEntry());
        } else if (preference instanceof EditTextPreference) {
            EditTextPreference etp = (EditTextPreference) preference;
            preference.setSummary(getEditTextSummary(key, etp.getText()));
        } else if (PREF_KCA_NOTI_RINGTONE.equals(preference.getKey())) {
            String uri = sharedPref.getString(PREF_KCA_NOTI_RINGTONE, "");
            Uri ringtoneUri = Uri.parse(uri);
            String ringtoneTitle = getStringWithLocale(R.string.settings_string_silent);
            if (uri.length() > 0) {
                ringtoneTitle = getRingtoneTitle(ringtoneUri);
            }
            preference.setSummary(ringtoneTitle);
        }
        preference.setOnPreferenceChangeListener(this);
    }
}
Also used : EditTextPreference(androidx.preference.EditTextPreference) Preference(androidx.preference.Preference) ListPreference(androidx.preference.ListPreference) Activity(android.app.Activity) ListPreference(androidx.preference.ListPreference) EditTextPreference(androidx.preference.EditTextPreference) Uri(android.net.Uri)

Example 97 with ListPreference

use of androidx.preference.ListPreference in project kcanotify by antest1.

the class NestedPreferenceFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    Map<String, ?> allEntries = getPreferenceManager().getSharedPreferences().getAll();
    // SharedPreferences prefs = this.getActivity().getSharedPreferences("pref", MODE_PRIVATE);
    for (String key : allEntries.keySet()) {
        Preference pref = findPreference(key);
        if (pref == null)
            continue;
        pref.setOnPreferenceChangeListener(this);
        if (pref instanceof ListPreference) {
            ListPreference etp = (ListPreference) pref;
            pref.setSummary(etp.getEntry());
        } else if (pref instanceof EditTextPreference) {
            EditTextPreference etp = (EditTextPreference) pref;
            pref.setSummary(etp.getText());
        }
    }
}
Also used : Preference(androidx.preference.Preference) ListPreference(androidx.preference.ListPreference) EditTextPreference(androidx.preference.EditTextPreference) ListPreference(androidx.preference.ListPreference) EditTextPreference(androidx.preference.EditTextPreference)

Example 98 with ListPreference

use of androidx.preference.ListPreference in project kcanotify by antest1.

the class NestedPreferenceFragment method onSharedPreferenceChanged.

@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
    Preference pref = findPreference(key);
    if (pref instanceof ListPreference) {
        ListPreference etp = (ListPreference) pref;
        pref.setSummary(etp.getEntry());
    } else if (pref instanceof EditTextPreference) {
        EditTextPreference etp = (EditTextPreference) pref;
        pref.setSummary(etp.getText());
    }
}
Also used : Preference(androidx.preference.Preference) ListPreference(androidx.preference.ListPreference) EditTextPreference(androidx.preference.EditTextPreference) ListPreference(androidx.preference.ListPreference) EditTextPreference(androidx.preference.EditTextPreference)

Example 99 with ListPreference

use of androidx.preference.ListPreference in project android_packages_apps_crDroidSettings by crdroidandroid.

the class Navigation method initList.

private ListPreference initList(String key, int value) {
    ListPreference list = (ListPreference) getPreferenceScreen().findPreference(key);
    if (list == null)
        return null;
    list.setValue(Integer.toString(value));
    list.setSummary(list.getEntry());
    list.setOnPreferenceChangeListener(this);
    return list;
}
Also used : ListPreference(androidx.preference.ListPreference)

Example 100 with ListPreference

use of androidx.preference.ListPreference in project android_packages_apps_crDroidSettings by crdroidandroid.

the class Navigation method onPreferenceChange.

@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
    ContentResolver resolver = getActivity().getContentResolver();
    if (preference == mNavbarVisibility) {
        if (mIsNavSwitchingMode) {
            return false;
        }
        mIsNavSwitchingMode = true;
        boolean showing = ((Boolean) newValue);
        LineageSettings.System.putIntForUser(resolver, LineageSettings.System.FORCE_SHOW_NAVBAR, showing ? 1 : 0, UserHandle.USER_CURRENT);
        mNavbarVisibility.setChecked(showing);
        mHandler.postDelayed(new Runnable() {

            @Override
            public void run() {
                mIsNavSwitchingMode = false;
            }
        }, 1500);
        return true;
    } else if (preference == mNavigationBackLongPressAction) {
        handleListChange((ListPreference) preference, newValue, LineageSettings.System.KEY_BACK_LONG_PRESS_ACTION);
        return true;
    } else if (preference == mNavigationHomeLongPressAction) {
        handleListChange((ListPreference) preference, newValue, LineageSettings.System.KEY_HOME_LONG_PRESS_ACTION);
        return true;
    } else if (preference == mNavigationHomeDoubleTapAction) {
        handleListChange((ListPreference) preference, newValue, LineageSettings.System.KEY_HOME_DOUBLE_TAP_ACTION);
        return true;
    } else if (preference == mNavigationAppSwitchLongPressAction) {
        handleListChange((ListPreference) preference, newValue, LineageSettings.System.KEY_APP_SWITCH_LONG_PRESS_ACTION);
        return true;
    } else if (preference == mEdgeLongSwipeAction) {
        handleListChange(mEdgeLongSwipeAction, newValue, LineageSettings.System.KEY_EDGE_LONG_SWIPE_ACTION);
        return true;
    }
    return false;
}
Also used : ListPreference(androidx.preference.ListPreference) ContentResolver(android.content.ContentResolver)

Aggregations

ListPreference (androidx.preference.ListPreference)170 Test (org.junit.Test)24 Before (org.junit.Before)23 Preference (androidx.preference.Preference)20 EditTextPreference (androidx.preference.EditTextPreference)10 PreferenceScreen (androidx.preference.PreferenceScreen)10 SwitchPreference (androidx.preference.SwitchPreference)9 Context (android.content.Context)8 ContentResolver (android.content.ContentResolver)7 Intent (android.content.Intent)7 PersistableBundle (android.os.PersistableBundle)6 MultiSelectListPreference (androidx.preference.MultiSelectListPreference)6 Resources (android.content.res.Resources)5 Bundle (android.os.Bundle)5 RemoteException (android.os.RemoteException)5 RestrictionEntry (android.content.RestrictionEntry)4 OverlayInfo (android.content.om.OverlayInfo)4 ApplicationInfo (android.content.pm.ApplicationInfo)4 PackageInfo (android.content.pm.PackageInfo)4 WifiConfiguration (android.net.wifi.WifiConfiguration)4