diff options
author | John Spurlock <jspurlock@google.com> | 2014-07-19 23:11:36 -0400 |
---|---|---|
committer | John Spurlock <jspurlock@google.com> | 2014-07-20 02:50:34 -0400 |
commit | eb2727bb2f0f32016ca7c4bdd2c0a79eec8cb80a (patch) | |
tree | 7f710ade0d6b32df9f2e7401bcfdaf0ec256ae96 | |
parent | 802603572c77591183a6ef27163137aff88ee1dd (diff) | |
download | frameworks_base-eb2727bb2f0f32016ca7c4bdd2c0a79eec8cb80a.zip frameworks_base-eb2727bb2f0f32016ca7c4bdd2c0a79eec8cb80a.tar.gz frameworks_base-eb2727bb2f0f32016ca7c4bdd2c0a79eec8cb80a.tar.bz2 |
Volume: new coat of paint.
- Two sections (lighter header, darker detail) like QS.
- Fewer text variants.
- Remove backgrounds for segmented buttons.
- Remove alarm warning background.
- Fix slider-only style.
- Ensure all touch-targets are 48dp.
Bug:16419191
Change-Id: I220f3a736eba3dd7a1b9ff58a8fe4bf3d21db61a
17 files changed, 181 insertions, 268 deletions
diff --git a/packages/SystemUI/res/drawable/qs_panel_background.xml b/packages/SystemUI/res/drawable/qs_background_primary.xml index b4e311f..b4e311f 100644 --- a/packages/SystemUI/res/drawable/qs_panel_background.xml +++ b/packages/SystemUI/res/drawable/qs_background_primary.xml diff --git a/packages/SystemUI/res/drawable/zen_alarm_hard_background.xml b/packages/SystemUI/res/drawable/qs_background_secondary.xml index 3620212..3662e5a 100644 --- a/packages/SystemUI/res/drawable/zen_alarm_hard_background.xml +++ b/packages/SystemUI/res/drawable/qs_background_secondary.xml @@ -14,7 +14,7 @@ limitations under the License. --> <shape xmlns:android="http://schemas.android.com/apk/res/android"> - <solid android:color="@color/system_warning_color" /> + <solid android:color="@color/system_secondary_color" /> <corners android:topLeftRadius="0dp" android:topRightRadius="0dp" diff --git a/packages/SystemUI/res/drawable/segmented_button.xml b/packages/SystemUI/res/drawable/segmented_button.xml deleted file mode 100644 index 9669985..0000000 --- a/packages/SystemUI/res/drawable/segmented_button.xml +++ /dev/null @@ -1,27 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - Copyright (C) 2014 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. ---> -<selector xmlns:android="http://schemas.android.com/apk/res/android"> - <item android:state_selected="true"> - <shape android:shape="rectangle"> - <solid android:color="@color/segmented_button_selected" /> - <corners android:radius="@dimen/segmented_button_radius" /> - </shape> - </item> - <item> - <ripple android:color="@color/segmented_button_selected" /> - </item> -</selector>
\ No newline at end of file diff --git a/packages/SystemUI/res/drawable/segmented_buttons.xml b/packages/SystemUI/res/drawable/segmented_buttons.xml deleted file mode 100644 index bfbac97..0000000 --- a/packages/SystemUI/res/drawable/segmented_buttons.xml +++ /dev/null @@ -1,21 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - Copyright (C) 2014 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. ---> -<shape xmlns:android="http://schemas.android.com/apk/res/android" - android:shape="rectangle" > - <solid android:color="@color/segmented_button_background" /> - <corners android:radius="@dimen/segmented_button_radius" /> -</shape>
\ No newline at end of file diff --git a/packages/SystemUI/res/drawable/zen_alarm_soft_background.xml b/packages/SystemUI/res/drawable/zen_alarm_soft_background.xml deleted file mode 100644 index a99c79c..0000000 --- a/packages/SystemUI/res/drawable/zen_alarm_soft_background.xml +++ /dev/null @@ -1,23 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2014 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. ---> -<shape xmlns:android="http://schemas.android.com/apk/res/android"> - <solid android:color="@color/zen_alarm_soft_warning_background" /> - <corners - android:topLeftRadius="0dp" - android:topRightRadius="0dp" - android:bottomLeftRadius="@dimen/notification_material_rounded_rect_radius" - android:bottomRightRadius="@dimen/notification_material_rounded_rect_radius"/> -</shape> diff --git a/packages/SystemUI/res/layout/qs_panel.xml b/packages/SystemUI/res/layout/qs_panel.xml index d0a07ad..087bf07 100644 --- a/packages/SystemUI/res/layout/qs_panel.xml +++ b/packages/SystemUI/res/layout/qs_panel.xml @@ -18,7 +18,7 @@ android:id="@+id/quick_settings_container" android:layout_width="match_parent" android:layout_height="wrap_content" - android:background="@drawable/qs_panel_background" + android:background="@drawable/qs_background_primary" android:elevation="2dp"> <com.android.systemui.qs.QSPanel diff --git a/packages/SystemUI/res/layout/segmented_button.xml b/packages/SystemUI/res/layout/segmented_button.xml index 538e434..9953b46 100644 --- a/packages/SystemUI/res/layout/segmented_button.xml +++ b/packages/SystemUI/res/layout/segmented_button.xml @@ -20,7 +20,7 @@ android:layout_marginStart="@dimen/segmented_button_spacing" android:layout_weight="1" android:textColor="@color/segmented_button_text_selector" - android:background="@drawable/segmented_button" + android:background="@drawable/btn_borderless_rect" android:textAppearance="@style/TextAppearance.QS.SegmentedButton" - android:minHeight="0dp" + android:minHeight="36dp" android:padding="10dp" /> diff --git a/packages/SystemUI/res/layout/volume_dialog.xml b/packages/SystemUI/res/layout/volume_dialog.xml index 7bd0aea..112f3a9 100644 --- a/packages/SystemUI/res/layout/volume_dialog.xml +++ b/packages/SystemUI/res/layout/volume_dialog.xml @@ -17,7 +17,7 @@ <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="@dimen/volume_panel_width" android:layout_height="wrap_content" - android:background="@drawable/qs_panel_background" + android:background="@drawable/qs_background_primary" android:translationZ="@dimen/volume_panel_z" android:layout_marginBottom="@dimen/volume_panel_z"> diff --git a/packages/SystemUI/res/layout/volume_panel.xml b/packages/SystemUI/res/layout/volume_panel.xml index 6416308..c85a750 100644 --- a/packages/SystemUI/res/layout/volume_panel.xml +++ b/packages/SystemUI/res/layout/volume_panel.xml @@ -18,20 +18,21 @@ android:id="@+id/visible_panel" android:layout_width="match_parent" android:layout_height="wrap_content" - android:paddingTop="8dp" android:orientation="vertical" > <FrameLayout android:id="@+id/slider_panel" android:layout_width="match_parent" android:layout_height="wrap_content" + android:background="@color/system_secondary_color" + android:paddingTop="12dp" + android:paddingLeft="8dp" + android:paddingRight="8dp" android:clipChildren="false" /> - <ViewStub - android:id="@+id/zen_panel_stub" + <include android:layout_width="match_parent" android:layout_height="wrap_content" - android:inflatedId="@+id/zen_panel" - android:layout="@layout/zen_mode_panel" /> + layout="@layout/zen_mode_panel" /> </LinearLayout>
\ No newline at end of file diff --git a/packages/SystemUI/res/layout/volume_panel_item.xml b/packages/SystemUI/res/layout/volume_panel_item.xml index b1dd237..18b496c 100644 --- a/packages/SystemUI/res/layout/volume_panel_item.xml +++ b/packages/SystemUI/res/layout/volume_panel_item.xml @@ -23,22 +23,20 @@ <ImageView android:id="@+id/stream_icon" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:contentDescription="@null" - android:paddingBottom="10dip" - android:paddingLeft="16dip" - android:paddingRight="16dip" - android:paddingTop="10dip" /> + android:layout_width="48dp" + android:layout_height="48dp" + android:scaleType="center" + android:background="@drawable/btn_borderless_rect" + android:contentDescription="@null" /> <SeekBar android:id="@+id/seekbar" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" - android:paddingBottom="0dip" - android:paddingEnd="17dip" - android:paddingStart="0dip" + android:paddingBottom="0dp" + android:paddingEnd="16dp" + android:paddingStart="8dp" android:paddingTop="0dip" /> </LinearLayout>
\ No newline at end of file diff --git a/packages/SystemUI/res/layout/zen_mode_panel.xml b/packages/SystemUI/res/layout/zen_mode_panel.xml index b0e43fc..aa8d114 100644 --- a/packages/SystemUI/res/layout/zen_mode_panel.xml +++ b/packages/SystemUI/res/layout/zen_mode_panel.xml @@ -19,51 +19,59 @@ android:id="@+id/zen_mode_panel" android:layout_width="match_parent" android:layout_height="wrap_content" - android:background="@drawable/qs_panel_background" android:clipChildren="false" - android:orientation="vertical" - android:paddingBottom="@dimen/qs_panel_padding" > + android:orientation="vertical" > - <com.android.systemui.volume.SegmentedButtons - android:id="@+id/zen_buttons" + <FrameLayout android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginLeft="@dimen/qs_panel_padding" - android:layout_marginRight="@dimen/qs_panel_padding" - android:layout_marginTop="12dp" - android:background="@drawable/segmented_buttons" - android:clipChildren="false" /> + android:minHeight="12dp" + 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="@dimen/qs_panel_padding" + android:layout_marginRight="@dimen/qs_panel_padding" + android:layout_marginTop="8dp" + android:layout_marginBottom="12dp" + android:clipChildren="false" /> + </FrameLayout> <FrameLayout android:id="@+id/zen_subhead" android:layout_width="match_parent" - android:layout_height="wrap_content" - android:paddingLeft="@dimen/qs_panel_padding" - android:paddingRight="@dimen/qs_panel_padding" - android:paddingTop="@dimen/qs_panel_padding" > + android:layout_height="62dp" + android:paddingLeft="8dp" + android:paddingRight="8dp" > <TextView android:id="@+id/zen_subhead_collapsed" android:layout_width="wrap_content" - android:layout_height="32dp" + android:layout_height="48dp" + android:layout_gravity="center_vertical" + android:gravity="center_vertical" + android:paddingLeft="8dp" android:background="@drawable/btn_borderless_rect" android:clickable="true" android:drawableEnd="@drawable/qs_subhead_caret" - android:gravity="center_vertical" android:textAppearance="@style/TextAppearance.QS.Subhead" /> <TextView android:id="@+id/zen_subhead_expanded" android:layout_width="wrap_content" - android:layout_height="32dp" + android:layout_height="48dp" + android:layout_gravity="center_vertical" android:gravity="center_vertical" + android:paddingLeft="8dp" android:textAppearance="@style/TextAppearance.QS.Subhead" /> <ImageView android:id="@+id/zen_more_settings" - android:layout_width="32dp" - android:layout_height="32dp" - android:layout_gravity="end" + android:layout_width="48dp" + android:layout_height="48dp" + android:layout_gravity="end|center_vertical" android:background="@drawable/btn_borderless_rect" android:clickable="true" android:contentDescription="@null" @@ -76,15 +84,16 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" - android:paddingTop="3dp" /> + android:paddingBottom="@dimen/qs_panel_padding" /> <TextView android:id="@+id/zen_alarm_warning" android:layout_width="match_parent" - android:layout_height="48dp" - android:layout_marginTop="@dimen/qs_panel_padding" + android:layout_height="wrap_content" + android:layout_marginBottom="@dimen/qs_panel_padding" android:paddingLeft="@dimen/qs_panel_padding" android:paddingRight="@dimen/qs_panel_padding" - android:gravity="center_vertical" - android:textAppearance="@style/TextAppearance.QS.DetailEmpty" /> + android:paddingTop="4dp" + android:paddingBottom="4dp" + android:textAppearance="@style/TextAppearance.QS.Subhead" /> </com.android.systemui.volume.ZenModePanel>
\ No newline at end of file diff --git a/packages/SystemUI/res/values/colors.xml b/packages/SystemUI/res/values/colors.xml index f23486e..627f11c 100644 --- a/packages/SystemUI/res/values/colors.xml +++ b/packages/SystemUI/res/values/colors.xml @@ -34,17 +34,15 @@ <color name="batterymeter_charge_color">#FFFFFFFF</color> <color name="batterymeter_bolt_color">#FFFFFFFF</color> <color name="qs_batterymeter_frame_color">#FF404040</color> - <color name="system_primary_color">#ff263238</color> + <color name="system_primary_color">#ff263238</color><!-- blue grey 900 --> <color name="system_secondary_color">#ff384248</color> <color name="system_accent_color">#ff80CBC4</color><!-- deep teal 200 --> <color name="system_warning_color">#fff4511e</color><!-- deep orange 600 --> <color name="qs_text">#FFFFFFFF</color> <color name="qs_tile_divider">#29ffffff</color><!-- 16% white --> <color name="qs_tile_text">#B3FFFFFF</color><!-- 70% white --> - <color name="qs_subhead">#66FFFFFF</color><!-- 40% white --> + <color name="qs_subhead">#99FFFFFF</color><!-- 60% white --> <color name="qs_detail_empty">#24B0BEC5</color><!-- 14% blue grey 200--> - <color name="zen_alarm_soft_warning_text">#99FFFFFF</color><!-- 60% white --> - <color name="zen_alarm_soft_warning_background">#15FFFFFF</color><!-- 8% white --> <color name="data_usage_secondary">#99FFFFFF</color><!-- 60% white --> <color name="data_usage_graph_track">#33FFFFFF</color><!-- 20% white --> <color name="data_usage_graph_warning">#FFFFFFFF</color> @@ -94,7 +92,5 @@ <!-- The color of the circle around the primary user in the user switcher --> <color name="current_user_border_color">@color/system_accent_color</color> - <color name="segmented_button_selected">#ff3d4549</color><!-- #33afbdc4 = 20% #afbdc4 = #ff3d4549 composite --> - <color name="segmented_button_background">#ff21272b</color> - <color name="segmented_button_text_inactive">#b3afbdc4</color><!-- 70% --> + <color name="segmented_button_text_inactive">#99afbdc4</color><!-- 60% --> </resources> diff --git a/packages/SystemUI/res/values/styles.xml b/packages/SystemUI/res/values/styles.xml index 419ecc7..abf9337 100644 --- a/packages/SystemUI/res/values/styles.xml +++ b/packages/SystemUI/res/values/styles.xml @@ -186,12 +186,11 @@ <style name="TextAppearance.QS.Subhead"> <item name="android:textSize">14sp</item> - <item name="android:fontFamily">sans-serif-medium</item> <item name="android:textColor">@color/qs_subhead</item> </style> <style name="TextAppearance.QS.SegmentedButton"> - <item name="android:textSize">12sp</item> + <item name="android:textSize">14sp</item> <item name="android:textAllCaps">true</item> <item name="android:fontFamily">sans-serif-medium</item> </style> diff --git a/packages/SystemUI/src/com/android/systemui/volume/SegmentedButtons.java b/packages/SystemUI/src/com/android/systemui/volume/SegmentedButtons.java index d339dd4..6d30bce 100644 --- a/packages/SystemUI/src/com/android/systemui/volume/SegmentedButtons.java +++ b/packages/SystemUI/src/com/android/systemui/volume/SegmentedButtons.java @@ -17,17 +17,21 @@ 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; import android.widget.Button; import android.widget.LinearLayout; +import android.widget.TextView; import com.android.systemui.R; import java.util.Objects; public class SegmentedButtons extends LinearLayout { + private static final Typeface MEDIUM = Typeface.create("sans-serif-medium", Typeface.NORMAL); + private static final Typeface BOLD = Typeface.create("sans-serif", Typeface.BOLD); private final Context mContext; private final LayoutInflater mInflater; @@ -54,9 +58,11 @@ public class SegmentedButtons extends LinearLayout { if (Objects.equals(value, mSelectedValue)) return; mSelectedValue = value; for (int i = 0; i < getChildCount(); i++) { - final View c = getChildAt(i); + final TextView c = (TextView) getChildAt(i); final Object tag = c.getTag(); - c.setSelected(Objects.equals(mSelectedValue, tag)); + final boolean selected = Objects.equals(mSelectedValue, tag); + c.setSelected(selected); + c.setTypeface(selected ? BOLD : MEDIUM); } fireOnSelected(); } diff --git a/packages/SystemUI/src/com/android/systemui/volume/VolumePanel.java b/packages/SystemUI/src/com/android/systemui/volume/VolumePanel.java index fc530d0..55851fc 100644 --- a/packages/SystemUI/src/com/android/systemui/volume/VolumePanel.java +++ b/packages/SystemUI/src/com/android/systemui/volume/VolumePanel.java @@ -130,18 +130,14 @@ public class VolumePanel extends Handler { /** Volume panel content view */ private final View mView; - /** Dialog hosting the panel, if not embedded */ + /** Dialog hosting the panel */ private final Dialog mDialog; - /** Parent view hosting the panel, if embedded */ - private final ViewGroup mParent; /** The visible portion of the volume overlay */ private final ViewGroup mPanel; /** Contains the slider and its touchable icons */ private final ViewGroup mSliderPanel; - /** The zen mode configuration panel view stub */ - private final ViewStub mZenPanelStub; - /** The zen mode configuration panel view, once inflated */ + /** The zen mode configuration panel view */ private ZenModePanel mZenPanel; private Callback mCallback; @@ -276,10 +272,9 @@ public class VolumePanel extends Handler { } - public VolumePanel(Context context, ViewGroup parent, ZenModeController zenController) { - mTag = String.format("%s.%s.%08x", TAG, parent == null ? "Dialog" : "Embed", hashCode()); + public VolumePanel(Context context, ZenModeController zenController) { + mTag = String.format("%s.%08x", TAG, hashCode()); mContext = context; - mParent = parent; mZenController = zenController; mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); @@ -292,71 +287,65 @@ public class VolumePanel extends Handler { streamRes.show = (streamRes.streamType == STREAM_MASTER); } } - if (LOGD) Log.d(mTag, String.format("new VolumePanel hasParent=%s", parent != null)); - if (parent == null) { - // dialog mode - mDialog = new Dialog(context) { - @Override - public boolean onTouchEvent(MotionEvent event) { - if (isShowing() && event.getAction() == MotionEvent.ACTION_OUTSIDE && - sConfirmSafeVolumeDialog == null) { - forceTimeout(0); - return true; - } - return false; - } - }; - - // Change some window properties - final Window window = mDialog.getWindow(); - final LayoutParams lp = window.getAttributes(); - lp.token = null; - // Offset from the top - lp.y = res.getDimensionPixelOffset(com.android.systemui.R.dimen.volume_panel_top); - lp.type = LayoutParams.TYPE_STATUS_BAR_PANEL; - lp.format = PixelFormat.TRANSLUCENT; - lp.windowAnimations = com.android.systemui.R.style.VolumePanelAnimation; - lp.gravity = Gravity.TOP; - window.setAttributes(lp); - window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); - window.requestFeature(Window.FEATURE_NO_TITLE); - window.addFlags(LayoutParams.FLAG_NOT_FOCUSABLE - | LayoutParams.FLAG_NOT_TOUCH_MODAL - | LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH - | LayoutParams.FLAG_HARDWARE_ACCELERATED); - mDialog.setCanceledOnTouchOutside(true); - mDialog.setContentView(com.android.systemui.R.layout.volume_dialog); - mDialog.setOnDismissListener(new OnDismissListener() { - @Override - public void onDismiss(DialogInterface dialog) { - mActiveStreamType = -1; - mAudioManager.forceVolumeControlStream(mActiveStreamType); - setZenPanelVisible(false); - } - }); - - mDialog.create(); - // temporary workaround, until we support window-level shadows - mDialog.getWindow().setBackgroundDrawable(new ColorDrawable(0x00000000)); - - mView = window.findViewById(R.id.content); - mView.setOnTouchListener(new View.OnTouchListener() { - @Override - public boolean onTouch(View v, MotionEvent event) { - resetTimeout(); - return false; + if (LOGD) Log.d(mTag, "new VolumePanel"); + + mDialog = new Dialog(context) { + @Override + public boolean onTouchEvent(MotionEvent event) { + if (isShowing() && event.getAction() == MotionEvent.ACTION_OUTSIDE && + sConfirmSafeVolumeDialog == null) { + forceTimeout(0); + return true; } - }); + return false; + } + }; + + // Change some window properties + final Window window = mDialog.getWindow(); + final LayoutParams lp = window.getAttributes(); + lp.token = null; + // Offset from the top + lp.y = res.getDimensionPixelOffset(com.android.systemui.R.dimen.volume_panel_top); + lp.type = LayoutParams.TYPE_STATUS_BAR_PANEL; + lp.format = PixelFormat.TRANSLUCENT; + lp.windowAnimations = com.android.systemui.R.style.VolumePanelAnimation; + lp.gravity = Gravity.TOP; + window.setAttributes(lp); + window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); + window.requestFeature(Window.FEATURE_NO_TITLE); + window.addFlags(LayoutParams.FLAG_NOT_FOCUSABLE + | LayoutParams.FLAG_NOT_TOUCH_MODAL + | LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH + | LayoutParams.FLAG_HARDWARE_ACCELERATED); + mDialog.setCanceledOnTouchOutside(true); + mDialog.setContentView(com.android.systemui.R.layout.volume_dialog); + mDialog.setOnDismissListener(new OnDismissListener() { + @Override + public void onDismiss(DialogInterface dialog) { + mActiveStreamType = -1; + mAudioManager.forceVolumeControlStream(mActiveStreamType); + setZenPanelVisible(false); + } + }); + + mDialog.create(); + // temporary workaround, until we support window-level shadows + mDialog.getWindow().setBackgroundDrawable(new ColorDrawable(0x00000000)); + + mView = window.findViewById(R.id.content); + mView.setOnTouchListener(new View.OnTouchListener() { + @Override + public boolean onTouch(View v, MotionEvent event) { + resetTimeout(); + return false; + } + }); - } else { - // embedded mode - mDialog = null; - mView = LayoutInflater.from(mContext).inflate( - com.android.systemui.R.layout.volume_panel, parent, false); - } mPanel = (ViewGroup) mView.findViewById(com.android.systemui.R.id.visible_panel); mSliderPanel = (ViewGroup) mView.findViewById(com.android.systemui.R.id.slider_panel); - mZenPanelStub = (ViewStub)mView.findViewById(com.android.systemui.R.id.zen_panel_stub); + mZenPanel = (ZenModePanel) mView.findViewById(com.android.systemui.R.id.zen_mode_panel); + initZenModePanel(); mToneGenerators = new ToneGenerator[AudioSystem.getNumStreamTypes()]; mVibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE); @@ -373,8 +362,29 @@ public class VolumePanel extends Handler { listenToRingerMode(); } - public View getContentView() { - return mView; + private void initZenModePanel() { + mZenPanel.init(mZenController); + mZenPanel.setCallback(new ZenModePanel.Callback() { + @Override + public void onMoreSettings() { + if (mCallback != null) { + mCallback.onZenSettings(); + } + } + + @Override + public void onInteraction() { + resetTimeout(); + } + + @Override + public void onExpanded(boolean expanded) { + if (mZenPanelExpanded == expanded) return; + mZenPanelExpanded = expanded; + updateTimeoutDelay(); + resetTimeout(); + } + }); } private void setLayoutDirection(int layoutDirection) { @@ -612,37 +622,10 @@ public class VolumePanel extends Handler { if (LOGD) Log.d(mTag, "setZenPanelVisible " + visible + " mZenPanel=" + mZenPanel); final boolean changing = visible != isZenPanelVisible(); if (visible) { - if (mZenPanel == null) { - mZenPanel = (ZenModePanel) mZenPanelStub.inflate(); - mZenPanel.init(mZenController, mDialog != null ? 'D' : 'E'); - mZenPanel.setCallback(new ZenModePanel.Callback() { - @Override - public void onMoreSettings() { - if (mCallback != null) { - mCallback.onZenSettings(); - } - } - - @Override - public void onInteraction() { - resetTimeout(); - } - - @Override - public void onExpanded(boolean expanded) { - if (mZenPanelExpanded == expanded) return; - mZenPanelExpanded = expanded; - updateTimeoutDelay(); - resetTimeout(); - } - }); - } - mZenPanel.setVisibility(View.VISIBLE); + mZenPanel.setHidden(false); resetTimeout(); } else { - if (mZenPanel != null) { - mZenPanel.setVisibility(View.GONE); - } + mZenPanel.setHidden(true); } if (changing) { updateTimeoutDelay(); @@ -913,11 +896,9 @@ public class VolumePanel extends Handler { // when the stream is for remote playback, use -1 to reset the stream type evaluation mAudioManager.forceVolumeControlStream(stream); - if (mDialog != null) { - mDialog.show(); - if (mCallback != null) { - mCallback.onVisible(true); - } + mDialog.show(); + if (mCallback != null) { + mCallback.onVisible(true); } } @@ -936,7 +917,7 @@ public class VolumePanel extends Handler { } private boolean isShowing() { - return mDialog != null ? mDialog.isShowing() : mParent.isAttachedToWindow(); + return mDialog.isShowing(); } protected void onPlaySound(int streamType, int flags) { @@ -1166,13 +1147,11 @@ public class VolumePanel extends Handler { case MSG_TIMEOUT: { if (isShowing()) { - if (mDialog != null) { - mDialog.dismiss(); - clearRemoteStreamController(); - mActiveStreamType = -1; - if (mCallback != null) { - mCallback.onVisible(false); - } + mDialog.dismiss(); + clearRemoteStreamController(); + mActiveStreamType = -1; + if (mCallback != null) { + mCallback.onVisible(false); } } synchronized (sConfirmSafeVolumeLock) { diff --git a/packages/SystemUI/src/com/android/systemui/volume/VolumeUI.java b/packages/SystemUI/src/com/android/systemui/volume/VolumeUI.java index 6d6fd60..d3f4db6 100644 --- a/packages/SystemUI/src/com/android/systemui/volume/VolumeUI.java +++ b/packages/SystemUI/src/com/android/systemui/volume/VolumeUI.java @@ -84,7 +84,7 @@ public class VolumeUI extends SystemUI { private void initPanel() { mDismissDelay = mContext.getResources().getInteger(R.integer.volume_panel_dismiss_delay); - mPanel = new VolumePanel(mContext, null, new ZenModeControllerImpl(mContext, mHandler)); + mPanel = new VolumePanel(mContext, new ZenModeControllerImpl(mContext, mHandler)); mPanel.setCallback(new VolumePanel.Callback() { @Override public void onZenSettings() { diff --git a/packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java b/packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java index 7473c41..191f993 100644 --- a/packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java +++ b/packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java @@ -84,8 +84,7 @@ public class ZenModePanel extends LinearLayout { private final int mHardWarningColor; private final int mSoftWarningColor; - private char mLogTag = '?'; - private String mTag; + private String mTag = TAG + "/" + Integer.toHexString(System.identityHashCode(this)); private SegmentedButtons mZenButtons; private View mZenSubhead; @@ -95,13 +94,13 @@ public class ZenModePanel extends LinearLayout { private LinearLayout mZenConditions; private TextView mAlarmWarning; - private int mBottomPadding; private Callback mCallback; private ZenModeController mController; private boolean mRequestingConditions; private Uri mExitConditionId; private int mBucketIndex = -1; private boolean mExpanded; + private boolean mHidden = false; private int mSessionZen; private Uri mSessionExitConditionId; private String mExitConditionText; @@ -115,22 +114,15 @@ public class ZenModePanel extends LinearLayout { mFastOutSlowInInterpolator = AnimationUtils.loadInterpolator(mContext, android.R.interpolator.fast_out_slow_in); final Resources res = mContext.getResources(); - mHardWarningColor = res.getColor(R.color.qs_text); - mSoftWarningColor = res.getColor(R.color.zen_alarm_soft_warning_text); - updateTag(); + mHardWarningColor = res.getColor(R.color.system_warning_color); + mSoftWarningColor = res.getColor(R.color.qs_subhead); if (DEBUG) Log.d(mTag, "new ZenModePanel"); } - private void updateTag() { - mTag = TAG + "/" + mLogTag + "/" + Integer.toHexString(System.identityHashCode(this)); - } - @Override protected void onFinishInflate() { super.onFinishInflate(); - mBottomPadding = getPaddingBottom(); - mZenButtons = (SegmentedButtons) findViewById(R.id.zen_buttons); mZenButtons.addButton(R.string.interruption_level_none, Global.ZEN_MODE_NO_INTERRUPTIONS); mZenButtons.addButton(R.string.interruption_level_priority, @@ -184,6 +176,12 @@ public class ZenModePanel extends LinearLayout { setExpanded(false); } + public void setHidden(boolean hidden) { + if (mHidden == hidden) return; + mHidden = hidden; + updateWidgets(); + } + private void setExpanded(boolean expanded) { if (expanded == mExpanded) return; mExpanded = expanded; @@ -217,10 +215,8 @@ public class ZenModePanel extends LinearLayout { } } - public void init(ZenModeController controller, char logTag) { + public void init(ZenModeController controller) { mController = controller; - mLogTag = logTag; - updateTag(); setExitConditionId(mController.getExitConditionId()); refreshExitConditionText(); mSessionZen = getSelectedZen(-1); @@ -290,15 +286,17 @@ public class ZenModePanel extends LinearLayout { final boolean zenNone = zen == Global.ZEN_MODE_NO_INTERRUPTIONS; final boolean foreverSelected = mExitConditionId == null; final boolean hasNextAlarm = mNextAlarm != 0; - final boolean showAlarmWarning = zenNone && mExpanded && hasNextAlarm; - - mZenSubhead.setVisibility(!zenOff && (mExpanded || !foreverSelected) ? VISIBLE : GONE); - mZenSubheadExpanded.setVisibility(mExpanded ? VISIBLE : GONE); - mZenSubheadCollapsed.setVisibility(!mExpanded ? VISIBLE : GONE); - mMoreSettings.setVisibility(zenImportant && mExpanded ? VISIBLE : GONE); - mZenConditions.setVisibility(!zenOff && mExpanded ? VISIBLE : GONE); - mAlarmWarning.setVisibility(zenNone && mExpanded && hasNextAlarm ? VISIBLE : GONE); - setPadding(0, 0, 0, showAlarmWarning ? 0 : mBottomPadding); + final boolean expanded = !mHidden && mExpanded; + final boolean showAlarmWarning = zenNone && expanded && hasNextAlarm; + + mZenButtons.setVisibility(mHidden ? GONE : VISIBLE); + mZenSubhead.setVisibility(!mHidden && !zenOff && (expanded || !foreverSelected) ? VISIBLE + : GONE); + mZenSubheadExpanded.setVisibility(expanded ? VISIBLE : GONE); + mZenSubheadCollapsed.setVisibility(!expanded ? VISIBLE : GONE); + mMoreSettings.setVisibility(zenImportant && expanded ? VISIBLE : GONE); + mZenConditions.setVisibility(!zenOff && expanded ? VISIBLE : GONE); + mAlarmWarning.setVisibility(zenNone && expanded && hasNextAlarm ? VISIBLE : GONE); if (showAlarmWarning) { final long exitTime = ZenModeConfig.tryParseCountdownConditionId(mExitConditionId); final long now = System.currentTimeMillis(); @@ -311,13 +309,11 @@ public class ZenModePanel extends LinearLayout { if (isWarning) { mAlarmWarning.setText(mContext.getString(R.string.zen_alarm_warning, alarm)); mAlarmWarning.setTextColor(mHardWarningColor); - mAlarmWarning.setBackgroundResource(R.drawable.zen_alarm_hard_background); } else { mAlarmWarning.setText(mContext.getString(alarmToday ? R.string.zen_alarm_information_time : R.string.zen_alarm_information_day_time, alarm)); mAlarmWarning.setTextColor(mSoftWarningColor); - mAlarmWarning.setBackgroundResource(R.drawable.zen_alarm_soft_background); } } |