Merge pull request #162 from sm4rk0/patch-2

Time picker should use system 12/24h format
This commit is contained in:
Moez Bhatti
2015-08-22 23:10:16 -04:00
2 changed files with 5 additions and 3 deletions
@@ -3,6 +3,7 @@ package com.moez.QKSMS.common.utils;
import android.content.Context;
import android.content.SharedPreferences;
import android.text.format.DateUtils;
import android.text.format.DateFormat;
import com.moez.QKSMS.QKSMSApp;
import com.moez.QKSMS.R;
@@ -49,7 +50,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 = MainActivity.getPrefs(context);
boolean isUsing24HourTime = prefs.getBoolean(SettingsFragment.TIMESTAMPS_24H, false);
boolean isUsing24HourTime = prefs.getBoolean(SettingsFragment.TIMESTAMPS_24H, DateFormat.is24HourFormat(context));
if (isUsing24HourTime) {
return new SimpleDateFormat(input.toPattern().replace('h', 'H').replaceAll(" a", ""));
@@ -22,6 +22,7 @@ import android.preference.Preference;
import android.preference.PreferenceCategory;
import android.preference.PreferenceFragment;
import android.preference.PreferenceScreen;
import android.text.format.DateFormat;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
@@ -732,8 +733,8 @@ public class SettingsFragment extends PreferenceFragment implements
int hour = c.get(Calendar.HOUR_OF_DAY);
int minute = c.get(Calendar.MINUTE);
return new TimePickerDialog(getActivity(), this, hour, minute, false);
boolean isUsing24HourTime = mPrefs.getBoolean(SettingsFragment.TIMESTAMPS_24H, DateFormat.is24HourFormat(getActivity()));
return new TimePickerDialog(getActivity(), this, hour, minute, isUsing24HourTime);
}
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {