diff options
Diffstat (limited to 'packages/SystemUI/src')
4 files changed, 124 insertions, 143 deletions
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); } } |