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;
}
}
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);
}
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) {
}
}
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);
}
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);
}
}
Aggregations