本文整理汇总了Java中android.preference.Preference.getKey方法的典型用法代码示例。如果您正苦于以下问题:Java Preference.getKey方法的具体用法?Java Preference.getKey怎么用?Java Preference.getKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.preference.Preference
的用法示例。
在下文中一共展示了Preference.getKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onPreferenceChange
import android.preference.Preference; //导入方法依赖的package包/类
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
WCFPXSharedPreferencesUtil.notifyReload();
switch (preference.getKey()) {
case VersionInfo.PREF_KEY_ENABLE:
break;
case VersionInfo.PREF_KEY_PWD:
if (!((String) newValue).matches("\\d{6}")) {
new AlertDialog.Builder(getActivity())
.setTitle(getString(R.string.title_error))
.setPositiveButton(getString(R.string.hint_confirm), null)
.setMessage(getString(R.string.error_six_digit))
.show();
return false;
}
spEditor = sharedPreferences.edit();
final String android_id = WCFPXSharedPreferencesUtil.getID(getContext());
final String key = AESHelper.encrypt(android_id, VersionInfo.DU_EN_KEY);
spEditor.putString(VersionInfo.PREF_KEY_PWD, AESHelper.encrypt((String) newValue, key));
spEditor.apply();
return false;
default:
break;
}
return true;
}
示例2: onPreferenceClick
import android.preference.Preference; //导入方法依赖的package包/类
@Override
public boolean onPreferenceClick(Preference preference) {
String key = preference.getKey();
if (key.equals(prefAboutPageKey)) {
ActivityOptionsCompat options =
ActivityOptionsCompat.makeSceneTransitionAnimation(getActivity());
((NavigationDrawerActivity) getActivity()).newAchievementUnlocked(1L << Constants.CURIOUS);
startActivity(new Intent(getActivity(), AboutActivity.class), options.toBundle());
return true;
} else if (key.equals(prefLogoutButtonKey)) {
//Clear login cache
CacheUtils.clearLoginInfo(context);
//Now launch on-board activity
startActivity(new Intent(context, OnBoardActivity.class));
//Now finish the activity
((NavigationDrawerActivity) context).finish();
return true;
}
return false;
}
示例3: onPreferenceClick
import android.preference.Preference; //导入方法依赖的package包/类
@Override
public boolean onPreferenceClick(Preference preference) {
switch (preference.getKey()) {
case KEY_ABOUT_VERSION :
if (mDevHitCountdown > 0) {
mDevHitCountdown--;
if (mDevHitCountdown == 0) {
getActivity().getSharedPreferences(DeveloperOptionsFragment.PREF_FILE,
Context.MODE_PRIVATE).edit().putBoolean(
DeveloperOptionsFragment.PREF_SHOW, true).apply();
// This is good time to index the Developer Options
startActivity(new Intent(getActivity(), SettingsActivity.class));
getActivity().finish();
}
}
return true;
}
return false;
}
示例4: onPreferenceTreeClick
import android.preference.Preference; //导入方法依赖的package包/类
@Override
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
final String key = preference.getKey();
switch (key) {
case KEY_CHECK_UPDATE:
mTask = CheckUpdateTask.getInstance(false);
if (!mTask.getStatus().equals(AsyncTask.Status.RUNNING)) {
mTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, getActivity());
}
return true;
case KEY_CHANGELOG:
ChangelogFragment changelogFrag = new ChangelogFragment();
FragmentTransaction transaction = getFragmentManager().beginTransaction();
transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
transaction.replace(this.getId(), changelogFrag);
transaction.addToBackStack(this.getClass().getName());
transaction.commit();
return true;
default:
OTALink link = LinkConfig.getInstance().findLink(key, getActivity());
if (link != null) {
OTAUtils.launchUrl(link.getUrl(), getActivity());
}
break;
}
return super.onPreferenceTreeClick(preferenceScreen, preference);
}
示例5: onPreferenceChange
import android.preference.Preference; //导入方法依赖的package包/类
@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;
}
示例6: createManagedPreferenceDelegate
import android.preference.Preference; //导入方法依赖的package包/类
private ManagedPreferenceDelegate createManagedPreferenceDelegate() {
return new ManagedPreferenceDelegate() {
@Override
public boolean isPreferenceControlledByPolicy(Preference preference) {
String key = preference.getKey();
PrefServiceBridge prefs = PrefServiceBridge.getInstance();
if (PREF_NAVIGATION_ERROR.equals(key)) {
return prefs.isResolveNavigationErrorManaged();
}
if (PREF_SEARCH_SUGGESTIONS.equals(key)) {
return prefs.isSearchSuggestManaged();
}
if (PREF_SAFE_BROWSING_EXTENDED_REPORTING.equals(key)
|| PREF_SAFE_BROWSING_SCOUT_REPORTING.equals(key)) {
return prefs.isSafeBrowsingExtendedReportingManaged();
}
if (PREF_SAFE_BROWSING.equals(key)) {
return prefs.isSafeBrowsingManaged();
}
if (PREF_NETWORK_PREDICTIONS.equals(key)) {
return prefs.isNetworkPredictionManaged();
}
return false;
}
};
}
示例7: onPreferenceClick
import android.preference.Preference; //导入方法依赖的package包/类
@Override
public boolean onPreferenceClick(@NonNull Preference preference) {
switch (preference.getKey()) {
case SETTINGS_RENDERINGMODE:
renderPicker();
return true;
case SETTINGS_URLCONTENT:
urlBoxPicker();
return true;
case SETTINGS_TEXTENCODING:
textEncodingPicker();
return true;
default:
return false;
}
}
示例8: onPreferenceClick
import android.preference.Preference; //导入方法依赖的package包/类
@Override
public boolean onPreferenceClick(Preference preference) {
switch (preference.getKey()){
case "platform_WeChat_setting":
getActivity().startActivity(new Intent(getActivity(), PreferenceActivity.class)
.putExtra(PreferenceActivity.TYPE_FRAGMENT, WeChatSettingFragment.class));
break;
case "platform_QQ_setting":
getActivity().startActivity(new Intent(getActivity(), PreferenceActivity.class)
.putExtra(PreferenceActivity.TYPE_FRAGMENT, QQSettingFragment.class));
break;
case "setting":
getActivity().startActivity(new Intent(getActivity(), PreferenceActivity.class)
.putExtra(PreferenceActivity.TYPE_FRAGMENT, OtherSettingFragment.class));
break;
case "exit":
exit();
break;
case "about":
getActivity().startActivity(new Intent(getActivity(), AboutActivity.class));
break;
}
return true;
}
示例9: onPreferenceClick
import android.preference.Preference; //导入方法依赖的package包/类
@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;
}
}
示例10: onPreferenceClick
import android.preference.Preference; //导入方法依赖的package包/类
public boolean onPreferenceClick(Preference preference) {
String key = preference.getKey();
switch (key) {
case "pro1":
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.get_key))));
break;
case "pro2":
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.get_key))));
break;
}
return false;
}
示例11: onPreferenceChange
import android.preference.Preference; //导入方法依赖的package包/类
@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;
}
}
示例12: onPreferenceChange
import android.preference.Preference; //导入方法依赖的package包/类
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
String stringValue = newValue.toString();
//only used the first "load". Subsequent changes not because in SeekbarPreferences don't call
//to update listeners
if (preference instanceof SeekBarPreference) {
preference.setSummary(("" + stringValue + " Km"));
} else if (preference instanceof Preference) {
String key = preference.getKey();
//we take the versionName and assign it to the pref var.
if (key == getString(R.string.pref_version_key)) {
String versionName;
try {
versionName = getActivity().getPackageManager().getPackageInfo(
getActivity().getPackageName(), 0).versionName;
} catch (PackageManager.NameNotFoundException e) {
versionName = null;
}
preference.setSummary(versionName);
}
}
return true;
}
示例13: onPreferenceClick
import android.preference.Preference; //导入方法依赖的package包/类
@Override
public boolean onPreferenceClick(Preference preference) {
String key = preference.getKey();
if (key.equals(getString(R.string.pref_email_key))) {
Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto",
getString(R.string.mailto), null));
emailIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.subject));
startActivity(Intent.createChooser(emailIntent, "Send mail..."));
} else if (key.equals(getString(R.string.pref_share_app_key))) {
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
//https://play.google.com/store/apps/details?id=com.carlos.capstone
sendIntent.putExtra(Intent.EXTRA_TEXT, getString(R.string.app_play_store_address));
sendIntent.setType("text/plain");
startActivity(sendIntent);
} else if (key.equals(getString(R.string.pref_delete_history_key))) {
DialogBorrarHistorialBusqueda dialog = new DialogBorrarHistorialBusqueda();
dialog.show(((SettingsActivity)getActivity()).getSupportFragmentManager(),"HISTORIAL");
}
return true;
}
示例14: onPreferenceChange
import android.preference.Preference; //导入方法依赖的package包/类
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
String key = preference.getKey();
if(automaticUpdatesKey.equals(key)) {
onAutomaticUpdatesToggle((Boolean) newValue);
}
else {
throw new RuntimeException("Unknown preference change event received!");
}
return true;
}
示例15: onPreferenceChange
import android.preference.Preference; //导入方法依赖的package包/类
@Override
public boolean onPreferenceChange(@NonNull Preference preference, Object newValue) {
boolean checked = false;
if (newValue instanceof Boolean) {
checked = Boolean.TRUE.equals(newValue);
}
switch (preference.getKey()) {
case SETTINGS_FLASH:
if (!Utils.isFlashInstalled(mActivity) && checked) {
Utils.createInformativeDialog(mActivity, R.string.title_warning, R.string.dialog_adobe_not_installed);
mPreferenceManager.setFlashSupport(0);
return false;
} else {
if (checked) {
getFlashChoice();
} else {
mPreferenceManager.setFlashSupport(0);
}
}
return true;
case SETTINGS_ADS:
mPreferenceManager.setAdBlockEnabled(checked);
return true;
case SETTINGS_IMAGES:
mPreferenceManager.setBlockImagesEnabled(checked);
return true;
case SETTINGS_JAVASCRIPT:
mPreferenceManager.setJavaScriptEnabled(checked);
return true;
case SETTINGS_COLORMODE:
mPreferenceManager.setColorModeEnabled(checked);
return true;
default:
return false;
}
}