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