Search in sources :

Example 66 with PreferenceCategory

use of androidx.preference.PreferenceCategory in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class SecuritySettings method updateCategoryVisibility.

/* Remove empty categories */
@Override
public void updateCategoryVisibility() {
    final PreferenceScreen screen = getPreferenceScreen();
    if (screen == null) {
        return;
    }
    PreferenceCategory category = findPreference(SECURITY_STATUS_CATEGORY);
    if (category == null) {
        return;
    }
    // This category only holds some google play tiles which don't exist without gapps
    if (category.getPreferenceCount() == 0) {
        screen.removePreference(category);
    }
}
Also used : PreferenceScreen(androidx.preference.PreferenceScreen) PreferenceCategory(androidx.preference.PreferenceCategory)

Example 67 with PreferenceCategory

use of androidx.preference.PreferenceCategory in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class FingerprintSettings method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.rr_fp);
    PreferenceScreen prefSet = getPreferenceScreen();
    ContentResolver resolver = getActivity().getContentResolver();
    mSupported = getResources().getBoolean(R.bool.config_supportScreenOffFod);
    mFingerprintUnlock = (SystemSettingSwitchPreference) findPreference(FP_KEYSTORE);
    mExp = (Preference) findPreference(EXP);
    // FOD category
    PreferenceCategory fodIconPickerCategory = (PreferenceCategory) findPreference(FOD_ICON_PICKER_CATEGORY);
    PackageManager packageManager = getContext().getPackageManager();
    supportsFod = packageManager.hasSystemFeature(RRContextConstants.Features.FOD);
    if (fodIconPickerCategory != null && !supportsFod) {
        fodIconPickerCategory.getParent().removePreference(fodIconPickerCategory);
    }
    mFingerprintManager = (FingerprintManager) getActivity().getSystemService(Context.FINGERPRINT_SERVICE);
    if (mFingerprintUnlock != null) {
        if (LockPatternUtils.isDeviceEncryptionEnabled()) {
            mFingerprintUnlock.setEnabled(false);
            mFingerprintUnlock.setSummary(R.string.fp_encrypt_warning);
        } else {
            mFingerprintUnlock.setEnabled(true);
            mFingerprintUnlock.setSummary(R.string.fp_unlock_keystore_summary);
        }
    }
    int anim = Settings.System.getInt(getActivity().getContentResolver(), Settings.System.RR_CONFIG_ANIM, 0);
    try {
        if (anim == 0) {
            removePreference("animation");
        } else if (anim == 1) {
            removePreference("preview");
        } else if (anim == 2) {
            removePreference("animation");
            removePreference("preview");
        }
    } catch (Exception e) {
    }
}
Also used : PreferenceScreen(androidx.preference.PreferenceScreen) PackageManager(android.content.pm.PackageManager) PreferenceCategory(androidx.preference.PreferenceCategory) ContentResolver(android.content.ContentResolver)

Example 68 with PreferenceCategory

use of androidx.preference.PreferenceCategory in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class UsbDetailsPowerRoleControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = RuntimeEnvironment.application;
    mLifecycle = new Lifecycle(() -> mLifecycle);
    mPreferenceManager = new PreferenceManager(mContext);
    mScreen = mPreferenceManager.createPreferenceScreen(mContext);
    when(mFragment.getActivity()).thenReturn(mActivity);
    when(mActivity.getApplicationContext()).thenReturn(mContext);
    when(mFragment.getContext()).thenReturn(mContext);
    when(mFragment.getPreferenceManager()).thenReturn(mPreferenceManager);
    when(mFragment.getPreferenceScreen()).thenReturn(mScreen);
    mDetailsPowerRoleController = new UsbDetailsPowerRoleController(mContext, mFragment, mUsbBackend);
    mPreference = new PreferenceCategory(mContext);
    mPreference.setKey(mDetailsPowerRoleController.getPreferenceKey());
    mScreen.addPreference(mPreference);
    mDetailsPowerRoleController.mHandler = mHandler;
}
Also used : PreferenceCategory(androidx.preference.PreferenceCategory) Lifecycle(com.android.settingslib.core.lifecycle.Lifecycle) PreferenceManager(androidx.preference.PreferenceManager) Before(org.junit.Before)

Example 69 with PreferenceCategory

