diff options
author | Selim Cinek <cinek@google.com> | 2014-11-21 17:44:34 +0100 |
---|---|---|
committer | Selim Cinek <cinek@google.com> | 2014-11-21 18:25:30 +0100 |
commit | 9c4a707912da2c954b2d3d1311b8a691ded8aa16 (patch) | |
tree | 5c7804aa0c697aeaf70aaba0226b800ccd7dc2d1 /core/java/android/text/format | |
parent | 7b8157ef238d4eec7698338e768a602d4182cbb7 (diff) | |
download | frameworks_base-9c4a707912da2c954b2d3d1311b8a691ded8aa16.zip frameworks_base-9c4a707912da2c954b2d3d1311b8a691ded8aa16.tar.gz frameworks_base-9c4a707912da2c954b2d3d1311b8a691ded8aa16.tar.bz2 |
Fixed several time related states for secondary users
The 24 hour setting was not respected correctly. Also
fixed a bug where the next alarm would not display itself
in the QS panel.
Bug: 16239208
Change-Id: I89734f783912dead5831db49db53fba04dbf54ee
Diffstat (limited to 'core/java/android/text/format')
-rwxr-xr-x | core/java/android/text/format/DateFormat.java | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/core/java/android/text/format/DateFormat.java b/core/java/android/text/format/DateFormat.java index 933bcee..72bbb2b 100755 --- a/core/java/android/text/format/DateFormat.java +++ b/core/java/android/text/format/DateFormat.java @@ -17,6 +17,7 @@ package android.text.format; import android.content.Context; +import android.os.UserHandle; import android.provider.Settings; import android.text.SpannableStringBuilder; import android.text.Spanned; @@ -166,8 +167,20 @@ public class DateFormat { * @return true if 24 hour time format is selected, false otherwise. */ public static boolean is24HourFormat(Context context) { - String value = Settings.System.getString(context.getContentResolver(), - Settings.System.TIME_12_24); + return is24HourFormat(context, UserHandle.myUserId()); + } + + /** + * Returns true if user preference with the given user handle is set to 24-hour format. + * @param context the context to use for the content resolver + * @param userHandle the user handle of the user to query. + * @return true if 24 hour time format is selected, false otherwise. + * + * @hide + */ + public static boolean is24HourFormat(Context context, int userHandle) { + String value = Settings.System.getStringForUser(context.getContentResolver(), + Settings.System.TIME_12_24, userHandle); if (value == null) { Locale locale = context.getResources().getConfiguration().locale; @@ -179,7 +192,7 @@ public class DateFormat { } java.text.DateFormat natural = - java.text.DateFormat.getTimeInstance(java.text.DateFormat.LONG, locale); + java.text.DateFormat.getTimeInstance(java.text.DateFormat.LONG, locale); if (natural instanceof SimpleDateFormat) { SimpleDateFormat sdf = (SimpleDateFormat) natural; @@ -253,8 +266,19 @@ public class DateFormat { * @hide */ public static String getTimeFormatString(Context context) { + return getTimeFormatString(context, UserHandle.myUserId()); + } + + /** + * Returns a String pattern that can be used to format the time according + * to the current locale and the user's 12-/24-hour clock preference. + * @param context the application context + * @param userHandle the user handle of the user to query the format for + * @hide + */ + public static String getTimeFormatString(Context context, int userHandle) { LocaleData d = LocaleData.get(context.getResources().getConfiguration().locale); - return is24HourFormat(context) ? d.timeFormat24 : d.timeFormat12; + return is24HourFormat(context, userHandle) ? d.timeFormat24 : d.timeFormat12; } /** |