diff options
author | John Spurlock <jspurlock@google.com> | 2015-05-13 15:42:04 -0400 |
---|---|---|
committer | John Spurlock <jspurlock@google.com> | 2015-05-13 15:45:40 -0400 |
commit | bbde26774fcf7ea65abd92d60f7468478c015053 (patch) | |
tree | b7e7b3ea1f4a91d681cea75f7b92a16fc7ff17b7 | |
parent | a7d92b19c048fe2b3115073286103e9194a915d6 (diff) | |
download | frameworks_base-bbde26774fcf7ea65abd92d60f7468478c015053.zip frameworks_base-bbde26774fcf7ea65abd92d60f7468478c015053.tar.gz frameworks_base-bbde26774fcf7ea65abd92d60f7468478c015053.tar.bz2 |
Zen: Use shorter version of countdown condition summary in footer.
To try and keep to two-lines.
Bug: 21119801
Change-Id: I5a6760381a6b673b8481164f92cf6b7b236af349
5 files changed, 55 insertions, 15 deletions
diff --git a/core/java/android/service/notification/ZenModeConfig.java b/core/java/android/service/notification/ZenModeConfig.java index 599ac74..1e42913 100644 --- a/core/java/android/service/notification/ZenModeConfig.java +++ b/core/java/android/service/notification/ZenModeConfig.java @@ -573,24 +573,34 @@ public class ZenModeConfig implements Parcelable { } public static Condition toTimeCondition(Context context, int minutesFromNow, int userHandle) { + return toTimeCondition(context, minutesFromNow, userHandle, false /*shortVersion*/); + } + + public static Condition toTimeCondition(Context context, int minutesFromNow, int userHandle, + boolean shortVersion) { final long now = System.currentTimeMillis(); final long millis = minutesFromNow == 0 ? ZERO_VALUE_MS : minutesFromNow * MINUTES_MS; - return toTimeCondition(context, now + millis, minutesFromNow, now, userHandle); + return toTimeCondition(context, now + millis, minutesFromNow, now, userHandle, + shortVersion); } public static Condition toTimeCondition(Context context, long time, int minutes, long now, - int userHandle) { + int userHandle, boolean shortVersion) { final int num, summaryResId, line1ResId; if (minutes < 60) { // display as minutes num = minutes; - summaryResId = R.plurals.zen_mode_duration_minutes_summary; - line1ResId = R.plurals.zen_mode_duration_minutes; + summaryResId = shortVersion ? R.plurals.zen_mode_duration_minutes_summary_short + : R.plurals.zen_mode_duration_minutes_summary; + line1ResId = shortVersion ? R.plurals.zen_mode_duration_minutes_short + : R.plurals.zen_mode_duration_minutes; } else { // display as hours num = Math.round(minutes / 60f); - summaryResId = com.android.internal.R.plurals.zen_mode_duration_hours_summary; - line1ResId = com.android.internal.R.plurals.zen_mode_duration_hours; + summaryResId = shortVersion ? R.plurals.zen_mode_duration_hours_summary_short + : R.plurals.zen_mode_duration_hours_summary; + line1ResId = shortVersion ? R.plurals.zen_mode_duration_hours_short + : R.plurals.zen_mode_duration_hours; } final String skeleton = DateFormat.is24HourFormat(context, userHandle) ? "Hm" : "hma"; final String pattern = DateFormat.getBestDateTimePattern(Locale.getDefault(), skeleton); @@ -793,17 +803,17 @@ public class ZenModeConfig implements Parcelable { } public static String getConditionLine1(Context context, ZenModeConfig config, - int userHandle) { - return getConditionLine(context, config, userHandle, true /*useLine1*/); + int userHandle, boolean shortVersion) { + return getConditionLine(context, config, userHandle, true /*useLine1*/, shortVersion); } public static String getConditionSummary(Context context, ZenModeConfig config, - int userHandle) { - return getConditionLine(context, config, userHandle, false /*useLine1*/); + int userHandle, boolean shortVersion) { + return getConditionLine(context, config, userHandle, false /*useLine1*/, shortVersion); } private static String getConditionLine(Context context, ZenModeConfig config, - int userHandle, boolean useLine1) { + int userHandle, boolean useLine1, boolean shortVersion) { if (config == null) return ""; if (config.manualRule != null) { final Uri id = config.manualRule.conditionId; @@ -816,7 +826,7 @@ public class ZenModeConfig implements Parcelable { final long now = System.currentTimeMillis(); final long span = time - now; c = toTimeCondition(context, - time, Math.round(span / (float) MINUTES_MS), now, userHandle); + time, Math.round(span / (float) MINUTES_MS), now, userHandle, shortVersion); } final String rt = c == null ? "" : useLine1 ? c.line1 : c.summary; return TextUtils.isEmpty(rt) ? "" : rt; diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml index 5b564e1..47ff16b 100644 --- a/core/res/res/values/strings.xml +++ b/core/res/res/values/strings.xml @@ -4031,24 +4031,48 @@ <item quantity="other">For %1$d minutes (until <xliff:g id="formattedTime" example="10:00 PM">%2$s</xliff:g>)</item> </plurals> + <!-- Zen mode condition - summary: time duration in minutes (short version). [CHAR LIMIT=NONE] --> + <plurals name="zen_mode_duration_minutes_summary_short"> + <item quantity="one">For 1 min (until <xliff:g id="formattedTime" example="10:00 PM">%2$s</xliff:g>)</item> + <item quantity="other">For %1$d min (until <xliff:g id="formattedTime" example="10:00 PM">%2$s</xliff:g>)</item> + </plurals> + <!-- Zen mode condition - summary: time duration in hours. [CHAR LIMIT=NONE] --> <plurals name="zen_mode_duration_hours_summary"> <item quantity="one">For one hour (until <xliff:g id="formattedTime" example="10:00 PM">%2$s</xliff:g>)</item> <item quantity="other">For %1$d hours (until <xliff:g id="formattedTime" example="10:00 PM">%2$s</xliff:g>)</item> </plurals> + <!-- Zen mode condition - summary: time duration in hours (short version). [CHAR LIMIT=NONE] --> + <plurals name="zen_mode_duration_hours_summary_short"> + <item quantity="one">For 1 hr (until <xliff:g id="formattedTime" example="10:00 PM">%2$s</xliff:g>)</item> + <item quantity="other">For %1$d hr (until <xliff:g id="formattedTime" example="10:00 PM">%2$s</xliff:g>)</item> + </plurals> + <!-- Zen mode condition - line one: time duration in minutes. [CHAR LIMIT=NONE] --> <plurals name="zen_mode_duration_minutes"> <item quantity="one">For one minute</item> <item quantity="other">For %d minutes</item> </plurals> + <!-- Zen mode condition - line one: time duration in minutes (short version). [CHAR LIMIT=NONE] --> + <plurals name="zen_mode_duration_minutes_short"> + <item quantity="one">For 1 min</item> + <item quantity="other">For %d min</item> + </plurals> + <!-- Zen mode condition - line one: time duration in hours. [CHAR LIMIT=NONE] --> <plurals name="zen_mode_duration_hours"> <item quantity="one">For one hour</item> <item quantity="other">For %d hours</item> </plurals> + <!-- Zen mode condition - line one: time duration in hours (short version). [CHAR LIMIT=NONE] --> + <plurals name="zen_mode_duration_hours_short"> + <item quantity="one">For 1 hr</item> + <item quantity="other">For %d hr</item> + </plurals> + <!-- Zen mode condition - line two: ending time. [CHAR LIMIT=NONE] --> <string name="zen_mode_until">Until <xliff:g id="formattedTime" example="10:00 PM">%1$s</xliff:g></string> diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index 8f949e1..5faa869 100755 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -2060,6 +2060,10 @@ <java-symbol type="plurals" name="zen_mode_duration_hours" /> <java-symbol type="plurals" name="zen_mode_duration_minutes_summary" /> <java-symbol type="plurals" name="zen_mode_duration_hours_summary" /> + <java-symbol type="plurals" name="zen_mode_duration_minutes_short" /> + <java-symbol type="plurals" name="zen_mode_duration_hours_short" /> + <java-symbol type="plurals" name="zen_mode_duration_minutes_summary_short" /> + <java-symbol type="plurals" name="zen_mode_duration_hours_summary_short" /> <java-symbol type="string" name="zen_mode_until" /> <java-symbol type="string" name="zen_mode_feature_name" /> <java-symbol type="string" name="zen_mode_downtime_feature_name" /> diff --git a/packages/SystemUI/src/com/android/systemui/volume/ZenFooter.java b/packages/SystemUI/src/com/android/systemui/volume/ZenFooter.java index 66c4993..6d67d11 100644 --- a/packages/SystemUI/src/com/android/systemui/volume/ZenFooter.java +++ b/packages/SystemUI/src/com/android/systemui/volume/ZenFooter.java @@ -127,7 +127,7 @@ public class ZenFooter extends LinearLayout { Util.setText(mSummaryLine1, line1); final String line2 = ZenModeConfig.getConditionSummary(mContext, mConfig, - mController.getCurrentUser()); + mController.getCurrentUser(), true /*shortVersion*/); Util.setText(mSummaryLine2, line2); } diff --git a/packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java b/packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java index b3b6725..8dfa9b0 100644 --- a/packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java +++ b/packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java @@ -438,7 +438,8 @@ public class ZenModePanel extends LinearLayout { final long span = time - now; if (span <= 0 || span > MAX_BUCKET_MINUTES * MINUTES_MS) return null; return ZenModeConfig.toTimeCondition(context, - time, Math.round(span / (float) MINUTES_MS), now, ActivityManager.getCurrentUser()); + time, Math.round(span / (float) MINUTES_MS), now, ActivityManager.getCurrentUser(), + false /*shortVersion*/); } private void handleUpdateConditions(Condition[] conditions) { @@ -717,7 +718,8 @@ public class ZenModePanel extends LinearLayout { if (up && bucketTime > time || !up && bucketTime < time) { mBucketIndex = j; newCondition = ZenModeConfig.toTimeCondition(mContext, - bucketTime, bucketMinutes, now, ActivityManager.getCurrentUser()); + bucketTime, bucketMinutes, now, ActivityManager.getCurrentUser(), + false /*shortVersion*/); break; } } |