public void onActivityResult(Intent data) { Uri docTree=data.getData(); ContentResolver cr=pref.getContext().getContentResolver(); int perms=Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION; cr.takePersistableUriPermission(docTree, perms); pref .getSharedPreferences() .edit() .putString(getUriKey(), docTree.toString()) .apply(); } }
public S hasSummary(int resId) { isNotNull(); return hasSummary(actual.getContext().getString(resId)); }
public S hasTitle(int resId) { isNotNull(); return hasTitle(actual.getContext().getString(resId)); }
public S hasContext(Context context) { isNotNull(); Context actualContext = actual.getContext(); assertThat(actualContext) // .overridingErrorMessage("Expected context <%s> but was <%s>.", context, actualContext) // .isSameAs(context); return myself; }
@Override public boolean onPreferenceChange(Preference pref, Object o) { StorageManager storage= pref.getContext().getSystemService(StorageManager.class); List<StorageVolume> volumes=storage.getStorageVolumes(); String uuid=o.toString(); for (StorageVolume volume : volumes) { if ((volume.getUuid()==null && uuid.equals(SettingsFragment.STORAGE_FAKE_UUID)) || (uuid.equals(volume.getUuid()))) { Intent i=volume.createAccessIntent(dirName); host.startActivityForHelper(i, this); break; } } return(true); } }
Context context = preference.getContext(); if (context instanceof Activity) { ((Activity) context).setResult(Activity.RESULT_OK);
/** * Binds a preference's summary to its value. More specifically, when the preference's value is changed, its summary * (line of text below the preference title) is updated to reflect the value. The summary is also immediately * updated upon calling this method. The exact display format is dependent on the type of preference. * * @see #sBindPreferenceSummaryToValueListener */ private static void bindPreferenceSummaryToValue(Preference preference) { // Set the listener to watch for value changes. preference.setOnPreferenceChangeListener(SettingsActivity.sBindPreferenceSummaryToValueListener); // Trigger the listener immediately with the preference's current value. String newValue = PreferenceManager.getDefaultSharedPreferences(preference.getContext()).getString(preference.getKey(), ""); SettingsActivity.sBindPreferenceSummaryToValueListener.onPreferenceChange(preference, newValue); }
private static void bindPreferenceSummaryToValue(Preference preference) { // Set the listener to watch for value changes. preference .setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener); if (preference instanceof SeekBarPreference) { // Trigger the listener immediately with the preference's // current value. sBindPreferenceSummaryToValueListener.onPreferenceChange( preference, PreferenceManager.getDefaultSharedPreferences( preference.getContext()).getInt(preference.getKey(),0)); } else if (preference instanceof CheckBoxPreference) { // Trigger the listener immediately with the preference's // current value. sBindPreferenceSummaryToValueListener.onPreferenceChange( preference, PreferenceManager.getDefaultSharedPreferences( preference.getContext()).getBoolean(preference.getKey(),true)); } }
@Override public boolean onPreferenceChange(Preference preference, Object newValue) { Toast.makeText(preference.getContext(), "Crash Setting takes effect on next restart", Toast.LENGTH_LONG).show(); return true; } });
@Override public boolean onPreferenceChange(Preference preference, Object newValue) { final Context context = preference.getContext(); Boolean enabled = (boolean) newValue; if (enabled==true) { context.startService(new Intent(context, Amazfitservice.class)); }else { context.stopService(new Intent(context, Amazfitservice.class)); } return true; } });
@Override public boolean onPreferenceChange(Preference preference, Object newValue) { preference.setSummary(newValue.toString()); Context context = preference.getContext(); PlusSyncService.clearandRestartSyncService(context); return true; } });
@Override public boolean onPreferenceChange(Preference preference, Object newValue) { Context context = preference.getContext(); if (AppWidgetManager.getInstance(context).getAppWidgetIds(new ComponentName(context, xDripWidget.class)).length > 0) { context.startService(new Intent(context, WidgetUpdateService.class)); } return true; } }
private static void bindPreferenceSummaryToValueAndEnsureNumeric(Preference preference) { preference.setOnPreferenceChangeListener(sBindNumericPreferenceSummaryToValueListener); sBindPreferenceSummaryToValueListener.onPreferenceChange(preference, PreferenceManager .getDefaultSharedPreferences(preference.getContext()) .getString(preference.getKey(), "")); }
private static void bindPreferenceSummaryToValue(Preference preference) { preference.setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener); sBindPreferenceSummaryToValueListener.onPreferenceChange(preference, PreferenceManager .getDefaultSharedPreferences(preference.getContext()) .getString(preference.getKey(), "")); }
private static void bindPreferenceSummaryToValue(Preference preference) { try { preference.setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener); sBindPreferenceSummaryToValueListener.onPreferenceChange(preference, PreferenceManager .getDefaultSharedPreferences(preference.getContext()) .getString(preference.getKey(), "")); } catch (Exception e) { Log.e(TAG, "Got exception binding preference summary: " + e.toString()); } }
private static void bindPreferenceTitleAppendToValueUpdateChannel(Preference preference) { try { preference.setOnPreferenceChangeListener(sBindPreferenceTitleAppendToValueListenerUpdateChannel); sBindPreferenceTitleAppendToValueListenerUpdateChannel.onPreferenceChange(preference, PreferenceManager .getDefaultSharedPreferences(preference.getContext()) .getString(preference.getKey(), "")); } catch (Exception e) { Log.e(TAG, "Got exception binding preference title: " + e.toString()); } }
private static void bindPreferenceTitleAppendToStringValue(Preference preference) { try { preference.setOnPreferenceChangeListener(sBindPreferenceTitleAppendToStringValueListener); sBindPreferenceTitleAppendToStringValueListener.onPreferenceChange(preference, PreferenceManager .getDefaultSharedPreferences(preference.getContext()) .getString(preference.getKey(), "")); } catch (Exception e) { Log.e(TAG, "Got exception binding preference title: " + e.toString()); } }
private static void bindPreferenceTitleAppendToIntegerValue(Preference preference) { try { preference.setOnPreferenceChangeListener(sBindPreferenceTitleAppendToIntegerValueListener); sBindPreferenceTitleAppendToIntegerValueListener.onPreferenceChange(preference, PreferenceManager .getDefaultSharedPreferences(preference.getContext()) .getInt(preference.getKey(), 0)); } catch (Exception e) { Log.e(TAG, "Got exception binding preference title: " + e.toString()); } }
@Override public boolean onPreferenceChange(Preference preference, Object newValue) { if ((boolean)newValue) { ShotStateStore.resetAllShots(); JoH.static_toast(preference.getContext(),getString(R.string.interface_tips_from_start),Toast.LENGTH_LONG); } return true; } });
@Override public boolean onPreferenceChange(final Preference preference, final Object newValue) { final CacheLocation newLocation = EnumUtils.getByResValue(CacheLocation.class, LengthUtils.toString(newValue), null); if (newLocation != null) { CacheManager.moveCacheLocation(preference.getContext(), newLocation); } return true; } });