Java Code Examples for android.preference.Preference#getKey()
The following examples show how to use
android.preference.Preference#getKey() .
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: DownloadFragment.java From MHViewer with Apache License 2.0 | 6 votes |
@Override public boolean onPreferenceClick(Preference preference) { String key = preference.getKey(); if (KEY_DOWNLOAD_LOCATION.equals(key)) { int sdk = Build.VERSION.SDK_INT; if (sdk < Build.VERSION_CODES.KITKAT) { openDirPicker(); } else if (sdk < Build.VERSION_CODES.LOLLIPOP) { showDirPickerDialogKK(); } else { showDirPickerDialogL(); } return true; } return false; }
Example 2
Source File: SettingsFragment.java From FaceSlim with GNU General Public License v2.0 | 6 votes |
@Override public boolean onPreferenceClick(Preference preference) { String key = preference.getKey(); Log.v("OnPreferenceClick", key + " clicked in SettingsFragment"); switch (key) { case "notifications_settings": //noinspection ResourceType getFragmentManager().beginTransaction() .setCustomAnimations(R.anim.slide_in_right, 0) .addToBackStack(null).replace(R.id.content_frame, new NotificationsSettingsFragment()).commit(); return true; case "clear_cache": // clear cache dirs FileOperation.deleteCache(getActivity().getApplicationContext()); // restart the app (really ugly way of doing it but...) android.os.Process.killProcess(android.os.Process.myPid()); return true; } return false; }
Example 3
Source File: GeneralSettingsFragment.java From JumpGo with Mozilla Public License 2.0 | 6 votes |
@Override public boolean onPreferenceClick(@NonNull Preference preference) { switch (preference.getKey()) { case SETTINGS_PROXY: proxyChoicePicker(); return true; case SETTINGS_USERAGENT: agentDialog(); return true; case SETTINGS_DOWNLOAD: downloadLocDialog(); return true; case SETTINGS_HOME: homepageDialog(); return true; case SETTINGS_SEARCHENGINE: searchDialog(); return true; case SETTINGS_SUGGESTIONS: suggestionsDialog(); return true; default: return false; } }
Example 4
Source File: AdvancedSettingsFragment.java From Xndroid with GNU General Public License v3.0 | 6 votes |
@Override public boolean onPreferenceChange(@NonNull Preference preference, Object newValue) { // switch preferences switch (preference.getKey()) { case SETTINGS_NEWWINDOW: mPreferenceManager.setPopupsEnabled((Boolean) newValue); cbAllowPopups.setChecked((Boolean) newValue); return true; case SETTINGS_ENABLECOOKIES: mPreferenceManager.setCookiesEnabled((Boolean) newValue); cbenablecookies.setChecked((Boolean) newValue); return true; case SETTINGS_COOKIESINKOGNITO: mPreferenceManager.setIncognitoCookiesEnabled((Boolean) newValue); cbcookiesInkognito.setChecked((Boolean) newValue); return true; case SETTINGS_RESTORETABS: mPreferenceManager.setRestoreLostTabsEnabled((Boolean) newValue); cbrestoreTabs.setChecked((Boolean) newValue); return true; default: return false; } }
Example 5
Source File: DownloadFragment.java From EhViewer with Apache License 2.0 | 6 votes |
@Override public boolean onPreferenceChange(Preference preference, Object newValue) { String key = preference.getKey(); if (Settings.KEY_MEDIA_SCAN.equals(key)) { if (newValue instanceof Boolean) { UniFile downloadLocation = Settings.getDownloadLocation(); if ((Boolean) newValue) { CommonOperations.removeNoMediaFile(downloadLocation); } else { CommonOperations.ensureNoMediaFile(downloadLocation); } } return true; } else if (Settings.KEY_IMAGE_RESOLUTION.equals(key)) { if (newValue instanceof String) { Settings.putImageResolution((String) newValue); } return true; } return false; }
Example 6
Source File: PrivacyPreferences.java From 365browser with Apache License 2.0 | 6 votes |
@Override public boolean onPreferenceChange(Preference preference, Object newValue) { String key = preference.getKey(); if (PREF_SEARCH_SUGGESTIONS.equals(key)) { PrefServiceBridge.getInstance().setSearchSuggestEnabled((boolean) newValue); } else if (PREF_SAFE_BROWSING.equals(key)) { PrefServiceBridge.getInstance().setSafeBrowsingEnabled((boolean) newValue); } else if (PREF_SAFE_BROWSING_EXTENDED_REPORTING.equals(key) || PREF_SAFE_BROWSING_SCOUT_REPORTING.equals(key)) { PrefServiceBridge.getInstance().setSafeBrowsingExtendedReportingEnabled( (boolean) newValue); } else if (PREF_NETWORK_PREDICTIONS.equals(key)) { PrefServiceBridge.getInstance().setNetworkPredictionEnabled((boolean) newValue); PrecacheLauncher.updatePrecachingEnabled(getActivity()); } else if (PREF_NAVIGATION_ERROR.equals(key)) { PrefServiceBridge.getInstance().setResolveNavigationErrorEnabled((boolean) newValue); } return true; }
Example 7
Source File: MainActivity.java From Akoi-Translator with MIT License | 6 votes |
@Override public boolean onPreferenceClick(Preference preference) { String clickedKey = preference.getKey(); MobclickAgent.onEvent(this, clickedKey); AppLog.i(LOGTAG, "onPreferenceClick clickedKey=" + clickedKey); if (getString(R.string.pref_key_feedback).equals(clickedKey)) { FeedbackAgent agent = new FeedbackAgent(this); agent.startFeedbackActivity(); } else if (getString(R.string.pref_key_recommend).equals(clickedKey)) { YoumiAdProxy.getInstance().showVideoAd(this); } else if (getString(R.string.pref_key_about).equals(clickedKey)) { showDialog(0); } else if (getString(R.string.pref_key_donate).equals(clickedKey)) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse("http://droidyue.com/donate/")); startActivity(intent); } return false; }
Example 8
Source File: STAATriggerFragment.java From FreezeYou with Apache License 2.0 | 5 votes |
@Override public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) { String key = preference.getKey(); if (key != null) { switch (key) { case "stma_add_help": MoreUtils.requestOpenWebSite(getActivity(), "https://zidon.net/zh-CN/guide/schedules.html"); break; default: break; } } return super.onPreferenceTreeClick(preferenceScreen, preference); }
Example 9
Source File: PreferenceActivity.java From ContentProviderHelper with MIT License | 5 votes |
@Override public boolean onPreferenceClick(Preference preference) { String key = preference.getKey(); String keyGithub = getString(R.string.preferences_key_github); if (key.equals(keyGithub)) { launchGithubRepo(); return true; } return false; }
Example 10
Source File: DebugSettingsFragment.java From Xndroid with GNU General Public License v3.0 | 5 votes |
@Override public boolean onPreferenceChange(@NonNull Preference preference, @NonNull Object newValue) { switch (preference.getKey()) { case LEAK_CANARY: boolean value = Boolean.TRUE.equals(newValue); mPreferenceManager.setUseLeakCanary(value); Activity activity = getActivity(); if (activity != null) { Utils.showSnackbar(activity, R.string.app_restart); } mSwitchLeakCanary.setChecked(value); return true; } return false; }
Example 11
Source File: DisplaySettingsFragment.java From Xndroid with GNU General Public License v3.0 | 5 votes |
@Override public boolean onPreferenceChange(@NonNull Preference preference, Object newValue) { boolean checked = false; if (newValue instanceof Boolean) { checked = Boolean.TRUE.equals(newValue); } // switch preferences switch (preference.getKey()) { case SETTINGS_HIDESTATUSBAR: mPreferenceManager.setHideStatusBarEnabled(checked); return true; case SETTINGS_FULLSCREEN: mPreferenceManager.setFullScreenEnabled(checked); return true; case SETTINGS_VIEWPORT: mPreferenceManager.setUseWideViewportEnabled(checked); return true; case SETTINGS_OVERVIEWMODE: mPreferenceManager.setOverviewModeEnabled(checked); return true; case SETTINGS_REFLOW: mPreferenceManager.setTextReflowEnabled(checked); return true; case SETTINGS_DRAWERTABS: mPreferenceManager.setShowTabsInDrawer(checked); return true; case SETTINGS_SWAPTABS: mPreferenceManager.setBookmarkAndTabsSwapped(checked); return true; case SETTINGS_BLACK_STATUS: mPreferenceManager.setUseBlackStatusBar(checked); return true; default: return false; } }
Example 12
Source File: DisplaySettingsFragment.java From Xndroid with GNU General Public License v3.0 | 5 votes |
@Override public boolean onPreferenceClick(@NonNull Preference preference) { switch (preference.getKey()) { case SETTINGS_THEME: themePicker(); return true; case SETTINGS_TEXTSIZE: textSizePicker(); return true; default: return false; } }
Example 13
Source File: PreferenceActivity.java From ContentProviderHelper with MIT License | 5 votes |
@Override public boolean onPreferenceChange(Preference preference, Object newValue) { String key = preference.getKey(); String keyTheme = getString(R.string.preferences_key_theme); if (key.equals(keyTheme)) { String newTheme = newValue.toString(); if (isDifferentTheme(newTheme)) { restartApp(); return true; } } return false; }
Example 14
Source File: SettingsFragment.java From 920-text-editor-v2 with Apache License 2.0 | 5 votes |
@Override public boolean onPreferenceChange(Preference preference, Object value) { if (value == null) return true; String stringValue = value.toString(); String key = preference.getKey(); if (preference instanceof ListPreference) { // For list preferences, look up the correct display value in // the preference's 'entries' list. ListPreference listPreference = (ListPreference) preference; int index = listPreference.findIndexOfValue(stringValue); // Set the summary to reflect the new value. preference.setSummary( index >= 0 ? listPreference.getEntries()[index] : null); } else if (preference instanceof CheckBoxPreference) { ((CheckBoxPreference) preference).setChecked((boolean) value); } else if("pref_highlight_file_size_limit".equals(key)) { preference.setSummary(stringValue + " KB"); } else { // For all other preferences, set the summary to the value's // simple string representation. preference.setSummary(String.valueOf(stringValue)); } return true; }
Example 15
Source File: PCSettings.java From android-kernel-tweaker with GNU General Public License v3.0 | 5 votes |
@Override public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) { String key = preference.getKey(); if ("use_light_theme".equals(key)) { Helpers.restartPC(getActivity()); return true; } return false; }
Example 16
Source File: SettingsActivity.java From Advanced_Android_Development with Apache License 2.0 | 5 votes |
private void setPreferenceSummary(Preference preference, Object value) { String stringValue = value.toString(); String key = preference.getKey(); if (preference instanceof ListPreference) { // For list preferences, look up the correct display value in // the preference's 'entries' list (since they have separate labels/values). ListPreference listPreference = (ListPreference) preference; int prefIndex = listPreference.findIndexOfValue(stringValue); if (prefIndex >= 0) { preference.setSummary(listPreference.getEntries()[prefIndex]); } } else if (key.equals(getString(R.string.pref_location_key))) { @SunshineSyncAdapter.LocationStatus int status = Utility.getLocationStatus(this); switch (status) { case SunshineSyncAdapter.LOCATION_STATUS_OK: preference.setSummary(stringValue); break; case SunshineSyncAdapter.LOCATION_STATUS_UNKNOWN: preference.setSummary(getString(R.string.pref_location_unknown_description, value.toString())); break; case SunshineSyncAdapter.LOCATION_STATUS_INVALID: preference.setSummary(getString(R.string.pref_location_error_description, value.toString())); break; default: // Note --- if the server is down we still assume the value // is valid preference.setSummary(stringValue); } } else { // For other preferences, set the summary to the value's simple string representation. preference.setSummary(stringValue); } }
Example 17
Source File: DownloadSettingFragment.java From HHComicViewer with Apache License 2.0 | 5 votes |
@Override public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, final Preference preference) { switch (preference.getKey()) { case "download_path": Dialog.Builder builder = null; builder = new SimpleDialog.Builder() { @Override public void onPositiveActionClicked(DialogFragment fragment) { PreferenceActivity activity = (PreferenceActivity) getActivity(); activity.checkPermission(PreferenceActivity.OPEN_DIALOG); super.onPositiveActionClicked(fragment); } @Override public void onNegativeActionClicked(DialogFragment fragment) { super.onNegativeActionClicked(fragment); } }; ((SimpleDialog.Builder) builder).message("在Android4.4及以后的版本中,无法把数据写入外置SD卡,除非你进行了root操作。" + "不过<SDcard>/Android/data/org.huxizhijian.hhcomicviewer2 这个路径比较特殊,是可以写入的。" + "但是使用此文件夹卸载了程序之后所有下载文件都会删除。") .title("注意") .positiveAction("继续"); DialogFragment fragment = DialogFragment.newInstance(builder); fragment.show(((PreferenceActivity) getActivity()).getSupportFragmentManager(), null); return true; case "allow_media": CheckBoxPreference checkBoxPreference = (CheckBoxPreference) preference; SharedPreferencesManager manager = new SharedPreferencesManager(getActivity()); manager.putBoolean("allow_media", checkBoxPreference.isChecked()); PreferenceActivity activity = (PreferenceActivity) getActivity(); activity.checkPermission(PreferenceActivity.MAKE_NO_MEDIA); return true; } return super.onPreferenceTreeClick(preferenceScreen, preference); }
Example 18
Source File: PreferencesPlain.java From callmeter with GNU General Public License v3.0 | 5 votes |
@Override public boolean onPreferenceClick(final Preference preference) { final String k = preference.getKey(); if (k.equals("export_rules")) { Preferences .exportData(this, null, null, null, ExportProvider.EXPORT_RULESET_FILE, null); return true; } else if (k.equals("export_rules_sd")) { Preferences.exportData(this, null, null, null, ExportProvider.EXPORT_RULESET_FILE, "sdcard"); return true; } else if (k.equals("export_rules_dev")) { Preferences.exportData(this, null, null, null, ExportProvider.EXPORT_RULESET_FILE, "[email protected]"); return true; } else if (k.equals("export_logs")) { Preferences.exportData(this, null, null, null, ExportProvider.EXPORT_LOGS_FILE, null); return true; } else if (k.equals("export_logs_csv")) { Preferences.exportLogsCsv(this); return true; } else if (k.equals("export_numgroups")) { Preferences.exportData(this, null, null, null, ExportProvider.EXPORT_NUMGROUPS_FILE, null); return true; } else if (k.equals("export_hourgroups")) { Preferences.exportData(this, null, null, null, ExportProvider.EXPORT_HOURGROUPS_FILE, null); return true; } else if (k.equals("import_rules_default")) { final Intent i = new Intent(this, Preferences.class); i.setData(Uri.parse("content://default")); startActivity(i); return true; } return false; }
Example 19
Source File: ConfigActivity.java From aedict with GNU General Public License v3.0 | 5 votes |
@Override public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) { final String key = preference.getKey(); if (key.equals(KEY_DOWNLOAD_DICTIONARIES)) { final Intent intent = new Intent(this, DownloadDictionaryActivity.class); startActivity(intent); return true; } if (key.equals(KEY_SDCARD_CLEANUP)) { cleanup(); return true; } if (key.equals(KEY_RESET_INTRODUCTIONS)) { final DialogUtils utils = new DialogUtils(ConfigActivity.this); utils.clearInfoOccurency(); utils.showToast(R.string.resetIntroductionsSummary); return true; } if (key.equals(KEY_ABOUT)) { AboutActivity.launch(this); return true; } if(key.equals(KEY_SHOW_DOWNLOADER)){ DownloadActivity.launch(this); return true; } if (key.equals(KEY_DONATE)) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://code.google.com/p/aedict/#Donate"))); return true; } if(key.equals(KEY_CHECK_FOR_UPDATES)) { checkForNewVersions(); return true; } return super.onPreferenceTreeClick(preferenceScreen, preference); }
Example 20
Source File: NavigationBarButtonsActivity.java From Taskbar with Apache License 2.0 | 5 votes |
@Override public boolean onPreferenceClick(Preference preference) { switch(preference.getKey()) { case PREF_AUTO_HIDE_NAVBAR: if(U.isServiceRunning(this, TaskbarService.class)) U.showHideNavigationBar(this, !((CheckBoxPreference) preference).isChecked()); break; default: U.restartTaskbar(this); break; } return true; }