am 2d67b288: am 8dbcda1b: Merge "Volume: Simple dialog footer, DND in quick settings." into mnc-dev

* commit '2d67b2887c0a279aa182646f0e23b176783a1aca':
  Volume: Simple dialog footer, DND in quick settings.
This commit is contained in:
John Spurlock
2015-04-29 14:27:19 +00:00
committed by Android Git Automerger
32 changed files with 349 additions and 806 deletions

View File

@@ -62,7 +62,7 @@ public class ZenModeConfig implements Parcelable {
Calendar.WEDNESDAY, Calendar.THURSDAY };
public static final int[] WEEKEND_DAYS = { Calendar.FRIDAY, Calendar.SATURDAY };
public static final int[] MINUTE_BUCKETS = new int[] { 15, 30, 45, 60, 120, 180, 240, 480 };
public static final int[] MINUTE_BUCKETS = generateMinuteBuckets();
private static final int SECONDS_MS = 1000;
private static final int MINUTES_MS = 60 * SECONDS_MS;
private static final int ZERO_VALUE_MS = 10 * SECONDS_MS;
@@ -201,6 +201,18 @@ public class ZenModeConfig implements Parcelable {
}
}
private static int[] generateMinuteBuckets() {
final int maxHrs = 12;
final int[] buckets = new int[maxHrs + 3];
buckets[0] = 15;
buckets[1] = 30;
buckets[2] = 45;
for (int i = 1; i <= maxHrs; i++) {
buckets[2 + i] = 60 * i;
}
return buckets;
}
public static String sourceToString(int source) {
switch (source) {
case SOURCE_ANYONE:
@@ -298,10 +310,10 @@ public class ZenModeConfig implements Parcelable {
throw new IndexOutOfBoundsException("bad source in config:" + rt.allowFrom);
}
} else if (MANUAL_TAG.equals(tag)) {
rt.manualRule = readRuleXml(parser);
rt.manualRule = readRuleXml(parser, false /*conditionRequired*/);
} else if (AUTOMATIC_TAG.equals(tag)) {
final String id = parser.getAttributeValue(null, RULE_ATT_ID);
final ZenRule automaticRule = readRuleXml(parser);
final ZenRule automaticRule = readRuleXml(parser, true /*conditionRequired*/);
if (id != null && automaticRule != null) {
rt.automaticRules.put(id, automaticRule);
}
@@ -341,7 +353,7 @@ public class ZenModeConfig implements Parcelable {
out.endTag(null, ZEN_TAG);
}
public static ZenRule readRuleXml(XmlPullParser parser) {
public static ZenRule readRuleXml(XmlPullParser parser, boolean conditionRequired) {
final ZenRule rt = new ZenRule();
rt.enabled = safeBoolean(parser, RULE_ATT_ENABLED, true);
rt.snoozing = safeBoolean(parser, RULE_ATT_SNOOZING, false);
@@ -355,7 +367,7 @@ public class ZenModeConfig implements Parcelable {
rt.conditionId = safeUri(parser, RULE_ATT_CONDITION_ID);
rt.component = safeComponentName(parser, RULE_ATT_COMPONENT);
rt.condition = readConditionXml(parser);
return rt.condition != null ? rt : null;
return rt.condition != null || !conditionRequired ? rt : null;
}
public static void writeRuleXml(ZenRule rule, XmlSerializer out) throws IOException {

View File

@@ -51,5 +51,7 @@ public abstract class AudioManagerInternal {
/** Called when internal ringer mode is evaluated, returns the new external ringer mode */
int onSetRingerModeInternal(int ringerModeOld, int ringerModeNew, String caller,
int ringerModeExternal, VolumePolicy policy);
boolean canVolumeDownEnterSilent();
}
}

View File

@@ -18,7 +18,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/qs_detail_background"
android:paddingBottom="16dp"
android:paddingBottom="8dp"
android:orientation="vertical">
<FrameLayout
@@ -30,7 +30,7 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingEnd="16dp"
android:paddingEnd="8dp"
android:gravity="end">
<TextView

View File

@@ -19,10 +19,10 @@
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/segmented_button_spacing"
android:layout_weight="1"
android:paddingStart="8dp"
android:gravity="start|center_vertical"
android:gravity="center"
android:maxLines="2"
android:lineSpacingMultiplier="1.05026"
android:textColor="@color/segmented_button_text_selector"
android:background="@drawable/btn_borderless_rect"
android:textAppearance="@style/TextAppearance.Volume.ZenSwitchSummary"
android:minHeight="48dp" />
android:textAppearance="@style/TextAppearance.QS.SegmentedButton"
android:minHeight="64dp" />

View File

@@ -21,40 +21,31 @@
android:layout_marginBottom="4dp"
android:layout_marginLeft="@dimen/notification_side_padding"
android:layout_marginRight="@dimen/notification_side_padding"
android:layout_marginTop="4dp"
android:background="@drawable/volume_dialog_background"
android:translationZ="4dp" >
<com.android.keyguard.AlphaOptimizedImageButton
android:id="@+id/volume_expand_button"
style="@style/VolumeButtons"
android:layout_alignParentLeft="true"
android:layout_width="@dimen/volume_button_size"
android:layout_height="@dimen/volume_button_size"
android:layout_alignParentLeft="true"
android:clickable="true"
android:soundEffectsEnabled="false"
android:src="@drawable/ic_volume_collapse_animation" />
android:src="@drawable/ic_volume_collapse_animation"
tools:ignore="RtlHardcoded" />
<LinearLayout
android:id="@+id/volume_dialog_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="4dp"
android:paddingTop="6dp" >
android:paddingBottom="8dp"
android:paddingTop="8dp" >
<!-- volume rows added and removed here! :-) -->
<FrameLayout
android:id="@+id/volume_footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:ignore="UselessParent" >
<include layout="@layout/volume_text_footer" />
<include layout="@layout/volume_zen_footer" />
</FrameLayout>
<include layout="@layout/volume_zen_footer" />
</LinearLayout>
</RelativeLayout>

View File

@@ -16,16 +16,15 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="4dp"
android:paddingEnd="4dp"
android:clipChildren="false" >
android:clipChildren="false"
android:paddingEnd="8dp"
android:paddingStart="8dp" >
<TextView
android:id="@+id/volume_row_header"
style="?android:attr/textAppearanceButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:alpha="@dimen/volume_secondary_alpha"
android:ellipsize="end"
android:maxLines="1"
android:paddingBottom="0dp"
@@ -50,8 +49,8 @@
android:layout_below="@id/volume_row_header"
android:layout_toEndOf="@id/volume_row_icon"
android:layout_toStartOf="@+id/volume_settings_button"
android:paddingEnd="4dp"
android:paddingStart="4dp"
android:paddingEnd="8dp"
android:paddingStart="8dp"
android:progressTint="@android:color/white"
android:thumbTint="@android:color/white" />

View File

@@ -1,54 +0,0 @@
<!--
Copyright (C) 2015 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/volume_text_footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
tools:ignore="UselessParent" >
<TextView
android:id="@+id/volume_footline_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/volume_footline_action_button"
android:alpha="@dimen/volume_secondary_alpha"
android:fontFamily="sans-serif"
android:paddingEnd="8dp"
android:paddingStart="13dp"
android:textColor="?android:attr/textColorPrimary" />
<Button
android:id="@+id/volume_footline_action_button"
style="@android:style/Widget.Material.Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="@dimen/volume_button_size"
android:layout_toEndOf="@id/volume_footline_text"
android:layout_toStartOf="@+id/volume_settings_button"
android:alpha="@dimen/volume_secondary_alpha"
android:paddingEnd="0dp"
android:paddingStart="0dp" />
<com.android.keyguard.AlphaOptimizedImageButton
android:id="@+id/volume_settings_button"
style="@style/VolumeButtons"
android:layout_width="@dimen/volume_button_size"
android:layout_height="@dimen/volume_button_size"
android:layout_alignParentEnd="true"
android:src="@drawable/ic_volume_settings" />
</RelativeLayout>

View File

@@ -20,93 +20,58 @@
android:layout_height="wrap_content"
android:orientation="vertical" > <!-- extends LinearLayout -->
<LinearLayout
android:id="@+id/volume_zen_switch_bar"
<View
android:id="@+id/zen_embedded_divider"
android:layout_width="match_parent"
android:layout_height="@dimen/volume_button_size"
android:layout_marginStart="4dp"
android:layout_marginEnd="4dp"
android:clickable="true"
android:orientation="horizontal" >
android:layout_height="1dp"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:background="#4dffffff" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingEnd="8dp"
android:paddingStart="8dp" >
<ImageView
android:id="@+id/volume_zen_switch_bar_icon"
android:id="@+id/volume_zen_icon"
android:layout_width="@dimen/volume_button_size"
android:layout_height="@dimen/volume_button_size"
android:layout_marginEnd="7dp"
android:scaleType="center"
android:src="@drawable/ic_dnd" />
<TextView
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical"
android:textDirection="locale"
android:padding="3dp"
android:text="@string/volume_zen_switch_text"
android:textAppearance="@style/TextAppearance.Volume.ZenSwitch" />
android:orientation="vertical" >
<Switch
android:id="@+id/volume_zen_switch"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginEnd="11dp" />
<TextView
android:id="@+id/volume_zen_summary_line_1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.Volume.ZenSummary" />
</LinearLayout>
<RelativeLayout
android:id="@+id/volume_zen_panel_summary"
android:layout_width="match_parent"
android:layout_height="@dimen/volume_button_size"
android:layout_marginStart="@dimen/volume_button_size"
android:paddingEnd="7dp"
android:paddingStart="7dp" >
<TextView
android:id="@+id/volume_zen_summary_line_2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.Volume.ZenDetail" />
</LinearLayout>
<TextView
android:id="@+id/volume_zen_panel_summary_line_1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.Volume.ZenSwitchSummary" />
<TextView
android:id="@+id/volume_zen_panel_summary_line_2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/volume_zen_panel_summary_line_1"
android:textAppearance="@style/TextAppearance.Volume.ZenSwitchDetail" />
</RelativeLayout>
<include layout="@layout/zen_mode_panel" />
<LinearLayout
android:id="@+id/volume_zen_mode_panel_buttons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:layout_marginEnd="4dp"
android:gravity="end" >
<TextView
android:id="@+id/volume_zen_mode_panel_more"
style="@style/QSBorderlessButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:clickable="true"
android:focusable="true"
android:minWidth="132dp"
android:text="@string/quick_settings_more_settings"
android:textAppearance="@style/TextAppearance.QS.DetailButton" />
<TextView
android:id="@+id/volume_zen_mode_panel_done"
android:id="@+id/volume_zen_end_now"
style="@style/QSBorderlessButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true"
android:minWidth="66dp"
android:text="@string/quick_settings_done"
android:minWidth="91dp"
android:text="@string/volume_zen_end_now"
android:textAppearance="@style/TextAppearance.QS.DetailButton" />
</LinearLayout>

View File

@@ -22,80 +22,20 @@
android:clipChildren="false"
android:orientation="vertical" >
<FrameLayout
android:id="@+id/zen_buttons_container"
<com.android.systemui.volume.SegmentedButtons
android:id="@+id/zen_buttons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="8dp"
android:layout_marginStart="39dp"
android:elevation="4dp"
android:background="@drawable/qs_background_secondary" >
<com.android.systemui.volume.SegmentedButtons
android:id="@+id/zen_buttons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="8dp"
android:clipChildren="false" />
</FrameLayout>
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp" />
<View
android:id="@+id/zen_embedded_divider"
android:layout_width="match_parent"
android:layout_marginTop="8dp"
android:layout_height="1dp"
android:visibility="gone"
android:background="#4dffffff" />
<RelativeLayout
android:id="@+id/zen_subhead"
android:layout_width="match_parent"
android:layout_height="62dp"
android:layout_marginStart="39dp"
android:gravity="center_vertical"
android:paddingLeft="8dp"
android:paddingRight="8dp" >
<TextView
android:id="@+id/zen_subhead_collapsed"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:layout_gravity="center_vertical"
android:gravity="center_vertical"
android:paddingLeft="8dp"
android:paddingRight="4dp"
android:background="@drawable/btn_borderless_rect"
android:clickable="true"
android:drawableEnd="@drawable/qs_subhead_caret"
android:maxLines="2"
android:ellipsize="end"
android:textAppearance="@style/TextAppearance.QS.Subhead" />
<TextView
android:id="@+id/zen_subhead_expanded"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:layout_gravity="center_vertical"
android:gravity="center_vertical"
android:paddingLeft="8dp"
android:maxLines="2"
android:ellipsize="end"
android:textAppearance="@style/TextAppearance.QS.Subhead" />
<ImageView
android:id="@+id/zen_more_settings"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignParentEnd="true"
android:background="@drawable/btn_borderless_rect"
android:clickable="true"
android:contentDescription="@string/accessibility_desc_settings"
android:scaleType="center"
android:src="@drawable/ic_settings" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/zen_introduction"
android:layout_width="match_parent"
@@ -122,10 +62,9 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:layout_marginStart="55dp"
android:layout_marginStart="24dp"
android:lineSpacingMultiplier="1.20029"
android:layout_toStartOf="@id/zen_introduction_confirm"
android:text="@string/zen_priority_introduction"
android:textAppearance="@style/TextAppearance.QS.Introduction" />
<TextView
@@ -141,6 +80,12 @@
android:text="@string/zen_priority_customize_button"
android:textAppearance="@style/TextAppearance.QS.DetailButton.White" />
<View
android:layout_width="0dp"
android:layout_height="16dp"
android:layout_below="@id/zen_introduction_message"
android:layout_alignParentEnd="true" />
</RelativeLayout>
<LinearLayout
@@ -149,7 +94,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginEnd="4dp"
android:layout_marginStart="39dp"
android:layout_marginStart="4dp"
android:orientation="vertical"
android:paddingBottom="@dimen/zen_mode_condition_detail_bottom_padding" />

View File

@@ -128,7 +128,7 @@
<color name="screen_pinning_request_window_bg">#80000000</color>
<color name="segmented_button_selected">#FFFFFFFF</color>
<color name="segmented_button_unselected">#B3B0BEC5</color><!-- 70% blue grey 200 -->
<color name="segmented_button_unselected">#FFB0BEC5</color><!-- blue grey 200 -->
<color name="dark_mode_icon_color_single_tone">#99000000</color>
<color name="dark_mode_icon_color_dual_tone_background">#3d000000</color>
@@ -139,4 +139,6 @@
<color name="light_mode_icon_color_dual_tone_fill">#ffffff</color>
<color name="zen_introduction_message_background">#ff009688</color><!-- deep teal 500 -->
<color name="volume_icon_color">#ffffffff</color>
<color name="volume_settings_icon_color">#7fffffff</color>
</resources>

View File

@@ -293,5 +293,9 @@
<!-- Duration of the full carrier network change icon animation. -->
<integer name="carrier_network_change_anim_time">3000</integer>
<!-- Duration of the expansion animation in the volume dialog -->
<item name="volume_expand_animation_duration" type="integer">300</item>
</resources>

View File

@@ -573,4 +573,13 @@
<!-- Minimum margin of the notification panel on the side, when being positioned dynamically -->
<dimen name="notification_panel_min_side_margin">48dp</dimen>
<!-- Vertical spacing between multiple volume slider rows -->
<dimen name="volume_slider_interspacing">8dp</dimen>
<!-- Volume dialog vertical offset from the top of the screen -->
<dimen name="volume_offset_top">0dp</dimen>
<!-- Standard image button size for volume dialog buttons -->
<dimen name="volume_button_size">48dp</dimen>
</resources>

View File

@@ -439,7 +439,7 @@
<!-- Content description of the do not disturb tile in quick settings when on in priority (not shown on the screen). [CHAR LIMIT=NONE] -->
<string name="accessibility_quick_settings_dnd_priority_on">Do not disturb on, priority only.</string>
<!-- Content description of the do not disturb tile in quick settings when on in none (not shown on the screen). [CHAR LIMIT=NONE] -->
<string name="accessibility_quick_settings_dnd_none_on">Do not disturb on, no interruptions.</string>
<string name="accessibility_quick_settings_dnd_none_on">Do not disturb on, total silence.</string>
<!-- Content description of the do not disturb tile in quick settings when on in alarms only (not shown on the screen). [CHAR LIMIT=NONE] -->
<string name="accessibility_quick_settings_dnd_alarms_on">Do not disturb on, alarms only.</string>
<!-- Content description of the do not disturb tile in quick settings when off (not shown on the screen). [CHAR LIMIT=NONE] -->
@@ -576,8 +576,8 @@
<string name="quick_settings_dnd_priority_label">Priority only</string>
<!-- QuickSettings: Do not disturb - Alarms only [CHAR LIMIT=NONE] -->
<string name="quick_settings_dnd_alarms_label">Alarms only</string>
<!-- QuickSettings: Do not disturb - No interruptions [CHAR LIMIT=NONE] -->
<string name="quick_settings_dnd_none_label">No interruptions</string>
<!-- QuickSettings: Do not disturb - Total silence [CHAR LIMIT=NONE] -->
<string name="quick_settings_dnd_none_label">Total silence</string>
<!-- QuickSettings: Bluetooth [CHAR LIMIT=NONE] -->
<string name="quick_settings_bluetooth_label">Bluetooth</string>
<!-- QuickSettings: Bluetooth (Multiple) [CHAR LIMIT=NONE] -->
@@ -725,32 +725,14 @@
<!-- Description of the left direction in which one can to slide the handle in the Slide unlock screen. [CHAR LIMIT=NONE] -->
<string name="description_direction_left">"Slide left for <xliff:g id="target_description" example="Unlock">%s</xliff:g>.</string>
<!-- Zen mode: No interruptions title, with a warning about alarms. [CHAR LIMIT=60] -->
<string name="zen_no_interruptions_with_warning">No interruptions. Not even alarms.</string>
<!-- Zen mode: Priority only introduction message on first use -->
<string name="zen_priority_introduction">You won\'t be disturbed by sounds and vibrations, except from alarms, reminders, events, and callers you specify.</string>
<string name="zen_priority_introduction">You wont be disturbed by sounds and vibrations, except from alarms, reminders, events, and callers you specify.</string>
<!-- Zen mode: Priority only customization button label -->
<string name="zen_priority_customize_button">Customize</string>
<!-- Zen mode: No interruptions. [CHAR LIMIT=40] -->
<string name="zen_no_interruptions">No interruptions</string>
<!-- Zen mode: Only important interruptions. [CHAR LIMIT=40] -->
<string name="zen_important_interruptions">Priority interruptions only</string>
<!-- Zen mode: Only alarms. [CHAR LIMIT=40] -->
<string name="zen_alarms">Alarms only</string>
<!-- Zen mode: Next alarm information - just a time. [CHAR LIMIT=40] -->
<string name="zen_alarm_information_time">Your next alarm is at <xliff:g id="alarm_time" example="5:00 PM">%s</xliff:g></string>
<!-- Zen mode: Next alarm information - day and time. [CHAR LIMIT=40] -->
<string name="zen_alarm_information_day_time">Your next alarm is <xliff:g id="alarm_day_and_time" example="Fri 5:00 PM">%s</xliff:g></string>
<!-- Zen mode: Next alarm warning. [CHAR LIMIT=40] -->
<string name="zen_alarm_warning">You won\'t hear your alarm at <xliff:g id="alarm_time" example="5:00 PM">%s</xliff:g></string>
<!-- Zen mode: Total silence introduction message on first use -->
<string name="zen_silence_introduction">This blocks ALL sounds and vibrations, including from alarms, music, videos, and games. Youll still be able to make phone calls.</string>
<!-- Text for overflow card on Keyguard when there is not enough space for all notifications on Keyguard. [CHAR LIMIT=1] -->
<string name="keyguard_more_overflow_text">+<xliff:g id="number_of_notifications" example="5">%d</xliff:g></string>
@@ -771,7 +753,7 @@
<string name="camera_hint">Swipe left for camera</string>
<!-- Interruption level: None. [CHAR LIMIT=20] -->
<string name="interruption_level_none">No interruptions</string>
<string name="interruption_level_none">Total silence</string>
<!-- Interruption level: Priority. [CHAR LIMIT=20] -->
<string name="interruption_level_priority">Priority only</string>
@@ -779,11 +761,8 @@
<!-- Interruption level: Alarms only. [CHAR LIMIT=20] -->
<string name="interruption_level_alarms">Alarms only</string>
<!-- Interruption level: All. [CHAR LIMIT=20] -->
<string name="interruption_level_all">All</string>
<!-- Interruption level: None. Optimized for narrow two-line display. [CHAR LIMIT=20] -->
<string name="interruption_level_none_twoline">No\ninterruptions</string>
<string name="interruption_level_none_twoline">Total\nsilence</string>
<!-- Interruption level: Priority. Optimized for narrow two-line display. [CHAR LIMIT=20] -->
<string name="interruption_level_priority_twoline">Priority\nonly</string>
@@ -953,6 +932,9 @@
<!-- Accessibility string for current zen mode and selected exit condition. A template that simply concatenates existing mode string and the current condition description. [CHAR LIMIT=20] -->
<string name="zen_mode_and_condition"><xliff:g id="zen_mode" example="Priority interruptions only">%1$s</xliff:g>. <xliff:g id="exit_condition" example="For one hour">%2$s</xliff:g></string>
<!-- Button label for ending zen mode in the volume dialog -->
<string name="volume_zen_end_now">End now</string>
<!-- Screen pinning dialog title. -->
<string name="screen_pinning_title">Screen is pinned</string>
<!-- Screen pinning dialog description. -->
@@ -988,9 +970,26 @@
<!-- VolumeUI restoration notification: text -->
<string name="volumeui_notification_text">Touch to restore the original.</string>
<!-- Volume dialog zen toggle switch title -->
<string name="volume_zen_switch_text" translatable="false">@*android:string/zen_mode_feature_name</string>
<!-- Toast shown when user unlocks screen and managed profile activity is in the foreground -->
<string name="managed_profile_foreground_toast">You are in the Work profile</string>
<string-array name="volume_stream_titles" translatable="false">
<item>Voice calls</item> <!-- STREAM_VOICE_CALL -->
<item>System</item> <!-- STREAM_SYSTEM -->
<item>Notifications</item> <!-- STREAM_RING -->
<item>Media</item> <!-- STREAM_MUSIC -->
<item>Alarms</item> <!-- STREAM_ALARM -->
<item></item> <!-- STREAM_NOTIFICATION -->
<item>Bluetooth calls</item> <!-- STREAM_BLUETOOTH_SCO -->
<item></item> <!-- STREAM_SYSTEM_ENFORCED -->
<item></item> <!-- STREAM_DTMF -->
<item></item> <!-- STREAM_TTS -->
</string-array>
<string name="volume_stream_muted" translatable="false">%s silent</string>
<string name="volume_stream_vibrate" translatable="false">%s vibrate</string>
<string name="volume_stream_suppressed" translatable="false">%1$s silent — %2$s</string>
<string name="volume_stream_muted_dnd" translatable="false">%s silent — Total silence</string>
<string name="volume_stream_limited_dnd" translatable="false">%s — Priority only</string>
<string name="volume_stream_vibrate_dnd" translatable="false">%s vibrate — Priority only</string>
</resources>

View File

@@ -165,7 +165,7 @@
</style>
<style name="TextAppearance.QS.SegmentedButton">
<item name="android:textSize">14sp</item>
<item name="android:textSize">16sp</item>
</style>
<style name="TextAppearance.QS.DataUsage">
@@ -262,4 +262,31 @@
<item name="fillColor">@color/dark_mode_icon_color_dual_tone_fill</item>
<item name="singleToneColor">@color/dark_mode_icon_color_single_tone</item>
</style>
<style name="TextAppearance.Volume">
<item name="android:textStyle">normal</item>
<item name="android:textColor">#ffffffff</item>
<item name="android:fontFamily">sans-serif</item>
</style>
<style name="TextAppearance.Volume.ZenSummary">
<item name="android:textSize">14sp</item>
<item name="android:fontFamily">sans-serif-medium</item>
</style>
<style name="TextAppearance.Volume.ZenDetail">
<item name="android:textSize">14sp</item>
<item name="android:fontFamily">sans-serif</item>
<item name="android:textColor">#ffb0b3c5</item>
</style>
<style name="VolumeDialogAnimations">
<item name="android:windowEnterAnimation">@android:anim/fade_in</item>
<item name="android:windowExitAnimation">@android:anim/fade_out</item>
</style>
<style name="VolumeButtons" parent="@android:style/Widget.Material.Button.Borderless">
<item name="android:background">@drawable/btn_borderless_rect</item>
</style>
</resources>

View File

@@ -1,87 +0,0 @@
<!--
Copyright (C) 2015 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<item name="volume_expand_animation_duration" type="integer">300</item>
<color name="volume_icon_color">#ffffffff</color>
<color name="volume_settings_icon_color">#7fffffff</color>
<dimen name="volume_slider_interspacing">2dp</dimen>
<dimen name="volume_offset_top">0dp</dimen>
<dimen name="volume_button_size">48dp</dimen>
<item name="volume_secondary_alpha" format="float" type="dimen">0.3</item>
<style name="VolumeDialogAnimations">
<item name="android:windowEnterAnimation">@android:anim/fade_in</item>
<item name="android:windowExitAnimation">@android:anim/fade_out</item>
</style>
<style name="VolumeButtons" parent="@android:style/Widget.Material.Button.Borderless">
<item name="android:background">@drawable/btn_borderless_rect</item>
</style>
<style name="TextAppearance" />
<style name="TextAppearance.Volume">
<item name="android:textStyle">normal</item>
<item name="android:textColor">#ffffffff</item>
<item name="android:fontFamily">sans-serif</item>
</style>
<style name="TextAppearance.Volume.ZenSwitch">
<item name="android:textSize">16sp</item>
<item name="android:fontFamily">sans-serif-medium</item>
</style>
<style name="TextAppearance.Volume.ZenSwitchSummary">
<item name="android:textSize">14sp</item>
<item name="android:fontFamily">sans-serif-medium</item>
</style>
<style name="TextAppearance.Volume.ZenSwitchDetail">
<item name="android:textSize">14sp</item>
<item name="android:fontFamily">sans-serif</item>
<item name="android:textColor">#ffb0b3c5</item>
</style>
<string-array name="volume_stream_titles" translatable="false">
<item>Voice calls</item> <!-- STREAM_VOICE_CALL -->
<item>System</item> <!-- STREAM_SYSTEM -->
<item>Notifications</item> <!-- STREAM_RING -->
<item>Media</item> <!-- STREAM_MUSIC -->
<item>Alarms</item> <!-- STREAM_ALARM -->
<item></item> <!-- STREAM_NOTIFICATION -->
<item>Bluetooth calls</item> <!-- STREAM_BLUETOOTH_SCO -->
<item></item> <!-- STREAM_SYSTEM_ENFORCED -->
<item></item> <!-- STREAM_DTMF -->
<item></item> <!-- STREAM_TTS -->
</string-array>
<string name="volume_dnd_is_on" translatable="false">Do not disturb is on</string>
<string name="volume_turn_off" translatable="false">Turn off</string>
<string name="volume_stream_muted" translatable="false">%s silent</string>
<string name="volume_stream_vibrate" translatable="false">%s vibrate</string>
<string name="volume_stream_suppressed" translatable="false">%1$s silent — %2$s</string>
<string name="volume_stream_muted_dnd" translatable="false">%s silent — No interruptions</string>
<string name="volume_stream_limited_dnd" translatable="false">%s — Priority only</string>
<string name="volume_stream_vibrate_dnd" translatable="false">%s vibrate — Priority only</string>
<string name="volume_dnd_ends_in" translatable="false">Do not disturb ends in %s</string>
<string name="volume_dnd_ends_at" translatable="false">Do not disturb ends at %s</string>
<string name="volume_end_now" translatable="false">End now</string>
</resources>

View File

@@ -37,8 +37,10 @@ public final class Prefs {
Key.DND_TILE_VISIBLE,
Key.DND_TILE_COMBINED_ICON,
Key.DND_CONFIRMED_PRIORITY_INTRODUCTION,
Key.DND_CONFIRMED_SILENCE_INTRODUCTION,
Key.DND_FAVORITE_BUCKET_INDEX,
Key.DND_NONE_SELECTED,
Key.DND_FAVORITE_ZEN,
})
public @interface Key {
String SEARCH_APP_WIDGET_ID = "searchAppWidgetId";
@@ -48,8 +50,10 @@ public final class Prefs {
String DND_TILE_VISIBLE = "DndTileVisible";
String DND_TILE_COMBINED_ICON = "DndTileCombinedIcon";
String DND_CONFIRMED_PRIORITY_INTRODUCTION = "DndConfirmedPriorityIntroduction";
String DND_CONFIRMED_SILENCE_INTRODUCTION = "DndConfirmedSilenceIntroduction";
String DND_FAVORITE_BUCKET_INDEX = "DndCountdownMinuteIndex";
String DND_NONE_SELECTED = "DndNoneSelected";
String DND_FAVORITE_ZEN = "DndFavoriteZen";
}
public static boolean getBoolean(Context context, @Key String key, boolean defaultValue) {

View File

@@ -37,7 +37,11 @@ import com.android.systemui.volume.ZenModePanel;
/** Quick settings tile: Do not disturb **/
public class DndTile extends QSTile<QSTile.BooleanState> {
private static final Intent ZEN_SETTINGS = new Intent(Settings.ACTION_ZEN_MODE_SETTINGS);
private static final Intent ZEN_SETTINGS =
new Intent(Settings.ACTION_ZEN_MODE_SETTINGS);
private static final Intent ZEN_PRIORITY_SETTINGS =
new Intent(Settings.ACTION_ZEN_MODE_PRIORITY_SETTINGS);
private static final String ACTION_SET_VISIBLE = "com.android.systemui.dndtile.SET_VISIBLE";
private static final String EXTRA_VISIBLE = "visible";
@@ -87,7 +91,9 @@ public class DndTile extends QSTile<QSTile.BooleanState> {
if (mState.value) {
mController.setZen(Global.ZEN_MODE_OFF, null, TAG);
} else {
mController.setZen(Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS, null, TAG);
int zen = Prefs.getInt(mContext, Prefs.Key.DND_FAVORITE_ZEN, Global.ZEN_MODE_ALARMS);
mController.setZen(zen, null, TAG);
refreshState(zen); // this one's optimistic
showDetail(true);
}
}
@@ -209,8 +215,8 @@ public class DndTile extends QSTile<QSTile.BooleanState> {
R.layout.zen_mode_panel, parent, false);
if (convertView == null) {
zmp.init(mController);
zmp.setEmbedded(true);
zmp.addOnAttachStateChangeListener(this);
zmp.setCallback(mZenModePanelCallback);
}
return zmp;
}
@@ -225,4 +231,22 @@ public class DndTile extends QSTile<QSTile.BooleanState> {
mShowingDetail = false;
}
}
private final ZenModePanel.Callback mZenModePanelCallback = new ZenModePanel.Callback() {
@Override
public void onPrioritySettings() {
mHost.startSettingsActivity(ZEN_PRIORITY_SETTINGS);
}
@Override
public void onInteraction() {
// noop
}
@Override
public void onExpanded(boolean expanded) {
// noop
}
};
}

View File

@@ -224,14 +224,14 @@ public class PhoneStatusBarPolicy {
} else if (mZen == Global.ZEN_MODE_NO_INTERRUPTIONS) {
zenVisible = true;
zenIconId = R.drawable.stat_sys_zen_none;
zenDescription = mContext.getString(R.string.zen_no_interruptions);
zenDescription = mContext.getString(R.string.interruption_level_none);
} else if (mZen == Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS) {
zenVisible = true;
zenIconId = R.drawable.stat_sys_zen_important;
zenDescription = mContext.getString(R.string.zen_important_interruptions);
zenDescription = mContext.getString(R.string.interruption_level_priority);
}
if (DndTile.isVisible(mContext)
if (DndTile.isVisible(mContext) && !DndTile.isCombinedIcon(mContext)
&& audioManager.getRingerModeInternal() == AudioManager.RINGER_MODE_SILENT) {
volumeVisible = true;
volumeIconId = R.drawable.stat_sys_ringer_silent;

View File

@@ -35,6 +35,7 @@ public interface ZenModeController {
boolean isZenAvailable();
ComponentName getEffectsSuppressor();
boolean isCountdownConditionSupported();
int getCurrentUser();
public static class Callback {
public void onZenChanged(int zen) {}
@@ -45,4 +46,5 @@ public interface ZenModeController {
public void onManualRuleChanged(ZenRule rule) {}
public void onConfigChanged(ZenModeConfig config) {}
}
}

View File

@@ -16,6 +16,7 @@
package com.android.systemui.statusbar.policy;
import android.app.ActivityManager;
import android.app.AlarmManager;
import android.app.NotificationManager;
import android.content.BroadcastReceiver;
@@ -159,6 +160,11 @@ public class ZenModeControllerImpl implements ZenModeController {
.isSystemConditionProviderEnabled(ZenModeConfig.COUNTDOWN_PATH);
}
@Override
public int getCurrentUser() {
return ActivityManager.getCurrentUser();
}
private void fireNextAlarmChanged() {
for (Callback cb : mCallbacks) {
cb.onNextAlarmChanged();

View File

@@ -17,6 +17,7 @@
package com.android.systemui.volume;
import android.content.Context;
import android.graphics.Typeface;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
@@ -30,6 +31,8 @@ import java.util.Objects;
public class SegmentedButtons extends LinearLayout {
private static final int LABEL_RES_KEY = R.id.label;
private static final Typeface REGULAR = Typeface.create("sans-serif", Typeface.NORMAL);
private static final Typeface MEDIUM = Typeface.create("sans-serif-medium", Typeface.NORMAL);
private final Context mContext;
private final LayoutInflater mInflater;
@@ -60,6 +63,7 @@ public class SegmentedButtons extends LinearLayout {
final Object tag = c.getTag();
final boolean selected = Objects.equals(mSelectedValue, tag);
c.setSelected(selected);
c.setTypeface(selected ? MEDIUM : REGULAR);
}
fireOnSelected();
}

View File

@@ -144,9 +144,14 @@ class Util {
return HMMAA.format(new Date(millis));
}
public static void setText(TextView tv, CharSequence text) {
if (Objects.equals(tv.getText(), text)) return;
private static CharSequence emptyToNull(CharSequence str) {
return str == null || str.length() == 0 ? null : str;
}
public static boolean setText(TextView tv, CharSequence text) {
if (Objects.equals(emptyToNull(tv.getText()), emptyToNull(text))) return false;
tv.setText(text);
return true;
}
public static final void setVisOrGone(View v, boolean vis) {

View File

@@ -37,7 +37,6 @@ import android.os.Looper;
import android.os.Message;
import android.os.SystemClock;
import android.provider.Settings.Global;
import android.service.notification.ZenModeConfig;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.SparseBooleanArray;
@@ -52,7 +51,6 @@ import android.view.ViewGroup.MarginLayoutParams;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.DecelerateInterpolator;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.SeekBar;
@@ -90,16 +88,12 @@ public class VolumeDialog {
private final ViewGroup mDialogView;
private final ViewGroup mDialogContentView;
private final ImageButton mExpandButton;
private final TextView mFootlineText;
private final Button mFootlineAction;
private final View mSettingsButton;
private final View mFooter;
private final List<VolumeRow> mRows = new ArrayList<VolumeRow>();
private final SpTexts mSpTexts;
private final SparseBooleanArray mDynamic = new SparseBooleanArray();
private final KeyguardManager mKeyguard;
private final int mExpandButtonAnimationDuration;
private final View mTextFooter;
private final ZenFooter mZenFooter;
private final LayoutTransition mLayoutTransition;
private final Object mSafetyWarningLock = new Object();
@@ -108,8 +102,6 @@ public class VolumeDialog {
private boolean mExpanded;
private int mActiveStream;
private boolean mShowHeaders = VolumePrefs.DEFAULT_SHOW_HEADERS;
private boolean mShowFooter = VolumePrefs.DEFAULT_SHOW_FOOTER;
private boolean mShowZenFooter = VolumePrefs.DEFAULT_ZEN_FOOTER;
private boolean mAutomute = VolumePrefs.DEFAULT_ENABLE_AUTOMUTE;
private boolean mSilentMode = VolumePrefs.DEFAULT_ENABLE_SILENT_MODE;
private State mState;
@@ -118,7 +110,7 @@ public class VolumeDialog {
private SafetyWarningDialog mSafetyWarning;
private Callback mCallback;
public VolumeDialog(Context context, VolumeDialogController controller,
public VolumeDialog(Context context, int windowType, VolumeDialogController controller,
ZenModeController zenModeController, Callback callback) {
mContext = context;
mController = controller;
@@ -141,7 +133,7 @@ public class VolumeDialog {
mDialog.setCanceledOnTouchOutside(true);
final Resources res = mContext.getResources();
final WindowManager.LayoutParams lp = window.getAttributes();
lp.type = WindowManager.LayoutParams.TYPE_VOLUME_OVERLAY;
lp.type = windowType;
lp.format = PixelFormat.TRANSLUCENT;
lp.setTitle(VolumeDialog.class.getSimpleName());
lp.gravity = Gravity.TOP | Gravity.CENTER_HORIZONTAL;
@@ -176,17 +168,11 @@ public class VolumeDialog {
addRow(AudioManager.STREAM_SYSTEM,
R.drawable.ic_volume_system, R.drawable.ic_volume_system_mute, false);
mTextFooter = mDialog.findViewById(R.id.volume_text_footer);
mFootlineText = (TextView) mDialog.findViewById(R.id.volume_footline_text);
mSpTexts.add(mFootlineText);
mFootlineAction = (Button) mDialog.findViewById(R.id.volume_footline_action_button);
mSpTexts.add(mFootlineAction);
mFooter = mDialog.findViewById(R.id.volume_footer);
mSettingsButton = mDialog.findViewById(R.id.volume_settings_button);
mSettingsButton.setOnClickListener(mClickSettings);
mExpandButtonAnimationDuration = res.getInteger(R.integer.volume_expand_animation_duration);
mZenFooter = (ZenFooter) mDialog.findViewById(R.id.volume_zen_footer);
mZenFooter.init(zenModeController, mZenFooterCallback);
mZenFooter.init(zenModeController);
controller.addCallback(mControllerCallbackH, mHandler);
controller.getState();
@@ -217,18 +203,6 @@ public class VolumeDialog {
mHandler.sendEmptyMessage(H.RECHECK_ALL);
}
public void setShowFooter(boolean show) {
if (mShowFooter == show) return;
mShowFooter = show;
mHandler.sendEmptyMessage(H.RECHECK_ALL);
}
public void setZenFooter(boolean zen) {
if (mShowZenFooter == zen) return;
mShowZenFooter = zen;
mHandler.sendEmptyMessage(H.RECHECK_ALL);
}
public void setAutomute(boolean automute) {
if (mAutomute == automute) return;
mAutomute = automute;
@@ -315,7 +289,6 @@ public class VolumeDialog {
writer.print(" mActiveStream: "); writer.println(mActiveStream);
writer.print(" mDynamic: "); writer.println(mDynamic);
writer.print(" mShowHeaders: "); writer.println(mShowHeaders);
writer.print(" mShowFooter: "); writer.println(mShowFooter);
writer.print(" mAutomute: "); writer.println(mAutomute);
writer.print(" mSilentMode: "); writer.println(mSilentMode);
}
@@ -444,7 +417,6 @@ public class VolumeDialog {
}
private int computeTimeoutH() {
if (mZenFooter != null && mZenFooter.isFooterExpanded()) return 10000;
if (mSafetyWarning != null) return 5000;
if (mExpanded || mExpanding) return 5000;
if (mActiveStream == AudioManager.STREAM_MUSIC) return 1500;
@@ -515,18 +487,9 @@ public class VolumeDialog {
final VolumeRow activeRow = getActiveRow();
updateFooterH();
updateExpandButtonH();
final boolean footerVisible = mFooter.getVisibility() == View.VISIBLE;
if (!mShowing) {
trimObsoleteH();
}
// first, find the last visible row
VolumeRow lastVisible = null;
for (VolumeRow row : mRows) {
final boolean isActive = row == activeRow;
if (isVisibleH(row, isActive)) {
lastVisible = row;
}
}
// apply changes to all rows
for (VolumeRow row : mRows) {
final boolean isActive = row == activeRow;
@@ -542,8 +505,7 @@ public class VolumeDialog {
row.settingsButton.setImageResource(expandButtonRes);
}
}
Util.setVisOrInvis(row.settingsButton,
mExpanded && (!footerVisible && row == lastVisible));
Util.setVisOrInvis(row.settingsButton, false);
row.header.setAlpha(mExpanded && isActive ? 1 : 0.5f);
}
}
@@ -585,51 +547,9 @@ public class VolumeDialog {
updateFooterH();
}
private void updateTextFooterH() {
final boolean zen = mState.zenMode != Global.ZEN_MODE_OFF;
final boolean wasVisible = mFooter.getVisibility() == View.VISIBLE;
Util.setVisOrGone(mTextFooter, mExpanded && mShowFooter && (zen || mShowing && wasVisible));
if (mTextFooter.getVisibility() == View.VISIBLE) {
String text = null;
String action = null;
if (mState.exitCondition != null) {
final long countdown = ZenModeConfig.tryParseCountdownConditionId(mState
.exitCondition.id);
if (countdown != 0) {
text = mContext.getString(R.string.volume_dnd_ends_at,
Util.getShortTime(countdown));
action = mContext.getString(R.string.volume_end_now);
}
}
if (text == null) {
text = mContext.getString(R.string.volume_dnd_is_on);
}
if (action == null) {
action = mContext.getString(R.string.volume_turn_off);
}
Util.setText(mFootlineText, text);
Util.setText(mFootlineAction, action);
mFootlineAction.setOnClickListener(mTurnOffDnd);
}
Util.setVisOrGone(mFootlineText, zen);
Util.setVisOrGone(mFootlineAction, zen);
}
private void updateFooterH() {
if (!mShowFooter) {
Util.setVisOrGone(mFooter, false);
return;
}
if (mShowZenFooter) {
Util.setVisOrGone(mTextFooter, false);
final boolean ringActive = mActiveStream == AudioManager.STREAM_RING;
Util.setVisOrGone(mZenFooter, mZenFooter.isZen() && ringActive
|| mShowing && (mExpanded || mZenFooter.getVisibility() == View.VISIBLE));
mZenFooter.update();
} else {
Util.setVisOrGone(mZenFooter, false);
updateTextFooterH();
}
Util.setVisOrGone(mZenFooter, mState.zenMode != Global.ZEN_MODE_OFF);
mZenFooter.update();
}
private void updateVolumeRowH(VolumeRow row) {
@@ -642,12 +562,20 @@ public class VolumeDialog {
}
final boolean isRingStream = row.stream == AudioManager.STREAM_RING;
final boolean isSystemStream = row.stream == AudioManager.STREAM_SYSTEM;
final boolean isAlarmStream = row.stream == AudioManager.STREAM_ALARM;
final boolean isMusicStream = row.stream == AudioManager.STREAM_MUSIC;
final boolean isRingVibrate = isRingStream
&& mState.ringerModeInternal == AudioManager.RINGER_MODE_VIBRATE;
final boolean isNoned = (isRingStream || isSystemStream)
&& mState.zenMode == Global.ZEN_MODE_NO_INTERRUPTIONS;
final boolean isLimited = isRingStream
&& mState.zenMode == Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS;
final boolean isRingSilent = isRingStream
&& mState.ringerModeInternal == AudioManager.RINGER_MODE_SILENT;
final boolean isZenAlarms = mState.zenMode == Global.ZEN_MODE_ALARMS;
final boolean isZenNone = mState.zenMode == Global.ZEN_MODE_NO_INTERRUPTIONS;
final boolean isZenPriority = mState.zenMode == Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS;
final boolean isRingZenNone = (isRingStream || isSystemStream) && isZenNone;
final boolean isRingLimited = isRingStream && isZenPriority;
final boolean zenMuted = isZenAlarms ? (isRingStream || isSystemStream)
: isZenNone ? (isRingStream || isSystemStream || isAlarmStream || isMusicStream)
: false;
// update slider max
final int max = ss.levelMax * 100;
@@ -663,15 +591,15 @@ public class VolumeDialog {
// update header text
final String text;
if (isNoned) {
if (isRingZenNone) {
text = mContext.getString(R.string.volume_stream_muted_dnd, ss.name);
} else if (isRingVibrate && isLimited) {
} else if (isRingVibrate && isRingLimited) {
text = mContext.getString(R.string.volume_stream_vibrate_dnd, ss.name);
} else if (isRingVibrate) {
text = mContext.getString(R.string.volume_stream_vibrate, ss.name);
} else if (ss.muted || mAutomute && ss.level == 0) {
text = mContext.getString(R.string.volume_stream_muted, ss.name);
} else if (isLimited) {
} else if (isRingLimited) {
text = mContext.getString(R.string.volume_stream_limited_dnd, ss.name);
} else {
text = ss.name;
@@ -679,11 +607,12 @@ public class VolumeDialog {
Util.setText(row.header, text);
// update icon
final boolean iconEnabled = mAutomute || ss.muteSupported;
final boolean iconEnabled = (mAutomute || ss.muteSupported) && !zenMuted;
row.icon.setEnabled(iconEnabled);
row.icon.setAlpha(iconEnabled ? 1 : 0.5f);
final int iconRes =
isRingVibrate ? R.drawable.ic_volume_ringer_vibrate
: isRingSilent || zenMuted ? row.cachedIconRes
: ss.routedToBluetooth ?
(ss.muted ? R.drawable.ic_volume_media_bt_mute
: R.drawable.ic_volume_media_bt)
@@ -705,10 +634,11 @@ public class VolumeDialog {
: Events.ICON_STATE_UNKNOWN;
// update slider
updateVolumeRowSliderH(row);
updateVolumeRowSliderH(row, zenMuted);
}
private void updateVolumeRowSliderH(VolumeRow row) {
private void updateVolumeRowSliderH(VolumeRow row, boolean zenMuted) {
row.slider.setEnabled(!zenMuted);
if (row.tracking) {
return; // don't update if user is sliding
}
@@ -887,46 +817,6 @@ public class VolumeDialog {
}
};
private final View.OnClickListener mTurnOffDnd = new View.OnClickListener() {
@Override
public void onClick(View v) {
mSettingsButton.postDelayed(new Runnable() {
@Override
public void run() {
mController.setZenMode(Global.ZEN_MODE_OFF);
}
}, WAIT_FOR_RIPPLE);
}
};
private final ZenFooter.Callback mZenFooterCallback = new ZenFooter.Callback() {
@Override
public void onFooterExpanded() {
mHandler.sendEmptyMessage(H.RESCHEDULE_TIMEOUT);
}
@Override
public void onSettingsClicked() {
dismiss(Events.DISMISS_REASON_SETTINGS_CLICKED);
if (mCallback != null) {
mCallback.onZenSettingsClicked();
}
}
@Override
public void onDoneClicked() {
dismiss(Events.DISMISS_REASON_DONE_CLICKED);
}
@Override
public void onPrioritySettingsClicked() {
dismiss(Events.DISMISS_REASON_SETTINGS_CLICKED);
if (mCallback != null) {
mCallback.onZenPrioritySettingsClicked();
}
}
};
private final class H extends Handler {
private static final int SHOW = 1;
private static final int DISMISS = 2;

View File

@@ -24,6 +24,7 @@ import android.media.VolumePolicy;
import android.os.Bundle;
import android.os.Handler;
import android.provider.Settings;
import android.view.WindowManager;
import com.android.systemui.SystemUI;
import com.android.systemui.keyguard.KeyguardViewMediator;
@@ -61,7 +62,8 @@ public class VolumeDialogComponent implements VolumeComponent {
}
};
mZenModeController = zen;
mDialog = new VolumeDialog(context, mController, zen, mVolumeDialogCallback);
mDialog = new VolumeDialog(context, WindowManager.LayoutParams.TYPE_VOLUME_OVERLAY,
mController, zen, mVolumeDialogCallback);
applyConfiguration();
}
@@ -76,12 +78,10 @@ public class VolumeDialogComponent implements VolumeComponent {
mDialog.setStreamImportant(AudioManager.STREAM_ALARM, true);
mDialog.setStreamImportant(AudioManager.STREAM_SYSTEM, false);
mDialog.setShowHeaders(false);
mDialog.setShowFooter(true);
mDialog.setZenFooter(true);
mDialog.setAutomute(true);
mDialog.setSilentMode(false);
mController.setVolumePolicy(mVolumePolicy);
mController.showDndTile(false);
mController.showDndTile(true);
}
@Override

View File

@@ -100,7 +100,7 @@ public class VolumeDialogController {
private boolean mEnabled;
private boolean mDestroyed;
private VolumePolicy mVolumePolicy;
private boolean mShowDndTile = false;
private boolean mShowDndTile = true;
public VolumeDialogController(Context context, ComponentName component) {
mContext = context.getApplicationContext();
@@ -125,6 +125,10 @@ public class VolumeDialogController {
return mAudio;
}
public ZenModeConfig getZenModeConfig() {
return mNoMan.getZenModeConfig();
}
public void dismiss() {
mCallbacks.onDismissRequested(Events.DISMISS_REASON_VOLUME_CONTROLLER);
}
@@ -342,7 +346,7 @@ public class VolumeDialogController {
updateRingerModeExternalW(mAudio.getRingerMode());
updateZenModeW();
updateEffectsSuppressorW(mNoMan.getEffectsSuppressor());
updateExitConditionW();
updateZenModeConfigW();
mCallbacks.onStateChanged(mState);
}
@@ -395,17 +399,10 @@ public class VolumeDialogController {
return stream == AudioManager.STREAM_RING || stream == AudioManager.STREAM_NOTIFICATION;
}
private Condition getExitCondition() {
final ZenModeConfig config = mNoMan.getZenModeConfig();
return config == null ? null
: config.manualRule == null ? null
: config.manualRule.condition;
}
private boolean updateExitConditionW() {
final Condition exitCondition = getExitCondition();
if (Objects.equals(mState.exitCondition, exitCondition)) return false;
mState.exitCondition = exitCondition;
private boolean updateZenModeConfigW() {
final ZenModeConfig zenModeConfig = getZenModeConfig();
if (Objects.equals(mState.zenModeConfig, zenModeConfig)) return false;
mState.zenModeConfig = zenModeConfig;
return true;
}
@@ -750,7 +747,7 @@ public class VolumeDialogController {
changed = updateZenModeW();
}
if (ZEN_MODE_CONFIG_URI.equals(uri)) {
changed = updateExitConditionW();
changed = updateZenModeConfigW();
}
if (changed) {
mCallbacks.onStateChanged(mState);
@@ -943,7 +940,7 @@ public class VolumeDialogController {
public int zenMode;
public ComponentName effectsSuppressor;
public String effectsSuppressorName;
public Condition exitCondition;
public ZenModeConfig zenModeConfig;
public int activeStream = NO_ACTIVE_STREAM;
public State copy() {
@@ -956,7 +953,7 @@ public class VolumeDialogController {
rt.zenMode = zenMode;
if (effectsSuppressor != null) rt.effectsSuppressor = effectsSuppressor.clone();
rt.effectsSuppressorName = effectsSuppressorName;
if (exitCondition != null) rt.exitCondition = exitCondition.copy();
if (zenModeConfig != null) rt.zenModeConfig = zenModeConfig.copy();
rt.activeStream = activeStream;
return rt;
}
@@ -977,10 +974,15 @@ public class VolumeDialogController {
sb.append(",zenMode:").append(zenMode);
sb.append(",effectsSuppressor:").append(effectsSuppressor);
sb.append(",effectsSuppressorName:").append(effectsSuppressorName);
sb.append(",exitCondition:").append(exitCondition);
sb.append(",zenModeConfig:").append(zenModeConfig);
sb.append(",activeStream:").append(activeStream);
return sb.append('}').toString();
}
public Condition getManualExitCondition() {
return zenModeConfig != null && zenModeConfig.manualRule != null
? zenModeConfig.manualRule.condition : null;
}
}
public interface Callbacks {

View File

@@ -32,8 +32,6 @@ public class VolumePrefs {
public static final String PREF_SHOW_HEADERS = "pref_show_headers";
public static final String PREF_SHOW_FAKE_REMOTE_1 = "pref_show_fake_remote_1";
public static final String PREF_SHOW_FAKE_REMOTE_2 = "pref_show_fake_remote_2";
public static final String PREF_SHOW_FOOTER = "pref_show_footer";
public static final String PREF_ZEN_FOOTER = "pref_zen_footer";
public static final String PREF_ENABLE_AUTOMUTE = "pref_enable_automute";
public static final String PREF_ENABLE_SILENT_MODE = "pref_enable_silent_mode";
public static final String PREF_DEBUG_LOGGING = "pref_debug_logging";
@@ -46,10 +44,8 @@ public class VolumePrefs {
public static final String PREF_ADJUST_NOTIFICATION = "pref_adjust_notification";
public static final boolean DEFAULT_SHOW_HEADERS = true;
public static final boolean DEFAULT_SHOW_FOOTER = true;
public static final boolean DEFAULT_ENABLE_AUTOMUTE = true;
public static final boolean DEFAULT_ENABLE_SILENT_MODE = true;
public static final boolean DEFAULT_ZEN_FOOTER = true;
public static void unregisterCallbacks(Context c, OnSharedPreferenceChangeListener listener) {
prefs(c).unregisterOnSharedPreferenceChangeListener(listener);

View File

@@ -103,7 +103,7 @@ public class VolumeUI extends SystemUI {
private void setDefaultVolumeController(boolean register) {
if (register) {
DndTile.setVisible(mContext, false);
DndTile.setVisible(mContext, true);
if (LOGD) Log.d(TAG, "Registering default volume controller");
getVolumeComponent().register();
} else {

View File

@@ -16,20 +16,12 @@
package com.android.systemui.volume;
import android.animation.LayoutTransition;
import android.animation.ValueAnimator;
import android.app.ActivityManager;
import android.content.Context;
import android.content.res.Resources;
import android.provider.Settings.Global;
import android.service.notification.ZenModeConfig;
import android.util.AttributeSet;
import android.util.Log;
import android.util.TypedValue;
import android.view.View;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.LinearLayout;
import android.widget.Switch;
import android.widget.TextView;
import com.android.systemui.R;
@@ -38,70 +30,36 @@ import com.android.systemui.statusbar.policy.ZenModeController;
import java.util.Objects;
/**
* Switch bar + zen mode panel (conditions) attached to the bottom of the volume dialog.
* Zen mode information (and end button) attached to the bottom of the volume dialog.
*/
public class ZenFooter extends LinearLayout {
private static final String TAG = Util.logTag(ZenFooter.class);
private final Context mContext;
private final float mSecondaryAlpha;
private final LayoutTransition mLayoutTransition;
private ZenModeController mController;
private Switch mSwitch;
private ZenModePanel mZenModePanel;
private View mZenModePanelButtons;
private View mZenModePanelMoreButton;
private View mZenModePanelDoneButton;
private View mSwitchBar;
private View mSwitchBarIcon;
private View mSummary;
private TextView mSummaryLine1;
private TextView mSummaryLine2;
private boolean mFooterExpanded;
private View mEndNowButton;
private int mZen = -1;
private ZenModeConfig mConfig;
private Callback mCallback;
private ZenModeController mController;
public ZenFooter(Context context, AttributeSet attrs) {
super(context, attrs);
mContext = context;
mSecondaryAlpha = getFloat(context.getResources(), R.dimen.volume_secondary_alpha);
mLayoutTransition = new LayoutTransition();
mLayoutTransition.setDuration(new ValueAnimator().getDuration() / 2);
mLayoutTransition.disableTransitionType(LayoutTransition.DISAPPEARING);
mLayoutTransition.disableTransitionType(LayoutTransition.CHANGE_DISAPPEARING);
}
private static float getFloat(Resources r, int resId) {
final TypedValue tv = new TypedValue();
r.getValue(resId, tv, true);
return tv.getFloat();
setLayoutTransition(new LayoutTransition());
}
@Override
protected void onFinishInflate() {
super.onFinishInflate();
mSwitchBar = findViewById(R.id.volume_zen_switch_bar);
mSwitchBarIcon = findViewById(R.id.volume_zen_switch_bar_icon);
mSwitch = (Switch) findViewById(R.id.volume_zen_switch);
mZenModePanel = (ZenModePanel) findViewById(R.id.zen_mode_panel);
mZenModePanelButtons = findViewById(R.id.volume_zen_mode_panel_buttons);
mZenModePanelMoreButton = findViewById(R.id.volume_zen_mode_panel_more);
mZenModePanelDoneButton = findViewById(R.id.volume_zen_mode_panel_done);
mSummary = findViewById(R.id.volume_zen_panel_summary);
mSummaryLine1 = (TextView) findViewById(R.id.volume_zen_panel_summary_line_1);
mSummaryLine2 = (TextView) findViewById(R.id.volume_zen_panel_summary_line_2);
mSummaryLine1 = (TextView) findViewById(R.id.volume_zen_summary_line_1);
mSummaryLine2 = (TextView) findViewById(R.id.volume_zen_summary_line_2);
mEndNowButton = findViewById(R.id.volume_zen_end_now);
}
public void init(ZenModeController controller, Callback callback) {
mCallback = callback;
mController = controller;
mZenModePanel.init(controller);
mZenModePanel.setEmbedded(true);
mZenModePanel.setCallback(mZenModePanelCallback);
mSwitch.setOnCheckedChangeListener(mCheckedListener);
mController.addCallback(new ZenModeController.Callback() {
public void init(final ZenModeController controller) {
controller.addCallback(new ZenModeController.Callback() {
@Override
public void onZenChanged(int zen) {
setZen(zen);
@@ -111,30 +69,15 @@ public class ZenFooter extends LinearLayout {
setConfig(config);
}
});
mSwitchBar.setOnClickListener(new OnClickListener() {
mEndNowButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
mSwitch.setChecked(!mSwitch.isChecked());
controller.setZen(Global.ZEN_MODE_OFF, null, TAG);
}
});
mZenModePanelMoreButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (mCallback != null) {
mCallback.onSettingsClicked();
}
}
});
mZenModePanelDoneButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (mCallback != null) {
mCallback.onDoneClicked();
}
}
});
mZen = mController.getZen();
mConfig = mController.getConfig();
mZen = controller.getZen();
mConfig = controller.getConfig();
mController = controller;
update();
}
@@ -166,96 +109,17 @@ public class ZenFooter extends LinearLayout {
return mZen == Global.ZEN_MODE_NO_INTERRUPTIONS;
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
setLayoutTransition(null);
setFooterExpanded(false);
}
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
setLayoutTransition(mLayoutTransition);
}
private boolean setFooterExpanded(boolean expanded) {
if (mFooterExpanded == expanded) return false;
mFooterExpanded = expanded;
update();
if (mCallback != null) {
mCallback.onFooterExpanded();
}
return true;
}
public boolean isFooterExpanded() {
return mFooterExpanded;
}
public void update() {
final boolean isZen = isZen();
mSwitch.setOnCheckedChangeListener(null);
mSwitch.setChecked(isZen);
mSwitch.setOnCheckedChangeListener(mCheckedListener);
Util.setVisOrGone(mZenModePanel, isZen && mFooterExpanded);
Util.setVisOrGone(mZenModePanelButtons, isZen && mFooterExpanded);
Util.setVisOrGone(mSummary, isZen && !mFooterExpanded);
mSwitchBarIcon.setAlpha(isZen ? 1 : mSecondaryAlpha);
final String line1 =
isZenPriority() ? mContext.getString(R.string.interruption_level_priority)
: isZenAlarms() ? mContext.getString(R.string.interruption_level_alarms)
: isZenNone() ? mContext.getString(R.string.interruption_level_none)
: null;
Util.setText(mSummaryLine1, line1);
final String line2 = ZenModeConfig.getConditionSummary(mContext, mConfig,
ActivityManager.getCurrentUser());
mController.getCurrentUser());
Util.setText(mSummaryLine2, line2);
}
private final ZenModePanel.Callback mZenModePanelCallback = new ZenModePanel.Callback() {
@Override
public void onMoreSettings() {
if (mCallback != null) {
mCallback.onSettingsClicked();
}
}
@Override
public void onPrioritySettings() {
if (mCallback != null) {
mCallback.onPrioritySettingsClicked();
}
}
@Override
public void onInteraction() {
// noop
}
@Override
public void onExpanded(boolean expanded) {
// noop
}
};
private final OnCheckedChangeListener mCheckedListener = new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (D.BUG) Log.d(TAG, "onCheckedChanged " + isChecked);
if (isChecked != isZen()) {
final int newZen = isChecked ? Global.ZEN_MODE_ALARMS : Global.ZEN_MODE_OFF;
mZen = newZen; // this one's optimistic
setFooterExpanded(isChecked);
mController.setZen(newZen, null, TAG);
}
}
};
public interface Callback {
void onFooterExpanded();
void onSettingsClicked();
void onDoneClicked();
void onPrioritySettingsClicked();
}
}

View File

@@ -41,8 +41,6 @@ import android.util.MathUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AnimationUtils;
import android.view.animation.Interpolator;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.ImageView;
@@ -85,22 +83,14 @@ public class ZenModePanel extends LinearLayout {
private final H mHandler = new H();
private final ZenPrefs mPrefs;
private final IconPulser mIconPulser;
private final int mSubheadWarningColor;
private final int mSubheadColor;
private final Interpolator mInterpolator;
private final TransitionHelper mTransitionHelper = new TransitionHelper();
private final Uri mForeverId;
private String mTag = TAG + "/" + Integer.toHexString(System.identityHashCode(this));
private SegmentedButtons mZenButtons;
private ViewGroup mZenButtonsContainer;
private View mZenSubhead;
private TextView mZenSubheadCollapsed;
private TextView mZenSubheadExpanded;
private View mZenEmbeddedDivider;
private View mMoreSettings;
private View mZenIntroduction;
private TextView mZenIntroductionMessage;
private View mZenIntroductionConfirm;
private View mZenIntroductionCustomize;
private LinearLayout mZenConditions;
@@ -113,7 +103,6 @@ public class ZenModePanel extends LinearLayout {
private int mFirstConditionIndex;
private boolean mRequestingConditions;
private Condition mExitCondition;
private String mExitConditionText;
private int mBucketIndex = -1;
private boolean mExpanded;
private boolean mHidden;
@@ -123,7 +112,6 @@ public class ZenModePanel extends LinearLayout {
private Condition mSessionExitCondition;
private Condition[] mConditions;
private Condition mTimeCondition;
private boolean mEmbedded;
public ZenModePanel(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -131,10 +119,6 @@ public class ZenModePanel extends LinearLayout {
mPrefs = new ZenPrefs();
mInflater = LayoutInflater.from(mContext.getApplicationContext());
mIconPulser = new IconPulser(mContext);
mSubheadWarningColor = context.getColor(R.color.system_warning_color);
mSubheadColor = context.getColor(R.color.qs_subhead);
mInterpolator = AnimationUtils.loadInterpolator(mContext,
com.android.internal.R.interpolator.fast_out_slow_in);
mForeverId = Condition.newId(mContext).appendPath("forever").build();
if (DEBUG) Log.d(mTag, "new ZenModePanel");
}
@@ -149,25 +133,13 @@ public class ZenModePanel extends LinearLayout {
pw.print(" mExpanded="); pw.println(mExpanded);
pw.print(" mSessionZen="); pw.println(mSessionZen);
pw.print(" mAttachedZen="); pw.println(mAttachedZen);
pw.print(" mEmbedded="); pw.println(mEmbedded);
pw.print(" mConfirmedPriorityIntroduction=");
pw.println(mPrefs.mConfirmedPriorityIntroduction);
pw.print(" mConfirmedSilenceIntroduction=");
pw.println(mPrefs.mConfirmedSilenceIntroduction);
mTransitionHelper.dump(fd, pw, args);
}
public void setEmbedded(boolean embedded) {
if (mEmbedded == embedded) return;
mEmbedded = embedded;
mZenButtonsContainer.setLayoutTransition(mEmbedded ? null : newLayoutTransition(null));
setLayoutTransition(mEmbedded ? null : newLayoutTransition(null));
if (mEmbedded) {
mZenButtonsContainer.setBackground(null);
} else {
mZenButtonsContainer.setBackgroundResource(R.drawable.qs_background_secondary);
}
mZenButtons.getChildAt(3).setVisibility(mEmbedded ? GONE : VISIBLE);
mZenEmbeddedDivider.setVisibility(mEmbedded ? VISIBLE : GONE);
updateWidgets();
}
@Override
protected void onFinishInflate() {
super.onFinishInflate();
@@ -179,37 +151,10 @@ public class ZenModePanel extends LinearLayout {
Global.ZEN_MODE_ALARMS);
mZenButtons.addButton(R.string.interruption_level_priority_twoline,
Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS);
mZenButtons.addButton(R.string.interruption_level_all, Global.ZEN_MODE_OFF);
mZenButtons.setCallback(mZenButtonsCallback);
mZenButtonsContainer = (ViewGroup) findViewById(R.id.zen_buttons_container);
mZenButtonsContainer.setLayoutTransition(newLayoutTransition(null));
mZenSubhead = findViewById(R.id.zen_subhead);
mZenEmbeddedDivider = findViewById(R.id.zen_embedded_divider);
mZenSubheadCollapsed = (TextView) findViewById(R.id.zen_subhead_collapsed);
mZenSubheadCollapsed.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
setExpanded(true);
}
});
Interaction.register(mZenSubheadCollapsed, mInteractionCallback);
mZenSubheadExpanded = (TextView) findViewById(R.id.zen_subhead_expanded);
Interaction.register(mZenSubheadExpanded, mInteractionCallback);
mMoreSettings = findViewById(R.id.zen_more_settings);
mMoreSettings.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
fireMoreSettings();
}
});
Interaction.register(mMoreSettings, mInteractionCallback);
mZenIntroduction = findViewById(R.id.zen_introduction);
mZenIntroductionMessage = (TextView) findViewById(R.id.zen_introduction_message);
mZenIntroductionConfirm = findViewById(R.id.zen_introduction_confirm);
mZenIntroductionConfirm.setOnClickListener(new OnClickListener() {
@Override
@@ -230,25 +175,25 @@ public class ZenModePanel extends LinearLayout {
mZenConditions = (LinearLayout) findViewById(R.id.zen_conditions);
setLayoutTransition(newLayoutTransition(mTransitionHelper));
}
private void confirmZenIntroduction() {
if (DEBUG) Log.d(TAG, "confirmZenIntroduction");
Prefs.putBoolean(mContext, Prefs.Key.DND_CONFIRMED_PRIORITY_INTRODUCTION, true);
final String prefKey = prefKeyForConfirmation(getSelectedZen(Global.ZEN_MODE_OFF));
if (prefKey == null) return;
if (DEBUG) Log.d(TAG, "confirmZenIntroduction " + prefKey);
Prefs.putBoolean(mContext, prefKey, true);
mHandler.sendEmptyMessage(H.UPDATE_WIDGETS);
}
private LayoutTransition newLayoutTransition(TransitionListener listener) {
final LayoutTransition transition = new LayoutTransition();
transition.disableTransitionType(LayoutTransition.DISAPPEARING);
transition.disableTransitionType(LayoutTransition.CHANGE_DISAPPEARING);
transition.disableTransitionType(LayoutTransition.APPEARING);
transition.setInterpolator(LayoutTransition.CHANGE_APPEARING, mInterpolator);
if (listener != null) {
transition.addTransitionListener(listener);
private static String prefKeyForConfirmation(int zen) {
switch (zen) {
case Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS:
return Prefs.Key.DND_CONFIRMED_PRIORITY_INTRODUCTION;
case Global.ZEN_MODE_NO_INTERRUPTIONS:
return Prefs.Key.DND_CONFIRMED_SILENCE_INTRODUCTION;
default:
return null;
}
return transition;
}
@Override
@@ -260,7 +205,6 @@ public class ZenModePanel extends LinearLayout {
mSessionZen = mAttachedZen;
mTransitionHelper.clear();
setSessionExitCondition(copy(mExitCondition));
refreshExitConditionText();
updateWidgets();
setRequestingConditions(!mHidden);
}
@@ -274,9 +218,6 @@ public class ZenModePanel extends LinearLayout {
mAttachedZen = -1;
mSessionZen = -1;
setSessionExitCondition(null);
if (!mEmbedded) {
setExpanded(false);
}
setRequestingConditions(false);
mTransitionHelper.clear();
}
@@ -359,7 +300,6 @@ public class ZenModePanel extends LinearLayout {
for (int i = 0; i < mMaxConditions; i++) {
mZenConditions.addView(mInflater.inflate(R.layout.zen_mode_condition, this, false));
}
refreshExitConditionText();
mSessionZen = getSelectedZen(-1);
handleUpdateManualRule(mController.getManualRule());
if (DEBUG) Log.d(mTag, "init mExitCondition=" + mExitCondition);
@@ -375,7 +315,6 @@ public class ZenModePanel extends LinearLayout {
if (Objects.equals(mExitCondition, exitCondition)) return;
mExitCondition = exitCondition;
if (DEBUG) Log.d(mTag, "mExitCondition=" + getConditionId(mExitCondition));
refreshExitConditionText();
updateWidgets();
}
@@ -395,10 +334,6 @@ public class ZenModePanel extends LinearLayout {
return condition == null ? null : condition.copy();
}
private void refreshExitConditionText() {
mExitConditionText = getExitConditionText(mContext, mExitCondition);
}
public static String getExitConditionText(Context context, Condition exitCondition) {
if (exitCondition == null) {
return foreverSummary(context);
@@ -430,7 +365,7 @@ public class ZenModePanel extends LinearLayout {
private void handleUpdateZen(int zen) {
if (mSessionZen != -1 && mSessionZen != zen) {
setExpanded(mEmbedded && isShown() || !mEmbedded && zen != Global.ZEN_MODE_OFF);
setExpanded(isShown());
mSessionZen = zen;
}
mZenButtons.setSelectedValue(zen);
@@ -480,30 +415,18 @@ public class ZenModePanel extends LinearLayout {
return;
}
final int zen = getSelectedZen(Global.ZEN_MODE_OFF);
final boolean zenOff = zen == Global.ZEN_MODE_OFF;
final boolean zenImportant = zen == Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS;
final boolean zenNone = zen == Global.ZEN_MODE_NO_INTERRUPTIONS;
final boolean expanded = !mHidden && mExpanded;
final boolean conditions = mEmbedded || !zenOff && expanded;
final boolean introduction = conditions && zenImportant && !mPrefs.mConfirmedIntroduction;
final boolean introduction = (zenImportant && !mPrefs.mConfirmedPriorityIntroduction
|| zenNone && !mPrefs.mConfirmedSilenceIntroduction);
mZenButtons.setVisibility(mHidden ? GONE : VISIBLE);
mZenSubhead.setVisibility(!mHidden && !zenOff && !mEmbedded ? VISIBLE : GONE);
mZenSubheadExpanded.setVisibility(expanded ? VISIBLE : GONE);
mZenSubheadCollapsed.setVisibility(!expanded ? VISIBLE : GONE);
mMoreSettings.setVisibility(zenImportant && expanded ? VISIBLE : GONE);
mZenConditions.setVisibility(conditions ? VISIBLE : GONE);
if (zenNone) {
mZenSubheadExpanded.setText(R.string.zen_no_interruptions_with_warning);
mZenSubheadCollapsed.setText(mExitConditionText);
} else if (zenImportant) {
mZenSubheadExpanded.setText(R.string.zen_important_interruptions);
mZenSubheadCollapsed.setText(mExitConditionText);
}
mZenSubheadExpanded.setTextColor(zenNone && mPrefs.isNoneDangerous()
? mSubheadWarningColor : mSubheadColor);
mZenIntroduction.setVisibility(introduction ? VISIBLE : GONE);
if (introduction) {
mZenIntroductionMessage.setText(zenImportant ? R.string.zen_priority_introduction
: R.string.zen_silence_introduction);
mZenIntroductionCustomize.setVisibility(zenImportant ? VISIBLE : GONE);
}
}
private static Condition parseExistingTimeCondition(Context context, Condition condition) {
@@ -761,13 +684,13 @@ public class ZenModePanel extends LinearLayout {
String modeText;
switch(zen) {
case Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS:
modeText = mContext.getString(R.string.zen_important_interruptions);
modeText = mContext.getString(R.string.interruption_level_priority);
break;
case Global.ZEN_MODE_NO_INTERRUPTIONS:
modeText = mContext.getString(R.string.zen_no_interruptions);
modeText = mContext.getString(R.string.interruption_level_none);
break;
case Global.ZEN_MODE_ALARMS:
modeText = mContext.getString(R.string.zen_alarms);
modeText = mContext.getString(R.string.interruption_level_alarms);
break;
default:
return;
@@ -837,12 +760,6 @@ public class ZenModePanel extends LinearLayout {
setSessionExitCondition(copy(condition));
}
private void fireMoreSettings() {
if (mCallback != null) {
mCallback.onMoreSettings();
}
}
private void fireInteraction() {
if (mCallback != null) {
mCallback.onInteraction();
@@ -887,7 +804,6 @@ public class ZenModePanel extends LinearLayout {
}
public interface Callback {
void onMoreSettings();
void onPrioritySettings();
void onInteraction();
void onExpanded(boolean expanded);
@@ -907,7 +823,8 @@ public class ZenModePanel extends LinearLayout {
private int mMinuteIndex;
private int mNoneSelected;
private boolean mConfirmedIntroduction;
private boolean mConfirmedPriorityIntroduction;
private boolean mConfirmedSilenceIntroduction;
private ZenPrefs() {
mNoneDangerousThreshold = mContext.getResources()
@@ -915,11 +832,8 @@ public class ZenModePanel extends LinearLayout {
Prefs.registerListener(mContext, this);
updateMinuteIndex();
updateNoneSelected();
updateConfirmedIntroduction();
}
public boolean isNoneDangerous() {
return mNoneSelected < mNoneDangerousThreshold;
updateConfirmedPriorityIntroduction();
updateConfirmedSilenceIntroduction();
}
public void trackNoneSelected() {
@@ -945,7 +859,8 @@ public class ZenModePanel extends LinearLayout {
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
updateMinuteIndex();
updateNoneSelected();
updateConfirmedIntroduction();
updateConfirmedPriorityIntroduction();
updateConfirmedSilenceIntroduction();
}
private void updateMinuteIndex() {
@@ -968,12 +883,22 @@ public class ZenModePanel extends LinearLayout {
return MathUtils.constrain(noneSelected, 0, Integer.MAX_VALUE);
}
private void updateConfirmedIntroduction() {
private void updateConfirmedPriorityIntroduction() {
final boolean confirmed = Prefs.getBoolean(mContext,
Prefs.Key.DND_CONFIRMED_PRIORITY_INTRODUCTION, false);
if (confirmed == mConfirmedIntroduction) return;
mConfirmedIntroduction = confirmed;
if (DEBUG) Log.d(mTag, "Confirmed introduction: " + mConfirmedIntroduction);
if (confirmed == mConfirmedPriorityIntroduction) return;
mConfirmedPriorityIntroduction = confirmed;
if (DEBUG) Log.d(mTag, "Confirmed priority introduction: "
+ mConfirmedPriorityIntroduction);
}
private void updateConfirmedSilenceIntroduction() {
final boolean confirmed = Prefs.getBoolean(mContext,
Prefs.Key.DND_CONFIRMED_SILENCE_INTRODUCTION, false);
if (confirmed == mConfirmedSilenceIntroduction) return;
mConfirmedSilenceIntroduction = confirmed;
if (DEBUG) Log.d(mTag, "Confirmed silence introduction: "
+ mConfirmedSilenceIntroduction);
}
}
@@ -981,12 +906,16 @@ public class ZenModePanel extends LinearLayout {
@Override
public void onSelected(final Object value) {
if (value != null && mZenButtons.isShown() && isAttachedToWindow()) {
if (DEBUG) Log.d(mTag, "mZenButtonsCallback selected=" + value);
final int zen = (Integer) value;
if (DEBUG) Log.d(mTag, "mZenButtonsCallback selected=" + zen);
final Uri realConditionId = getRealConditionId(mSessionExitCondition);
AsyncTask.execute(new Runnable() {
@Override
public void run() {
mController.setZen((Integer) value, realConditionId, TAG + ".selectZen");
mController.setZen(zen, realConditionId, TAG + ".selectZen");
if (zen != Global.ZEN_MODE_OFF) {
Prefs.putInt(mContext, Prefs.Key.DND_FAVORITE_ZEN, zen);
}
}
});
}

View File

@@ -1803,9 +1803,7 @@ public class AudioService extends IAudioService.Stub {
if (!shouldMute) {
// unmute
// ring and notifications volume should never be 0 when not silenced
// on voice capable devices or devices that support vibration
if ((isPlatformVoice() || mHasVibrator) &&
mStreamVolumeAlias[streamType] == AudioSystem.STREAM_RING) {
if (mStreamVolumeAlias[streamType] == AudioSystem.STREAM_RING) {
synchronized (VolumeStreamState.class) {
final VolumeStreamState vss = mStreamStates[streamType];
for (int i = 0; i < vss.mIndexMap.size(); i++) {
@@ -2986,10 +2984,7 @@ public class AudioService extends IAudioService.Stub {
mLoweredFromNormalToVibrateTime = SystemClock.uptimeMillis();
}
} else {
// (oldIndex < step) is equivalent to (old UI index == 0)
if ((oldIndex < step)
&& mVolumePolicy.volumeDownToEnterSilent
&& mPrevVolDirection != AudioManager.ADJUST_LOWER) {
if (oldIndex == step && mVolumePolicy.volumeDownToEnterSilent) {
ringerMode = RINGER_MODE_SILENT;
}
}
@@ -3018,7 +3013,8 @@ public class AudioService extends IAudioService.Stub {
if (mVolumePolicy.volumeDownToEnterSilent) {
final long diff = SystemClock.uptimeMillis()
- mLoweredFromNormalToVibrateTime;
if (diff > mVolumePolicy.vibrateToSilentDebounce) {
if (diff > mVolumePolicy.vibrateToSilentDebounce
&& mRingerModeDelegate.canVolumeDownEnterSilent()) {
ringerMode = RINGER_MODE_SILENT;
}
} else {

View File

@@ -115,8 +115,8 @@ public class ZenLog {
append(TYPE_UNSUBSCRIBE, uri + "," + subscribeResult(provider, e));
}
public static void traceConfig(ZenModeConfig oldConfig, ZenModeConfig newConfig) {
append(TYPE_CONFIG, newConfig != null ? newConfig.toString() : null);
public static void traceConfig(String reason, ZenModeConfig newConfig) {
append(TYPE_CONFIG, reason + "," + (newConfig != null ? newConfig.toString() : null));
}
public static void traceDisableEffects(NotificationRecord record, String reason) {

View File

@@ -17,6 +17,7 @@
package com.android.server.notification;
import static android.media.AudioAttributes.USAGE_ALARM;
import static android.media.AudioAttributes.USAGE_MEDIA;
import static android.media.AudioAttributes.USAGE_NOTIFICATION;
import static android.media.AudioAttributes.USAGE_NOTIFICATION_RINGTONE;
@@ -262,8 +263,8 @@ public class ZenModeHelper {
}
mConditions.evaluateConfig(config); // may modify config
if (config.equals(mConfig)) return true;
if (DEBUG) Log.d(TAG, "setConfig reason=" + reason);
ZenLog.traceConfig(mConfig, config);
if (DEBUG) Log.d(TAG, "setConfig reason=" + reason, new Throwable());
ZenLog.traceConfig(reason, config);
final boolean policyChanged = !Objects.equals(getNotificationPolicy(mConfig),
getNotificationPolicy(config));
mConfig = config;
@@ -329,9 +330,10 @@ public class ZenModeHelper {
|| mEffectsSuppressed;
applyRestrictions(muteCalls, USAGE_NOTIFICATION_RINGTONE);
// alarm restrictions
final boolean muteAlarms = mZenMode == Global.ZEN_MODE_NO_INTERRUPTIONS;
applyRestrictions(muteAlarms, USAGE_ALARM);
// alarm/media restrictions
final boolean zenNone = mZenMode == Global.ZEN_MODE_NO_INTERRUPTIONS;
applyRestrictions(zenNone, USAGE_ALARM);
applyRestrictions(zenNone, USAGE_MEDIA);
}
private void applyRestrictions(boolean mute, int usage) {
@@ -590,6 +592,11 @@ public class ZenModeHelper {
ringerModeInternal, ringerModeInternalOut);
return ringerModeInternalOut;
}
@Override
public boolean canVolumeDownEnterSilent() {
return mZenMode == Global.ZEN_MODE_OFF;
}
}
private final class SettingsObserver extends ContentObserver {