Loading packages/SystemUI/res/layout/volume_dialog.xml +1 −1 Original line number Original line Diff line number Diff line Loading @@ -18,7 +18,7 @@ android:id="@+id/volume_dialog" android:id="@+id/volume_dialog" android:layout_width="match_parent" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="4dp" android:layout_marginBottom="@dimen/volume_dialog_margin_bottom" android:layout_marginLeft="@dimen/notification_side_padding" android:layout_marginLeft="@dimen/notification_side_padding" android:layout_marginRight="@dimen/notification_side_padding" android:layout_marginRight="@dimen/notification_side_padding" android:background="@drawable/volume_dialog_background" android:background="@drawable/volume_dialog_background" Loading packages/SystemUI/res/layout/volume_dialog_row.xml +1 −0 Original line number Original line Diff line number Diff line Loading @@ -17,6 +17,7 @@ android:layout_width="match_parent" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_height="wrap_content" android:clipChildren="false" android:clipChildren="false" android:id="@+id/volume_dialog_row" android:paddingEnd="8dp" android:paddingEnd="8dp" android:paddingStart="8dp" > android:paddingStart="8dp" > Loading packages/SystemUI/res/values/dimens.xml +3 −0 Original line number Original line Diff line number Diff line Loading @@ -576,6 +576,9 @@ <!-- Standard image button size for volume dialog buttons --> <!-- Standard image button size for volume dialog buttons --> <dimen name="volume_button_size">48dp</dimen> <dimen name="volume_button_size">48dp</dimen> <!-- Volume dialog root view bottom margin, at rest --> <dimen name="volume_dialog_margin_bottom">4dp</dimen> <!-- Padding between icon and text for managed profile toast --> <!-- Padding between icon and text for managed profile toast --> <dimen name="managed_profile_toast_padding">4dp</dimen> <dimen name="managed_profile_toast_padding">4dp</dimen> Loading packages/SystemUI/res/values/styles.xml +0 −5 Original line number Original line Diff line number Diff line Loading @@ -291,11 +291,6 @@ <item name="android:textColor">#ffb0b3c5</item> <item name="android:textColor">#ffb0b3c5</item> </style> </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"> <style name="VolumeButtons" parent="@android:style/Widget.Material.Button.Borderless"> <item name="android:background">@drawable/btn_borderless_rect</item> <item name="android:background">@drawable/btn_borderless_rect</item> </style> </style> Loading packages/SystemUI/src/com/android/systemui/volume/VolumeDialog.java +99 −18 Original line number Original line Diff line number Diff line Loading @@ -111,6 +111,7 @@ public class VolumeDialog { private final Accessibility mAccessibility = new Accessibility(); private final Accessibility mAccessibility = new Accessibility(); private final ColorStateList mActiveSliderTint; private final ColorStateList mActiveSliderTint; private final ColorStateList mInactiveSliderTint; private final ColorStateList mInactiveSliderTint; private final VolumeDialogMotion mMotion; private boolean mShowing; private boolean mShowing; private boolean mExpanded; private boolean mExpanded; Loading @@ -120,9 +121,12 @@ public class VolumeDialog { private boolean mSilentMode = VolumePrefs.DEFAULT_ENABLE_SILENT_MODE; private boolean mSilentMode = VolumePrefs.DEFAULT_ENABLE_SILENT_MODE; private State mState; private State mState; private int mExpandButtonRes; private int mExpandButtonRes; private boolean mExpanding; private boolean mExpandButtonAnimationRunning; private SafetyWarningDialog mSafetyWarning; private SafetyWarningDialog mSafetyWarning; private Callback mCallback; private Callback mCallback; private boolean mPendingStateChanged; private boolean mPendingRecheckAll; private long mCollapseTime; public VolumeDialog(Context context, int windowType, VolumeDialogController controller, public VolumeDialog(Context context, int windowType, VolumeDialogController controller, ZenModeController zenModeController, Callback callback) { ZenModeController zenModeController, Callback callback) { Loading Loading @@ -151,7 +155,6 @@ public class VolumeDialog { lp.format = PixelFormat.TRANSLUCENT; lp.format = PixelFormat.TRANSLUCENT; lp.setTitle(VolumeDialog.class.getSimpleName()); lp.setTitle(VolumeDialog.class.getSimpleName()); lp.gravity = Gravity.TOP | Gravity.CENTER_HORIZONTAL; lp.gravity = Gravity.TOP | Gravity.CENTER_HORIZONTAL; lp.windowAnimations = R.style.VolumeDialogAnimations; lp.y = res.getDimensionPixelSize(R.dimen.volume_offset_top); lp.y = res.getDimensionPixelSize(R.dimen.volume_offset_top); lp.gravity = Gravity.TOP; lp.gravity = Gravity.TOP; window.setAttributes(lp); window.setAttributes(lp); Loading @@ -168,9 +171,22 @@ public class VolumeDialog { updateExpandButtonH(); updateExpandButtonH(); mLayoutTransition = new LayoutTransition(); mLayoutTransition = new LayoutTransition(); mLayoutTransition.setDuration(new ValueAnimator().getDuration() / 2); mLayoutTransition.setDuration(new ValueAnimator().getDuration() / 2); mLayoutTransition.disableTransitionType(LayoutTransition.DISAPPEARING); mLayoutTransition.disableTransitionType(LayoutTransition.CHANGE_DISAPPEARING); mDialogContentView.setLayoutTransition(mLayoutTransition); mDialogContentView.setLayoutTransition(mLayoutTransition); mMotion = new VolumeDialogMotion(mDialog, mDialogView, mDialogContentView, mExpandButton, new VolumeDialogMotion.Callback() { @Override public void onAnimatingChanged(boolean animating) { if (animating) return; if (mPendingStateChanged) { mHandler.sendEmptyMessage(H.STATE_CHANGED); mPendingStateChanged = false; } if (mPendingRecheckAll) { mHandler.sendEmptyMessage(H.RECHECK_ALL); mPendingRecheckAll = false; } } }); addRow(AudioManager.STREAM_RING, addRow(AudioManager.STREAM_RING, R.drawable.ic_volume_ringer, R.drawable.ic_volume_ringer_mute, true); R.drawable.ic_volume_ringer, R.drawable.ic_volume_ringer_mute, true); Loading Loading @@ -242,6 +258,7 @@ public class VolumeDialog { final VolumeRow row = initRow(stream, iconRes, iconMuteRes, important); final VolumeRow row = initRow(stream, iconRes, iconMuteRes, important); if (!mRows.isEmpty()) { if (!mRows.isEmpty()) { final View v = new View(mContext); final View v = new View(mContext); v.setId(android.R.id.background); final int h = mContext.getResources() final int h = mContext.getResources() .getDimensionPixelSize(R.dimen.volume_slider_interspacing); .getDimensionPixelSize(R.dimen.volume_slider_interspacing); final LinearLayout.LayoutParams lp = final LinearLayout.LayoutParams lp = Loading @@ -253,10 +270,11 @@ public class VolumeDialog { @Override @Override public void onLayoutChange(View v, int left, int top, int right, int bottom, public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { int oldLeft, int oldTop, int oldRight, int oldBottom) { if (D.BUG) Log.d(TAG, "onLayoutChange" final boolean moved = oldLeft != left || oldTop != top; if (D.BUG) Log.d(TAG, "onLayoutChange moved=" + moved + " old=" + new Rect(oldLeft, oldTop, oldRight, oldBottom).toShortString() + " old=" + new Rect(oldLeft, oldTop, oldRight, oldBottom).toShortString() + " new=" + new Rect(left,top,right,bottom).toShortString()); + " new=" + new Rect(left,top,right,bottom).toShortString()); if (oldLeft != left || oldTop != top) { if (moved) { for (int i = 0; i < mDialogContentView.getChildCount(); i++) { for (int i = 0; i < mDialogContentView.getChildCount(); i++) { final View c = mDialogContentView.getChildAt(i); final View c = mDialogContentView.getChildAt(i); if (!c.isShown()) continue; if (!c.isShown()) continue; Loading Loading @@ -302,18 +320,21 @@ public class VolumeDialog { if (D.BUG) Log.d(TAG, "repositionExpandAnim x=" + x + " y=" + y); if (D.BUG) Log.d(TAG, "repositionExpandAnim x=" + x + " y=" + y); mExpandButton.setTranslationX(x); mExpandButton.setTranslationX(x); mExpandButton.setTranslationY(y); mExpandButton.setTranslationY(y); mExpandButton.setTag((Integer) y); } } public void dump(PrintWriter writer) { public void dump(PrintWriter writer) { writer.println(VolumeDialog.class.getSimpleName() + " state:"); writer.println(VolumeDialog.class.getSimpleName() + " state:"); writer.print(" mShowing: "); writer.println(mShowing); writer.print(" mShowing: "); writer.println(mShowing); writer.print(" mExpanded: "); writer.println(mExpanded); writer.print(" mExpanded: "); writer.println(mExpanded); writer.print(" mExpanding: "); writer.println(mExpanding); writer.print(" mExpandButtonAnimationRunning: "); writer.println(mExpandButtonAnimationRunning); writer.print(" mActiveStream: "); writer.println(mActiveStream); writer.print(" mActiveStream: "); writer.println(mActiveStream); writer.print(" mDynamic: "); writer.println(mDynamic); writer.print(" mDynamic: "); writer.println(mDynamic); writer.print(" mShowHeaders: "); writer.println(mShowHeaders); writer.print(" mShowHeaders: "); writer.println(mShowHeaders); writer.print(" mAutomute: "); writer.println(mAutomute); writer.print(" mAutomute: "); writer.println(mAutomute); writer.print(" mSilentMode: "); writer.println(mSilentMode); writer.print(" mSilentMode: "); writer.println(mSilentMode); writer.print(" mCollapseTime: "); writer.println(mCollapseTime); writer.print(" mAccessibility.mFeedbackEnabled: "); writer.print(" mAccessibility.mFeedbackEnabled: "); writer.println(mAccessibility.mFeedbackEnabled); writer.println(mAccessibility.mFeedbackEnabled); } } Loading Loading @@ -412,12 +433,13 @@ public class VolumeDialog { } } private void showH(int reason) { private void showH(int reason) { if (D.BUG) Log.d(TAG, "showH r=" + Events.DISMISS_REASONS[reason]); mHandler.removeMessages(H.SHOW); mHandler.removeMessages(H.SHOW); mHandler.removeMessages(H.DISMISS); mHandler.removeMessages(H.DISMISS); rescheduleTimeoutH(); rescheduleTimeoutH(); if (mShowing) return; if (mShowing) return; mShowing = true; mShowing = true; mDialog.show(); mMotion.startShow(); Events.writeEvent(mContext, Events.EVENT_SHOW_DIALOG, reason, mKeyguard.isKeyguardLocked()); Events.writeEvent(mContext, Events.EVENT_SHOW_DIALOG, reason, mKeyguard.isKeyguardLocked()); mController.notifyVisible(true); mController.notifyVisible(true); } } Loading @@ -434,7 +456,7 @@ public class VolumeDialog { private int computeTimeoutH() { private int computeTimeoutH() { if (mAccessibility.mFeedbackEnabled) return 20000; if (mAccessibility.mFeedbackEnabled) return 20000; if (mSafetyWarning != null) return 5000; if (mSafetyWarning != null) return 5000; if (mExpanded || mExpanding) return 5000; if (mExpanded || mExpandButtonAnimationRunning) return 5000; if (mActiveStream == AudioManager.STREAM_MUSIC) return 1500; if (mActiveStream == AudioManager.STREAM_MUSIC) return 1500; return 3000; return 3000; } } Loading @@ -444,9 +466,13 @@ public class VolumeDialog { mHandler.removeMessages(H.SHOW); mHandler.removeMessages(H.SHOW); if (!mShowing) return; if (!mShowing) return; mShowing = false; mShowing = false; mDialog.dismiss(); mMotion.startDismiss(new Runnable() { Events.writeEvent(mContext, Events.EVENT_DISMISS_DIALOG, reason); @Override public void run() { setExpandedH(false); setExpandedH(false); } }); Events.writeEvent(mContext, Events.EVENT_DISMISS_DIALOG, reason); mController.notifyVisible(false); mController.notifyVisible(false); synchronized (mSafetyWarningLock) { synchronized (mSafetyWarningLock) { if (mSafetyWarning != null) { if (mSafetyWarning != null) { Loading @@ -456,13 +482,40 @@ public class VolumeDialog { } } } } private void updateDialogBottomMarginH() { final long diff = System.currentTimeMillis() - mCollapseTime; final boolean collapsing = mCollapseTime != 0 && diff < getConservativeCollapseDuration(); final ViewGroup.MarginLayoutParams mlp = (MarginLayoutParams) mDialogView.getLayoutParams(); final int bottomMargin = collapsing ? mDialogContentView.getHeight() : mContext.getResources().getDimensionPixelSize(R.dimen.volume_dialog_margin_bottom); if (bottomMargin != mlp.bottomMargin) { if (D.BUG) Log.d(TAG, "bottomMargin " + mlp.bottomMargin + " -> " + bottomMargin); mlp.bottomMargin = bottomMargin; mDialogView.setLayoutParams(mlp); } } private long getConservativeCollapseDuration() { return mExpandButtonAnimationDuration * 3; } private void prepareForCollapse() { mHandler.removeMessages(H.UPDATE_BOTTOM_MARGIN); mCollapseTime = System.currentTimeMillis(); updateDialogBottomMarginH(); mHandler.sendEmptyMessageDelayed(H.UPDATE_BOTTOM_MARGIN, getConservativeCollapseDuration()); } private void setExpandedH(boolean expanded) { private void setExpandedH(boolean expanded) { if (mExpanded == expanded) return; if (mExpanded == expanded) return; mExpanded = expanded; mExpanded = expanded; mExpanding = isAttached(); mExpandButtonAnimationRunning = isAttached(); if (D.BUG) Log.d(TAG, "setExpandedH " + expanded); if (D.BUG) Log.d(TAG, "setExpandedH " + expanded); if (!mExpanded && mExpandButtonAnimationRunning) { prepareForCollapse(); } updateRowsH(); updateRowsH(); if (mExpanding) { if (mExpandButtonAnimationRunning) { final Drawable d = mExpandButton.getDrawable(); final Drawable d = mExpandButton.getDrawable(); if (d instanceof AnimatedVectorDrawable) { if (d instanceof AnimatedVectorDrawable) { // workaround to reset drawable // workaround to reset drawable Loading @@ -473,7 +526,7 @@ public class VolumeDialog { mHandler.postDelayed(new Runnable() { mHandler.postDelayed(new Runnable() { @Override @Override public void run() { public void run() { mExpanding = false; mExpandButtonAnimationRunning = false; updateExpandButtonH(); updateExpandButtonH(); rescheduleTimeoutH(); rescheduleTimeoutH(); } } Loading @@ -484,8 +537,9 @@ public class VolumeDialog { } } private void updateExpandButtonH() { private void updateExpandButtonH() { mExpandButton.setClickable(!mExpanding); if (D.BUG) Log.d(TAG, "updateExpandButtonH"); if (mExpanding && isAttached()) return; mExpandButton.setClickable(!mExpandButtonAnimationRunning); if (mExpandButtonAnimationRunning && isAttached()) return; final int res = mExpanded ? R.drawable.ic_volume_collapse_animation final int res = mExpanded ? R.drawable.ic_volume_collapse_animation : R.drawable.ic_volume_expand_animation; : R.drawable.ic_volume_expand_animation; if (res == mExpandButtonRes) return; if (res == mExpandButtonRes) return; Loading @@ -502,6 +556,7 @@ public class VolumeDialog { } } private void updateRowsH() { private void updateRowsH() { if (D.BUG) Log.d(TAG, "updateRowsH"); final VolumeRow activeRow = getActiveRow(); final VolumeRow activeRow = getActiveRow(); updateFooterH(); updateFooterH(); updateExpandButtonH(); updateExpandButtonH(); Loading Loading @@ -531,6 +586,7 @@ public class VolumeDialog { } } private void trimObsoleteH() { private void trimObsoleteH() { if (D.BUG) Log.d(TAG, "trimObsoleteH"); for (int i = mRows.size() -1; i >= 0; i--) { for (int i = mRows.size() -1; i >= 0; i--) { final VolumeRow row = mRows.get(i); final VolumeRow row = mRows.get(i); if (row.ss == null || !row.ss.dynamic) continue; if (row.ss == null || !row.ss.dynamic) continue; Loading @@ -543,7 +599,13 @@ public class VolumeDialog { } } private void onStateChangedH(State state) { private void onStateChangedH(State state) { final boolean animating = mMotion.isAnimating(); if (D.BUG) Log.d(TAG, "onStateChangedH animating=" + animating); mState = state; mState = state; if (animating) { mPendingStateChanged = true; return; } mDynamic.clear(); mDynamic.clear(); // add any new dynamic rows // add any new dynamic rows for (int i = 0; i < state.states.size(); i++) { for (int i = 0; i < state.states.size(); i++) { Loading @@ -568,11 +630,18 @@ public class VolumeDialog { } } private void updateFooterH() { private void updateFooterH() { Util.setVisOrGone(mZenFooter, mState.zenMode != Global.ZEN_MODE_OFF); if (D.BUG) Log.d(TAG, "updateFooterH"); final boolean wasVisible = mZenFooter.getVisibility() == View.VISIBLE; final boolean visible = mState.zenMode != Global.ZEN_MODE_OFF; if (wasVisible != visible && !visible) { prepareForCollapse(); } Util.setVisOrGone(mZenFooter, visible); mZenFooter.update(); mZenFooter.update(); } } private void updateVolumeRowH(VolumeRow row) { private void updateVolumeRowH(VolumeRow row) { if (D.BUG) Log.d(TAG, "updateVolumeRowH s=" + row.stream); if (mState == null) return; if (mState == null) return; final StreamState ss = mState.states.get(row.stream); final StreamState ss = mState.states.get(row.stream); if (ss == null) return; if (ss == null) return; Loading Loading @@ -841,7 +910,7 @@ public class VolumeDialog { private final OnClickListener mClickExpand = new OnClickListener() { private final OnClickListener mClickExpand = new OnClickListener() { @Override @Override public void onClick(View v) { public void onClick(View v) { if (mExpanding) return; if (mExpandButtonAnimationRunning) return; final boolean newExpand = !mExpanded; final boolean newExpand = !mExpanded; Events.writeEvent(mContext, Events.EVENT_EXPAND, newExpand); Events.writeEvent(mContext, Events.EVENT_EXPAND, newExpand); setExpandedH(newExpand); setExpandedH(newExpand); Loading Loading @@ -870,6 +939,8 @@ public class VolumeDialog { private static final int RECHECK_ALL = 4; private static final int RECHECK_ALL = 4; private static final int SET_STREAM_IMPORTANT = 5; private static final int SET_STREAM_IMPORTANT = 5; private static final int RESCHEDULE_TIMEOUT = 6; private static final int RESCHEDULE_TIMEOUT = 6; private static final int STATE_CHANGED = 7; private static final int UPDATE_BOTTOM_MARGIN = 8; public H() { public H() { super(Looper.getMainLooper()); super(Looper.getMainLooper()); Loading @@ -884,6 +955,8 @@ public class VolumeDialog { case RECHECK_ALL: recheckH(null); break; case RECHECK_ALL: recheckH(null); break; case SET_STREAM_IMPORTANT: setStreamImportantH(msg.arg1, msg.arg2 != 0); break; case SET_STREAM_IMPORTANT: setStreamImportantH(msg.arg1, msg.arg2 != 0); break; case RESCHEDULE_TIMEOUT: rescheduleTimeoutH(); break; case RESCHEDULE_TIMEOUT: rescheduleTimeoutH(); break; case STATE_CHANGED: onStateChangedH(mState); break; case UPDATE_BOTTOM_MARGIN: updateDialogBottomMarginH(); break; } } } } } } Loading @@ -902,6 +975,12 @@ public class VolumeDialog { @Override @Override protected void onStop() { protected void onStop() { super.onStop(); super.onStop(); final boolean animating = mMotion.isAnimating(); if (D.BUG) Log.d(TAG, "onStop animating=" + animating); if (animating) { mPendingRecheckAll = true; return; } mHandler.sendEmptyMessage(H.RECHECK_ALL); mHandler.sendEmptyMessage(H.RECHECK_ALL); } } Loading Loading @@ -978,11 +1057,13 @@ public class VolumeDialog { mDialogView.addOnAttachStateChangeListener(new OnAttachStateChangeListener() { mDialogView.addOnAttachStateChangeListener(new OnAttachStateChangeListener() { @Override @Override public void onViewDetachedFromWindow(View v) { public void onViewDetachedFromWindow(View v) { if (D.BUG) Log.d(TAG, "onViewDetachedFromWindow"); // noop // noop } } @Override @Override public void onViewAttachedToWindow(View v) { public void onViewAttachedToWindow(View v) { if (D.BUG) Log.d(TAG, "onViewAttachedToWindow"); updateFeedbackEnabled(); updateFeedbackEnabled(); } } }); }); Loading Loading
packages/SystemUI/res/layout/volume_dialog.xml +1 −1 Original line number Original line Diff line number Diff line Loading @@ -18,7 +18,7 @@ android:id="@+id/volume_dialog" android:id="@+id/volume_dialog" android:layout_width="match_parent" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="4dp" android:layout_marginBottom="@dimen/volume_dialog_margin_bottom" android:layout_marginLeft="@dimen/notification_side_padding" android:layout_marginLeft="@dimen/notification_side_padding" android:layout_marginRight="@dimen/notification_side_padding" android:layout_marginRight="@dimen/notification_side_padding" android:background="@drawable/volume_dialog_background" android:background="@drawable/volume_dialog_background" Loading
packages/SystemUI/res/layout/volume_dialog_row.xml +1 −0 Original line number Original line Diff line number Diff line Loading @@ -17,6 +17,7 @@ android:layout_width="match_parent" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_height="wrap_content" android:clipChildren="false" android:clipChildren="false" android:id="@+id/volume_dialog_row" android:paddingEnd="8dp" android:paddingEnd="8dp" android:paddingStart="8dp" > android:paddingStart="8dp" > Loading
packages/SystemUI/res/values/dimens.xml +3 −0 Original line number Original line Diff line number Diff line Loading @@ -576,6 +576,9 @@ <!-- Standard image button size for volume dialog buttons --> <!-- Standard image button size for volume dialog buttons --> <dimen name="volume_button_size">48dp</dimen> <dimen name="volume_button_size">48dp</dimen> <!-- Volume dialog root view bottom margin, at rest --> <dimen name="volume_dialog_margin_bottom">4dp</dimen> <!-- Padding between icon and text for managed profile toast --> <!-- Padding between icon and text for managed profile toast --> <dimen name="managed_profile_toast_padding">4dp</dimen> <dimen name="managed_profile_toast_padding">4dp</dimen> Loading
packages/SystemUI/res/values/styles.xml +0 −5 Original line number Original line Diff line number Diff line Loading @@ -291,11 +291,6 @@ <item name="android:textColor">#ffb0b3c5</item> <item name="android:textColor">#ffb0b3c5</item> </style> </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"> <style name="VolumeButtons" parent="@android:style/Widget.Material.Button.Borderless"> <item name="android:background">@drawable/btn_borderless_rect</item> <item name="android:background">@drawable/btn_borderless_rect</item> </style> </style> Loading
packages/SystemUI/src/com/android/systemui/volume/VolumeDialog.java +99 −18 Original line number Original line Diff line number Diff line Loading @@ -111,6 +111,7 @@ public class VolumeDialog { private final Accessibility mAccessibility = new Accessibility(); private final Accessibility mAccessibility = new Accessibility(); private final ColorStateList mActiveSliderTint; private final ColorStateList mActiveSliderTint; private final ColorStateList mInactiveSliderTint; private final ColorStateList mInactiveSliderTint; private final VolumeDialogMotion mMotion; private boolean mShowing; private boolean mShowing; private boolean mExpanded; private boolean mExpanded; Loading @@ -120,9 +121,12 @@ public class VolumeDialog { private boolean mSilentMode = VolumePrefs.DEFAULT_ENABLE_SILENT_MODE; private boolean mSilentMode = VolumePrefs.DEFAULT_ENABLE_SILENT_MODE; private State mState; private State mState; private int mExpandButtonRes; private int mExpandButtonRes; private boolean mExpanding; private boolean mExpandButtonAnimationRunning; private SafetyWarningDialog mSafetyWarning; private SafetyWarningDialog mSafetyWarning; private Callback mCallback; private Callback mCallback; private boolean mPendingStateChanged; private boolean mPendingRecheckAll; private long mCollapseTime; public VolumeDialog(Context context, int windowType, VolumeDialogController controller, public VolumeDialog(Context context, int windowType, VolumeDialogController controller, ZenModeController zenModeController, Callback callback) { ZenModeController zenModeController, Callback callback) { Loading Loading @@ -151,7 +155,6 @@ public class VolumeDialog { lp.format = PixelFormat.TRANSLUCENT; lp.format = PixelFormat.TRANSLUCENT; lp.setTitle(VolumeDialog.class.getSimpleName()); lp.setTitle(VolumeDialog.class.getSimpleName()); lp.gravity = Gravity.TOP | Gravity.CENTER_HORIZONTAL; lp.gravity = Gravity.TOP | Gravity.CENTER_HORIZONTAL; lp.windowAnimations = R.style.VolumeDialogAnimations; lp.y = res.getDimensionPixelSize(R.dimen.volume_offset_top); lp.y = res.getDimensionPixelSize(R.dimen.volume_offset_top); lp.gravity = Gravity.TOP; lp.gravity = Gravity.TOP; window.setAttributes(lp); window.setAttributes(lp); Loading @@ -168,9 +171,22 @@ public class VolumeDialog { updateExpandButtonH(); updateExpandButtonH(); mLayoutTransition = new LayoutTransition(); mLayoutTransition = new LayoutTransition(); mLayoutTransition.setDuration(new ValueAnimator().getDuration() / 2); mLayoutTransition.setDuration(new ValueAnimator().getDuration() / 2); mLayoutTransition.disableTransitionType(LayoutTransition.DISAPPEARING); mLayoutTransition.disableTransitionType(LayoutTransition.CHANGE_DISAPPEARING); mDialogContentView.setLayoutTransition(mLayoutTransition); mDialogContentView.setLayoutTransition(mLayoutTransition); mMotion = new VolumeDialogMotion(mDialog, mDialogView, mDialogContentView, mExpandButton, new VolumeDialogMotion.Callback() { @Override public void onAnimatingChanged(boolean animating) { if (animating) return; if (mPendingStateChanged) { mHandler.sendEmptyMessage(H.STATE_CHANGED); mPendingStateChanged = false; } if (mPendingRecheckAll) { mHandler.sendEmptyMessage(H.RECHECK_ALL); mPendingRecheckAll = false; } } }); addRow(AudioManager.STREAM_RING, addRow(AudioManager.STREAM_RING, R.drawable.ic_volume_ringer, R.drawable.ic_volume_ringer_mute, true); R.drawable.ic_volume_ringer, R.drawable.ic_volume_ringer_mute, true); Loading Loading @@ -242,6 +258,7 @@ public class VolumeDialog { final VolumeRow row = initRow(stream, iconRes, iconMuteRes, important); final VolumeRow row = initRow(stream, iconRes, iconMuteRes, important); if (!mRows.isEmpty()) { if (!mRows.isEmpty()) { final View v = new View(mContext); final View v = new View(mContext); v.setId(android.R.id.background); final int h = mContext.getResources() final int h = mContext.getResources() .getDimensionPixelSize(R.dimen.volume_slider_interspacing); .getDimensionPixelSize(R.dimen.volume_slider_interspacing); final LinearLayout.LayoutParams lp = final LinearLayout.LayoutParams lp = Loading @@ -253,10 +270,11 @@ public class VolumeDialog { @Override @Override public void onLayoutChange(View v, int left, int top, int right, int bottom, public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { int oldLeft, int oldTop, int oldRight, int oldBottom) { if (D.BUG) Log.d(TAG, "onLayoutChange" final boolean moved = oldLeft != left || oldTop != top; if (D.BUG) Log.d(TAG, "onLayoutChange moved=" + moved + " old=" + new Rect(oldLeft, oldTop, oldRight, oldBottom).toShortString() + " old=" + new Rect(oldLeft, oldTop, oldRight, oldBottom).toShortString() + " new=" + new Rect(left,top,right,bottom).toShortString()); + " new=" + new Rect(left,top,right,bottom).toShortString()); if (oldLeft != left || oldTop != top) { if (moved) { for (int i = 0; i < mDialogContentView.getChildCount(); i++) { for (int i = 0; i < mDialogContentView.getChildCount(); i++) { final View c = mDialogContentView.getChildAt(i); final View c = mDialogContentView.getChildAt(i); if (!c.isShown()) continue; if (!c.isShown()) continue; Loading Loading @@ -302,18 +320,21 @@ public class VolumeDialog { if (D.BUG) Log.d(TAG, "repositionExpandAnim x=" + x + " y=" + y); if (D.BUG) Log.d(TAG, "repositionExpandAnim x=" + x + " y=" + y); mExpandButton.setTranslationX(x); mExpandButton.setTranslationX(x); mExpandButton.setTranslationY(y); mExpandButton.setTranslationY(y); mExpandButton.setTag((Integer) y); } } public void dump(PrintWriter writer) { public void dump(PrintWriter writer) { writer.println(VolumeDialog.class.getSimpleName() + " state:"); writer.println(VolumeDialog.class.getSimpleName() + " state:"); writer.print(" mShowing: "); writer.println(mShowing); writer.print(" mShowing: "); writer.println(mShowing); writer.print(" mExpanded: "); writer.println(mExpanded); writer.print(" mExpanded: "); writer.println(mExpanded); writer.print(" mExpanding: "); writer.println(mExpanding); writer.print(" mExpandButtonAnimationRunning: "); writer.println(mExpandButtonAnimationRunning); writer.print(" mActiveStream: "); writer.println(mActiveStream); writer.print(" mActiveStream: "); writer.println(mActiveStream); writer.print(" mDynamic: "); writer.println(mDynamic); writer.print(" mDynamic: "); writer.println(mDynamic); writer.print(" mShowHeaders: "); writer.println(mShowHeaders); writer.print(" mShowHeaders: "); writer.println(mShowHeaders); writer.print(" mAutomute: "); writer.println(mAutomute); writer.print(" mAutomute: "); writer.println(mAutomute); writer.print(" mSilentMode: "); writer.println(mSilentMode); writer.print(" mSilentMode: "); writer.println(mSilentMode); writer.print(" mCollapseTime: "); writer.println(mCollapseTime); writer.print(" mAccessibility.mFeedbackEnabled: "); writer.print(" mAccessibility.mFeedbackEnabled: "); writer.println(mAccessibility.mFeedbackEnabled); writer.println(mAccessibility.mFeedbackEnabled); } } Loading Loading @@ -412,12 +433,13 @@ public class VolumeDialog { } } private void showH(int reason) { private void showH(int reason) { if (D.BUG) Log.d(TAG, "showH r=" + Events.DISMISS_REASONS[reason]); mHandler.removeMessages(H.SHOW); mHandler.removeMessages(H.SHOW); mHandler.removeMessages(H.DISMISS); mHandler.removeMessages(H.DISMISS); rescheduleTimeoutH(); rescheduleTimeoutH(); if (mShowing) return; if (mShowing) return; mShowing = true; mShowing = true; mDialog.show(); mMotion.startShow(); Events.writeEvent(mContext, Events.EVENT_SHOW_DIALOG, reason, mKeyguard.isKeyguardLocked()); Events.writeEvent(mContext, Events.EVENT_SHOW_DIALOG, reason, mKeyguard.isKeyguardLocked()); mController.notifyVisible(true); mController.notifyVisible(true); } } Loading @@ -434,7 +456,7 @@ public class VolumeDialog { private int computeTimeoutH() { private int computeTimeoutH() { if (mAccessibility.mFeedbackEnabled) return 20000; if (mAccessibility.mFeedbackEnabled) return 20000; if (mSafetyWarning != null) return 5000; if (mSafetyWarning != null) return 5000; if (mExpanded || mExpanding) return 5000; if (mExpanded || mExpandButtonAnimationRunning) return 5000; if (mActiveStream == AudioManager.STREAM_MUSIC) return 1500; if (mActiveStream == AudioManager.STREAM_MUSIC) return 1500; return 3000; return 3000; } } Loading @@ -444,9 +466,13 @@ public class VolumeDialog { mHandler.removeMessages(H.SHOW); mHandler.removeMessages(H.SHOW); if (!mShowing) return; if (!mShowing) return; mShowing = false; mShowing = false; mDialog.dismiss(); mMotion.startDismiss(new Runnable() { Events.writeEvent(mContext, Events.EVENT_DISMISS_DIALOG, reason); @Override public void run() { setExpandedH(false); setExpandedH(false); } }); Events.writeEvent(mContext, Events.EVENT_DISMISS_DIALOG, reason); mController.notifyVisible(false); mController.notifyVisible(false); synchronized (mSafetyWarningLock) { synchronized (mSafetyWarningLock) { if (mSafetyWarning != null) { if (mSafetyWarning != null) { Loading @@ -456,13 +482,40 @@ public class VolumeDialog { } } } } private void updateDialogBottomMarginH() { final long diff = System.currentTimeMillis() - mCollapseTime; final boolean collapsing = mCollapseTime != 0 && diff < getConservativeCollapseDuration(); final ViewGroup.MarginLayoutParams mlp = (MarginLayoutParams) mDialogView.getLayoutParams(); final int bottomMargin = collapsing ? mDialogContentView.getHeight() : mContext.getResources().getDimensionPixelSize(R.dimen.volume_dialog_margin_bottom); if (bottomMargin != mlp.bottomMargin) { if (D.BUG) Log.d(TAG, "bottomMargin " + mlp.bottomMargin + " -> " + bottomMargin); mlp.bottomMargin = bottomMargin; mDialogView.setLayoutParams(mlp); } } private long getConservativeCollapseDuration() { return mExpandButtonAnimationDuration * 3; } private void prepareForCollapse() { mHandler.removeMessages(H.UPDATE_BOTTOM_MARGIN); mCollapseTime = System.currentTimeMillis(); updateDialogBottomMarginH(); mHandler.sendEmptyMessageDelayed(H.UPDATE_BOTTOM_MARGIN, getConservativeCollapseDuration()); } private void setExpandedH(boolean expanded) { private void setExpandedH(boolean expanded) { if (mExpanded == expanded) return; if (mExpanded == expanded) return; mExpanded = expanded; mExpanded = expanded; mExpanding = isAttached(); mExpandButtonAnimationRunning = isAttached(); if (D.BUG) Log.d(TAG, "setExpandedH " + expanded); if (D.BUG) Log.d(TAG, "setExpandedH " + expanded); if (!mExpanded && mExpandButtonAnimationRunning) { prepareForCollapse(); } updateRowsH(); updateRowsH(); if (mExpanding) { if (mExpandButtonAnimationRunning) { final Drawable d = mExpandButton.getDrawable(); final Drawable d = mExpandButton.getDrawable(); if (d instanceof AnimatedVectorDrawable) { if (d instanceof AnimatedVectorDrawable) { // workaround to reset drawable // workaround to reset drawable Loading @@ -473,7 +526,7 @@ public class VolumeDialog { mHandler.postDelayed(new Runnable() { mHandler.postDelayed(new Runnable() { @Override @Override public void run() { public void run() { mExpanding = false; mExpandButtonAnimationRunning = false; updateExpandButtonH(); updateExpandButtonH(); rescheduleTimeoutH(); rescheduleTimeoutH(); } } Loading @@ -484,8 +537,9 @@ public class VolumeDialog { } } private void updateExpandButtonH() { private void updateExpandButtonH() { mExpandButton.setClickable(!mExpanding); if (D.BUG) Log.d(TAG, "updateExpandButtonH"); if (mExpanding && isAttached()) return; mExpandButton.setClickable(!mExpandButtonAnimationRunning); if (mExpandButtonAnimationRunning && isAttached()) return; final int res = mExpanded ? R.drawable.ic_volume_collapse_animation final int res = mExpanded ? R.drawable.ic_volume_collapse_animation : R.drawable.ic_volume_expand_animation; : R.drawable.ic_volume_expand_animation; if (res == mExpandButtonRes) return; if (res == mExpandButtonRes) return; Loading @@ -502,6 +556,7 @@ public class VolumeDialog { } } private void updateRowsH() { private void updateRowsH() { if (D.BUG) Log.d(TAG, "updateRowsH"); final VolumeRow activeRow = getActiveRow(); final VolumeRow activeRow = getActiveRow(); updateFooterH(); updateFooterH(); updateExpandButtonH(); updateExpandButtonH(); Loading Loading @@ -531,6 +586,7 @@ public class VolumeDialog { } } private void trimObsoleteH() { private void trimObsoleteH() { if (D.BUG) Log.d(TAG, "trimObsoleteH"); for (int i = mRows.size() -1; i >= 0; i--) { for (int i = mRows.size() -1; i >= 0; i--) { final VolumeRow row = mRows.get(i); final VolumeRow row = mRows.get(i); if (row.ss == null || !row.ss.dynamic) continue; if (row.ss == null || !row.ss.dynamic) continue; Loading @@ -543,7 +599,13 @@ public class VolumeDialog { } } private void onStateChangedH(State state) { private void onStateChangedH(State state) { final boolean animating = mMotion.isAnimating(); if (D.BUG) Log.d(TAG, "onStateChangedH animating=" + animating); mState = state; mState = state; if (animating) { mPendingStateChanged = true; return; } mDynamic.clear(); mDynamic.clear(); // add any new dynamic rows // add any new dynamic rows for (int i = 0; i < state.states.size(); i++) { for (int i = 0; i < state.states.size(); i++) { Loading @@ -568,11 +630,18 @@ public class VolumeDialog { } } private void updateFooterH() { private void updateFooterH() { Util.setVisOrGone(mZenFooter, mState.zenMode != Global.ZEN_MODE_OFF); if (D.BUG) Log.d(TAG, "updateFooterH"); final boolean wasVisible = mZenFooter.getVisibility() == View.VISIBLE; final boolean visible = mState.zenMode != Global.ZEN_MODE_OFF; if (wasVisible != visible && !visible) { prepareForCollapse(); } Util.setVisOrGone(mZenFooter, visible); mZenFooter.update(); mZenFooter.update(); } } private void updateVolumeRowH(VolumeRow row) { private void updateVolumeRowH(VolumeRow row) { if (D.BUG) Log.d(TAG, "updateVolumeRowH s=" + row.stream); if (mState == null) return; if (mState == null) return; final StreamState ss = mState.states.get(row.stream); final StreamState ss = mState.states.get(row.stream); if (ss == null) return; if (ss == null) return; Loading Loading @@ -841,7 +910,7 @@ public class VolumeDialog { private final OnClickListener mClickExpand = new OnClickListener() { private final OnClickListener mClickExpand = new OnClickListener() { @Override @Override public void onClick(View v) { public void onClick(View v) { if (mExpanding) return; if (mExpandButtonAnimationRunning) return; final boolean newExpand = !mExpanded; final boolean newExpand = !mExpanded; Events.writeEvent(mContext, Events.EVENT_EXPAND, newExpand); Events.writeEvent(mContext, Events.EVENT_EXPAND, newExpand); setExpandedH(newExpand); setExpandedH(newExpand); Loading Loading @@ -870,6 +939,8 @@ public class VolumeDialog { private static final int RECHECK_ALL = 4; private static final int RECHECK_ALL = 4; private static final int SET_STREAM_IMPORTANT = 5; private static final int SET_STREAM_IMPORTANT = 5; private static final int RESCHEDULE_TIMEOUT = 6; private static final int RESCHEDULE_TIMEOUT = 6; private static final int STATE_CHANGED = 7; private static final int UPDATE_BOTTOM_MARGIN = 8; public H() { public H() { super(Looper.getMainLooper()); super(Looper.getMainLooper()); Loading @@ -884,6 +955,8 @@ public class VolumeDialog { case RECHECK_ALL: recheckH(null); break; case RECHECK_ALL: recheckH(null); break; case SET_STREAM_IMPORTANT: setStreamImportantH(msg.arg1, msg.arg2 != 0); break; case SET_STREAM_IMPORTANT: setStreamImportantH(msg.arg1, msg.arg2 != 0); break; case RESCHEDULE_TIMEOUT: rescheduleTimeoutH(); break; case RESCHEDULE_TIMEOUT: rescheduleTimeoutH(); break; case STATE_CHANGED: onStateChangedH(mState); break; case UPDATE_BOTTOM_MARGIN: updateDialogBottomMarginH(); break; } } } } } } Loading @@ -902,6 +975,12 @@ public class VolumeDialog { @Override @Override protected void onStop() { protected void onStop() { super.onStop(); super.onStop(); final boolean animating = mMotion.isAnimating(); if (D.BUG) Log.d(TAG, "onStop animating=" + animating); if (animating) { mPendingRecheckAll = true; return; } mHandler.sendEmptyMessage(H.RECHECK_ALL); mHandler.sendEmptyMessage(H.RECHECK_ALL); } } Loading Loading @@ -978,11 +1057,13 @@ public class VolumeDialog { mDialogView.addOnAttachStateChangeListener(new OnAttachStateChangeListener() { mDialogView.addOnAttachStateChangeListener(new OnAttachStateChangeListener() { @Override @Override public void onViewDetachedFromWindow(View v) { public void onViewDetachedFromWindow(View v) { if (D.BUG) Log.d(TAG, "onViewDetachedFromWindow"); // noop // noop } } @Override @Override public void onViewAttachedToWindow(View v) { public void onViewAttachedToWindow(View v) { if (D.BUG) Log.d(TAG, "onViewAttachedToWindow"); updateFeedbackEnabled(); updateFeedbackEnabled(); } } }); }); Loading