Search in sources :

Example 1 with PreferenceManager

use of android.preference.PreferenceManager in project meatspace-android by RomainPiel.

the class PreferenceDialogFragment method onCreatePreferenceManager.

/**
     * Creates the {@link android.preference.PreferenceManager}.
     *
     * @return The {@link android.preference.PreferenceManager} used by this activity.
     */
private PreferenceManager onCreatePreferenceManager() {
    try {
        Constructor<PreferenceManager> c = PreferenceManager.class.getDeclaredConstructor(Activity.class, int.class);
        c.setAccessible(true);
        PreferenceManager preferenceManager = c.newInstance(this.getActivity(), FIRST_REQUEST_CODE);
        return preferenceManager;
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}
Also used : PreferenceManager(android.preference.PreferenceManager)

Example 2 with PreferenceManager

use of android.preference.PreferenceManager in project Fairphone by Kwamecorp.

the class SettingsFragment method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    PreferenceManager preferenceManager = getPreferenceManager();
    preferenceManager.setSharedPreferencesName("HomeSettings");
    preferenceManager.setSharedPreferencesMode(Context.MODE_WORLD_WRITEABLE);
    // Load the preferences from an XML resource
    addPreferencesFromResource(R.xml.launcher_settings);
}
Also used : PreferenceManager(android.preference.PreferenceManager)

Example 3 with PreferenceManager

use of android.preference.PreferenceManager in project material-dialogs by afollestad.

the class PrefUtil method registerOnActivityDestroyListener.

static void registerOnActivityDestroyListener(@NonNull Preference preference, @NonNull PreferenceManager.OnActivityDestroyListener listener) {
    try {
        PreferenceManager pm = preference.getPreferenceManager();
        Method method = pm.getClass().getDeclaredMethod("registerOnActivityDestroyListener", PreferenceManager.OnActivityDestroyListener.class);
        method.setAccessible(true);
        method.invoke(pm, listener);
    } catch (Exception ignored) {
    }
}
Also used : Method(java.lang.reflect.Method) PreferenceManager(android.preference.PreferenceManager)

Example 4 with PreferenceManager

use of android.preference.PreferenceManager in project robolectric by robolectric.

the class ShadowPreferenceGroupTest method shouldFindPreferenceRecursively.

@Test
public void shouldFindPreferenceRecursively() {
    TestPreferenceGroup group2 = new TestPreferenceGroup(activity, attrs);
    shadowOf(group2).callOnAttachedToHierarchy(new PreferenceManager(activity, 0));
    group2.addPreference(pref2);
    group.addPreference(pref1);
    group.addPreference(group2);
    assertThat(group.findPreference(pref2.getKey())).isSameAs(pref2);
}
Also used : PreferenceManager(android.preference.PreferenceManager) Test(org.junit.Test)

Example 5 with PreferenceManager

use of android.preference.PreferenceManager in project robolectric by robolectric.

the class ShadowPreferenceGroupTest method shouldSetEnabledRecursively.

@Test
public void shouldSetEnabledRecursively() {
    boolean[] values = { false, true };
    TestPreferenceGroup group2 = new TestPreferenceGroup(activity, attrs);
    shadowOf(group2).callOnAttachedToHierarchy(new PreferenceManager(activity, 0));
    group2.addPreference(pref2);
    group.addPreference(pref1);
    group.addPreference(group2);
    for (boolean enabled : values) {
        group.setEnabled(enabled);
        assertThat(group.isEnabled()).isEqualTo(enabled);
        assertThat(group2.isEnabled()).isEqualTo(enabled);
        assertThat(pref1.isEnabled()).isEqualTo(enabled);
        assertThat(pref2.isEnabled()).isEqualTo(enabled);
    }
}
Also used : PreferenceManager(android.preference.PreferenceManager) Test(org.junit.Test)

Aggregations

PreferenceManager (android.preference.PreferenceManager)16 Activity (android.app.Activity)3 SharedPreferences (android.content.SharedPreferences)3 Preference (android.preference.Preference)3 Method (java.lang.reflect.Method)3 Test (org.junit.Test)2 TimePickerDialog (android.app.TimePickerDialog)1 Editor (android.content.SharedPreferences.Editor)1 Vibrator (android.os.Vibrator)1 CheckBoxPreference (android.preference.CheckBoxPreference)1 ListPreference (android.preference.ListPreference)1 OnPreferenceChangeListener (android.preference.Preference.OnPreferenceChangeListener)1 OnPreferenceClickListener (android.preference.Preference.OnPreferenceClickListener)1 PreferenceCategory (android.preference.PreferenceCategory)1 PreferenceScreen (android.preference.PreferenceScreen)1 RingtonePreference (android.preference.RingtonePreference)1 ListView (android.widget.ListView)1 TimeZonePickerDialog (com.android.timezonepicker.TimeZonePickerDialog)1 TimeZonePickerUtils (com.android.timezonepicker.TimeZonePickerUtils)1 Module (de.robv.android.xposed.installer.repo.Module)1