use of androidx.preference.PreferenceScreen in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ChannelNotificationSettings method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final PreferenceScreen screen = getPreferenceScreen();
Bundle args = getArguments();
// If linking to this screen from an external app, expand settings
if (screen != null && args != null) {
if (!args.getBoolean(ARG_FROM_SETTINGS, false)) {
screen.setInitialExpandedChildrenCount(Integer.MAX_VALUE);
}
}
}
use of androidx.preference.PreferenceScreen in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ConfigureNotificationSettings method onCreate.
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
final PreferenceScreen screen = getPreferenceScreen();
final Bundle arguments = getArguments();
if (screen == null) {
return;
}
if (arguments != null) {
final String highlightKey = arguments.getString(EXTRA_FRAGMENT_ARG_KEY);
if (!TextUtils.isEmpty(highlightKey)) {
final PreferenceCategory advancedCategory = screen.findPreference(KEY_ADVANCED_CATEGORY);
// Has highlight row - expand everything
advancedCategory.setInitialExpandedChildrenCount(Integer.MAX_VALUE);
scrollToPreference(advancedCategory);
}
}
}
use of androidx.preference.PreferenceScreen in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class AppNotificationSettings method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final PreferenceScreen screen = getPreferenceScreen();
if (mShowLegacyChannelConfig && screen != null) {
// if showing legacy settings, pull advanced settings out of the advanced category
PreferenceGroup advanced = (PreferenceGroup) findPreference(KEY_ADVANCED_CATEGORY);
removePreference(KEY_ADVANCED_CATEGORY);
if (advanced != null) {
for (String key : LEGACY_NON_ADVANCED_KEYS) {
Preference pref = advanced.findPreference(key);
advanced.removePreference(pref);
if (pref != null) {
screen.addPreference(pref);
}
}
}
}
}
use of androidx.preference.PreferenceScreen in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ZenModeScheduleRuleSettings method onCreateInternal.
@Override
protected void onCreateInternal() {
final PreferenceScreen root = getPreferenceScreen();
mDays = root.findPreference(KEY_DAYS);
mDays.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
showDaysDialog();
return true;
}
});
final FragmentManager mgr = getFragmentManager();
mStart = new TimePickerPreference(getPrefContext(), mgr);
mStart.setKey(KEY_START_TIME);
mStart.setTitle(R.string.zen_mode_start_time);
mStart.setCallback(new TimePickerPreference.Callback() {
@Override
public boolean onSetTime(final int hour, final int minute) {
if (mDisableListeners)
return true;
if (!ZenModeConfig.isValidHour(hour))
return false;
if (!ZenModeConfig.isValidMinute(minute))
return false;
if (hour == mSchedule.startHour && minute == mSchedule.startMinute) {
return true;
}
if (DEBUG)
Log.d(TAG, "onPrefChange start h=" + hour + " m=" + minute);
mSchedule.startHour = hour;
mSchedule.startMinute = minute;
updateRule(ZenModeConfig.toScheduleConditionId(mSchedule));
return true;
}
});
root.addPreference(mStart);
mStart.setDependency(mDays.getKey());
mEnd = new TimePickerPreference(getPrefContext(), mgr);
mEnd.setKey(KEY_END_TIME);
mEnd.setTitle(R.string.zen_mode_end_time);
mEnd.setCallback(new TimePickerPreference.Callback() {
@Override
public boolean onSetTime(final int hour, final int minute) {
if (mDisableListeners)
return true;
if (!ZenModeConfig.isValidHour(hour))
return false;
if (!ZenModeConfig.isValidMinute(minute))
return false;
if (hour == mSchedule.endHour && minute == mSchedule.endMinute) {
return true;
}
if (DEBUG)
Log.d(TAG, "onPrefChange end h=" + hour + " m=" + minute);
mSchedule.endHour = hour;
mSchedule.endMinute = minute;
updateRule(ZenModeConfig.toScheduleConditionId(mSchedule));
return true;
}
});
root.addPreference(mEnd);
mEnd.setDependency(mDays.getKey());
mExitAtAlarm = (SwitchPreference) root.findPreference(KEY_EXIT_AT_ALARM);
mExitAtAlarm.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object o) {
mSchedule.exitAtAlarm = (Boolean) o;
updateRule(ZenModeConfig.toScheduleConditionId(mSchedule));
return true;
}
});
}
use of androidx.preference.PreferenceScreen in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ZenModeSettingsBase method updatePreference.
void updatePreference(AbstractPreferenceController controller) {
final PreferenceScreen screen = getPreferenceScreen();
if (!controller.isAvailable()) {
return;
}
final String key = controller.getPreferenceKey();
final Preference preference = screen.findPreference(key);
if (preference == null) {
Log.d(TAG, String.format("Cannot find preference with key %s in Controller %s", key, controller.getClass().getSimpleName()));
return;
}
controller.updateState(preference);
}
Aggregations