use of androidx.preference.PreferenceCategory in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class PhysicalKeyboardFragment method updateHardKeyboards.

private void updateHardKeyboards(@NonNull List<HardKeyboardDeviceInfo> newHardKeyboards) {
    if (Objects.equals(mLastHardKeyboards, newHardKeyboards)) {
        // Nothing has changed.  Ignore.
        return;
    }
    // TODO(yukawa): Maybe we should follow the style used in ConnectedDeviceDashboardFragment.
    mLastHardKeyboards.clear();
    mLastHardKeyboards.addAll(newHardKeyboards);
    final PreferenceScreen preferenceScreen = getPreferenceScreen();
    preferenceScreen.removeAll();
    final PreferenceCategory category = new PreferenceCategory(getPrefContext());
    category.setTitle(R.string.builtin_keyboard_settings_title);
    category.setOrder(0);
    preferenceScreen.addPreference(category);
    for (HardKeyboardDeviceInfo hardKeyboardDeviceInfo : newHardKeyboards) {
        // TODO(yukawa): Consider using com.android.settings.widget.GearPreference
        final Preference pref = new Preference(getPrefContext());
        pref.setTitle(hardKeyboardDeviceInfo.mDeviceName);
        pref.setSummary(hardKeyboardDeviceInfo.mLayoutLabel);
        pref.setOnPreferenceClickListener(preference -> {
            showKeyboardLayoutDialog(hardKeyboardDeviceInfo.mDeviceIdentifier);
            return true;
        });
        category.addPreference(pref);
    }
    mKeyboardAssistanceCategory.setOrder(1);
    preferenceScreen.addPreference(mKeyboardAssistanceCategory);
    updateShowVirtualKeyboardSwitch();
}
Also used : PreferenceScreen(androidx.preference.PreferenceScreen) PreferenceCategory(androidx.preference.PreferenceCategory) SwitchPreference(androidx.preference.SwitchPreference) Preference(androidx.preference.Preference)

Example 70 with PreferenceCategory

use of androidx.preference.PreferenceCategory in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class PhysicalKeyboardFragment method onCreatePreferences.

@Override
public void onCreatePreferences(Bundle bundle, String s) {
    Activity activity = Preconditions.checkNotNull(getActivity());
    addPreferencesFromResource(R.xml.physical_keyboard_settings);
    mIm = Preconditions.checkNotNull(activity.getSystemService(InputManager.class));
    mKeyboardAssistanceCategory = Preconditions.checkNotNull((PreferenceCategory) findPreference(KEYBOARD_ASSISTANCE_CATEGORY));
    mShowVirtualKeyboardSwitch = Preconditions.checkNotNull((SwitchPreference) mKeyboardAssistanceCategory.findPreference(SHOW_VIRTUAL_KEYBOARD_SWITCH));
    findPreference(KEYBOARD_SHORTCUTS_HELPER).setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference preference) {
            toggleKeyboardShortcutsMenu();
            return true;
        }
    });
}
Also used : PreferenceCategory(androidx.preference.PreferenceCategory) SwitchPreference(androidx.preference.SwitchPreference) SwitchPreference(androidx.preference.SwitchPreference) Preference(androidx.preference.Preference) Activity(android.app.Activity)

Aggregations

PreferenceCategory (androidx.preference.PreferenceCategory)111 Preference (androidx.preference.Preference)38 PreferenceManager (androidx.preference.PreferenceManager)24 Before (org.junit.Before)24 PreferenceScreen (androidx.preference.PreferenceScreen)22 Test (org.junit.Test)19 SwitchPreference (androidx.preference.SwitchPreference)13 NotificationChannel (android.app.NotificationChannel)11 ArrayList (java.util.ArrayList)11 NotificationChannelGroup (android.app.NotificationChannelGroup)9 ShortcutInfo (android.content.pm.ShortcutInfo)9 Context (android.content.Context)8 ConversationChannel (android.app.people.ConversationChannel)7 View (android.view.View)7 PreferenceViewHolder (androidx.preference.PreferenceViewHolder)7 Lifecycle (com.android.settingslib.core.lifecycle.Lifecycle)7 ListPreference (androidx.preference.ListPreference)6 ComponentName (android.content.ComponentName)5 ContentResolver (android.content.ContentResolver)5 Bundle (android.os.Bundle)5