summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Julia Reynolds <juliacr@google.com> 2015-10-16 20:37:46 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2015-10-16 20:37:46 +0000
commit52815c3bb45593ba74395adaa5b69be6e9a604e5 (patch)
tree5ef68d6d87b02ebb93eeae5c3312621765744a69
parent97339f196fe0cea06a6c9eff0ba3ce285ba2ef50 (diff)
parentc72c931eb8c5c336b9cb8b600b9e777ca169687c (diff)
Merge "resolved conflicts for 429e7dcd to master"
-rw-r--r--core/java/android/service/notification/ZenModeConfig.java20
-rw-r--r--packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java20
2 files changed, 21 insertions, 19 deletions
diff --git a/core/java/android/service/notification/ZenModeConfig.java b/core/java/android/service/notification/ZenModeConfig.java
index 2c49d16d5096..82f1b28c39ae 100644
--- a/core/java/android/service/notification/ZenModeConfig.java
+++ b/core/java/android/service/notification/ZenModeConfig.java
@@ -41,6 +41,7 @@ import org.xmlpull.v1.XmlSerializer;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Calendar;
+import java.util.GregorianCalendar;
import java.util.Locale;
import java.util.Objects;
import java.util.UUID;
@@ -661,7 +662,7 @@ public class ZenModeConfig implements Parcelable {
int userHandle, boolean shortVersion) {
final int num;
String summary, line1, line2;
- final CharSequence formattedTime = getFormattedTime(context, time, minutes, userHandle);
+ final CharSequence formattedTime = getFormattedTime(context, time, userHandle);
final Resources res = context.getResources();
if (minutes < 60) {
// display as minutes
@@ -694,8 +695,7 @@ public class ZenModeConfig implements Parcelable {
public static Condition toNextAlarmCondition(Context context, long now, long alarm,
int userHandle) {
- int minutes = Math.round((alarm-now) / (float) MINUTES_MS);
- final CharSequence formattedTime = getFormattedTime(context, alarm, minutes, userHandle);
+ final CharSequence formattedTime = getFormattedTime(context, alarm, userHandle);
final Resources res = context.getResources();
final String line1 = res.getString(R.string.zen_mode_alarm, formattedTime);
final Uri id = toCountdownConditionId(alarm);
@@ -703,11 +703,15 @@ public class ZenModeConfig implements Parcelable {
Condition.FLAG_RELEVANT_NOW);
}
- private static CharSequence getFormattedTime(Context context, long time, int minutes,
- int userHandle) {
- String skeleton = DateFormat.is24HourFormat(context, userHandle) ? "Hm" : "hma";
- if (minutes > DAY_MINUTES) {
- skeleton = "EEE " + (DateFormat.is24HourFormat(context, userHandle) ? "Hm" : "hma");
+ private static CharSequence getFormattedTime(Context context, long time, int userHandle) {
+ String skeleton = "EEE " + (DateFormat.is24HourFormat(context, userHandle) ? "Hm" : "hma");
+ GregorianCalendar now = new GregorianCalendar();
+ GregorianCalendar endTime = new GregorianCalendar();
+ endTime.setTimeInMillis(time);
+ if (now.get(Calendar.YEAR) == endTime.get(Calendar.YEAR)
+ && now.get(Calendar.MONTH) == endTime.get(Calendar.MONTH)
+ && now.get(Calendar.DATE) == endTime.get(Calendar.DATE)) {
+ skeleton = DateFormat.is24HourFormat(context, userHandle) ? "Hm" : "hma";
}
final String pattern = DateFormat.getBestDateTimePattern(Locale.getDefault(), skeleton);
return DateFormat.format(pattern, time);
diff --git a/packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java b/packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java
index 02ee5d4cf235..1770a06b74bc 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java
+++ b/packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java
@@ -79,6 +79,7 @@ public class ZenModePanel extends LinearLayout {
private static final int FOREVER_CONDITION_INDEX = 0;
private static final int COUNTDOWN_CONDITION_INDEX = 1;
private static final int COUNTDOWN_ALARM_CONDITION_INDEX = 2;
+ private static final int COUNTDOWN_CONDITION_COUNT = 2;
public static final Intent ZEN_SETTINGS
= new Intent(Settings.ACTION_ZEN_MODE_SETTINGS);
@@ -89,7 +90,6 @@ public class ZenModePanel extends LinearLayout {
private final LayoutInflater mInflater;
private final H mHandler = new H();
private final ZenPrefs mPrefs;
- private final IconPulser mIconPulser;
private final TransitionHelper mTransitionHelper = new TransitionHelper();
private final Uri mForeverId;
private final SpTexts mSpTexts;
@@ -126,7 +126,6 @@ public class ZenModePanel extends LinearLayout {
mContext = context;
mPrefs = new ZenPrefs();
mInflater = LayoutInflater.from(mContext.getApplicationContext());
- mIconPulser = new IconPulser(mContext);
mForeverId = Condition.newId(mContext).appendPath("forever").build();
mSpTexts = new SpTexts(mContext);
mVoiceCapable = Util.isVoiceCapable(mContext);
@@ -297,10 +296,6 @@ public class ZenModePanel extends LinearLayout {
}
if (DEBUG) Log.d(mTag, "Initial bucket index: " + mBucketIndex);
- mTimeUntilAlarmCondition = parseExistingTimeCondition(mContext, mExitCondition);
- if (mTimeUntilAlarmCondition == null) {
- mTimeUntilAlarmCondition = getTimeUntilNextAlarmCondition();
- }
mConditions = null; // reset conditions
handleUpdateConditions();
} else {
@@ -311,7 +306,7 @@ public class ZenModePanel extends LinearLayout {
public void init(ZenModeController controller) {
mController = controller;
mCountdownConditionSupported = mController.isCountdownConditionSupported();
- final int countdownDelta = mCountdownConditionSupported ? 2 : 0;
+ final int countdownDelta = mCountdownConditionSupported ? COUNTDOWN_CONDITION_COUNT : 0;
final int minConditions = 1 /*forever*/ + countdownDelta;
for (int i = 0; i < minConditions; i++) {
mZenConditions.addView(mInflater.inflate(R.layout.zen_mode_condition, this, false));
@@ -489,10 +484,13 @@ public class ZenModePanel extends LinearLayout {
COUNTDOWN_CONDITION_INDEX);
}
// countdown until alarm
- if (mCountdownConditionSupported && mTimeUntilAlarmCondition != null) {
- bind(mTimeUntilAlarmCondition,
- mZenConditions.getChildAt(COUNTDOWN_ALARM_CONDITION_INDEX),
- COUNTDOWN_ALARM_CONDITION_INDEX);
+ if (mCountdownConditionSupported) {
+ Condition nextAlarmCondition = getTimeUntilNextAlarmCondition();
+ if (nextAlarmCondition != null) {
+ bind(nextAlarmCondition,
+ mZenConditions.getChildAt(COUNTDOWN_ALARM_CONDITION_INDEX),
+ COUNTDOWN_ALARM_CONDITION_INDEX);
+ }
}
// ensure something is selected
if (mExpanded && isShown()) {