am 962b06f9: Merge "Fixed several time related states for secondary users" into lmp-mr1-dev
* commit '962b06f9a02f08392b6f87225a314ebf39dd7a07': Fixed several time related states for secondary users
This commit is contained in:
@@ -474,13 +474,14 @@ public class ZenModeConfig implements Parcelable {
|
|||||||
return downtime;
|
return downtime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Condition toTimeCondition(Context context, int minutesFromNow) {
|
public static Condition toTimeCondition(Context context, int minutesFromNow, int userHandle) {
|
||||||
final long now = System.currentTimeMillis();
|
final long now = System.currentTimeMillis();
|
||||||
final long millis = minutesFromNow == 0 ? ZERO_VALUE_MS : minutesFromNow * MINUTES_MS;
|
final long millis = minutesFromNow == 0 ? ZERO_VALUE_MS : minutesFromNow * MINUTES_MS;
|
||||||
return toTimeCondition(context, now + millis, minutesFromNow, now);
|
return toTimeCondition(context, now + millis, minutesFromNow, now, userHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Condition toTimeCondition(Context context, long time, int minutes, long now) {
|
public static Condition toTimeCondition(Context context, long time, int minutes, long now,
|
||||||
|
int userHandle) {
|
||||||
final int num, summaryResId, line1ResId;
|
final int num, summaryResId, line1ResId;
|
||||||
if (minutes < 60) {
|
if (minutes < 60) {
|
||||||
// display as minutes
|
// display as minutes
|
||||||
@@ -493,7 +494,7 @@ public class ZenModeConfig implements Parcelable {
|
|||||||
summaryResId = com.android.internal.R.plurals.zen_mode_duration_hours_summary;
|
summaryResId = com.android.internal.R.plurals.zen_mode_duration_hours_summary;
|
||||||
line1ResId = com.android.internal.R.plurals.zen_mode_duration_hours;
|
line1ResId = com.android.internal.R.plurals.zen_mode_duration_hours;
|
||||||
}
|
}
|
||||||
final String skeleton = DateFormat.is24HourFormat(context) ? "Hm" : "hma";
|
final String skeleton = DateFormat.is24HourFormat(context, userHandle) ? "Hm" : "hma";
|
||||||
final String pattern = DateFormat.getBestDateTimePattern(Locale.getDefault(), skeleton);
|
final String pattern = DateFormat.getBestDateTimePattern(Locale.getDefault(), skeleton);
|
||||||
final CharSequence formattedTime = DateFormat.format(pattern, time);
|
final CharSequence formattedTime = DateFormat.format(pattern, time);
|
||||||
final Resources res = context.getResources();
|
final Resources res = context.getResources();
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
package android.text.format;
|
package android.text.format;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.os.UserHandle;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.text.SpannableStringBuilder;
|
import android.text.SpannableStringBuilder;
|
||||||
import android.text.Spanned;
|
import android.text.Spanned;
|
||||||
@@ -166,8 +167,20 @@ public class DateFormat {
|
|||||||
* @return true if 24 hour time format is selected, false otherwise.
|
* @return true if 24 hour time format is selected, false otherwise.
|
||||||
*/
|
*/
|
||||||
public static boolean is24HourFormat(Context context) {
|
public static boolean is24HourFormat(Context context) {
|
||||||
String value = Settings.System.getString(context.getContentResolver(),
|
return is24HourFormat(context, UserHandle.myUserId());
|
||||||
Settings.System.TIME_12_24);
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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) {
|
if (value == null) {
|
||||||
Locale locale = context.getResources().getConfiguration().locale;
|
Locale locale = context.getResources().getConfiguration().locale;
|
||||||
@@ -179,7 +192,7 @@ public class DateFormat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
java.text.DateFormat natural =
|
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) {
|
if (natural instanceof SimpleDateFormat) {
|
||||||
SimpleDateFormat sdf = (SimpleDateFormat) natural;
|
SimpleDateFormat sdf = (SimpleDateFormat) natural;
|
||||||
@@ -253,8 +266,19 @@ public class DateFormat {
|
|||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public static String getTimeFormatString(Context context) {
|
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);
|
LocaleData d = LocaleData.get(context.getResources().getConfiguration().locale);
|
||||||
return is24HourFormat(context) ? d.timeFormat24 : d.timeFormat12;
|
return is24HourFormat(context, userHandle) ? d.timeFormat24 : d.timeFormat12;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package android.widget;
|
package android.widget;
|
||||||
|
|
||||||
|
import android.app.ActivityManager;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@@ -26,6 +27,7 @@ import android.database.ContentObserver;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
|
import android.os.UserHandle;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.text.format.DateFormat;
|
import android.text.format.DateFormat;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
@@ -127,6 +129,8 @@ public class TextClock extends TextView {
|
|||||||
private Calendar mTime;
|
private Calendar mTime;
|
||||||
private String mTimeZone;
|
private String mTimeZone;
|
||||||
|
|
||||||
|
private boolean mShowCurrentUserTime;
|
||||||
|
|
||||||
private final ContentObserver mFormatChangeObserver = new ContentObserver(new Handler()) {
|
private final ContentObserver mFormatChangeObserver = new ContentObserver(new Handler()) {
|
||||||
@Override
|
@Override
|
||||||
public void onChange(boolean selfChange) {
|
public void onChange(boolean selfChange) {
|
||||||
@@ -341,6 +345,22 @@ public class TextClock extends TextView {
|
|||||||
onTimeChanged();
|
onTimeChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets whether this clock should always track the current user and not the user of the
|
||||||
|
* current process. This is used for single instance processes like the systemUI who need
|
||||||
|
* to display time for different users.
|
||||||
|
*
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public void setShowCurrentUserTime(boolean showCurrentUserTime) {
|
||||||
|
mShowCurrentUserTime = showCurrentUserTime;
|
||||||
|
|
||||||
|
chooseFormat();
|
||||||
|
onTimeChanged();
|
||||||
|
unregisterObserver();
|
||||||
|
registerObserver();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates whether the system is currently using the 24-hour mode.
|
* Indicates whether the system is currently using the 24-hour mode.
|
||||||
*
|
*
|
||||||
@@ -360,7 +380,11 @@ public class TextClock extends TextView {
|
|||||||
* @see #getFormat24Hour()
|
* @see #getFormat24Hour()
|
||||||
*/
|
*/
|
||||||
public boolean is24HourModeEnabled() {
|
public boolean is24HourModeEnabled() {
|
||||||
return DateFormat.is24HourFormat(getContext());
|
if (mShowCurrentUserTime) {
|
||||||
|
return DateFormat.is24HourFormat(getContext(), ActivityManager.getCurrentUser());
|
||||||
|
} else {
|
||||||
|
return DateFormat.is24HourFormat(getContext());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -500,7 +524,13 @@ public class TextClock extends TextView {
|
|||||||
|
|
||||||
private void registerObserver() {
|
private void registerObserver() {
|
||||||
final ContentResolver resolver = getContext().getContentResolver();
|
final ContentResolver resolver = getContext().getContentResolver();
|
||||||
resolver.registerContentObserver(Settings.System.CONTENT_URI, true, mFormatChangeObserver);
|
if (mShowCurrentUserTime) {
|
||||||
|
resolver.registerContentObserver(Settings.System.CONTENT_URI, true,
|
||||||
|
mFormatChangeObserver, UserHandle.USER_ALL);
|
||||||
|
} else {
|
||||||
|
resolver.registerContentObserver(Settings.System.CONTENT_URI, true,
|
||||||
|
mFormatChangeObserver);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void unregisterReceiver() {
|
private void unregisterReceiver() {
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.android.keyguard;
|
package com.android.keyguard;
|
||||||
|
|
||||||
|
import android.app.ActivityManager;
|
||||||
import android.app.AlarmManager;
|
import android.app.AlarmManager;
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@@ -105,6 +106,8 @@ public class KeyguardStatusView extends GridLayout {
|
|||||||
mAlarmStatusView = (TextView) findViewById(R.id.alarm_status);
|
mAlarmStatusView = (TextView) findViewById(R.id.alarm_status);
|
||||||
mDateView = (TextClock) findViewById(R.id.date_view);
|
mDateView = (TextClock) findViewById(R.id.date_view);
|
||||||
mClockView = (TextClock) findViewById(R.id.clock_view);
|
mClockView = (TextClock) findViewById(R.id.clock_view);
|
||||||
|
mDateView.setShowCurrentUserTime(true);
|
||||||
|
mClockView.setShowCurrentUserTime(true);
|
||||||
mOwnerInfo = (TextView) findViewById(R.id.owner_info);
|
mOwnerInfo = (TextView) findViewById(R.id.owner_info);
|
||||||
mLockPatternUtils = new LockPatternUtils(getContext());
|
mLockPatternUtils = new LockPatternUtils(getContext());
|
||||||
final boolean screenOn = KeyguardUpdateMonitor.getInstance(mContext).isScreenOn();
|
final boolean screenOn = KeyguardUpdateMonitor.getInstance(mContext).isScreenOn();
|
||||||
@@ -160,7 +163,9 @@ public class KeyguardStatusView extends GridLayout {
|
|||||||
if (info == null) {
|
if (info == null) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
String skeleton = DateFormat.is24HourFormat(context) ? "EHm" : "Ehma";
|
String skeleton = DateFormat.is24HourFormat(context, ActivityManager.getCurrentUser())
|
||||||
|
? "EHm"
|
||||||
|
: "Ehma";
|
||||||
String pattern = DateFormat.getBestDateTimePattern(Locale.getDefault(), skeleton);
|
String pattern = DateFormat.getBestDateTimePattern(Locale.getDefault(), skeleton);
|
||||||
return DateFormat.format(pattern, info.getTriggerTime()).toString();
|
return DateFormat.format(pattern, info.getTriggerTime()).toString();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,12 +16,14 @@
|
|||||||
|
|
||||||
package com.android.systemui.statusbar.policy;
|
package com.android.systemui.statusbar.policy;
|
||||||
|
|
||||||
|
import android.app.ActivityManager;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.UserHandle;
|
||||||
import android.text.Spannable;
|
import android.text.Spannable;
|
||||||
import android.text.SpannableStringBuilder;
|
import android.text.SpannableStringBuilder;
|
||||||
import android.text.format.DateFormat;
|
import android.text.format.DateFormat;
|
||||||
@@ -91,7 +93,8 @@ public class Clock extends TextView implements DemoMode {
|
|||||||
filter.addAction(Intent.ACTION_CONFIGURATION_CHANGED);
|
filter.addAction(Intent.ACTION_CONFIGURATION_CHANGED);
|
||||||
filter.addAction(Intent.ACTION_USER_SWITCHED);
|
filter.addAction(Intent.ACTION_USER_SWITCHED);
|
||||||
|
|
||||||
getContext().registerReceiver(mIntentReceiver, filter, null, getHandler());
|
getContext().registerReceiverAsUser(mIntentReceiver, UserHandle.ALL, filter,
|
||||||
|
null, getHandler());
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: It's safe to do these after registering the receiver since the receiver always runs
|
// NOTE: It's safe to do these after registering the receiver since the receiver always runs
|
||||||
@@ -142,7 +145,7 @@ public class Clock extends TextView implements DemoMode {
|
|||||||
|
|
||||||
private final CharSequence getSmallTime() {
|
private final CharSequence getSmallTime() {
|
||||||
Context context = getContext();
|
Context context = getContext();
|
||||||
boolean is24 = DateFormat.is24HourFormat(context);
|
boolean is24 = DateFormat.is24HourFormat(context, ActivityManager.getCurrentUser());
|
||||||
LocaleData d = LocaleData.get(context.getResources().getConfiguration().locale);
|
LocaleData d = LocaleData.get(context.getResources().getConfiguration().locale);
|
||||||
|
|
||||||
final char MAGIC1 = '\uEF00';
|
final char MAGIC1 = '\uEF00';
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ public class NextAlarmController extends BroadcastReceiver {
|
|||||||
IntentFilter filter = new IntentFilter();
|
IntentFilter filter = new IntentFilter();
|
||||||
filter.addAction(Intent.ACTION_USER_SWITCHED);
|
filter.addAction(Intent.ACTION_USER_SWITCHED);
|
||||||
filter.addAction(AlarmManager.ACTION_NEXT_ALARM_CLOCK_CHANGED);
|
filter.addAction(AlarmManager.ACTION_NEXT_ALARM_CLOCK_CHANGED);
|
||||||
context.registerReceiver(this, filter);
|
context.registerReceiverAsUser(this, UserHandle.ALL, filter, null, null);
|
||||||
updateNextAlarm();
|
updateNextAlarm();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,10 +16,12 @@
|
|||||||
|
|
||||||
package com.android.systemui.statusbar.policy;
|
package com.android.systemui.statusbar.policy;
|
||||||
|
|
||||||
|
import android.app.ActivityManager;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
|
import android.os.UserHandle;
|
||||||
import android.text.format.DateFormat;
|
import android.text.format.DateFormat;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
@@ -42,7 +44,9 @@ public class SplitClockView extends LinearLayout {
|
|||||||
final String action = intent.getAction();
|
final String action = intent.getAction();
|
||||||
if (Intent.ACTION_TIME_CHANGED.equals(action)
|
if (Intent.ACTION_TIME_CHANGED.equals(action)
|
||||||
|| Intent.ACTION_TIMEZONE_CHANGED.equals(action)
|
|| Intent.ACTION_TIMEZONE_CHANGED.equals(action)
|
||||||
|| Intent.ACTION_LOCALE_CHANGED.equals(action)) {
|
|| Intent.ACTION_LOCALE_CHANGED.equals(action)
|
||||||
|
|| Intent.ACTION_CONFIGURATION_CHANGED.equals(action)
|
||||||
|
|| Intent.ACTION_USER_SWITCHED.equals(action)) {
|
||||||
updatePatterns();
|
updatePatterns();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -57,6 +61,8 @@ public class SplitClockView extends LinearLayout {
|
|||||||
super.onFinishInflate();
|
super.onFinishInflate();
|
||||||
mTimeView = (TextClock) findViewById(R.id.time_view);
|
mTimeView = (TextClock) findViewById(R.id.time_view);
|
||||||
mAmPmView = (TextClock) findViewById(R.id.am_pm_view);
|
mAmPmView = (TextClock) findViewById(R.id.am_pm_view);
|
||||||
|
mTimeView.setShowCurrentUserTime(true);
|
||||||
|
mAmPmView.setShowCurrentUserTime(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -67,7 +73,9 @@ public class SplitClockView extends LinearLayout {
|
|||||||
filter.addAction(Intent.ACTION_TIME_CHANGED);
|
filter.addAction(Intent.ACTION_TIME_CHANGED);
|
||||||
filter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
|
filter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
|
||||||
filter.addAction(Intent.ACTION_LOCALE_CHANGED);
|
filter.addAction(Intent.ACTION_LOCALE_CHANGED);
|
||||||
getContext().registerReceiver(mIntentReceiver, filter, null, null);
|
filter.addAction(Intent.ACTION_CONFIGURATION_CHANGED);
|
||||||
|
filter.addAction(Intent.ACTION_USER_SWITCHED);
|
||||||
|
getContext().registerReceiverAsUser(mIntentReceiver, UserHandle.ALL, filter, null, null);
|
||||||
|
|
||||||
updatePatterns();
|
updatePatterns();
|
||||||
}
|
}
|
||||||
@@ -79,7 +87,8 @@ public class SplitClockView extends LinearLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updatePatterns() {
|
private void updatePatterns() {
|
||||||
String formatString = DateFormat.getTimeFormatString(getContext());
|
String formatString = DateFormat.getTimeFormatString(getContext(),
|
||||||
|
ActivityManager.getCurrentUser());
|
||||||
int index = getAmPmPartEndIndex(formatString);
|
int index = getAmPmPartEndIndex(formatString);
|
||||||
String timeString;
|
String timeString;
|
||||||
String amPmString;
|
String amPmString;
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ package com.android.systemui.volume;
|
|||||||
|
|
||||||
import android.animation.Animator;
|
import android.animation.Animator;
|
||||||
import android.animation.AnimatorListenerAdapter;
|
import android.animation.AnimatorListenerAdapter;
|
||||||
|
import android.app.ActivityManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
@@ -218,7 +219,7 @@ public class ZenModePanel extends LinearLayout {
|
|||||||
} else {
|
} else {
|
||||||
mBucketIndex = DEFAULT_BUCKET_INDEX;
|
mBucketIndex = DEFAULT_BUCKET_INDEX;
|
||||||
mTimeCondition = ZenModeConfig.toTimeCondition(mContext,
|
mTimeCondition = ZenModeConfig.toTimeCondition(mContext,
|
||||||
MINUTE_BUCKETS[mBucketIndex]);
|
MINUTE_BUCKETS[mBucketIndex], ActivityManager.getCurrentUser());
|
||||||
}
|
}
|
||||||
if (DEBUG) Log.d(mTag, "Initial bucket index: " + mBucketIndex);
|
if (DEBUG) Log.d(mTag, "Initial bucket index: " + mBucketIndex);
|
||||||
mConditions = null; // reset conditions
|
mConditions = null; // reset conditions
|
||||||
@@ -341,7 +342,7 @@ public class ZenModePanel extends LinearLayout {
|
|||||||
final long span = time - now;
|
final long span = time - now;
|
||||||
if (span <= 0 || span > MAX_BUCKET_MINUTES * MINUTES_MS) return null;
|
if (span <= 0 || span > MAX_BUCKET_MINUTES * MINUTES_MS) return null;
|
||||||
return ZenModeConfig.toTimeCondition(mContext,
|
return ZenModeConfig.toTimeCondition(mContext,
|
||||||
time, Math.round(span / (float) MINUTES_MS), now);
|
time, Math.round(span / (float) MINUTES_MS), now, ActivityManager.getCurrentUser());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleUpdateConditions(Condition[] conditions) {
|
private void handleUpdateConditions(Condition[] conditions) {
|
||||||
@@ -397,7 +398,8 @@ public class ZenModePanel extends LinearLayout {
|
|||||||
if (favoriteIndex == -1) {
|
if (favoriteIndex == -1) {
|
||||||
getConditionTagAt(FOREVER_CONDITION_INDEX).rb.setChecked(true);
|
getConditionTagAt(FOREVER_CONDITION_INDEX).rb.setChecked(true);
|
||||||
} else {
|
} else {
|
||||||
mTimeCondition = ZenModeConfig.toTimeCondition(mContext, MINUTE_BUCKETS[favoriteIndex]);
|
mTimeCondition = ZenModeConfig.toTimeCondition(mContext,
|
||||||
|
MINUTE_BUCKETS[favoriteIndex], ActivityManager.getCurrentUser());
|
||||||
mBucketIndex = favoriteIndex;
|
mBucketIndex = favoriteIndex;
|
||||||
bind(mTimeCondition, mZenConditions.getChildAt(TIME_CONDITION_INDEX));
|
bind(mTimeCondition, mZenConditions.getChildAt(TIME_CONDITION_INDEX));
|
||||||
getConditionTagAt(TIME_CONDITION_INDEX).rb.setChecked(true);
|
getConditionTagAt(TIME_CONDITION_INDEX).rb.setChecked(true);
|
||||||
@@ -511,7 +513,7 @@ public class ZenModePanel extends LinearLayout {
|
|||||||
final long span = time - System.currentTimeMillis();
|
final long span = time - System.currentTimeMillis();
|
||||||
button1.setEnabled(span > MIN_BUCKET_MINUTES * MINUTES_MS);
|
button1.setEnabled(span > MIN_BUCKET_MINUTES * MINUTES_MS);
|
||||||
final Condition maxCondition = ZenModeConfig.toTimeCondition(mContext,
|
final Condition maxCondition = ZenModeConfig.toTimeCondition(mContext,
|
||||||
MAX_BUCKET_MINUTES);
|
MAX_BUCKET_MINUTES, ActivityManager.getCurrentUser());
|
||||||
button2.setEnabled(!Objects.equals(condition.summary, maxCondition.summary));
|
button2.setEnabled(!Objects.equals(condition.summary, maxCondition.summary));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -562,20 +564,20 @@ public class ZenModePanel extends LinearLayout {
|
|||||||
if (up && bucketTime > time || !up && bucketTime < time) {
|
if (up && bucketTime > time || !up && bucketTime < time) {
|
||||||
mBucketIndex = j;
|
mBucketIndex = j;
|
||||||
newCondition = ZenModeConfig.toTimeCondition(mContext,
|
newCondition = ZenModeConfig.toTimeCondition(mContext,
|
||||||
bucketTime, bucketMinutes, now);
|
bucketTime, bucketMinutes, now, ActivityManager.getCurrentUser());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (newCondition == null) {
|
if (newCondition == null) {
|
||||||
mBucketIndex = DEFAULT_BUCKET_INDEX;
|
mBucketIndex = DEFAULT_BUCKET_INDEX;
|
||||||
newCondition = ZenModeConfig.toTimeCondition(mContext,
|
newCondition = ZenModeConfig.toTimeCondition(mContext,
|
||||||
MINUTE_BUCKETS[mBucketIndex]);
|
MINUTE_BUCKETS[mBucketIndex], ActivityManager.getCurrentUser());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// on a known index, simply increment or decrement
|
// on a known index, simply increment or decrement
|
||||||
mBucketIndex = Math.max(0, Math.min(N - 1, mBucketIndex + (up ? 1 : -1)));
|
mBucketIndex = Math.max(0, Math.min(N - 1, mBucketIndex + (up ? 1 : -1)));
|
||||||
newCondition = ZenModeConfig.toTimeCondition(mContext,
|
newCondition = ZenModeConfig.toTimeCondition(mContext,
|
||||||
MINUTE_BUCKETS[mBucketIndex]);
|
MINUTE_BUCKETS[mBucketIndex], ActivityManager.getCurrentUser());
|
||||||
}
|
}
|
||||||
mTimeCondition = newCondition;
|
mTimeCondition = newCondition;
|
||||||
bind(mTimeCondition, row);
|
bind(mTimeCondition, row);
|
||||||
|
|||||||
@@ -1124,7 +1124,7 @@ class AlarmManagerService extends SystemService {
|
|||||||
|
|
||||||
if (DEBUG_ALARM_CLOCK) {
|
if (DEBUG_ALARM_CLOCK) {
|
||||||
Log.v(TAG, "Found AlarmClockInfo at " +
|
Log.v(TAG, "Found AlarmClockInfo at " +
|
||||||
formatNextAlarm(getContext(), a.alarmClock) +
|
formatNextAlarm(getContext(), a.alarmClock, userId) +
|
||||||
" for user " + userId);
|
" for user " + userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1162,7 +1162,7 @@ class AlarmManagerService extends SystemService {
|
|||||||
if (alarmClock != null) {
|
if (alarmClock != null) {
|
||||||
if (DEBUG_ALARM_CLOCK) {
|
if (DEBUG_ALARM_CLOCK) {
|
||||||
Log.v(TAG, "Next AlarmClockInfoForUser(" + userId + "): " +
|
Log.v(TAG, "Next AlarmClockInfoForUser(" + userId + "): " +
|
||||||
formatNextAlarm(getContext(), alarmClock));
|
formatNextAlarm(getContext(), alarmClock, userId));
|
||||||
}
|
}
|
||||||
mNextAlarmClockForUser.put(userId, alarmClock);
|
mNextAlarmClockForUser.put(userId, alarmClock);
|
||||||
} else {
|
} else {
|
||||||
@@ -1204,7 +1204,7 @@ class AlarmManagerService extends SystemService {
|
|||||||
AlarmManager.AlarmClockInfo alarmClock = pendingUsers.valueAt(i);
|
AlarmManager.AlarmClockInfo alarmClock = pendingUsers.valueAt(i);
|
||||||
Settings.System.putStringForUser(getContext().getContentResolver(),
|
Settings.System.putStringForUser(getContext().getContentResolver(),
|
||||||
Settings.System.NEXT_ALARM_FORMATTED,
|
Settings.System.NEXT_ALARM_FORMATTED,
|
||||||
formatNextAlarm(getContext(), alarmClock),
|
formatNextAlarm(getContext(), alarmClock, userId),
|
||||||
userId);
|
userId);
|
||||||
|
|
||||||
getContext().sendBroadcastAsUser(NEXT_ALARM_CLOCK_CHANGED_INTENT,
|
getContext().sendBroadcastAsUser(NEXT_ALARM_CLOCK_CHANGED_INTENT,
|
||||||
@@ -1215,8 +1215,9 @@ class AlarmManagerService extends SystemService {
|
|||||||
/**
|
/**
|
||||||
* Formats an alarm like platform/packages/apps/DeskClock used to.
|
* Formats an alarm like platform/packages/apps/DeskClock used to.
|
||||||
*/
|
*/
|
||||||
private static String formatNextAlarm(final Context context, AlarmManager.AlarmClockInfo info) {
|
private static String formatNextAlarm(final Context context, AlarmManager.AlarmClockInfo info,
|
||||||
String skeleton = DateFormat.is24HourFormat(context) ? "EHm" : "Ehma";
|
int userId) {
|
||||||
|
String skeleton = DateFormat.is24HourFormat(context, userId) ? "EHm" : "Ehma";
|
||||||
String pattern = DateFormat.getBestDateTimePattern(Locale.getDefault(), skeleton);
|
String pattern = DateFormat.getBestDateTimePattern(Locale.getDefault(), skeleton);
|
||||||
return (info == null) ? "" :
|
return (info == null) ? "" :
|
||||||
DateFormat.format(pattern, info.getTriggerTime()).toString();
|
DateFormat.format(pattern, info.getTriggerTime()).toString();
|
||||||
|
|||||||
Reference in New Issue
Block a user