diff --git a/packages/SystemUI/res/drawable/qs_panel_background.xml b/packages/SystemUI/res/drawable/qs_background_primary.xml similarity index 100% rename from packages/SystemUI/res/drawable/qs_panel_background.xml rename to 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 similarity index 94% rename from packages/SystemUI/res/drawable/zen_alarm_hard_background.xml rename to packages/SystemUI/res/drawable/qs_background_secondary.xml index 36202127d6c26..3662e5a7e3016 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. --> - + - - - - - - - - - - - - \ 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 bfbac971b8dae..0000000000000 --- a/packages/SystemUI/res/drawable/segmented_buttons.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - \ 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 a99c79c371d74..0000000000000 --- a/packages/SystemUI/res/drawable/zen_alarm_soft_background.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - diff --git a/packages/SystemUI/res/layout/qs_panel.xml b/packages/SystemUI/res/layout/qs_panel.xml index d0a07ad36aa14..087bf078676e7 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"> diff --git a/packages/SystemUI/res/layout/volume_dialog.xml b/packages/SystemUI/res/layout/volume_dialog.xml index 7bd0aea6c3125..112f3a92efe59 100644 --- a/packages/SystemUI/res/layout/volume_dialog.xml +++ b/packages/SystemUI/res/layout/volume_dialog.xml @@ -17,7 +17,7 @@ diff --git a/packages/SystemUI/res/layout/volume_panel.xml b/packages/SystemUI/res/layout/volume_panel.xml index 641630809e34b..c85a7501d8b69 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" > - + layout="@layout/zen_mode_panel" /> \ 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 b1dd237e81881..18b496c133996 100644 --- a/packages/SystemUI/res/layout/volume_panel_item.xml +++ b/packages/SystemUI/res/layout/volume_panel_item.xml @@ -23,22 +23,20 @@ + android:layout_width="48dp" + android:layout_height="48dp" + android:scaleType="center" + android:background="@drawable/btn_borderless_rect" + android:contentDescription="@null" /> \ 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 b0e43fcabcbef..aa8d1146f0f82 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" > - + android:minHeight="12dp" + android:background="@drawable/qs_background_secondary" > + + + + android:layout_height="62dp" + android:paddingLeft="8dp" + android:paddingRight="8dp" > + android:paddingBottom="@dimen/qs_panel_padding" /> + android:paddingTop="4dp" + android:paddingBottom="4dp" + android:textAppearance="@style/TextAppearance.QS.Subhead" /> \ No newline at end of file diff --git a/packages/SystemUI/res/values/colors.xml b/packages/SystemUI/res/values/colors.xml index f23486eb77bae..627f11cfe170b 100644 --- a/packages/SystemUI/res/values/colors.xml +++ b/packages/SystemUI/res/values/colors.xml @@ -34,17 +34,15 @@ #FFFFFFFF #FFFFFFFF #FF404040 - #ff263238 + #ff263238 #ff384248 #ff80CBC4 #fff4511e #FFFFFFFF #29ffffff #B3FFFFFF - #66FFFFFF + #99FFFFFF #24B0BEC5 - #99FFFFFF - #15FFFFFF #99FFFFFF #33FFFFFF #FFFFFFFF @@ -94,7 +92,5 @@ @color/system_accent_color - #ff3d4549 - #ff21272b - #b3afbdc4 + #99afbdc4 diff --git a/packages/SystemUI/res/values/styles.xml b/packages/SystemUI/res/values/styles.xml index 419ecc77e5a4b..abf9337d6ec72 100644 --- a/packages/SystemUI/res/values/styles.xml +++ b/packages/SystemUI/res/values/styles.xml @@ -186,12 +186,11 @@ diff --git a/packages/SystemUI/src/com/android/systemui/volume/SegmentedButtons.java b/packages/SystemUI/src/com/android/systemui/volume/SegmentedButtons.java index d339dd40cbaeb..6d30bce61da22 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 fc530d02f0964..55851fcb32a54 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; + 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); - } - }); + // 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)); + 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; - } - }); + 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 6d6fd60ec1893..d3f4db65a40ff 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 7473c41584c11..191f9933dc585 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; + final boolean expanded = !mHidden && mExpanded; + final boolean showAlarmWarning = zenNone && expanded && 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); + 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); } }