Java Code Examples for android.preference.PreferenceCategory#removePreference()
The following examples show how to use
android.preference.PreferenceCategory#removePreference() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SettingsFragment.java From Conversations with GNU General Public License v3.0 | 6 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.preferences); // Remove from standard preferences if the flag ONLY_INTERNAL_STORAGE is false if (!Config.ONLY_INTERNAL_STORAGE) { PreferenceCategory mCategory = (PreferenceCategory) findPreference("security_options"); if (mCategory != null) { Preference cleanCache = findPreference("clean_cache"); Preference cleanPrivateStorage = findPreference("clean_private_storage"); mCategory.removePreference(cleanCache); mCategory.removePreference(cleanPrivateStorage); } } Compatibility.removeUnusedPreferences(this); if (!TextUtils.isEmpty(page)) { openPreferenceScreen(page); } }
Example 2
Source File: ConfigurationActivity.java From Noyze with Apache License 2.0 | 6 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Accountant.getInstance(getActivity()); getActivity().setTitle(getString(R.string.media_settings)); addPreferencesFromResource(R.xml.media_preferences); // Check whether to show the notification-ringer volume link setting. AudioManager manager = (AudioManager) getActivity().getSystemService(Context.AUDIO_SERVICE); RingerNotificationLink linkChecker = new RingerNotificationLink(); boolean isNotifRingLinked = linkChecker.apply(manager); Preference link = findPreference("VolumePanel_linkNotifRinger"); link.setEnabled(!isNotifRingLinked); if (isNotifRingLinked) { PreferenceCategory category = (PreferenceCategory) findPreference("AudioMedia"); category.removePreference(link); } }
Example 3
Source File: SettingsFragment.java From Pix-Art-Messenger with GNU General Public License v3.0 | 6 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.preferences); // Remove from standard preferences if the flag ONLY_INTERNAL_STORAGE is false if (!Config.ONLY_INTERNAL_STORAGE) { PreferenceCategory mCategory = (PreferenceCategory) findPreference("security_options"); if (mCategory != null) { Preference cleanCache = findPreference("clean_cache"); Preference cleanPrivateStorage = findPreference("clean_private_storage"); mCategory.removePreference(cleanCache); mCategory.removePreference(cleanPrivateStorage); } } Compatibility.removeUnusedPreferences(this); if (!TextUtils.isEmpty(page)) { openPreferenceScreen(page); } }
Example 4
Source File: ConfigurationActivity.java From Noyze with Apache License 2.0 | 6 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Accountant.getInstance(getActivity()); getActivity().setTitle(getString(R.string.media_settings)); addPreferencesFromResource(R.xml.media_preferences); // Check whether to show the notification-ringer volume link setting. AudioManager manager = (AudioManager) getActivity().getSystemService(Context.AUDIO_SERVICE); RingerNotificationLink linkChecker = new RingerNotificationLink(); boolean isNotifRingLinked = linkChecker.apply(manager); Preference link = findPreference("VolumePanel_linkNotifRinger"); link.setEnabled(!isNotifRingLinked); if (isNotifRingLinked) { PreferenceCategory category = (PreferenceCategory) findPreference("AudioMedia"); category.removePreference(link); } }
Example 5
Source File: Settings.java From trekarta with GNU General Public License v3.0 | 6 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.preferences); Bundle args = getArguments(); if (!args.getBoolean(ARG_HILLSHADES_AVAILABLE, false)) { PreferenceCategory category = (PreferenceCategory) findPreference("category_general"); category.removePreference(findPreference("hillshades_transparency")); } Preference sdcardPref = findPreference("move_data"); sdcardPref.setOnPreferenceClickListener(preference -> { mFragmentHolder.popCurrent(); return false; }); Preference resetPref = findPreference("reset_advices"); resetPref.setOnPreferenceClickListener(preference -> { mFragmentHolder.popCurrent(); return false; }); getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this); }
Example 6
Source File: SettingsFragment.java From Popeens-DSub with GNU General Public License v3.0 | 6 votes |
@Override public void onCreate(Bundle bundle) { super.onCreate(bundle); if(Build.VERSION.SDK_INT >= 21) { CheckBoxPreference mediaButtons = (CheckBoxPreference) findPreference("mediaButtons"); if (mediaButtons != null) { PreferenceCategory otherCategory = (PreferenceCategory) findPreference("otherSettings"); otherCategory.removePreference(mediaButtons); } } int instance = this.getArguments().getInt(Constants.PREFERENCES_KEY_SERVER_INSTANCE, -1); if (instance != -1) { PreferenceScreen preferenceScreen = expandServer(instance); setPreferenceScreen(preferenceScreen); serverSettings.put(Integer.toString(instance), new ServerSettings(instance)); onInitPreferences(preferenceScreen); } }
Example 7
Source File: SettingsActivity.java From HayaiLauncher with Apache License 2.0 | 6 votes |
@SuppressWarnings("deprecation") @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.preferences); if(Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) { //remove priority preference (not supported) PreferenceCategory notificationCategory = (PreferenceCategory) findPreference("pref_category_notification"); ListPreference priorityPreference = (ListPreference) findPreference("pref_notification_priority"); notificationCategory.removePreference(priorityPreference); } }
Example 8
Source File: OpenFitActivity.java From OpenFit with MIT License | 6 votes |
@Override public void onReceive(Context context, Intent intent) { final String packageName = intent.getStringExtra(OpenFitIntent.EXTRA_PACKAGE_NAME); final String appName = intent.getStringExtra(OpenFitIntent.EXTRA_APP_NAME); Log.d(LOG_TAG, "Recieved del application: "+appName+" : "+packageName); appManager.delNotificationApp(packageName); oPrefs.removeSet(packageName); oPrefs.removeString(packageName); PreferenceCategory category = (PreferenceCategory) findPreference("preference_category_apps"); Preference app = (Preference) findPreference(packageName); category.removePreference(app); // If no more preference in the category, restore the placeholder if(category.getPreferenceCount() <= 0) { category.addPreference(preference_apps_placeholder); } sendNotificationApplications(); }
Example 9
Source File: OpenFitActivity.java From OpenFit with MIT License | 5 votes |
@Override public void onReceive(Context context, Intent intent) { final String packageName = intent.getStringExtra(OpenFitIntent.EXTRA_PACKAGE_NAME); final String appName = intent.getStringExtra(OpenFitIntent.EXTRA_APP_NAME); Log.d(LOG_TAG, "Recieved add application: "+appName+" : "+packageName); appManager.addNotificationApp(packageName); oPrefs.saveSet(packageName); oPrefs.saveString(packageName, appName); Preference app = createAppPreference(packageName, appName); PreferenceCategory category = (PreferenceCategory) findPreference("preference_category_apps"); category.removePreference(preference_apps_placeholder); category.addPreference(app); sendNotificationApplications(); }
Example 10
Source File: PrefFragment.java From BlitzMail with GNU Affero General Public License v3.0 | 5 votes |
@Override public void onResume() { super.onResume(); getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this); // recreate send now preference PreferenceCategory cat = (PreferenceCategory) findPreference("pref_sending"); if(cat.findPreference("pref_send_now") != null) { cat.removePreference(findPreference("pref_send_now")); } addSendNowPref(getActivity()); }
Example 11
Source File: ProfileEditFragment.java From SecondScreen with Apache License 2.0 | 5 votes |
private void disablePreference(String preferenceName, String categoryName, boolean shouldClear) { SharedPreferences prefNew = U.getPrefNew(getActivity()); if(shouldClear && prefNew.getBoolean(preferenceName, false)) { SharedPreferences.Editor editor = prefNew.edit(); editor.putBoolean(preferenceName, false); editor.apply(); } PreferenceCategory category = (PreferenceCategory) getPreferenceScreen().findPreference(categoryName); category.removePreference(getPreferenceScreen().findPreference(preferenceName)); }
Example 12
Source File: DesktopModeFragment.java From Taskbar with Apache License 2.0 | 5 votes |
@Override protected void loadPrefs() { // Add preferences addPreferencesFromResource(R.xml.tb_pref_desktop_mode); // Set OnClickListeners for certain preferences findPreference(PREF_DESKTOP_MODE).setOnPreferenceClickListener(this); findPreference(PREF_SET_LAUNCHER_DEFAULT).setOnPreferenceClickListener(this); findPreference(PREF_PRIMARY_LAUNCHER).setOnPreferenceClickListener(this); findPreference(PREF_DIM_SCREEN).setOnPreferenceClickListener(this); findPreference(PREF_ENABLE_ADDITIONAL_SETTINGS).setOnPreferenceClickListener(this); if(!U.isShowHideNavbarSupported()) { PreferenceCategory category = (PreferenceCategory) findPreference(PREF_ADDITIONAL_SETTINGS); category.removePreference(findPreference(PREF_AUTO_HIDE_NAVBAR_DESKTOP_MODE)); } SharedPreferences pref = U.getSharedPreferences(getActivity()); if(pref.getBoolean(PREF_LAUNCHER, false)) { findPreference(PREF_DESKTOP_MODE).setEnabled(false); U.showToastLong(getActivity(), R.string.tb_disable_home_setting); } else bindPreferenceSummaryToValue(findPreference(PREF_DESKTOP_MODE)); bindPreferenceSummaryToValue(findPreference(PREF_DISPLAY_DENSITY)); DisplayManager manager = (DisplayManager) getActivity().getSystemService(Context.DISPLAY_SERVICE); manager.registerDisplayListener(listener, null); updateAdditionalSettings(); }
Example 13
Source File: TalkBackKeyboardShortcutPreferencesActivity.java From talkback with Apache License 2.0 | 5 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); keymap = getArguments().getString(BUNDLE_KEYMAP); PreferenceSettingsUtils.addPreferencesFromResource(this, getPreferenceResourceId(keymap)); PreferenceScreen resetKeymapPreferenceScreen = (PreferenceScreen) findPreference(getString(R.string.pref_reset_keymap_key)); resetKeymapPreferenceScreen.setOnPreferenceClickListener(resetKeymapPreferenceClickListener); boolean isArc = FeatureSupport.isArc(); // Hide select keymap preference in Arc if current keymap is already set to default // keymap. if (isArc && getKeyComboManager().getKeyComboModel() instanceof DefaultKeyComboModel) { PreferenceCategory keymapPreferenceCategory = (PreferenceCategory) getPreferenceScreen().findPreference(getString(R.string.pref_keymap_category_key)); ListPreference keymapListPreference = (ListPreference) keymapPreferenceCategory.findPreference(getString(R.string.pref_select_keymap_key)); keymapPreferenceCategory.removePreference(keymapListPreference); } int[] hiddenShortcutKeyIds = isArc ? HIDDEN_SHORTCUT_KEY_IDS_IN_ARC : HIDDEN_SHORTCUT_KEY_IDS_IN_NON_ARC; Set<String> hiddenShortcutKeys = new HashSet<>(); for (int id : hiddenShortcutKeyIds) { hiddenShortcutKeys.add(getString(id)); } initPreferenceUIs(getPreferenceScreen(), hiddenShortcutKeys); }
Example 14
Source File: SwitchAccessPreferenceActivity.java From talkback with Apache License 2.0 | 5 votes |
private void removeAndSavePreference(PreferenceCategory category, int keyOfPreferenceToRemove) { Preference preferenceToRemove = findPreference(keyOfPreferenceToRemove); if (preferenceToRemove != null) { category.removePreference(preferenceToRemove); removedPreferenceMap.put(keyOfPreferenceToRemove, preferenceToRemove); } }
Example 15
Source File: SwitchAccessPreferenceActivity.java From talkback with Apache License 2.0 | 5 votes |
private void adjustPointScanPrefs() { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { // Remove point scan screen PreferenceCategory customizeScanningCategory = (PreferenceCategory) findPreference(R.string.pref_category_customize_scanning_key); customizeScanningCategory.removePreference( findPreference(R.string.pref_category_point_scan_key)); } else { SwitchPreference pointScanPreference = (SwitchPreference) findPreference(R.string.pref_key_point_scan_enabled); String enableAnimationsMessage = ((VERSION.SDK_INT >= VERSION_CODES.O) && !ValueAnimator.areAnimatorsEnabled()) ? getString(R.string.point_scan_enable_animations_message) : ""; String pointScanPreferenceSummary = getString(R.string.summary_pref_point_scan, enableAnimationsMessage); pointScanPreference.setSummary(pointScanPreferenceSummary); pointScanPreference.setEnabled( (VERSION.SDK_INT < VERSION_CODES.O) || ValueAnimator.areAnimatorsEnabled()); // Make sure the subtitle reflects Point scan state PreferenceScreen pointScanScreen = (PreferenceScreen) findPreference(R.string.pref_category_point_scan_key); if (SwitchAccessPreferenceUtils.isPointScanEnabled(getActivity())) { pointScanScreen.setSummary(R.string.preference_on); } else { pointScanScreen.setSummary(R.string.preference_off); } ((BaseAdapter) pointScanScreen.getRootAdapter()).notifyDataSetChanged(); } }
Example 16
Source File: SuntimesSettingsActivity.java From SuntimesWidget with GNU General Public License v3.0 | 4 votes |
private static void removePrefFromCategory(Preference pref, PreferenceCategory category) { if (pref != null && category != null) { category.removePreference(pref); } }
Example 17
Source File: TaskerQuickActionsActivity.java From SecondScreen with Apache License 2.0 | 4 votes |
@SuppressWarnings("deprecation") private void disablePreference(String preferenceName) { PreferenceCategory category = (PreferenceCategory) getPreferenceScreen().findPreference("available_actions"); category.removePreference(getPreferenceScreen().findPreference(preferenceName)); }
Example 18
Source File: MaxLockPreferenceFragment.java From MaxLock with GNU General Public License v3.0 | 4 votes |
@SuppressLint("WorldReadableFiles") @SuppressWarnings("deprecation") @Override public void onCreate(Bundle paramBundle) { super.onCreate(paramBundle); if (getArguments() != null) { screen = Screen.valueOf(getArguments().getString(Screen.KEY, Screen.MAIN.toString())); } else { screen = Screen.MAIN; } prefs = MLPreferences.getPreferences(getActivity()); setTitle(); if (screen == Screen.IMOD) { getPreferenceManager().setSharedPreferencesName(Common.PREFS_APPS); } addPreferencesFromResource(screen.preferenceXML); switch (screen) { case MAIN: updateImplementationStatus(); PreferenceCategory catAppUI = (PreferenceCategory) findPreference(Common.CATEGORY_APPLICATION_UI); CheckBoxPreference useDark = (CheckBoxPreference) findPreference(Common.USE_DARK_STYLE); if (!useDark.isChecked()) { catAppUI.removePreference(findPreference(Common.USE_AMOLED_BLACK)); } if (SDK_INT >= Build.VERSION_CODES.O) { catAppUI.removePreference(findPreference(Common.NEW_APP_NOTIFICATION)); } break; case TYPE: FingerprintManagerCompat fpm = FingerprintManagerCompat.from(getActivity()); if (!fpm.isHardwareDetected()) { getPreferenceScreen().removePreference(findPreference(Common.SHADOW_FINGERPRINT)); getPreferenceScreen().removePreference(findPreference(Common.CATEGORY_FINGERPRINT)); } else { CheckBoxPreference disableFP = (CheckBoxPreference) findPreference(Common.DISABLE_FINGERPRINT); if (!fpm.hasEnrolledFingerprints() && !disableFP.isChecked()) { disableFP.setSummary(disableFP.getSummary() + getResources().getString(R.string.pref_fingerprint_summary_non_enrolled)); } } break; case UI: ListPreference lp = (ListPreference) findPreference(Common.BACKGROUND); findPreference(Common.BACKGROUND_COLOR).setEnabled(lp.getValue().equals("color")); lp.setOnPreferenceChangeListener((preference, newValue) -> { if (preference.getKey().equals(Common.BACKGROUND)) { if (newValue.toString().equals("custom")) { Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("image/*"); startActivityForResult(intent, WALLPAPER_REQUEST_CODE); } else FileUtils.deleteQuietly(new File(getActivity().getFilesDir(), "background")); findPreference(Common.BACKGROUND_COLOR).setEnabled(newValue.toString().equals("color")); } return true; }); break; case OPTIONS: Preference el = findPreference(Common.ENABLE_LOGGING); el.setEnabled(prefs.getBoolean(Common.ENABLE_PRO, false)); if (!prefs.getBoolean(Common.ENABLE_PRO, false)) { el.setSummary(R.string.toast_pro_required); } if (MLImplementation.getImplementation(prefs) != MLImplementation.DEFAULT) { PreferenceCategory catOther = (PreferenceCategory) findPreference(Common.CATEGORY_OTHER); catOther.removePreference(findPreference(Common.HIDE_RECENTS_THUMBNAILS)); } break; case IMOD: // I.Mod - Pro setup Preference iModDelayGlobal = findPreference(Common.ENABLE_DELAY_GENERAL); Preference iModDelayPerApp = findPreference(Common.ENABLE_DELAY_PER_APP); iModDelayGlobal.setEnabled(prefs.getBoolean(Common.ENABLE_PRO, false)); iModDelayPerApp.setEnabled(prefs.getBoolean(Common.ENABLE_PRO, false)); if (!prefs.getBoolean(Common.ENABLE_PRO, false)) { iModDelayGlobal.setTitle(R.string.pref_delay_needpro); iModDelayPerApp.setTitle(R.string.pref_delay_needpro); } break; } }
Example 19
Source File: PreferencesFragment.java From Bluefruit_LE_Connect_Android with MIT License | 4 votes |
private void setupSpecialPreferences() { SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity()); // Update summaries updateEditTextPreferenceSummary("pref_uarttextmaxpackets"); updateEditTextPreferenceSummary("pref_updateserver"); // Set ignored version { String ignoredVersion = sharedPreferences.getString("pref_ignoredversion", null); EditTextPreference etp = (EditTextPreference) findPreference("pref_ignoredversion"); etp.setSummary(ignoredVersion); etp.setText(ignoredVersion); } // Set reset button Preference button = findPreference("pref_reset"); button.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference arg0) { Log.d(TAG, "Reset preferences"); // Reset prefs SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getActivity()); // PreferenceManager.setDefaultValues(getActivity(), R.xml.preferences, true); SharedPreferences.Editor editor = preferences.edit(); editor.clear(); editor.apply(); // Refresh view setPreferenceScreen(null); addPreferencesFromResource(R.xml.preferences); // Setup prefs setupSpecialPreferences(); return true; } }); // Hide advanced options (if not debug) if (!BuildConfig.DEBUG) { PreferenceCategory category = (PreferenceCategory) findPreference("pref_key_update_settings"); Preference updateServerPreference = findPreference("pref_updateserver"); category.removePreference(updateServerPreference); Preference versionCheckPreference = findPreference("pref_updatesversioncheck"); category.removePreference(versionCheckPreference); } }