Search in sources :

Example 6 with PreferenceManager

use of android.preference.PreferenceManager in project Etar-Calendar by Etar-Group.

the class OtherPreferences method onCreate.

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    PreferenceManager manager = getPreferenceManager();
    manager.setSharedPreferencesName(SHARED_PREFS_NAME);
    SharedPreferences prefs = manager.getSharedPreferences();
    addPreferencesFromResource(R.xml.other_preferences);
    mCopyDb = findPreference(KEY_OTHER_COPY_DB);
    mSkipReminders = (ListPreference) findPreference(KEY_OTHER_REMINDERS_RESPONDED);
    String skipPreferencesValue = null;
    if (mSkipReminders != null) {
        skipPreferencesValue = mSkipReminders.getValue();
        mSkipReminders.setOnPreferenceChangeListener(this);
    }
    updateSkipRemindersSummary(skipPreferencesValue);
    Activity activity = getActivity();
    if (activity == null) {
        Log.d(TAG, "Activity was null");
    }
    mIs24HourMode = DateFormat.is24HourFormat(activity);
    mQuietHours = (CheckBoxPreference) findPreference(KEY_OTHER_QUIET_HOURS);
    int startHour = prefs.getInt(KEY_OTHER_QUIET_HOURS_START_HOUR, QUIET_HOURS_DEFAULT_START_HOUR);
    int startMinute = prefs.getInt(KEY_OTHER_QUIET_HOURS_START_MINUTE, QUIET_HOURS_DEFAULT_START_MINUTE);
    mQuietHoursStart = findPreference(KEY_OTHER_QUIET_HOURS_START);
    mQuietHoursStartListener = new TimeSetListener(START_LISTENER);
    mQuietHoursStartDialog = new TimePickerDialog(activity, mQuietHoursStartListener, startHour, startMinute, mIs24HourMode);
    mQuietHoursStart.setSummary(formatTime(startHour, startMinute));
    int endHour = prefs.getInt(KEY_OTHER_QUIET_HOURS_END_HOUR, QUIET_HOURS_DEFAULT_END_HOUR);
    int endMinute = prefs.getInt(KEY_OTHER_QUIET_HOURS_END_MINUTE, QUIET_HOURS_DEFAULT_END_MINUTE);
    mQuietHoursEnd = findPreference(KEY_OTHER_QUIET_HOURS_END);
    mQuietHoursEndListener = new TimeSetListener(END_LISTENER);
    mQuietHoursEndDialog = new TimePickerDialog(activity, mQuietHoursEndListener, endHour, endMinute, mIs24HourMode);
    mQuietHoursEnd.setSummary(formatTime(endHour, endMinute));
}
Also used : SharedPreferences(android.content.SharedPreferences) Activity(android.app.Activity) TimePickerDialog(android.app.TimePickerDialog) PreferenceManager(android.preference.PreferenceManager)

Example 7 with PreferenceManager

use of android.preference.PreferenceManager in project android_packages_apps_DSPManager by CyanogenMod.

the class DSPScreen method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    String config = getArguments().getString("config");
    PreferenceManager prefMgr = getPreferenceManager();
    prefMgr.setSharedPreferencesName(DSPManager.SHARED_PREFERENCES_BASENAME + "." + config);
    try {
        int xmlId = R.xml.class.getField(config + "_preferences").getInt(null);
        addPreferencesFromResource(xmlId);
    } catch (IllegalAccessException e) {
        throw new RuntimeException(e);
    } catch (NoSuchFieldException e) {
        throw new RuntimeException(e);
    }
    prefMgr.getSharedPreferences().registerOnSharedPreferenceChangeListener(listener);
}
Also used : PreferenceManager(android.preference.PreferenceManager)

Example 8 with PreferenceManager

use of android.preference.PreferenceManager in project orWall by EthACKdotOrg.

the class AppPreferenceList method onCreateDialogView.

@Override
protected View onCreateDialogView() {
    PreferenceManager preferenceManager = getPreferenceManager();
    String chosen_app = preferenceManager.getSharedPreferences().getString(this.getKey(), "0");
    ListView view = new ListView(getContext());
    view.setAdapter(adapter());
    setEntries(entries());
    setEntryValues(entryValues());
    setValue(chosen_app);
    setPersistent(true);
    setDefaultValue(chosen_app);
    return view;
}
Also used : ListView(android.widget.ListView) PreferenceManager(android.preference.PreferenceManager)

Example 9 with PreferenceManager

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

the class OwnCloudListPreference method showDialog.

@Override
protected void showDialog(Bundle state) {
    if (getEntries() == null || getEntryValues() == null) {
        throw new IllegalStateException("ListPreference requires an entries array and an entryValues array.");
    }
    int preselect = findIndexOfValue(getValue());
    // same thing happens for the Standard ListPreference though
    android.support.v7.app.AlertDialog.Builder builder = new android.support.v7.app.AlertDialog.Builder(mContext).setTitle(getDialogTitle()).setIcon(getDialogIcon()).setSingleChoiceItems(getEntries(), preselect, this);
    PreferenceManager pm = getPreferenceManager();
    try {
        Method method = pm.getClass().getDeclaredMethod("registerOnActivityDestroyListener", PreferenceManager.OnActivityDestroyListener.class);
        method.setAccessible(true);
        method.invoke(pm, this);
    } catch (Exception e) {
        // no way to handle this but logging it
        Log_OC.e(TAG, "error invoking registerOnActivityDestroyListener", e);
    }
    mDialog = builder.create();
    if (state != null) {
        mDialog.onRestoreInstanceState(state);
    }
    mDialog.show();
}
Also used : Method(java.lang.reflect.Method) PreferenceManager(android.preference.PreferenceManager)

Example 10 with PreferenceManager

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

the class ShadowPreferenceGroupTest method setUp.

@Before
public void setUp() throws Exception {
    activity = buildActivity(Activity.class).create().get();
    attrs = Robolectric.buildAttributeSet().build();
    group = new TestPreferenceGroup(activity, attrs);
    shadow = shadowOf(group);
    shadow.callOnAttachedToHierarchy(new PreferenceManager(activity, 0));
    pref1 = new Preference(activity);
    pref1.setKey("pref1");
    pref2 = new Preference(activity);
    pref2.setKey("pref2");
}
Also used : Preference(android.preference.Preference) Robolectric.buildActivity(org.robolectric.Robolectric.buildActivity) Activity(android.app.Activity) PreferenceManager(android.preference.PreferenceManager) Before(org.junit.Before)

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