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);
}
}
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());
}
}
}
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());
}
}
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;
}
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;
}
Aggregations