forked from upstream-mirrors/quik
Respect system preference for 24 hour time
This commit is contained in:
@@ -1,9 +1,6 @@
|
||||
package com.moez.QKSMS.common.utils;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.test.AndroidTestCase;
|
||||
import com.moez.QKSMS.ui.settings.SettingsFragment;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
@@ -12,13 +9,6 @@ public class DateFormatterTest extends AndroidTestCase {
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
public void test24Hours() {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
prefs.edit().putBoolean(SettingsFragment.TIMESTAMPS_24H, true).apply();
|
||||
assertTrue(DateFormatter.accountFor24HourTime(getContext(), new SimpleDateFormat("h:mm a")).equals(new SimpleDateFormat("H:mm")));
|
||||
prefs.edit().putBoolean(SettingsFragment.TIMESTAMPS_24H, false).apply();
|
||||
}
|
||||
|
||||
public void testDateSymbolsAPI(){
|
||||
assertEquals(new SimpleDateFormat("H:mm a").toPattern(), "H:mm a");
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -197,8 +197,6 @@
|
||||
<string name="pref_long_as_mms_summary">Send long messages as MMS instead of splitting them</string>
|
||||
<string name="pref_long_as_mms_after">Send long as MMS after</string>
|
||||
<string name="pref_long_as_mms_after_summary">Send long messages as MMS when they exceed the length of a number of messages</string>
|
||||
<string name="pref_24h">24h time</string>
|
||||
<string name="pref_24h_summary">Display timestamps in 24-hour format</string>
|
||||
<string name="pref_return">Show return button</string>
|
||||
<string name="pref_return_summary">Show return key on keyboard instead of Emoji button</string>
|
||||
<string name="pref_text">Text</string>
|
||||
|
||||
@@ -135,12 +135,5 @@
|
||||
android:summary="@string/pref_message_count_summary"
|
||||
android:title="@string/pref_message_count"
|
||||
android:widgetLayout="@layout/view_switch" />
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:key="pref_key_24h"
|
||||
android:layout="@layout/list_item_preference"
|
||||
android:summary="@string/pref_24h_summary"
|
||||
android:title="@string/pref_24h"
|
||||
android:widgetLayout="@layout/view_switch" />
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
||||
Reference in New Issue
Block a user