Java Code Examples for android.preference.Preference#OnPreferenceClickListener
The following examples show how to use
android.preference.Preference#OnPreferenceClickListener .
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: SuntimesSettingsActivity.java From SuntimesWidget with GNU General Public License v3.0 | 6 votes |
/*** * Android 4 and under can enable/disable notifications per app .. the setting is located in App details. * Android 5 adds the ability to display notifications on the lock screen (global) .. global lock screen setting is in "Sound Settings". * Android 7 extends the ability to display notifications on the lock screen (per app) .. app lock screen setting is in App details. * Android 8 adds the ability to enable/disable notifications per channel. .. TODO */ private static Preference.OnPreferenceClickListener onNotificationPrefsClicked(final Context context) { final boolean notificationsOnLockScreen = notificationsOnLockScreen(context); return new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { openNotificationSettings(context); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (!notificationsOnLockScreen) { openSoundSettings(context); } else { openNotificationSettings(context); } } else { openNotificationSettings(context); } return false; } }; }
Example 2
Source File: Preferences.java From XInternalSD with BSD 2-Clause "Simplified" License | 6 votes |
@Override protected void onPostExecute(Void result) { CharSequence[] appNamesList = appNames .toArray(new CharSequence[appNames.size()]); CharSequence[] packageNamesList = packageNames .toArray(new CharSequence[packageNames.size()]); enabledApps.setEntries(appNamesList); enabledApps.setEntryValues(packageNamesList); enabledApps.setEnabled(true); disabledApps.setEntries(appNamesList); disabledApps.setEntryValues(packageNamesList); disabledApps.setEnabled(true); Preference.OnPreferenceClickListener listener = new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { ((MultiSelectListPreference) preference).getDialog().getWindow().setLayout(WindowManager.LayoutParams.FILL_PARENT, WindowManager.LayoutParams.FILL_PARENT); return false; } }; enabledApps.setOnPreferenceClickListener(listener); disabledApps.setOnPreferenceClickListener(listener); }
Example 3
Source File: SuntimesSettingsActivity.java From SuntimesWidget with GNU General Public License v3.0 | 5 votes |
private static Preference.OnPreferenceClickListener onVolumesPrefsClicked(final Context context) { return new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { openSoundSettings(context); return false; } }; }
Example 4
Source File: SuntimesSettingsActivity.java From SuntimesWidget with GNU General Public License v3.0 | 5 votes |
private static Preference.OnPreferenceClickListener onBatteryOptimizationClicked(final Context context) { return new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { if (Build.VERSION.SDK_INT >= 23) { context.startActivity(new Intent(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS)); } return false; } }; }
Example 5
Source File: SettingsActivityTest.java From JayPS-AndroidApp with MIT License | 5 votes |
@SmallTest public void testOnPreferenceClickExecutesInstallWatchFace(){ Preference.OnPreferenceClickListener onPreferenceClickListener = _installPreference.getOnPreferenceClickListener(); boolean b = onPreferenceClickListener.onPreferenceClick(new Preference(_targetContext)); verify(_watchFaceMock, times(1)).execute(any(Context.class), any(IMessageMaker.class), any(String.class)); }
Example 6
Source File: Pref.java From GeoLog with Apache License 2.0 | 5 votes |
public static Preference Preference(Context context, PreferenceCategory category, String caption, String summary, boolean enabled, Preference.OnPreferenceClickListener onClick) { Preference retval = new Preference(context); retval.setTitle(caption); retval.setSummary(summary); retval.setEnabled(enabled); if (onClick != null) { retval.setOnPreferenceClickListener(onClick); } if (category != null) category.addPreference(retval); return retval; }
Example 7
Source File: Pref.java From GeoLog with Apache License 2.0 | 5 votes |
public static Preference Preference(Context context, PreferenceCategory category, int caption, int summary, boolean enabled, Preference.OnPreferenceClickListener onClick) { Preference retval = new Preference(context); if (caption > 0) retval.setTitle(caption); if (summary > 0) retval.setSummary(summary); retval.setEnabled(enabled); if (onClick != null) { retval.setOnPreferenceClickListener(onClick); } if (category != null) category.addPreference(retval); return retval; }
Example 8
Source File: AbstractPreferenceAssert.java From assertj-android with Apache License 2.0 | 5 votes |
public S hasPreferenceClickListener(Preference.OnPreferenceClickListener listener) { isNotNull(); Preference.OnPreferenceClickListener actualListener = actual.getOnPreferenceClickListener(); assertThat(actualListener) // .overridingErrorMessage("Expected preference click listener <%s> but was <%s>.", listener, actualListener) // .isSameAs(listener); return myself; }
Example 9
Source File: SettingsActivityTest.java From JayPS-AndroidApp with MIT License | 4 votes |
@SmallTest public void testInstallListener() { Preference.OnPreferenceClickListener onPreferenceClickListener = _installPreference.getOnPreferenceClickListener(); assertNotNull(onPreferenceClickListener); }