Respect system preference for 24 hour time

This commit is contained in:
Moez Bhatti
2016-07-07 13:57:03 -04:00
parent dcf9cfd74d
commit 09a8b3864e
7 changed files with 2 additions and 27 deletions
@@ -1,13 +1,10 @@
package com.moez.QKSMS.common.utils;
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.text.format.DateFormat;
import android.text.format.DateUtils;
import com.moez.QKSMS.QKSMSApp;
import com.moez.QKSMS.R;
import com.moez.QKSMS.ui.settings.SettingsFragment;
import java.text.ParseException;
import java.text.SimpleDateFormat;
@@ -48,8 +45,7 @@ public abstract class DateFormatter {
}
public static SimpleDateFormat accountFor24HourTime(Context context, SimpleDateFormat input) { //pass in 12 hour time. If needed, change to 24 hr.
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean isUsing24HourTime = prefs.getBoolean(SettingsFragment.TIMESTAMPS_24H, DateFormat.is24HourFormat(context));
boolean isUsing24HourTime = DateFormat.is24HourFormat(context);
if (isUsing24HourTime) {
return new SimpleDateFormat(input.toPattern().replace('h', 'H').replaceAll(" a", ""));
@@ -33,7 +33,6 @@ public enum QKPreference {
HIDE_AVATAR_RECEIVED("pref_key_hide_avatar_received", false),
MESSAGE_COUNT("pref_key_message_count", false),
TIMESTAMPS_24H("pref_key_24h", false),
// General
DELAYED_MESSAGING("pref_key_delayed", false),
@@ -116,7 +116,6 @@ public class SettingsFragment extends PreferenceFragment implements Preference.O
public static final String SPLIT_COUNTER = "pref_key_split_counter";
public static final String LONG_AS_MMS = "pref_key_long_as_mms";
public static final String LONG_AS_MMS_AFTER = "pref_key_long_as_mms_after";
public static final String TIMESTAMPS_24H = "pref_key_24h";
public static final String NOTIFICATIONS = "pref_key_notifications";
public static final String NOTIFICATION_LED = "pref_key_led";
public static final String NOTIFICATION_LED_COLOR = "pref_key_theme_led";
@@ -55,7 +55,7 @@ public class TimePickerFragment extends DialogFragment implements TimePickerDial
int hour = c.get(Calendar.HOUR_OF_DAY);
int minute = c.get(Calendar.MINUTE);
boolean isUsing24HourTime = mPrefs.getBoolean(SettingsFragment.TIMESTAMPS_24H, DateFormat.is24HourFormat(getActivity()));
boolean isUsing24HourTime = DateFormat.is24HourFormat(getActivity());
return new TimePickerDialog(getActivity(), this, hour, minute, isUsing24HourTime);
}