Loading core/java/android/service/notification/ZenModeConfig.java +28 −9 Original line number Diff line number Diff line Loading @@ -17,11 +17,13 @@ package android.service.notification; import android.content.ComponentName; import android.content.Context; import android.content.res.Resources; import android.net.Uri; import android.os.Parcel; import android.os.Parcelable; import android.text.TextUtils; import android.text.format.DateFormat; import android.util.Slog; import org.xmlpull.v1.XmlPullParser; Loading @@ -32,8 +34,11 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.Calendar; import java.util.Locale; import java.util.Objects; import com.android.internal.R; /** * Persisted configuration for zen mode. * Loading Loading @@ -461,20 +466,34 @@ public class ZenModeConfig implements Parcelable { return downtime; } public static Condition toTimeCondition(int minutesFromNow) { public static Condition toTimeCondition(Context context, int minutesFromNow) { final long now = System.currentTimeMillis(); final long millis = minutesFromNow == 0 ? ZERO_VALUE_MS : minutesFromNow * MINUTES_MS; return toTimeCondition(now + millis, minutesFromNow); return toTimeCondition(context, now + millis, minutesFromNow, now); } public static Condition toTimeCondition(long time, int minutes) { final int num = minutes < 60 ? minutes : Math.round(minutes / 60f); final int resId = minutes < 60 ? com.android.internal.R.plurals.zen_mode_duration_minutes : com.android.internal.R.plurals.zen_mode_duration_hours; final String caption = Resources.getSystem().getQuantityString(resId, num, num); public static Condition toTimeCondition(Context context, long time, int minutes, long now) { 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; } 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; } final String skeleton = DateFormat.is24HourFormat(context) ? "Hm" : "hma"; final String pattern = DateFormat.getBestDateTimePattern(Locale.getDefault(), skeleton); final CharSequence formattedTime = DateFormat.format(pattern, time); final Resources res = context.getResources(); final String summary = res.getQuantityString(summaryResId, num, num, formattedTime); final String line1 = res.getQuantityString(line1ResId, num, num, formattedTime); final String line2 = res.getString(R.string.zen_mode_until, formattedTime); final Uri id = toCountdownConditionId(time); return new Condition(id, caption, "", "", 0, Condition.STATE_TRUE, return new Condition(id, summary, line1, line2, 0, Condition.STATE_TRUE, Condition.FLAG_RELEVANT_NOW); } Loading core/res/res/values/strings.xml +17 −2 Original line number Diff line number Diff line Loading @@ -4865,18 +4865,33 @@ <!-- [CHAR_LIMIT=NONE] Zen mode: Condition summary for built-in downtime condition, if active --> <string name="downtime_condition_summary">Until your downtime ends at <xliff:g id="formattedTime" example="10.00 PM">%1$s</xliff:g></string> <!-- Zen mode condition: time duration in minutes. [CHAR LIMIT=NONE] --> <!-- Zen mode condition - summary: time duration in minutes. [CHAR LIMIT=NONE] --> <plurals name="zen_mode_duration_minutes_summary"> <item quantity="one">For one minute (until <xliff:g id="formattedTime" example="10:00 PM">%1$s</xliff:g>)</item> <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 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">%1$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 - 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: time duration in hours. [CHAR LIMIT=NONE] --> <!-- 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 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> <!-- Zen mode condition: no exit criteria. [CHAR LIMIT=NONE] --> <string name="zen_mode_forever">Indefinitely</string> </resources> core/res/res/values/symbols.xml +3 −0 Original line number Diff line number Diff line Loading @@ -1984,6 +1984,9 @@ <java-symbol type="string" name="zen_mode_forever" /> <java-symbol type="plurals" name="zen_mode_duration_minutes" /> <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="string" name="zen_mode_until" /> <java-symbol type="string" name="item_is_selected" /> <java-symbol type="string" name="day_of_week_label_typeface" /> Loading packages/SystemUI/res/layout/zen_mode_condition.xml +26 −8 Original line number Diff line number Diff line Loading @@ -29,17 +29,35 @@ android:layout_alignParentStart="true" android:gravity="center" /> <TextView android:id="@android:id/title" <LinearLayout android:id="@android:id/content" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_height="wrap_content" android:layout_centerVertical="true" android:orientation="vertical" android:layout_toEndOf="@android:id/checkbox" android:layout_toStartOf="@android:id/button1" android:layout_toStartOf="@android:id/button1"> <TextView android:id="@android:id/text1" android:layout_width="match_parent" android:layout_height="wrap_content" android:ellipsize="end" android:gravity="center_vertical" android:textAlignment="viewStart" android:maxLines="1" android:textAppearance="@style/TextAppearance.QS.DetailItemPrimary" /> <TextView android:id="@android:id/text2" android:layout_width="match_parent" android:layout_height="wrap_content" android:ellipsize="end" android:textAlignment="viewStart" android:maxLines="1" android:textAppearance="@style/TextAppearance.QS.DetailItemSecondary" /> </LinearLayout> <ImageView android:id="@android:id/button1" style="@style/QSBorderlessButton" Loading packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java +44 −18 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import android.provider.Settings; import android.provider.Settings.Global; import android.service.notification.Condition; import android.service.notification.ZenModeConfig; import android.text.TextUtils; import android.util.AttributeSet; import android.util.Log; import android.util.MathUtils; Loading Loading @@ -220,7 +221,8 @@ public class ZenModePanel extends LinearLayout { mBucketIndex = -1; } else { mBucketIndex = DEFAULT_BUCKET_INDEX; mTimeCondition = ZenModeConfig.toTimeCondition(MINUTE_BUCKETS[mBucketIndex]); mTimeCondition = ZenModeConfig.toTimeCondition(mContext, MINUTE_BUCKETS[mBucketIndex]); } if (DEBUG) Log.d(mTag, "Initial bucket index: " + mBucketIndex); mConditions = null; // reset conditions Loading Loading @@ -339,9 +341,11 @@ public class ZenModePanel extends LinearLayout { if (condition == null) return null; final long time = ZenModeConfig.tryParseCountdownConditionId(condition.id); if (time == 0) return null; final long span = time - System.currentTimeMillis(); final long now = System.currentTimeMillis(); final long span = time - now; if (span <= 0 || span > MAX_BUCKET_MINUTES * MINUTES_MS) return null; return ZenModeConfig.toTimeCondition(time, Math.round(span / (float) MINUTES_MS)); return ZenModeConfig.toTimeCondition(mContext, time, Math.round(span / (float) MINUTES_MS), now); } private void handleUpdateConditions(Condition[] conditions) { Loading Loading @@ -395,7 +399,7 @@ public class ZenModePanel extends LinearLayout { if (favoriteIndex == -1) { getConditionTagAt(FOREVER_CONDITION_INDEX).rb.setChecked(true); } else { mTimeCondition = ZenModeConfig.toTimeCondition(MINUTE_BUCKETS[favoriteIndex]); mTimeCondition = ZenModeConfig.toTimeCondition(mContext, MINUTE_BUCKETS[favoriteIndex]); mBucketIndex = favoriteIndex; bind(mTimeCondition, mZenConditions.getChildAt(TIME_CONDITION_INDEX)); getConditionTagAt(TIME_CONDITION_INDEX).rb.setChecked(true); Loading Loading @@ -451,16 +455,32 @@ public class ZenModePanel extends LinearLayout { } }); if (tag.title == null) { tag.title = (TextView) row.findViewById(android.R.id.title); if (tag.lines == null) { tag.lines = row.findViewById(android.R.id.content); } if (tag.line1 == null) { tag.line1 = (TextView) row.findViewById(android.R.id.text1); } if (tag.line2 == null) { tag.line2 = (TextView) row.findViewById(android.R.id.text2); } final String line1, line2; if (condition == null) { tag.title.setText(mContext.getString(com.android.internal.R.string.zen_mode_forever)); line1 = mContext.getString(com.android.internal.R.string.zen_mode_forever); line2 = null; } else { line1 = !TextUtils.isEmpty(condition.line1) ? condition.line1 : condition.summary; line2 = condition.line2; } tag.line1.setText(line1); if (TextUtils.isEmpty(line2)) { tag.line2.setVisibility(GONE); } else { tag.title.setText(condition.summary); tag.line2.setVisibility(VISIBLE); tag.line2.setText(line2); } tag.title.setEnabled(enabled); tag.title.setAlpha(enabled ? 1 : .4f); tag.lines.setEnabled(enabled); tag.lines.setAlpha(enabled ? 1 : .4f); final ImageView button1 = (ImageView) row.findViewById(android.R.id.button1); button1.setOnClickListener(new OnClickListener() { Loading @@ -477,7 +497,7 @@ public class ZenModePanel extends LinearLayout { onClickTimeButton(row, tag, true /*up*/); } }); tag.title.setOnClickListener(new OnClickListener() { tag.lines.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { tag.rb.setChecked(true); Loading @@ -492,7 +512,8 @@ public class ZenModePanel extends LinearLayout { } else { final long span = time - System.currentTimeMillis(); button1.setEnabled(span > MIN_BUCKET_MINUTES * MINUTES_MS); final Condition maxCondition = ZenModeConfig.toTimeCondition(MAX_BUCKET_MINUTES); final Condition maxCondition = ZenModeConfig.toTimeCondition(mContext, MAX_BUCKET_MINUTES); button2.setEnabled(!Objects.equals(condition.summary, maxCondition.summary)); } Loading @@ -505,7 +526,7 @@ public class ZenModePanel extends LinearLayout { // wire up interaction callbacks for newly-added condition rows if (convertView == null) { Interaction.register(tag.rb, mInteractionCallback); Interaction.register(tag.title, mInteractionCallback); Interaction.register(tag.lines, mInteractionCallback); Interaction.register(button1, mInteractionCallback); Interaction.register(button2, mInteractionCallback); } Loading @@ -525,7 +546,7 @@ public class ZenModePanel extends LinearLayout { return; } announceForAccessibility(mContext.getString(R.string.zen_mode_and_condition, modeText, tag.title.getText())); tag.line1.getText())); } private void onClickTimeButton(View row, ConditionTag tag, boolean up) { Loading @@ -542,18 +563,21 @@ public class ZenModePanel extends LinearLayout { final long bucketTime = now + bucketMinutes * MINUTES_MS; if (up && bucketTime > time || !up && bucketTime < time) { mBucketIndex = j; newCondition = ZenModeConfig.toTimeCondition(bucketTime, bucketMinutes); newCondition = ZenModeConfig.toTimeCondition(mContext, bucketTime, bucketMinutes, now); break; } } if (newCondition == null) { mBucketIndex = DEFAULT_BUCKET_INDEX; newCondition = ZenModeConfig.toTimeCondition(MINUTE_BUCKETS[mBucketIndex]); newCondition = ZenModeConfig.toTimeCondition(mContext, MINUTE_BUCKETS[mBucketIndex]); } } else { // on a known index, simply increment or decrement mBucketIndex = Math.max(0, Math.min(N - 1, mBucketIndex + (up ? 1 : -1))); newCondition = ZenModeConfig.toTimeCondition(MINUTE_BUCKETS[mBucketIndex]); newCondition = ZenModeConfig.toTimeCondition(mContext, MINUTE_BUCKETS[mBucketIndex]); } mTimeCondition = newCondition; bind(mTimeCondition, row); Loading Loading @@ -640,7 +664,9 @@ public class ZenModePanel extends LinearLayout { // used as the view tag on condition rows private static class ConditionTag { RadioButton rb; TextView title; View lines; TextView line1; TextView line2; Condition condition; } Loading Loading
core/java/android/service/notification/ZenModeConfig.java +28 −9 Original line number Diff line number Diff line Loading @@ -17,11 +17,13 @@ package android.service.notification; import android.content.ComponentName; import android.content.Context; import android.content.res.Resources; import android.net.Uri; import android.os.Parcel; import android.os.Parcelable; import android.text.TextUtils; import android.text.format.DateFormat; import android.util.Slog; import org.xmlpull.v1.XmlPullParser; Loading @@ -32,8 +34,11 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.Calendar; import java.util.Locale; import java.util.Objects; import com.android.internal.R; /** * Persisted configuration for zen mode. * Loading Loading @@ -461,20 +466,34 @@ public class ZenModeConfig implements Parcelable { return downtime; } public static Condition toTimeCondition(int minutesFromNow) { public static Condition toTimeCondition(Context context, int minutesFromNow) { final long now = System.currentTimeMillis(); final long millis = minutesFromNow == 0 ? ZERO_VALUE_MS : minutesFromNow * MINUTES_MS; return toTimeCondition(now + millis, minutesFromNow); return toTimeCondition(context, now + millis, minutesFromNow, now); } public static Condition toTimeCondition(long time, int minutes) { final int num = minutes < 60 ? minutes : Math.round(minutes / 60f); final int resId = minutes < 60 ? com.android.internal.R.plurals.zen_mode_duration_minutes : com.android.internal.R.plurals.zen_mode_duration_hours; final String caption = Resources.getSystem().getQuantityString(resId, num, num); public static Condition toTimeCondition(Context context, long time, int minutes, long now) { 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; } 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; } final String skeleton = DateFormat.is24HourFormat(context) ? "Hm" : "hma"; final String pattern = DateFormat.getBestDateTimePattern(Locale.getDefault(), skeleton); final CharSequence formattedTime = DateFormat.format(pattern, time); final Resources res = context.getResources(); final String summary = res.getQuantityString(summaryResId, num, num, formattedTime); final String line1 = res.getQuantityString(line1ResId, num, num, formattedTime); final String line2 = res.getString(R.string.zen_mode_until, formattedTime); final Uri id = toCountdownConditionId(time); return new Condition(id, caption, "", "", 0, Condition.STATE_TRUE, return new Condition(id, summary, line1, line2, 0, Condition.STATE_TRUE, Condition.FLAG_RELEVANT_NOW); } Loading
core/res/res/values/strings.xml +17 −2 Original line number Diff line number Diff line Loading @@ -4865,18 +4865,33 @@ <!-- [CHAR_LIMIT=NONE] Zen mode: Condition summary for built-in downtime condition, if active --> <string name="downtime_condition_summary">Until your downtime ends at <xliff:g id="formattedTime" example="10.00 PM">%1$s</xliff:g></string> <!-- Zen mode condition: time duration in minutes. [CHAR LIMIT=NONE] --> <!-- Zen mode condition - summary: time duration in minutes. [CHAR LIMIT=NONE] --> <plurals name="zen_mode_duration_minutes_summary"> <item quantity="one">For one minute (until <xliff:g id="formattedTime" example="10:00 PM">%1$s</xliff:g>)</item> <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 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">%1$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 - 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: time duration in hours. [CHAR LIMIT=NONE] --> <!-- 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 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> <!-- Zen mode condition: no exit criteria. [CHAR LIMIT=NONE] --> <string name="zen_mode_forever">Indefinitely</string> </resources>
core/res/res/values/symbols.xml +3 −0 Original line number Diff line number Diff line Loading @@ -1984,6 +1984,9 @@ <java-symbol type="string" name="zen_mode_forever" /> <java-symbol type="plurals" name="zen_mode_duration_minutes" /> <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="string" name="zen_mode_until" /> <java-symbol type="string" name="item_is_selected" /> <java-symbol type="string" name="day_of_week_label_typeface" /> Loading
packages/SystemUI/res/layout/zen_mode_condition.xml +26 −8 Original line number Diff line number Diff line Loading @@ -29,17 +29,35 @@ android:layout_alignParentStart="true" android:gravity="center" /> <TextView android:id="@android:id/title" <LinearLayout android:id="@android:id/content" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_height="wrap_content" android:layout_centerVertical="true" android:orientation="vertical" android:layout_toEndOf="@android:id/checkbox" android:layout_toStartOf="@android:id/button1" android:layout_toStartOf="@android:id/button1"> <TextView android:id="@android:id/text1" android:layout_width="match_parent" android:layout_height="wrap_content" android:ellipsize="end" android:gravity="center_vertical" android:textAlignment="viewStart" android:maxLines="1" android:textAppearance="@style/TextAppearance.QS.DetailItemPrimary" /> <TextView android:id="@android:id/text2" android:layout_width="match_parent" android:layout_height="wrap_content" android:ellipsize="end" android:textAlignment="viewStart" android:maxLines="1" android:textAppearance="@style/TextAppearance.QS.DetailItemSecondary" /> </LinearLayout> <ImageView android:id="@android:id/button1" style="@style/QSBorderlessButton" Loading
packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java +44 −18 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import android.provider.Settings; import android.provider.Settings.Global; import android.service.notification.Condition; import android.service.notification.ZenModeConfig; import android.text.TextUtils; import android.util.AttributeSet; import android.util.Log; import android.util.MathUtils; Loading Loading @@ -220,7 +221,8 @@ public class ZenModePanel extends LinearLayout { mBucketIndex = -1; } else { mBucketIndex = DEFAULT_BUCKET_INDEX; mTimeCondition = ZenModeConfig.toTimeCondition(MINUTE_BUCKETS[mBucketIndex]); mTimeCondition = ZenModeConfig.toTimeCondition(mContext, MINUTE_BUCKETS[mBucketIndex]); } if (DEBUG) Log.d(mTag, "Initial bucket index: " + mBucketIndex); mConditions = null; // reset conditions Loading Loading @@ -339,9 +341,11 @@ public class ZenModePanel extends LinearLayout { if (condition == null) return null; final long time = ZenModeConfig.tryParseCountdownConditionId(condition.id); if (time == 0) return null; final long span = time - System.currentTimeMillis(); final long now = System.currentTimeMillis(); final long span = time - now; if (span <= 0 || span > MAX_BUCKET_MINUTES * MINUTES_MS) return null; return ZenModeConfig.toTimeCondition(time, Math.round(span / (float) MINUTES_MS)); return ZenModeConfig.toTimeCondition(mContext, time, Math.round(span / (float) MINUTES_MS), now); } private void handleUpdateConditions(Condition[] conditions) { Loading Loading @@ -395,7 +399,7 @@ public class ZenModePanel extends LinearLayout { if (favoriteIndex == -1) { getConditionTagAt(FOREVER_CONDITION_INDEX).rb.setChecked(true); } else { mTimeCondition = ZenModeConfig.toTimeCondition(MINUTE_BUCKETS[favoriteIndex]); mTimeCondition = ZenModeConfig.toTimeCondition(mContext, MINUTE_BUCKETS[favoriteIndex]); mBucketIndex = favoriteIndex; bind(mTimeCondition, mZenConditions.getChildAt(TIME_CONDITION_INDEX)); getConditionTagAt(TIME_CONDITION_INDEX).rb.setChecked(true); Loading Loading @@ -451,16 +455,32 @@ public class ZenModePanel extends LinearLayout { } }); if (tag.title == null) { tag.title = (TextView) row.findViewById(android.R.id.title); if (tag.lines == null) { tag.lines = row.findViewById(android.R.id.content); } if (tag.line1 == null) { tag.line1 = (TextView) row.findViewById(android.R.id.text1); } if (tag.line2 == null) { tag.line2 = (TextView) row.findViewById(android.R.id.text2); } final String line1, line2; if (condition == null) { tag.title.setText(mContext.getString(com.android.internal.R.string.zen_mode_forever)); line1 = mContext.getString(com.android.internal.R.string.zen_mode_forever); line2 = null; } else { line1 = !TextUtils.isEmpty(condition.line1) ? condition.line1 : condition.summary; line2 = condition.line2; } tag.line1.setText(line1); if (TextUtils.isEmpty(line2)) { tag.line2.setVisibility(GONE); } else { tag.title.setText(condition.summary); tag.line2.setVisibility(VISIBLE); tag.line2.setText(line2); } tag.title.setEnabled(enabled); tag.title.setAlpha(enabled ? 1 : .4f); tag.lines.setEnabled(enabled); tag.lines.setAlpha(enabled ? 1 : .4f); final ImageView button1 = (ImageView) row.findViewById(android.R.id.button1); button1.setOnClickListener(new OnClickListener() { Loading @@ -477,7 +497,7 @@ public class ZenModePanel extends LinearLayout { onClickTimeButton(row, tag, true /*up*/); } }); tag.title.setOnClickListener(new OnClickListener() { tag.lines.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { tag.rb.setChecked(true); Loading @@ -492,7 +512,8 @@ public class ZenModePanel extends LinearLayout { } else { final long span = time - System.currentTimeMillis(); button1.setEnabled(span > MIN_BUCKET_MINUTES * MINUTES_MS); final Condition maxCondition = ZenModeConfig.toTimeCondition(MAX_BUCKET_MINUTES); final Condition maxCondition = ZenModeConfig.toTimeCondition(mContext, MAX_BUCKET_MINUTES); button2.setEnabled(!Objects.equals(condition.summary, maxCondition.summary)); } Loading @@ -505,7 +526,7 @@ public class ZenModePanel extends LinearLayout { // wire up interaction callbacks for newly-added condition rows if (convertView == null) { Interaction.register(tag.rb, mInteractionCallback); Interaction.register(tag.title, mInteractionCallback); Interaction.register(tag.lines, mInteractionCallback); Interaction.register(button1, mInteractionCallback); Interaction.register(button2, mInteractionCallback); } Loading @@ -525,7 +546,7 @@ public class ZenModePanel extends LinearLayout { return; } announceForAccessibility(mContext.getString(R.string.zen_mode_and_condition, modeText, tag.title.getText())); tag.line1.getText())); } private void onClickTimeButton(View row, ConditionTag tag, boolean up) { Loading @@ -542,18 +563,21 @@ public class ZenModePanel extends LinearLayout { final long bucketTime = now + bucketMinutes * MINUTES_MS; if (up && bucketTime > time || !up && bucketTime < time) { mBucketIndex = j; newCondition = ZenModeConfig.toTimeCondition(bucketTime, bucketMinutes); newCondition = ZenModeConfig.toTimeCondition(mContext, bucketTime, bucketMinutes, now); break; } } if (newCondition == null) { mBucketIndex = DEFAULT_BUCKET_INDEX; newCondition = ZenModeConfig.toTimeCondition(MINUTE_BUCKETS[mBucketIndex]); newCondition = ZenModeConfig.toTimeCondition(mContext, MINUTE_BUCKETS[mBucketIndex]); } } else { // on a known index, simply increment or decrement mBucketIndex = Math.max(0, Math.min(N - 1, mBucketIndex + (up ? 1 : -1))); newCondition = ZenModeConfig.toTimeCondition(MINUTE_BUCKETS[mBucketIndex]); newCondition = ZenModeConfig.toTimeCondition(mContext, MINUTE_BUCKETS[mBucketIndex]); } mTimeCondition = newCondition; bind(mTimeCondition, row); Loading Loading @@ -640,7 +664,9 @@ public class ZenModePanel extends LinearLayout { // used as the view tag on condition rows private static class ConditionTag { RadioButton rb; TextView title; View lines; TextView line1; TextView line2; Condition condition; } Loading