Java Code Examples for androidx.preference.Preference#setSummary()
The following examples show how to use
androidx.preference.Preference#setSummary() .
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: PopupSettingsFragment.java From materialistic with Apache License 2.0 | 6 votes |
@Override public void onCreatePreferences(Bundle bundle, String s) { addPreferencesFromResource(R.xml.preferences_category); Preference category = findPreference(getString(R.string.pref_category)); int summary, title; if ((title = getArguments().getInt(EXTRA_TITLE, 0)) != 0) { category.setTitle(title); } if ((summary = getArguments().getInt(EXTRA_SUMMARY, 0)) != 0) { category.setSummary(summary); } int[] preferences = getArguments().getIntArray(EXTRA_XML_PREFERENCES); if (preferences != null) { for (int preference : preferences) { addPreferencesFromResource(preference); } } }
Example 2
Source File: NotificationsPreferenceFragment.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
@Override public boolean onPreferenceChange(Preference preference, Object newValue) { Uri value = (Uri) newValue; if (value == null || TextUtils.isEmpty(value.toString())) { preference.setSummary(R.string.preferences__silent); } else { Ringtone tone = RingtoneManager.getRingtone(getActivity(), value); if (tone != null) { preference.setSummary(tone.getTitle(getActivity())); } } return true; }
Example 3
Source File: SettingsFragment.java From Kore with Apache License 2.0 | 6 votes |
/** * Sets up the preferences state and summaries */ private void setupPreferences() { // Theme preferences ListPreference themePref = (ListPreference)findPreference(Settings.KEY_PREF_THEME); themePref.setSummary(themePref.getEntry()); // About preference String nameAndVersion = getActivity().getString(R.string.app_name); try { nameAndVersion += " " + getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0).versionName; } catch (PackageManager.NameNotFoundException exc) { } Preference aboutPreference = findPreference(Settings.KEY_PREF_ABOUT); aboutPreference.setSummary(nameAndVersion); aboutPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { AboutDialogFragment aboutDialog = new AboutDialogFragment(); aboutDialog.show(getFragmentManager(), null); return true; } }); }
Example 4
Source File: AdvancedPreferenceFragment.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
private void initializeIdentitySelection() { ContactIdentityManager identity = ContactIdentityManager.getInstance(getActivity()); Preference preference = this.findPreference(TextSecurePreferences.IDENTITY_PREF); if (identity.isSelfIdentityAutoDetected()) { this.getPreferenceScreen().removePreference(preference); } else { Uri contactUri = identity.getSelfIdentityUri(); if (contactUri != null) { String contactName = ContactAccessor.getInstance().getNameFromContact(getActivity(), contactUri); preference.setSummary(String.format(getString(R.string.ApplicationPreferencesActivity_currently_s), contactName)); } preference.setOnPreferenceClickListener(new IdentityPreferenceClickListener()); } }
Example 5
Source File: SettingsActivity.java From VinylMusicPlayer with GNU General Public License v3.0 | 6 votes |
@Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { switch (key) { case PreferenceUtil.NOW_PLAYING_SCREEN_ID: updateNowPlayingScreenSummary(); break; case PreferenceUtil.CLASSIC_NOTIFICATION: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { findPreference("colored_notification").setEnabled(sharedPreferences.getBoolean(key, false)); } break; case PreferenceUtil.RG_SOURCE_MODE: Preference pref = findPreference("replaygain_preamp"); if (!sharedPreferences.getString(key, "none").equals("none")) { pref.setEnabled(true); pref.setSummary(R.string.pref_summary_rg_preamp); } else { pref.setEnabled(false); pref.setSummary(getResources().getString(R.string.pref_rg_disabled)); } break; } }
Example 6
Source File: NotificationsPreferenceFragment.java From deltachat-android with GNU General Public License v3.0 | 6 votes |
@Override public boolean onPreferenceChange(Preference preference, Object newValue) { Uri value = (Uri) newValue; if (value == null || TextUtils.isEmpty(value.toString())) { preference.setSummary(R.string.pref_silent); } else { Ringtone tone = RingtoneManager.getRingtone(getActivity(), value); if (tone != null) { preference.setSummary(tone.getTitle(getActivity())); } } return true; }
Example 7
Source File: ServiceProviderSettingsFragment.java From GeometricWeather with GNU Lesser General Public License v3.0 | 5 votes |
private void initPreferences() { // weather source. Preference chineseSource = findPreference(getString(R.string.key_weather_source)); chineseSource.setSummary(getSettingsOptionManager().getWeatherSource().getSourceName(getActivity())); chineseSource.setOnPreferenceChangeListener((preference, newValue) -> { WeatherSource source = OptionMapper.getWeatherSource((String) newValue); getSettingsOptionManager().setWeatherSource(source); preference.setSummary(source.getSourceName(getActivity())); List<Location> locationList = DatabaseHelper.getInstance(requireActivity()).readLocationList(); for (int i = 0; i < locationList.size(); i ++) { if (locationList.get(i).isCurrentPosition()) { locationList.get(i).setWeatherSource(source); break; } } DatabaseHelper.getInstance(requireActivity()).writeLocationList(locationList); return true; }); // location source. Preference locationService = findPreference(getString(R.string.key_location_service)); locationService.setSummary(getSettingsOptionManager().getLocationProvider().getProviderName(getActivity())); locationService.setOnPreferenceChangeListener((preference, newValue) -> { getSettingsOptionManager().setLocationProvider(OptionMapper.getLocationProvider((String) newValue)); preference.setSummary(getSettingsOptionManager().getLocationProvider().getProviderName(getActivity())); SnackbarUtils.showSnackbar( (GeoActivity) requireActivity(), getString(R.string.feedback_restart), getString(R.string.restart), v -> GeometricWeather.getInstance().recreateAllActivities() ); return true; }); }
Example 8
Source File: PolicyManagementFragment.java From android-testdpc with Apache License 2.0 | 5 votes |
@TargetApi(VERSION_CODES.P) private void loadSeparateChallenge() { final Preference separateChallengePreference = findPreference(SEPARATE_CHALLENGE_KEY); if (!separateChallengePreference.isEnabled()) { return; } final Boolean separate = !mDevicePolicyManager.isUsingUnifiedPassword(mAdminComponentName); separateChallengePreference.setSummary(String.format( getString(R.string.separate_challenge_summary), Boolean.toString(separate))); }
Example 9
Source File: TalkBackDeveloperPreferencesActivity.java From talkback with Apache License 2.0 | 5 votes |
/** * Checks if the device is Android TV and removes preferences that shouldn't be set when on * Android TV. */ private void checkTelevision() { if (FeatureSupport.isTv(getActivity())) { final Preference treeDebugPreference = findPreference(getString(R.string.pref_tree_debug_reflect_key)); treeDebugPreference.setSummary(getString(R.string.summary_pref_tree_debug_tv)); } }
Example 10
Source File: SettingsFragment.java From fresco with MIT License | 5 votes |
private void populateVersionAndDeviceDetails() { final Preference preferenceAndroidVersion = findPreference(KEY_DETAILS_ANDROID_VERSION); final String androidVersion = getString( R.string.preference_details_android_version_summary, String.valueOf(Build.VERSION.SDK_INT), Build.VERSION.RELEASE); preferenceAndroidVersion.setSummary(androidVersion); final Preference preferenceCpuArchitecture = findPreference(KEY_DETAILS_CPU_ARCHITECTURE); final String cpuArch = System.getProperty("os.arch"); final String cpuDetails; if (Build.VERSION.SDK_INT < 21) { cpuDetails = getString( R.string.preference_details_cpu_architecture_summary_before_21, cpuArch, Build.CPU_ABI, Build.CPU_ABI2); } else { cpuDetails = getString( R.string.preference_details_cpu_architecture_summary_after_21, cpuArch, Arrays.toString(Build.SUPPORTED_ABIS)); } preferenceCpuArchitecture.setSummary(cpuDetails); final Preference preferenceDeviceName = findPreference(KEY_DETAILS_DEVICE_NAME); final String deviceName = getString( R.string.preference_details_device_name_summary, Build.MANUFACTURER, Build.DEVICE); preferenceDeviceName.setSummary(deviceName); }
Example 11
Source File: SettingsActivity.java From TwistyTimer with GNU General Public License v3.0 | 5 votes |
private void updateInspectionAlertText() { inspectionDuration = Prefs.getInt(R.string.pk_inspection_time, 15); Preference inspectionPreference = findPreference(getString(R.string.pk_inspection_alert_enabled)); if (inspectionPreference != null) inspectionPreference.setSummary(getString(R.string.pref_inspection_alert_summary, inspectionDuration == 15 ? 8 : (int) (inspectionDuration * 0.5f), inspectionDuration == 15 ? 12 : (int) (inspectionDuration * 0.8f))); }
Example 12
Source File: LocationPreferencesActivity.java From mage-android with Apache License 2.0 | 5 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final Context contextThemeWrapper = new ContextThemeWrapper(getActivity(), R.style.AppTheme); LayoutInflater localInflater = inflater.cloneInContext(contextThemeWrapper); if (!UserHelper.getInstance(context).isCurrentUserPartOfCurrentEvent()) { Preference reportLocationPreference = findPreference(getString(R.string.reportLocationKey)); reportLocationPreference.setEnabled(false); reportLocationPreference.setSummary("You are an administrator and not a member of the current event. You can not report your location in this event."); } return super.onCreateView(localInflater, container, savedInstanceState); }
Example 13
Source File: SettingsActivity.java From GotoBrowser with GNU General Public License v3.0 | 5 votes |
private void saveQuotesFile(JsonObject item, Response<JsonObject> response) { String message = ""; String locale_code = item.get("locale_code").getAsString(); String commit = item.get("latest_commit").getAsString(); String filename = String.format(Locale.US, "quotes_%s.json", locale_code); JsonObject data = response.body(); String subtitle_folder = getContext().getFilesDir().getAbsolutePath().concat("/subtitle/"); String subtitle_path = subtitle_folder.concat(filename); File file = new File(subtitle_folder); try { if (!file.exists()) file.mkdirs(); if (data != null) { File subtitle_file = new File(subtitle_path); FileOutputStream fos = new FileOutputStream(subtitle_file); fos.write(data.toString().getBytes()); fos.close(); versionTable.putValue(filename, commit); Preference subtitleUpdate = findPreference(PREF_SUBTITLE_UPDATE); subtitleUpdate.setSummary(getString(R.string.setting_latest_version)); subtitleUpdate.setEnabled(false); } else { message = "No data to write: quotes_".concat(locale_code).concat(".json"); KcUtils.showToast(getContext(), message); } } catch (IOException e) { KcUtils.reportException(e); message = "IOException while saving quotes_".concat(locale_code).concat(".json"); KcUtils.showToast(getContext(), message); } }
Example 14
Source File: PasswordConstraintsFragment.java From android-testdpc with Apache License 2.0 | 5 votes |
/** * Refresh summaries for settings related to the next password expiration. */ private void updateExpirationTimes() { final Preference byAdmin = findPreference(Keys.EXPIRATION_TIME); final Preference byAll = findPreference(Keys.EXPIRATION_BY_ALL); byAdmin.setSummary(Util.formatTimestamp(getDpm().getPasswordExpiration(getAdmin()))); byAll.setSummary(Util.formatTimestamp(getDpm().getPasswordExpiration(null))); }
Example 15
Source File: SettingsFragment.java From GeometricWeather with GNU Lesser General Public License v3.0 | 4 votes |
private void initBasicPart() { // background free. findPreference(getString(R.string.key_background_free)).setOnPreferenceChangeListener((preference, newValue) -> { boolean backgroundFree = (boolean) newValue; getSettingsOptionManager().setBackgroundFree(backgroundFree); PollingManager.resetNormalBackgroundTask(requireActivity(), false); if (!backgroundFree) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { new RunningInBackgroundODialog().show(getParentFragmentManager(), null); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { new RunningInBackgroundDialog().show(getParentFragmentManager(), null); } } return true; }); // alert notification. findPreference(getString(R.string.key_alert_notification_switch)).setOnPreferenceChangeListener((p, newValue) -> { getSettingsOptionManager().setAlertPushEnabled((Boolean) newValue); return true; }); // precipitation notification. findPreference(getString(R.string.key_precipitation_notification_switch)).setOnPreferenceChangeListener((p, v) -> { getSettingsOptionManager().setPrecipitationPushEnabled((Boolean) v); return true; }); // update interval. Preference refreshRate = findPreference(getString(R.string.key_refresh_rate)); refreshRate.setSummary(getSettingsOptionManager().getUpdateInterval().getUpdateIntervalName(getActivity())); refreshRate.setOnPreferenceChangeListener((preference, newValue) -> { getSettingsOptionManager().setUpdateInterval(OptionMapper.getUpdateInterval((String) newValue)); preference.setSummary(getSettingsOptionManager().getUpdateInterval().getUpdateIntervalName(getActivity())); PollingManager.resetNormalBackgroundTask(requireActivity(), false); return true; }); // dark mode. Preference darkMode = findPreference(getString(R.string.key_dark_mode)); darkMode.setSummary(getSettingsOptionManager().getDarkMode().getDarkModeName(getActivity())); darkMode.setOnPreferenceChangeListener((preference, newValue) -> { getSettingsOptionManager().setDarkMode(OptionMapper.getDarkMode((String) newValue)); preference.setSummary(getSettingsOptionManager().getDarkMode().getDarkModeName(getActivity())); GeometricWeather.getInstance().resetDayNightMode(); GeometricWeather.getInstance().recreateAllActivities(); return true; }); // live wallpaper. findPreference(getString(R.string.key_live_wallpaper)).setOnPreferenceClickListener(preference -> { IntentHelper.startLiveWallpaperActivity((GeoActivity) requireActivity()); return true; }); // service provider. findPreference(getString(R.string.key_service_provider)).setOnPreferenceClickListener(preference -> { pushFragment(new ServiceProviderSettingsFragment(), preference.getKey()); return true; }); // unit. findPreference(getString(R.string.key_unit)).setOnPreferenceClickListener(preference -> { pushFragment(new UnitSettingsFragment(), preference.getKey()); return true; }); // appearance. findPreference(getString(R.string.key_appearance)).setOnPreferenceClickListener(preference -> { pushFragment(new AppearanceSettingsFragment(), preference.getKey()); return true; }); }
Example 16
Source File: ChatsPreferenceFragment.java From mollyim-android with GNU General Public License v3.0 | 4 votes |
@SuppressWarnings("unchecked") @Override public boolean onPreferenceChange(Preference preference, Object newValue) { Log.i(TAG, "onPreferenceChange"); preference.setSummary(getSummaryForMediaPreference((Set<String>)newValue)); return true; }
Example 17
Source File: SettingsFragment.java From XposedSmsCode with GNU General Public License v3.0 | 4 votes |
private void showVersionInfo(Preference preference) { String summary = getString(R.string.pref_version_summary, BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE); preference.setSummary(summary); }
Example 18
Source File: EventPreferencesOrientation.java From PhoneProfilesPlus with Apache License 2.0 | 4 votes |
@Override void checkPreferences(PreferenceManager prefMng, Context context) { SensorManager sensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE); boolean hasAccelerometer = (sensorManager != null) && (sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER) != null); boolean hasMagneticField = (sensorManager != null) && (sensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD) != null); boolean hasProximity = (sensorManager != null) && (sensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY) != null); boolean hasLight = (sensorManager != null) && (sensorManager.getDefaultSensor(Sensor.TYPE_LIGHT) != null); boolean enabledAll = (hasAccelerometer) && (hasMagneticField); Preference preference = prefMng.findPreference(PREF_EVENT_ORIENTATION_DISPLAY); if (preference != null) { if (!hasAccelerometer) preference.setSummary(context.getString(R.string.profile_preferences_device_not_allowed)+ ": "+context.getString(R.string.preference_not_allowed_reason_no_hardware)); preference.setEnabled(hasAccelerometer); } preference = prefMng.findPreference(PREF_EVENT_ORIENTATION_SIDES); if (preference != null) { if (!enabledAll) preference.setSummary(context.getString(R.string.profile_preferences_device_not_allowed)+ ": "+context.getString(R.string.preference_not_allowed_reason_no_hardware)); preference.setEnabled(enabledAll); } boolean enabled = hasProximity; preference = prefMng.findPreference(PREF_EVENT_ORIENTATION_DISTANCE); if (preference != null) { if (!enabled) preference.setSummary(context.getString(R.string.profile_preferences_device_not_allowed)+ ": "+context.getString(R.string.preference_not_allowed_reason_no_hardware)); preference.setEnabled(enabled); } SwitchPreferenceCompat switchPreference = prefMng.findPreference(PREF_EVENT_ORIENTATION_CHECK_LIGHT); if (switchPreference != null) { boolean checkLight = switchPreference.isChecked(); if (checkLight) { enabled = hasLight; preference = prefMng.findPreference(PREF_EVENT_ORIENTATION_LIGHT_MIN); if (preference != null) { if (!enabled) preference.setSummary(context.getString(R.string.profile_preferences_device_not_allowed) + ": " + context.getString(R.string.preference_not_allowed_reason_no_hardware)); preference.setEnabled(enabled); } preference = prefMng.findPreference(PREF_EVENT_ORIENTATION_LIGHT_MAX); if (preference != null) { if (!enabled) preference.setSummary(context.getString(R.string.profile_preferences_device_not_allowed) + ": " + context.getString(R.string.preference_not_allowed_reason_no_hardware)); preference.setEnabled(enabled); } } } enabled = PPPExtenderBroadcastReceiver.isEnabled(context.getApplicationContext(), PPApplication.VERSION_CODE_EXTENDER_3_0); ApplicationsMultiSelectDialogPreferenceX applicationsPreference = prefMng.findPreference(PREF_EVENT_ORIENTATION_IGNORED_APPLICATIONS); if (applicationsPreference != null) { applicationsPreference.setEnabled(enabled); applicationsPreference.setSummaryAMSDP(); } SharedPreferences preferences = prefMng.getSharedPreferences(); setSummary(prefMng, PREF_EVENT_ORIENTATION_APP_SETTINGS, preferences, context); setCategorySummary(prefMng, preferences, context); }
Example 19
Source File: MainPreferenceFragment.java From kcanotify with GNU General Public License v3.0 | 4 votes |
@Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { if (sHandler != null) { JsonObject dmpData = new JsonObject(); String kca_url = ""; Bundle bundle = new Bundle(); switch (key) { case PREF_KCA_SEEK_CN: kca_url = KCA_API_PREF_CN_CHANGED; break; case PREF_KCA_EXP_VIEW: kca_url = KCA_API_PREF_EXPVIEW_CHANGED; break; case PREF_KCA_SET_PRIORITY: kca_url = KCA_API_PREF_PRIORITY_CHANGED; break; case PREF_FAIRY_SIZE: kca_url = KCA_API_PREF_FAIRYSIZE_CHANGED; break; default: break; } if (kca_url.length() > 0) { bundle.putString("url", kca_url); bundle.putString("data", gson.toJson(dmpData)); Message sMsg = sHandler.obtainMessage(); sMsg.setData(bundle); sHandler.sendMessage(sMsg); } } Preference preference = findPreference(key); if (preference instanceof ListPreference) { ListPreference lp = (ListPreference) preference; preference.setSummary(lp.getEntry()); } if (preference instanceof EditTextPreference) { EditTextPreference etp = (EditTextPreference) preference; preference.setSummary(getEditTextSummary(key, etp.getText())); } }
Example 20
Source File: SettingsFragment.java From XposedSmsCode with GNU General Public License v3.0 | 4 votes |
@Override public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { addPreferencesFromResource(R.xml.settings); // general group if (!ModuleUtils.isModuleEnabled()) { Preference enablePref = findPreference(PrefConst.KEY_ENABLE); // enablePref.setEnabled(false); enablePref.setSummary(R.string.pref_enable_summary_alt); } findPreference(PrefConst.KEY_HIDE_LAUNCHER_ICON).setOnPreferenceChangeListener(this); findPreference(PrefConst.KEY_CHOOSE_THEME).setOnPreferenceClickListener(this); findPreference(PrefConst.KEY_APP_BLOCK_ENTRY).setOnPreferenceClickListener(this); // general group end // experimental group // experimental group end // code message group findPreference(PrefConst.KEY_CODE_RULES).setOnPreferenceClickListener(this); findPreference(PrefConst.KEY_SMSCODE_TEST).setOnPreferenceClickListener(this); // code message group end // code records group Preference recordsEntryPref = findPreference(PrefConst.KEY_ENTRY_CODE_RECORDS); recordsEntryPref.setOnPreferenceClickListener(this); initRecordEntryPreference(recordsEntryPref); // code records group end // others group findPreference(PrefConst.KEY_VERBOSE_LOG_MODE).setOnPreferenceChangeListener(this); // others group end // about group // version info preference Preference versionPref = findPreference(PrefConst.KEY_VERSION); versionPref.setOnPreferenceClickListener(this); showVersionInfo(versionPref); findPreference(PrefConst.KEY_JOIN_QQ_GROUP).setOnPreferenceClickListener(this); findPreference(PrefConst.KEY_SOURCE_CODE).setOnPreferenceClickListener(this); findPreference(PrefConst.KEY_GET_ALIPAY_PACKET).setOnPreferenceClickListener(this); findPreference(PrefConst.KEY_DONATE_BY_ALIPAY).setOnPreferenceClickListener(this); // about group end }