Search in sources :

Example 91 with PreferenceScreen

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);
        }
    }
}
Also used : PreferenceScreen(androidx.preference.PreferenceScreen) Bundle(android.os.Bundle)

Example 92 with PreferenceScreen

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);
        }
    }
}
Also used : PreferenceScreen(androidx.preference.PreferenceScreen) PreferenceCategory(androidx.preference.PreferenceCategory) Bundle(android.os.Bundle)

Example 93 with PreferenceScreen

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);
                }
            }
        }
    }
}
Also used : PreferenceScreen(androidx.preference.PreferenceScreen) Preference(androidx.preference.Preference) PreferenceGroup(androidx.preference.PreferenceGroup)

Example 94 with PreferenceScreen

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;
        }
    });
}
Also used : OnPreferenceClickListener(androidx.preference.Preference.OnPreferenceClickListener) FragmentManager(androidx.fragment.app.FragmentManager) PreferenceScreen(androidx.preference.PreferenceScreen) SwitchPreference(androidx.preference.SwitchPreference) Preference(androidx.preference.Preference)

Example 95 with PreferenceScreen

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);
}
Also used : PreferenceScreen(androidx.preference.PreferenceScreen) Preference(androidx.preference.Preference)

Aggregations

PreferenceScreen (androidx.preference.PreferenceScreen)244 Preference (androidx.preference.Preference)81 Test (org.junit.Test)60 Context (android.content.Context)36 PreferenceManager (androidx.preference.PreferenceManager)36 ContentResolver (android.content.ContentResolver)25 PreferenceCategory (androidx.preference.PreferenceCategory)24 Bundle (android.os.Bundle)20 ArrayList (java.util.ArrayList)20 SwitchPreference (androidx.preference.SwitchPreference)19 Resources (android.content.res.Resources)18 Before (org.junit.Before)17 ListPreference (androidx.preference.ListPreference)14 PackageManager (android.content.pm.PackageManager)13 PreferenceGroup (androidx.preference.PreferenceGroup)13 ApplicationInfo (android.content.pm.ApplicationInfo)9 VisibleForTesting (androidx.annotation.VisibleForTesting)9 List (java.util.List)9 UserManager (android.os.UserManager)8 StorageItemPreference (com.android.settings.deviceinfo.StorageItemPreference)8