use of android.support.v7.preference.ListPreference in project Remindy by abicelis.
the class SettingsFragment method onCreatePreferencesFix.
@Override
public void onCreatePreferencesFix(@Nullable Bundle savedInstanceState, String rootKey) {
addPreferencesFromResource(R.xml.remindy_settings);
final Context packageContext = getActivity().getApplicationContext();
mManagePlaces = findPreference(getResources().getString(R.string.settings_manage_places_key));
mManagePlaces.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
Intent goToPlaceListActivity = new Intent(packageContext, PlaceListActivity.class);
startActivity(goToPlaceListActivity);
//TODO: Yes, this is a dirty hack, someday to be fixed
((SettingsActivity) getActivity()).mForceHomeRefresh = true;
return true;
}
});
mDateFormat = (ListPreference) findPreference(getResources().getString(R.string.settings_date_format_key));
mDateFormat.setEntries(getDateFormatEntries());
mTimeFormat = (ListPreference) findPreference(getResources().getString(R.string.settings_time_format_key));
mTriggerMinutesBeforeNotification = (ListPreference) findPreference(getResources().getString(R.string.settings_trigger_minutes_before_notification_key));
mTriggerMinutesBeforeNotification.setEntries(getTriggerMinutesBeforeNotificationEntries());
mTriggerMinutesBeforeNotification.setEntryValues(getTriggerMinutesBeforeNotificationEntryValues());
// mShowLocationBasedReminderInNewTab = (SwitchPreference) findPreference(getResources().getString(R.string.settings_show_location_based_reminder_in_new_tab_key));
// handleShowLocationBasedReminderInNewTabPreferenceChange(getShowLocationBasedReminderInNewTabValue());
// mShowLocationBasedReminderInNewTab.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
// @Override
// public boolean onPreferenceChange(Preference preference, Object newValue) {
// handleShowLocationBasedReminderInNewTabPreferenceChange((boolean) newValue);
// return true;
// }
// });
mBackup = findPreference(getResources().getString(R.string.settings_backup_key));
mRestore = findPreference(getResources().getString(R.string.settings_restore_key));
mBackup.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
// Check for external storage permissions
String[] nonGrantedPermissions = PermissionUtil.checkIfPermissionsAreGranted(getActivity(), Manifest.permission.WRITE_EXTERNAL_STORAGE);
if (nonGrantedPermissions != null) {
requestPermissions(nonGrantedPermissions, REQUEST_CODE_WRITE_STORAGE_EXPORT);
} else {
handleExportAction();
}
return false;
}
});
mRestore.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
// Check for external storage permissions
String[] nonGrantedPermissions = PermissionUtil.checkIfPermissionsAreGranted(getActivity(), Manifest.permission.WRITE_EXTERNAL_STORAGE);
if (nonGrantedPermissions != null) {
requestPermissions(nonGrantedPermissions, REQUEST_CODE_WRITE_STORAGE_IMPORT);
} else {
handleImportAction();
}
return false;
}
});
mAbout = findPreference(getResources().getString(R.string.settings_about_key));
mAbout.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
Intent goToAboutActivity = new Intent(packageContext, AboutActivity.class);
startActivity(goToAboutActivity);
return true;
}
});
mRate = findPreference(getResources().getString(R.string.remindy_settings_rate_key));
mRate.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
Intent playStoreIntent = new Intent(Intent.ACTION_VIEW);
playStoreIntent.setData(Uri.parse(getResources().getString(R.string.url_market)));
startActivity(playStoreIntent);
return true;
}
});
mContact = findPreference(getResources().getString(R.string.remindy_settings_contact_key));
mContact.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", getResources().getString(R.string.address_email), null));
startActivity(Intent.createChooser(emailIntent, "Send email..."));
return true;
}
});
}
Aggregations