mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-22 21:58:53 +01:00
Merge pull request #162 from sm4rk0/patch-2
Time picker should use system 12/24h format
This commit is contained in:
@@ -3,6 +3,7 @@ package com.moez.QKSMS.common.utils;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.text.format.DateUtils;
|
import android.text.format.DateUtils;
|
||||||
|
import android.text.format.DateFormat;
|
||||||
|
|
||||||
import com.moez.QKSMS.QKSMSApp;
|
import com.moez.QKSMS.QKSMSApp;
|
||||||
import com.moez.QKSMS.R;
|
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.
|
public static SimpleDateFormat accountFor24HourTime(Context context, SimpleDateFormat input) { //pass in 12 hour time. If needed, change to 24 hr.
|
||||||
SharedPreferences prefs = MainActivity.getPrefs(context);
|
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) {
|
if (isUsing24HourTime) {
|
||||||
return new SimpleDateFormat(input.toPattern().replace('h', 'H').replaceAll(" a", ""));
|
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.PreferenceCategory;
|
||||||
import android.preference.PreferenceFragment;
|
import android.preference.PreferenceFragment;
|
||||||
import android.preference.PreferenceScreen;
|
import android.preference.PreferenceScreen;
|
||||||
|
import android.text.format.DateFormat;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
@@ -732,8 +733,8 @@ public class SettingsFragment extends PreferenceFragment implements
|
|||||||
|
|
||||||
int hour = c.get(Calendar.HOUR_OF_DAY);
|
int hour = c.get(Calendar.HOUR_OF_DAY);
|
||||||
int minute = c.get(Calendar.MINUTE);
|
int minute = c.get(Calendar.MINUTE);
|
||||||
|
boolean isUsing24HourTime = mPrefs.getBoolean(SettingsFragment.TIMESTAMPS_24H, DateFormat.is24HourFormat(getActivity()));
|
||||||
return new TimePickerDialog(getActivity(), this, hour, minute, false);
|
return new TimePickerDialog(getActivity(), this, hour, minute, isUsing24HourTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
|
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
|
||||||
|
|||||||
Reference in New Issue
Block a user