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