summaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorJohn Spurlock <jspurlock@google.com>2015-05-29 18:07:35 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-05-29 18:07:36 +0000
commite648c5f1cb41f72a3404a9a7d2656e764c52f8e1 (patch)
treefe1816526e2faeaa550a54da17c0ee870c1979f9 /packages
parent1a23c31752f1295c708cf749a7828dc42e4e9d9e (diff)
parent8be53eaaf7b2dcc5617c6ed6bef14d15cbe9e28d (diff)
downloadframeworks_base-e648c5f1cb41f72a3404a9a7d2656e764c52f8e1.zip
frameworks_base-e648c5f1cb41f72a3404a9a7d2656e764c52f8e1.tar.gz
frameworks_base-e648c5f1cb41f72a3404a9a7d2656e764c52f8e1.tar.bz2
Merge "Zen: Add warning text if total silence will eat the next alarm." into mnc-dev
Diffstat (limited to 'packages')
-rw-r--r--packages/SystemUI/res/layout/zen_mode_panel.xml11
-rw-r--r--packages/SystemUI/res/values/strings.xml13
-rw-r--r--packages/SystemUI/res/values/styles.xml5
-rw-r--r--packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java38
4 files changed, 67 insertions, 0 deletions
diff --git a/packages/SystemUI/res/layout/zen_mode_panel.xml b/packages/SystemUI/res/layout/zen_mode_panel.xml
index 731d4c1..43ab4bb 100644
--- a/packages/SystemUI/res/layout/zen_mode_panel.xml
+++ b/packages/SystemUI/res/layout/zen_mode_panel.xml
@@ -97,4 +97,15 @@
android:orientation="vertical"
android:paddingBottom="@dimen/zen_mode_condition_detail_bottom_padding" />
+
+ <TextView
+ android:id="@+id/zen_alarm_warning"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="18dp"
+ android:layout_marginEnd="16dp"
+ android:textDirection="locale"
+ android:lineSpacingMultiplier="1.20029"
+ android:textAppearance="@style/TextAppearance.QS.Warning" />
+
</com.android.systemui.volume.ZenModePanel>
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index 5b1a5b3..d96ed96 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -1044,4 +1044,17 @@
<string name="regrettable_lack_of_easter_egg">
¯\\_(ツ)_/¯
</string>
+
+ <!-- Warning text when an alarm might be silenced by Do Not Disturb [CHAR LIMIT=NONE] -->
+ <string name="zen_alarm_warning_indef">You won\'t hear your next alarm <xliff:g id="when" example="at 7:00 AM">%1$s</xliff:g> unless you turn this off before then</string>
+
+ <!-- Warning text when an alarm might be silenced by Do Not Disturb due to a time-based condition [CHAR LIMIT=NONE] -->
+ <string name="zen_alarm_warning">You won\'t hear your next alarm <xliff:g id="when" example="at 7:00 AM">%1$s</xliff:g></string>
+
+ <!-- Alarm template for near alarms [CHAR LIMIT=25] -->
+ <string name="alarm_template">at <xliff:g id="when" example="7:00 AM">%1$s</xliff:g></string>
+
+ <!-- Alarm template for far alarms [CHAR LIMIT=25] -->
+ <string name="alarm_template_far">on <xliff:g id="when" example="Fri 7:00 AM">%1$s</xliff:g></string>
+
</resources>
diff --git a/packages/SystemUI/res/values/styles.xml b/packages/SystemUI/res/values/styles.xml
index 6709095..bda39b1 100644
--- a/packages/SystemUI/res/values/styles.xml
+++ b/packages/SystemUI/res/values/styles.xml
@@ -142,6 +142,11 @@
<item name="android:textSize">14sp</item>
</style>
+ <style name="TextAppearance.QS.Warning">
+ <item name="android:textSize">14sp</item>
+ <item name="android:textColor">@color/system_warning_color</item>
+ </style>
+
<style name="TextAppearance.QS.DetailButton">
<item name="android:textSize">@dimen/qs_detail_button_text_size</item>
<item name="android:textColor">@color/qs_detail_button</item>
diff --git a/packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java b/packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java
index ec24d75..027d637 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java
+++ b/packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java
@@ -35,6 +35,7 @@ import android.service.notification.Condition;
import android.service.notification.ZenModeConfig;
import android.service.notification.ZenModeConfig.ZenRule;
import android.text.TextUtils;
+import android.text.format.DateFormat;
import android.util.ArraySet;
import android.util.AttributeSet;
import android.util.Log;
@@ -57,6 +58,7 @@ import com.android.systemui.statusbar.policy.ZenModeController;
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.Arrays;
+import java.util.Locale;
import java.util.Objects;
public class ZenModePanel extends LinearLayout {
@@ -96,6 +98,7 @@ public class ZenModePanel extends LinearLayout {
private View mZenIntroductionConfirm;
private View mZenIntroductionCustomize;
private LinearLayout mZenConditions;
+ private TextView mZenAlarmWarning;
private Callback mCallback;
private ZenModeController mController;
@@ -176,6 +179,7 @@ public class ZenModePanel extends LinearLayout {
});
mZenConditions = (LinearLayout) findViewById(R.id.zen_conditions);
+ mZenAlarmWarning = (TextView) findViewById(R.id.zen_alarm_warning);
}
@Override
@@ -436,6 +440,40 @@ public class ZenModePanel extends LinearLayout {
: R.string.zen_silence_introduction);
mZenIntroductionCustomize.setVisibility(zenImportant ? VISIBLE : GONE);
}
+ final String warning = computeAlarmWarningText(zenNone);
+ mZenAlarmWarning.setVisibility(warning != null ? VISIBLE : GONE);
+ mZenAlarmWarning.setText(warning);
+ }
+
+ private String computeAlarmWarningText(boolean zenNone) {
+ if (!zenNone) {
+ return null;
+ }
+ final long now = System.currentTimeMillis();
+ final long nextAlarm = mController.getNextAlarm();
+ if (nextAlarm < now) {
+ return null;
+ }
+ int warningRes = 0;
+ if (mSessionExitCondition == null || isForever(mSessionExitCondition)) {
+ warningRes = R.string.zen_alarm_warning_indef;
+ } else {
+ final long time = ZenModeConfig.tryParseCountdownConditionId(mSessionExitCondition.id);
+ if (time > now && nextAlarm < time) {
+ warningRes = R.string.zen_alarm_warning;
+ }
+ }
+ if (warningRes == 0) {
+ return null;
+ }
+ final boolean soon = (nextAlarm - now) < 24 * 60 * 60 * 1000;
+ final boolean is24 = DateFormat.is24HourFormat(mContext, ActivityManager.getCurrentUser());
+ final String skeleton = soon ? (is24 ? "Hm" : "hma") : (is24 ? "EEEHm" : "EEEhma");
+ final String pattern = DateFormat.getBestDateTimePattern(Locale.getDefault(), skeleton);
+ final CharSequence formattedTime = DateFormat.format(pattern, nextAlarm);
+ final int templateRes = soon ? R.string.alarm_template : R.string.alarm_template_far;
+ final String template = getResources().getString(templateRes, formattedTime);
+ return getResources().getString(warningRes, template);
}
private static Condition parseExistingTimeCondition(Context context, Condition condition) {