Java Code Examples for androidx.preference.Preference#getContext()
The following examples show how to use
androidx.preference.Preference#getContext() .
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: AdvancedPreferenceFragment.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
@Override public boolean onPreferenceChange(final Preference preference, Object newValue) { final Context context = preference.getContext(); boolean enabled = (boolean) newValue; LogManager logManager = ApplicationContext.getInstance(context).getLogManager(); logManager.setLogging(enabled); if (!enabled) { logManager.wipeLogs(); } findPreference(SUBMIT_DEBUG_LOG_PREF).setEnabled(enabled); return true; }
Example 2
Source File: RecipientPreferenceActivity.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
@Override public boolean onPreferenceChange(Preference preference, Object newValue) { int value = Integer.parseInt((String) newValue); final VibrateState vibrateState = VibrateState.fromId(value); final Context context = preference.getContext(); new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(Void... params) { if (call) { DatabaseFactory.getRecipientDatabase(context).setCallVibrate(recipient.getId(), vibrateState); } else { DatabaseFactory.getRecipientDatabase(context).setMessageVibrate(recipient.getId(), vibrateState); NotificationChannels.updateMessageVibrate(context, recipient.get(), vibrateState); } return null; } }.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR); return false; }
Example 3
Source File: RecipientPreferenceActivity.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
@Override public boolean onPreferenceChange(Preference preference, Object newValue) { final Context context = preference.getContext(); final boolean enabled = (boolean) newValue; new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(Void... params) { if (enabled) { String channel = NotificationChannels.createChannelFor(context, recipient.get()); DatabaseFactory.getRecipientDatabase(context).setNotificationChannel(recipient.getId(), channel); } else { NotificationChannels.deleteChannelFor(context, recipient.get()); DatabaseFactory.getRecipientDatabase(context).setNotificationChannel(recipient.getId(), null); } return null; } }.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR); return true; }
Example 4
Source File: ApplicationPreferencesActivity.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
@Override public boolean onPreferenceClick(Preference preference) { Intent intent = new Intent(preference.getContext(), EditProfileActivity.class); intent.putExtra(EditProfileActivity.EXCLUDE_SYSTEM, true); intent.putExtra(EditProfileActivity.DISPLAY_USERNAME, true); intent.putExtra(EditProfileActivity.NEXT_BUTTON_TEXT, R.string.save); requireActivity().startActivity(intent); return true; }
Example 5
Source File: RecipientPreferenceActivity.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
@Override public boolean onPreferenceChange(Preference preference, Object newValue) { final Context context = preference.getContext(); Uri value = (Uri)newValue; Uri defaultValue; if (calls) defaultValue = TextSecurePreferences.getCallNotificationRingtone(context); else defaultValue = TextSecurePreferences.getNotificationRingtone(context); if (defaultValue.equals(value)) value = null; else if (value == null) value = Uri.EMPTY; new AsyncTask<Uri, Void, Void>() { @Override protected Void doInBackground(Uri... params) { if (calls) { DatabaseFactory.getRecipientDatabase(context).setCallRingtone(recipient.getId(), params[0]); } else { DatabaseFactory.getRecipientDatabase(context).setMessageRingtone(recipient.getId(), params[0]); NotificationChannels.updateMessageRingtone(context, recipient.get(), params[0]); } return null; } }.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR, value); return false; }
Example 6
Source File: RecipientPreferenceActivity.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
@Override public boolean onPreferenceClick(Preference preference) { Context context = preference.getContext(); if (recipient.get().isBlocked()) { BlockUnblockDialog.showUnblockFor(context, getLifecycle(), recipient.get(), () -> RecipientUtil.unblock(context, recipient.get())); } else { BlockUnblockDialog.showBlockFor(context, getLifecycle(), recipient.get(), () -> RecipientUtil.block(context, recipient.get())); } return true; }
Example 7
Source File: ChatsPreferenceFragment.java From deltachat-android with GNU General Public License v3.0 | 5 votes |
@Override public boolean onPreferenceChange(Preference preference, Object newValue) { int timeout = Util.objectToInt(newValue); if (timeout>0) { Context context = preference.getContext(); boolean fromServer = coreKey.equals("delete_server_after"); int delCount = DcHelper.getContext(context).estimateDeletionCount(fromServer, timeout); View gl = View.inflate(getActivity(), R.layout.autodel_confirm, null); CheckBox confirmCheckbox = gl.findViewById(R.id.i_understand); String msg = String.format(context.getString(fromServer? R.string.autodel_server_ask : R.string.autodel_device_ask), delCount, getSelectedSummary(preference, newValue)); new AlertDialog.Builder(context) .setTitle(preference.getTitle()) .setMessage(msg) .setView(gl) .setPositiveButton(android.R.string.ok, (dialog, whichButton) -> { if (confirmCheckbox.isChecked()) { dcContext.setConfigInt(coreKey, timeout); initAutodelFromCore(); } else { onPreferenceChange(preference, newValue); } }) .setNegativeButton(android.R.string.cancel, (dialog, whichButton) -> initAutodelFromCore()) .setCancelable(false) .show(); } else { updateListSummary(preference, newValue); dcContext.setConfigInt(coreKey, timeout); } return true; }
Example 8
Source File: ApplicationPreferencesActivity.java From deltachat-android with GNU General Public License v3.0 | 4 votes |
@Override public boolean onPreferenceClick(Preference preference) { Intent intent = new Intent(preference.getContext(), CreateProfileActivity.class); getActivity().startActivity(intent); return true; }