Loading packages/SystemUI/res/layout/volume_dialog.xml +13 −4 Original line number Diff line number Diff line Loading @@ -26,11 +26,20 @@ android:id="@+id/volume_dialog_content" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:paddingTop="@dimen/volume_dialog_collapsed_padding_top" android:animateLayoutChanges="true" > android:orientation="vertical" > <LinearLayout android:id="@+id/volume_dialog_rows" android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingEnd="@dimen/volume_button_size" android:orientation="vertical" > <View android:id="@+id/spacer" android:layout_width="match_parent" android:layout_height="@dimen/volume_dialog_expanded_spacer" android:visibility="gone"/> <!-- volume rows added and removed here! :-) --> </LinearLayout> <include layout="@layout/volume_zen_footer" /> Loading packages/SystemUI/res/layout/volume_dialog_row.xml +1 −4 Original line number Diff line number Diff line Loading @@ -19,11 +19,8 @@ android:layout_height="@dimen/volume_row_height" android:clipChildren="false" android:clipToPadding="false" android:id="@+id/volume_dialog_row" android:paddingEnd="@dimen/volume_dialog_padding_end" android:orientation="vertical" android:paddingBottom="@dimen/volume_row_padding_bottom" android:animateLayoutChanges="true"> android:paddingBottom="@dimen/volume_row_padding_bottom" > <TextView android:id="@+id/volume_row_header" Loading packages/SystemUI/res/values/dimens.xml +1 −2 Original line number Diff line number Diff line Loading @@ -538,8 +538,7 @@ <!-- Volume dialog root view bottom margin, at rest --> <dimen name="volume_dialog_margin_bottom">4dp</dimen> <dimen name="volume_dialog_collapsed_padding_top">8dp</dimen> <dimen name="volume_dialog_expanded_padding_top">22dp</dimen> <dimen name="volume_dialog_expanded_spacer">14dp</dimen> <dimen name="volume_dialog_padding_end">40dp</dimen> <dimen name="volume_row_padding_bottom">9.4dp</dimen> Loading packages/SystemUI/src/com/android/systemui/volume/VolumeDialog.java +93 −88 Original line number Diff line number Diff line Loading @@ -17,9 +17,7 @@ package com.android.systemui.volume; import android.accessibilityservice.AccessibilityServiceInfo; import android.animation.LayoutTransition; import android.animation.ObjectAnimator; import android.animation.ValueAnimator; import android.annotation.NonNull; import android.annotation.SuppressLint; import android.app.Dialog; Loading @@ -43,9 +41,11 @@ import android.os.Looper; import android.os.Message; import android.os.SystemClock; import android.provider.Settings.Global; import android.transition.AutoTransition; import android.transition.Transition; import android.transition.TransitionManager; import android.util.DisplayMetrics; import android.util.Log; import android.util.Slog; import android.util.SparseBooleanArray; import android.view.Gravity; import android.view.MotionEvent; Loading @@ -63,12 +63,12 @@ import android.view.accessibility.AccessibilityManager; import android.view.accessibility.AccessibilityManager.AccessibilityStateChangeListener; import android.view.animation.DecelerateInterpolator; import android.widget.ImageButton; import android.widget.LinearLayout; import android.widget.SeekBar; import android.widget.SeekBar.OnSeekBarChangeListener; import android.widget.TextView; import com.android.settingslib.Utils; import com.android.systemui.Interpolators; import com.android.systemui.R; import com.android.systemui.statusbar.policy.ZenModeController; import com.android.systemui.tuner.TunerService; Loading Loading @@ -102,8 +102,10 @@ public class VolumeDialog implements TunerService.Tunable { private final H mHandler = new H(); private final VolumeDialogController mController; private Window mWindow; private CustomDialog mDialog; private ViewGroup mDialogView; private ViewGroup mDialogRowsView; private ViewGroup mDialogContentView; private ImageButton mExpandButton; private final List<VolumeRow> mRows = new ArrayList<>(); Loading @@ -114,7 +116,6 @@ public class VolumeDialog implements TunerService.Tunable { private final AccessibilityManager mAccessibilityMgr; private int mExpandButtonAnimationDuration; private ZenFooter mZenFooter; private LayoutTransition mLayoutTransition; private final Object mSafetyWarningLock = new Object(); private final Accessibility mAccessibility = new Accessibility(); private final ColorStateList mActiveSliderTint; Loading Loading @@ -152,7 +153,8 @@ public class VolumeDialog implements TunerService.Tunable { mZenModeController = zenModeController; mKeyguard = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE); mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); mAccessibilityMgr = (AccessibilityManager) mContext.getSystemService(Context.ACCESSIBILITY_SERVICE); mAccessibilityMgr = (AccessibilityManager) mContext.getSystemService(Context.ACCESSIBILITY_SERVICE); mActiveSliderTint = ColorStateList.valueOf(Utils.getColorAccent(mContext)); mInactiveSliderTint = loadColorStateList(R.color.volume_slider_inactive); Loading @@ -172,15 +174,13 @@ public class VolumeDialog implements TunerService.Tunable { mDialog = new CustomDialog(mContext); mSpTexts = new SpTexts(mContext); mLayoutTransition = new LayoutTransition(); mLayoutTransition.setDuration(new ValueAnimator().getDuration() / 2); mHovering = false; mShowing = false; final Window window = mDialog.getWindow(); window.requestFeature(Window.FEATURE_NO_TITLE); window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); window.addFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE mWindow = mDialog.getWindow(); mWindow.requestFeature(Window.FEATURE_NO_TITLE); mWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); mWindow.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); mWindow.addFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED Loading @@ -188,7 +188,7 @@ public class VolumeDialog implements TunerService.Tunable { | WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED); mDialog.setCanceledOnTouchOutside(true); final Resources res = mContext.getResources(); final WindowManager.LayoutParams lp = window.getAttributes(); final WindowManager.LayoutParams lp = mWindow.getAttributes(); lp.type = mWindowType; lp.format = PixelFormat.TRANSLUCENT; lp.setTitle(VolumeDialog.class.getSimpleName()); Loading @@ -196,9 +196,8 @@ public class VolumeDialog implements TunerService.Tunable { lp.y = res.getDimensionPixelSize(R.dimen.volume_offset_top); lp.gravity = Gravity.TOP; lp.windowAnimations = -1; window.setAttributes(lp); window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING); mWindow.setAttributes(lp); mWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING); mDialog.setContentView(R.layout.volume_dialog); mDialogView = (ViewGroup) mDialog.findViewById(R.id.volume_dialog); Loading @@ -213,13 +212,13 @@ public class VolumeDialog implements TunerService.Tunable { } }); mDialogContentView = (ViewGroup) mDialog.findViewById(R.id.volume_dialog_content); mDialogRowsView = (ViewGroup) mDialogContentView.findViewById(R.id.volume_dialog_rows); mExpanded = false; mExpandButton = (ImageButton) mDialogView.findViewById(R.id.volume_expand_button); mExpandButton.setOnClickListener(mClickExpand); updateWindowWidthH(); updateExpandButtonH(); mDialogContentView.setLayoutTransition(mLayoutTransition); mMotion = new VolumeDialogMotion(mDialog, mDialogView, mDialogContentView, mExpandButton, new VolumeDialogMotion.Callback() { @Override Loading Loading @@ -310,10 +309,7 @@ public class VolumeDialog implements TunerService.Tunable { private void addRow(int stream, int iconRes, int iconMuteRes, boolean important) { VolumeRow row = new VolumeRow(); initRow(row, stream, iconRes, iconMuteRes, important); if (!mRows.isEmpty()) { addSpacer(row); } mDialogContentView.addView(row.view, mDialogContentView.getChildCount() - 2); mDialogRowsView.addView(row.view); mRows.add(row); } Loading @@ -322,23 +318,10 @@ public class VolumeDialog implements TunerService.Tunable { for (int i = 0; i < N; i++) { final VolumeRow row = mRows.get(i); initRow(row, row.stream, row.iconRes, row.iconMuteRes, row.important); if (i > 0) { addSpacer(row); } mDialogContentView.addView(row.view, mDialogContentView.getChildCount() - 2); mDialogRowsView.addView(row.view); } } private void addSpacer(VolumeRow row) { final View v = new View(mContext); v.setId(android.R.id.background); final int h = mContext.getResources() .getDimensionPixelSize(R.dimen.volume_slider_interspacing); final LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, h); mDialogContentView.addView(v, mDialogContentView.getChildCount() - 2, lp); row.space = v; } private boolean isAttached() { return mDialogContentView != null && mDialogContentView.isAttachedToWindow(); Loading Loading @@ -392,12 +375,15 @@ public class VolumeDialog implements TunerService.Tunable { row.iconMuteRes = iconMuteRes; row.important = important; row.view = mDialog.getLayoutInflater().inflate(R.layout.volume_dialog_row, null); row.view.setId(row.stream); row.view.setTag(row); row.header = (TextView) row.view.findViewById(R.id.volume_row_header); row.header.setId(20 * row.stream); mSpTexts.add(row.header); row.slider = (SeekBar) row.view.findViewById(R.id.volume_row_slider); row.slider.setOnSeekBarChangeListener(new VolumeSeekBarChangeListener(row)); row.anim = null; row.cachedShowHeaders = VolumePrefs.DEFAULT_SHOW_HEADERS; // forward events above the slider into the slider row.view.setOnTouchListener(new OnTouchListener() { Loading Loading @@ -509,7 +495,7 @@ public class VolumeDialog implements TunerService.Tunable { mMotion.startDismiss(new Runnable() { @Override public void run() { setExpandedH(false); updateExpandedH(false); } }); if (mAccessibilityMgr.isEnabled()) { Loading Loading @@ -555,48 +541,53 @@ public class VolumeDialog implements TunerService.Tunable { mHandler.sendEmptyMessageDelayed(H.UPDATE_BOTTOM_MARGIN, getConservativeCollapseDuration()); } private void setExpandedH(boolean expanded) { private void updateExpandedH(final boolean expanded) { if (mExpanded == expanded) return; mExpanded = expanded; mExpandButtonAnimationRunning = isAttached(); if (D.BUG) Log.d(TAG, "setExpandedH " + expanded); if (!mExpanded && mExpandButtonAnimationRunning) { prepareForCollapse(); if (D.BUG) Log.d(TAG, "updateExpandedH " + expanded); updateExpandButtonH(); updateFooterH(); final VolumeRow activeRow = getActiveRow(); mWindow.setLayout(mWindow.getAttributes().width, ViewGroup.LayoutParams.MATCH_PARENT); AutoTransition transition = new AutoTransition(); transition.setDuration(mExpandButtonAnimationDuration); transition.setInterpolator(Interpolators.LINEAR_OUT_SLOW_IN); transition.addListener(new Transition.TransitionListener() { @Override public void onTransitionStart(Transition transition) { } final Resources res = mContext.getResources(); int paddingTop = mExpanded ? res.getDimensionPixelSize(R.dimen.volume_dialog_expanded_padding_top) : res.getDimensionPixelSize(R.dimen.volume_dialog_collapsed_padding_top); mDialogContentView.setPaddingRelative(mDialogContentView.getPaddingStart(), paddingTop, mDialogContentView.getPaddingEnd(), mDialogContentView.getPaddingBottom()); updateRowsH(); if (mExpandButtonAnimationRunning) { final Drawable d = mExpandButton.getDrawable(); if (d instanceof AnimatedVectorDrawable) { // workaround to reset drawable final AnimatedVectorDrawable avd = (AnimatedVectorDrawable) d.getConstantState() .newDrawable(); mExpandButton.setImageDrawable(avd); avd.start(); mHandler.postDelayed(new Runnable() { @Override public void run() { mExpandButtonAnimationRunning = false; updateExpandButtonH(); rescheduleTimeoutH(); public void onTransitionEnd(Transition transition) { mWindow.setLayout( mWindow.getAttributes().width, ViewGroup.LayoutParams.WRAP_CONTENT); } }, mExpandButtonAnimationDuration); @Override public void onTransitionCancel(Transition transition) { mWindow.setLayout( mWindow.getAttributes().width, ViewGroup.LayoutParams.WRAP_CONTENT); } @Override public void onTransitionPause(Transition transition) { } @Override public void onTransitionResume(Transition transition) { } }); TransitionManager.endTransitions(mDialogView); TransitionManager.beginDelayedTransition(mDialogView, transition); updateRowsH(activeRow); rescheduleTimeoutH(); } private void updateExpandButtonH() { if (D.BUG) Log.d(TAG, "updateExpandButtonH"); mExpandButton.setClickable(!mExpandButtonAnimationRunning); if (mExpandButtonAnimationRunning && isAttached()) return; if (!(mExpandButtonAnimationRunning && isAttached())) { final int res = mExpanded ? R.drawable.ic_volume_collapse_animation : R.drawable.ic_volume_expand_animation; if (hasTouchFeature()) { Loading @@ -609,32 +600,51 @@ public class VolumeDialog implements TunerService.Tunable { mExpandButton.setContentDescription(mContext.getString(mExpanded ? R.string.accessibility_volume_collapse : R.string.accessibility_volume_expand)); } if (mExpandButtonAnimationRunning) { final Drawable d = mExpandButton.getDrawable(); if (d instanceof AnimatedVectorDrawable) { // workaround to reset drawable final AnimatedVectorDrawable avd = (AnimatedVectorDrawable) d.getConstantState() .newDrawable(); mExpandButton.setImageDrawable(avd); avd.start(); mHandler.postDelayed(new Runnable() { @Override public void run() { mExpandButtonAnimationRunning = false; updateExpandButtonH(); rescheduleTimeoutH(); } }, mExpandButtonAnimationDuration); } } } private boolean isVisibleH(VolumeRow row, boolean isActive) { private boolean shouldBeVisibleH(VolumeRow row, boolean isActive) { return mExpanded && row.view.getVisibility() == View.VISIBLE || (mExpanded && (row.important || isActive)) || !mExpanded && isActive; } private void updateRowsH() { private void updateRowsH(final VolumeRow activeRow) { if (D.BUG) Log.d(TAG, "updateRowsH"); final VolumeRow activeRow = getActiveRow(); updateFooterH(); updateExpandButtonH(); if (!mShowing) { trimObsoleteH(); } Util.setVisOrGone(mDialogRowsView.findViewById(R.id.spacer), mExpanded); // apply changes to all rows for (VolumeRow row : mRows) { for (final VolumeRow row : mRows) { final boolean isActive = row == activeRow; final boolean visible = isVisibleH(row, isActive); Util.setVisOrGone(row.view, visible); Util.setVisOrGone(row.space, visible && mExpanded); final boolean shouldBeVisible = shouldBeVisibleH(row, isActive); Util.setVisOrGone(row.view, shouldBeVisible); if (row.view.isShown()) { updateVolumeRowHeaderVisibleH(row); updateVolumeRowSliderTintH(row, isActive); } } } private void trimObsoleteH() { if (D.BUG) Log.d(TAG, "trimObsoleteH"); for (int i = mRows.size() - 1; i >= 0; i--) { Loading @@ -642,8 +652,7 @@ public class VolumeDialog implements TunerService.Tunable { if (row.ss == null || !row.ss.dynamic) continue; if (!mDynamic.get(row.stream)) { mRows.remove(i); mDialogContentView.removeView(row.view); mDialogContentView.removeView(row.space); mDialogRowsView.removeView(row.view); } } } Loading @@ -670,7 +679,7 @@ public class VolumeDialog implements TunerService.Tunable { if (mActiveStream != state.activeStream) { mActiveStream = state.activeStream; updateRowsH(); updateRowsH(getActiveRow()); rescheduleTimeoutH(); } for (VolumeRow row : mRows) { Loading Loading @@ -731,9 +740,6 @@ public class VolumeDialog implements TunerService.Tunable { && mState.ringerModeInternal == AudioManager.RINGER_MODE_SILENT; final boolean isZenAlarms = mState.zenMode == Global.ZEN_MODE_ALARMS; final boolean isZenNone = mState.zenMode == Global.ZEN_MODE_NO_INTERRUPTIONS; final boolean isZenPriority = mState.zenMode == Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS; final boolean isRingZenNone = (isRingStream || isSystemStream) && isZenNone; final boolean isRingLimited = isRingStream && isZenPriority; final boolean zenMuted = isZenAlarms ? (isRingStream || isSystemStream) : isZenNone ? (isRingStream || isSystemStream || isAlarmStream || isMusicStream) : false; Loading Loading @@ -1023,7 +1029,7 @@ public class VolumeDialog implements TunerService.Tunable { if (mExpandButtonAnimationRunning) return; final boolean newExpand = !mExpanded; Events.writeEvent(mContext, Events.EVENT_EXPAND, newExpand); setExpandedH(newExpand); updateExpandedH(newExpand); } }; Loading Loading @@ -1220,7 +1226,6 @@ public class VolumeDialog implements TunerService.Tunable { private static class VolumeRow { private View view; private View space; private TextView header; private ImageButton icon; private SeekBar slider; Loading Loading
packages/SystemUI/res/layout/volume_dialog.xml +13 −4 Original line number Diff line number Diff line Loading @@ -26,11 +26,20 @@ android:id="@+id/volume_dialog_content" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:paddingTop="@dimen/volume_dialog_collapsed_padding_top" android:animateLayoutChanges="true" > android:orientation="vertical" > <LinearLayout android:id="@+id/volume_dialog_rows" android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingEnd="@dimen/volume_button_size" android:orientation="vertical" > <View android:id="@+id/spacer" android:layout_width="match_parent" android:layout_height="@dimen/volume_dialog_expanded_spacer" android:visibility="gone"/> <!-- volume rows added and removed here! :-) --> </LinearLayout> <include layout="@layout/volume_zen_footer" /> Loading
packages/SystemUI/res/layout/volume_dialog_row.xml +1 −4 Original line number Diff line number Diff line Loading @@ -19,11 +19,8 @@ android:layout_height="@dimen/volume_row_height" android:clipChildren="false" android:clipToPadding="false" android:id="@+id/volume_dialog_row" android:paddingEnd="@dimen/volume_dialog_padding_end" android:orientation="vertical" android:paddingBottom="@dimen/volume_row_padding_bottom" android:animateLayoutChanges="true"> android:paddingBottom="@dimen/volume_row_padding_bottom" > <TextView android:id="@+id/volume_row_header" Loading
packages/SystemUI/res/values/dimens.xml +1 −2 Original line number Diff line number Diff line Loading @@ -538,8 +538,7 @@ <!-- Volume dialog root view bottom margin, at rest --> <dimen name="volume_dialog_margin_bottom">4dp</dimen> <dimen name="volume_dialog_collapsed_padding_top">8dp</dimen> <dimen name="volume_dialog_expanded_padding_top">22dp</dimen> <dimen name="volume_dialog_expanded_spacer">14dp</dimen> <dimen name="volume_dialog_padding_end">40dp</dimen> <dimen name="volume_row_padding_bottom">9.4dp</dimen> Loading
packages/SystemUI/src/com/android/systemui/volume/VolumeDialog.java +93 −88 Original line number Diff line number Diff line Loading @@ -17,9 +17,7 @@ package com.android.systemui.volume; import android.accessibilityservice.AccessibilityServiceInfo; import android.animation.LayoutTransition; import android.animation.ObjectAnimator; import android.animation.ValueAnimator; import android.annotation.NonNull; import android.annotation.SuppressLint; import android.app.Dialog; Loading @@ -43,9 +41,11 @@ import android.os.Looper; import android.os.Message; import android.os.SystemClock; import android.provider.Settings.Global; import android.transition.AutoTransition; import android.transition.Transition; import android.transition.TransitionManager; import android.util.DisplayMetrics; import android.util.Log; import android.util.Slog; import android.util.SparseBooleanArray; import android.view.Gravity; import android.view.MotionEvent; Loading @@ -63,12 +63,12 @@ import android.view.accessibility.AccessibilityManager; import android.view.accessibility.AccessibilityManager.AccessibilityStateChangeListener; import android.view.animation.DecelerateInterpolator; import android.widget.ImageButton; import android.widget.LinearLayout; import android.widget.SeekBar; import android.widget.SeekBar.OnSeekBarChangeListener; import android.widget.TextView; import com.android.settingslib.Utils; import com.android.systemui.Interpolators; import com.android.systemui.R; import com.android.systemui.statusbar.policy.ZenModeController; import com.android.systemui.tuner.TunerService; Loading Loading @@ -102,8 +102,10 @@ public class VolumeDialog implements TunerService.Tunable { private final H mHandler = new H(); private final VolumeDialogController mController; private Window mWindow; private CustomDialog mDialog; private ViewGroup mDialogView; private ViewGroup mDialogRowsView; private ViewGroup mDialogContentView; private ImageButton mExpandButton; private final List<VolumeRow> mRows = new ArrayList<>(); Loading @@ -114,7 +116,6 @@ public class VolumeDialog implements TunerService.Tunable { private final AccessibilityManager mAccessibilityMgr; private int mExpandButtonAnimationDuration; private ZenFooter mZenFooter; private LayoutTransition mLayoutTransition; private final Object mSafetyWarningLock = new Object(); private final Accessibility mAccessibility = new Accessibility(); private final ColorStateList mActiveSliderTint; Loading Loading @@ -152,7 +153,8 @@ public class VolumeDialog implements TunerService.Tunable { mZenModeController = zenModeController; mKeyguard = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE); mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); mAccessibilityMgr = (AccessibilityManager) mContext.getSystemService(Context.ACCESSIBILITY_SERVICE); mAccessibilityMgr = (AccessibilityManager) mContext.getSystemService(Context.ACCESSIBILITY_SERVICE); mActiveSliderTint = ColorStateList.valueOf(Utils.getColorAccent(mContext)); mInactiveSliderTint = loadColorStateList(R.color.volume_slider_inactive); Loading @@ -172,15 +174,13 @@ public class VolumeDialog implements TunerService.Tunable { mDialog = new CustomDialog(mContext); mSpTexts = new SpTexts(mContext); mLayoutTransition = new LayoutTransition(); mLayoutTransition.setDuration(new ValueAnimator().getDuration() / 2); mHovering = false; mShowing = false; final Window window = mDialog.getWindow(); window.requestFeature(Window.FEATURE_NO_TITLE); window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); window.addFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE mWindow = mDialog.getWindow(); mWindow.requestFeature(Window.FEATURE_NO_TITLE); mWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); mWindow.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); mWindow.addFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED Loading @@ -188,7 +188,7 @@ public class VolumeDialog implements TunerService.Tunable { | WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED); mDialog.setCanceledOnTouchOutside(true); final Resources res = mContext.getResources(); final WindowManager.LayoutParams lp = window.getAttributes(); final WindowManager.LayoutParams lp = mWindow.getAttributes(); lp.type = mWindowType; lp.format = PixelFormat.TRANSLUCENT; lp.setTitle(VolumeDialog.class.getSimpleName()); Loading @@ -196,9 +196,8 @@ public class VolumeDialog implements TunerService.Tunable { lp.y = res.getDimensionPixelSize(R.dimen.volume_offset_top); lp.gravity = Gravity.TOP; lp.windowAnimations = -1; window.setAttributes(lp); window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING); mWindow.setAttributes(lp); mWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING); mDialog.setContentView(R.layout.volume_dialog); mDialogView = (ViewGroup) mDialog.findViewById(R.id.volume_dialog); Loading @@ -213,13 +212,13 @@ public class VolumeDialog implements TunerService.Tunable { } }); mDialogContentView = (ViewGroup) mDialog.findViewById(R.id.volume_dialog_content); mDialogRowsView = (ViewGroup) mDialogContentView.findViewById(R.id.volume_dialog_rows); mExpanded = false; mExpandButton = (ImageButton) mDialogView.findViewById(R.id.volume_expand_button); mExpandButton.setOnClickListener(mClickExpand); updateWindowWidthH(); updateExpandButtonH(); mDialogContentView.setLayoutTransition(mLayoutTransition); mMotion = new VolumeDialogMotion(mDialog, mDialogView, mDialogContentView, mExpandButton, new VolumeDialogMotion.Callback() { @Override Loading Loading @@ -310,10 +309,7 @@ public class VolumeDialog implements TunerService.Tunable { private void addRow(int stream, int iconRes, int iconMuteRes, boolean important) { VolumeRow row = new VolumeRow(); initRow(row, stream, iconRes, iconMuteRes, important); if (!mRows.isEmpty()) { addSpacer(row); } mDialogContentView.addView(row.view, mDialogContentView.getChildCount() - 2); mDialogRowsView.addView(row.view); mRows.add(row); } Loading @@ -322,23 +318,10 @@ public class VolumeDialog implements TunerService.Tunable { for (int i = 0; i < N; i++) { final VolumeRow row = mRows.get(i); initRow(row, row.stream, row.iconRes, row.iconMuteRes, row.important); if (i > 0) { addSpacer(row); } mDialogContentView.addView(row.view, mDialogContentView.getChildCount() - 2); mDialogRowsView.addView(row.view); } } private void addSpacer(VolumeRow row) { final View v = new View(mContext); v.setId(android.R.id.background); final int h = mContext.getResources() .getDimensionPixelSize(R.dimen.volume_slider_interspacing); final LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, h); mDialogContentView.addView(v, mDialogContentView.getChildCount() - 2, lp); row.space = v; } private boolean isAttached() { return mDialogContentView != null && mDialogContentView.isAttachedToWindow(); Loading Loading @@ -392,12 +375,15 @@ public class VolumeDialog implements TunerService.Tunable { row.iconMuteRes = iconMuteRes; row.important = important; row.view = mDialog.getLayoutInflater().inflate(R.layout.volume_dialog_row, null); row.view.setId(row.stream); row.view.setTag(row); row.header = (TextView) row.view.findViewById(R.id.volume_row_header); row.header.setId(20 * row.stream); mSpTexts.add(row.header); row.slider = (SeekBar) row.view.findViewById(R.id.volume_row_slider); row.slider.setOnSeekBarChangeListener(new VolumeSeekBarChangeListener(row)); row.anim = null; row.cachedShowHeaders = VolumePrefs.DEFAULT_SHOW_HEADERS; // forward events above the slider into the slider row.view.setOnTouchListener(new OnTouchListener() { Loading Loading @@ -509,7 +495,7 @@ public class VolumeDialog implements TunerService.Tunable { mMotion.startDismiss(new Runnable() { @Override public void run() { setExpandedH(false); updateExpandedH(false); } }); if (mAccessibilityMgr.isEnabled()) { Loading Loading @@ -555,48 +541,53 @@ public class VolumeDialog implements TunerService.Tunable { mHandler.sendEmptyMessageDelayed(H.UPDATE_BOTTOM_MARGIN, getConservativeCollapseDuration()); } private void setExpandedH(boolean expanded) { private void updateExpandedH(final boolean expanded) { if (mExpanded == expanded) return; mExpanded = expanded; mExpandButtonAnimationRunning = isAttached(); if (D.BUG) Log.d(TAG, "setExpandedH " + expanded); if (!mExpanded && mExpandButtonAnimationRunning) { prepareForCollapse(); if (D.BUG) Log.d(TAG, "updateExpandedH " + expanded); updateExpandButtonH(); updateFooterH(); final VolumeRow activeRow = getActiveRow(); mWindow.setLayout(mWindow.getAttributes().width, ViewGroup.LayoutParams.MATCH_PARENT); AutoTransition transition = new AutoTransition(); transition.setDuration(mExpandButtonAnimationDuration); transition.setInterpolator(Interpolators.LINEAR_OUT_SLOW_IN); transition.addListener(new Transition.TransitionListener() { @Override public void onTransitionStart(Transition transition) { } final Resources res = mContext.getResources(); int paddingTop = mExpanded ? res.getDimensionPixelSize(R.dimen.volume_dialog_expanded_padding_top) : res.getDimensionPixelSize(R.dimen.volume_dialog_collapsed_padding_top); mDialogContentView.setPaddingRelative(mDialogContentView.getPaddingStart(), paddingTop, mDialogContentView.getPaddingEnd(), mDialogContentView.getPaddingBottom()); updateRowsH(); if (mExpandButtonAnimationRunning) { final Drawable d = mExpandButton.getDrawable(); if (d instanceof AnimatedVectorDrawable) { // workaround to reset drawable final AnimatedVectorDrawable avd = (AnimatedVectorDrawable) d.getConstantState() .newDrawable(); mExpandButton.setImageDrawable(avd); avd.start(); mHandler.postDelayed(new Runnable() { @Override public void run() { mExpandButtonAnimationRunning = false; updateExpandButtonH(); rescheduleTimeoutH(); public void onTransitionEnd(Transition transition) { mWindow.setLayout( mWindow.getAttributes().width, ViewGroup.LayoutParams.WRAP_CONTENT); } }, mExpandButtonAnimationDuration); @Override public void onTransitionCancel(Transition transition) { mWindow.setLayout( mWindow.getAttributes().width, ViewGroup.LayoutParams.WRAP_CONTENT); } @Override public void onTransitionPause(Transition transition) { } @Override public void onTransitionResume(Transition transition) { } }); TransitionManager.endTransitions(mDialogView); TransitionManager.beginDelayedTransition(mDialogView, transition); updateRowsH(activeRow); rescheduleTimeoutH(); } private void updateExpandButtonH() { if (D.BUG) Log.d(TAG, "updateExpandButtonH"); mExpandButton.setClickable(!mExpandButtonAnimationRunning); if (mExpandButtonAnimationRunning && isAttached()) return; if (!(mExpandButtonAnimationRunning && isAttached())) { final int res = mExpanded ? R.drawable.ic_volume_collapse_animation : R.drawable.ic_volume_expand_animation; if (hasTouchFeature()) { Loading @@ -609,32 +600,51 @@ public class VolumeDialog implements TunerService.Tunable { mExpandButton.setContentDescription(mContext.getString(mExpanded ? R.string.accessibility_volume_collapse : R.string.accessibility_volume_expand)); } if (mExpandButtonAnimationRunning) { final Drawable d = mExpandButton.getDrawable(); if (d instanceof AnimatedVectorDrawable) { // workaround to reset drawable final AnimatedVectorDrawable avd = (AnimatedVectorDrawable) d.getConstantState() .newDrawable(); mExpandButton.setImageDrawable(avd); avd.start(); mHandler.postDelayed(new Runnable() { @Override public void run() { mExpandButtonAnimationRunning = false; updateExpandButtonH(); rescheduleTimeoutH(); } }, mExpandButtonAnimationDuration); } } } private boolean isVisibleH(VolumeRow row, boolean isActive) { private boolean shouldBeVisibleH(VolumeRow row, boolean isActive) { return mExpanded && row.view.getVisibility() == View.VISIBLE || (mExpanded && (row.important || isActive)) || !mExpanded && isActive; } private void updateRowsH() { private void updateRowsH(final VolumeRow activeRow) { if (D.BUG) Log.d(TAG, "updateRowsH"); final VolumeRow activeRow = getActiveRow(); updateFooterH(); updateExpandButtonH(); if (!mShowing) { trimObsoleteH(); } Util.setVisOrGone(mDialogRowsView.findViewById(R.id.spacer), mExpanded); // apply changes to all rows for (VolumeRow row : mRows) { for (final VolumeRow row : mRows) { final boolean isActive = row == activeRow; final boolean visible = isVisibleH(row, isActive); Util.setVisOrGone(row.view, visible); Util.setVisOrGone(row.space, visible && mExpanded); final boolean shouldBeVisible = shouldBeVisibleH(row, isActive); Util.setVisOrGone(row.view, shouldBeVisible); if (row.view.isShown()) { updateVolumeRowHeaderVisibleH(row); updateVolumeRowSliderTintH(row, isActive); } } } private void trimObsoleteH() { if (D.BUG) Log.d(TAG, "trimObsoleteH"); for (int i = mRows.size() - 1; i >= 0; i--) { Loading @@ -642,8 +652,7 @@ public class VolumeDialog implements TunerService.Tunable { if (row.ss == null || !row.ss.dynamic) continue; if (!mDynamic.get(row.stream)) { mRows.remove(i); mDialogContentView.removeView(row.view); mDialogContentView.removeView(row.space); mDialogRowsView.removeView(row.view); } } } Loading @@ -670,7 +679,7 @@ public class VolumeDialog implements TunerService.Tunable { if (mActiveStream != state.activeStream) { mActiveStream = state.activeStream; updateRowsH(); updateRowsH(getActiveRow()); rescheduleTimeoutH(); } for (VolumeRow row : mRows) { Loading Loading @@ -731,9 +740,6 @@ public class VolumeDialog implements TunerService.Tunable { && mState.ringerModeInternal == AudioManager.RINGER_MODE_SILENT; final boolean isZenAlarms = mState.zenMode == Global.ZEN_MODE_ALARMS; final boolean isZenNone = mState.zenMode == Global.ZEN_MODE_NO_INTERRUPTIONS; final boolean isZenPriority = mState.zenMode == Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS; final boolean isRingZenNone = (isRingStream || isSystemStream) && isZenNone; final boolean isRingLimited = isRingStream && isZenPriority; final boolean zenMuted = isZenAlarms ? (isRingStream || isSystemStream) : isZenNone ? (isRingStream || isSystemStream || isAlarmStream || isMusicStream) : false; Loading Loading @@ -1023,7 +1029,7 @@ public class VolumeDialog implements TunerService.Tunable { if (mExpandButtonAnimationRunning) return; final boolean newExpand = !mExpanded; Events.writeEvent(mContext, Events.EVENT_EXPAND, newExpand); setExpandedH(newExpand); updateExpandedH(newExpand); } }; Loading Loading @@ -1220,7 +1226,6 @@ public class VolumeDialog implements TunerService.Tunable { private static class VolumeRow { private View view; private View space; private TextView header; private ImageButton icon; private SeekBar slider; Loading