Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4e8ff770 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Revert Early version of new volume"

parents cb764f81 98ad83cd
Loading
Loading
Loading
Loading
+3 −4
Original line number Original line Diff line number Diff line
@@ -16,12 +16,12 @@
<RelativeLayout
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/volume_dialog"
    android:id="@+id/volume_dialog"
    android:layout_width="@dimen/volume_dialog_panel_width"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginBottom="@dimen/volume_dialog_margin_bottom"
    android:layout_marginBottom="@dimen/volume_dialog_margin_bottom"
    android:layout_gravity="center_vertical|end"
    android:background="@drawable/volume_dialog_background"
    android:paddingTop="@dimen/volume_dialog_padding_top"
    android:paddingTop="@dimen/volume_dialog_padding_top"
    android:translationZ="8dp" >
    android:translationZ="4dp" >


    <LinearLayout
    <LinearLayout
        android:id="@+id/volume_dialog_content"
        android:id="@+id/volume_dialog_content"
@@ -57,7 +57,6 @@
            android:layout_height="wrap_content"
            android:layout_height="wrap_content"
            android:ellipsize="end"
            android:ellipsize="end"
            android:maxLines="1"
            android:maxLines="1"
            android:visibility="gone"
            android:textAppearance="@style/TextAppearance.Volume.Header" />
            android:textAppearance="@style/TextAppearance.Volume.Header" />
        <com.android.keyguard.AlphaOptimizedImageButton
        <com.android.keyguard.AlphaOptimizedImageButton
            xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:android="http://schemas.android.com/apk/res/android"
+0 −11
Original line number Original line Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<com.android.systemui.HardwareUiLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginTop="@dimen/top_padding"
    android:layout_marginBottom="@dimen/bottom_padding">

    <include layout="@layout/volume_dialog"/>

</com.android.systemui.HardwareUiLayout>
+2 −1
Original line number Original line Diff line number Diff line
@@ -216,6 +216,8 @@
    <!-- The width of the panel that holds the quick settings. -->
    <!-- The width of the panel that holds the quick settings. -->
    <dimen name="qs_panel_width">@dimen/notification_panel_width</dimen>
    <dimen name="qs_panel_width">@dimen/notification_panel_width</dimen>


    <dimen name="volume_dialog_panel_width">@dimen/standard_notification_panel_width</dimen>

    <!-- Gravity for the notification panel -->
    <!-- Gravity for the notification panel -->
    <integer name="notification_panel_layout_gravity">0x31</integer><!-- center_horizontal|top -->
    <integer name="notification_panel_layout_gravity">0x31</integer><!-- center_horizontal|top -->


@@ -800,7 +802,6 @@


    <dimen name="hwui_edge_margin">16dp</dimen>
    <dimen name="hwui_edge_margin">16dp</dimen>


    <dimen name="volume_dialog_panel_width">315dp</dimen>
    <dimen name="global_actions_panel_width">125dp</dimen>
    <dimen name="global_actions_panel_width">125dp</dimen>


    <dimen name="global_actions_top_padding">100dp</dimen>
    <dimen name="global_actions_top_padding">100dp</dimen>
+76 −85
Original line number Original line Diff line number Diff line
@@ -18,7 +18,6 @@ package com.android.systemui.volume;


import static android.accessibilityservice.AccessibilityServiceInfo.FEEDBACK_ALL_MASK;
import static android.accessibilityservice.AccessibilityServiceInfo.FEEDBACK_ALL_MASK;
import static android.accessibilityservice.AccessibilityServiceInfo.FEEDBACK_GENERIC;
import static android.accessibilityservice.AccessibilityServiceInfo.FEEDBACK_GENERIC;
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;


import android.accessibilityservice.AccessibilityServiceInfo;
import android.accessibilityservice.AccessibilityServiceInfo;
import android.animation.ObjectAnimator;
import android.animation.ObjectAnimator;
@@ -32,10 +31,12 @@ import android.content.pm.PackageManager;
import android.content.res.ColorStateList;
import android.content.res.ColorStateList;
import android.content.res.Configuration;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.PixelFormat;
import android.graphics.PixelFormat;
import android.graphics.Point;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.Rect;
import android.graphics.drawable.AnimatedVectorDrawable;
import android.graphics.drawable.AnimatedVectorDrawable;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.Drawable;
import android.media.AudioManager;
import android.media.AudioManager;
import android.media.AudioSystem;
import android.media.AudioSystem;
@@ -48,9 +49,11 @@ import android.provider.Settings.Global;
import android.transition.AutoTransition;
import android.transition.AutoTransition;
import android.transition.Transition;
import android.transition.Transition;
import android.transition.TransitionManager;
import android.transition.TransitionManager;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.Log;
import android.util.Slog;
import android.util.Slog;
import android.util.SparseBooleanArray;
import android.util.SparseBooleanArray;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.View;
import android.view.View.AccessibilityDelegate;
import android.view.View.AccessibilityDelegate;
@@ -71,7 +74,6 @@ import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.TextView;
import android.widget.TextView;
import com.android.settingslib.Utils;
import com.android.settingslib.Utils;
import com.android.systemui.Dependency;
import com.android.systemui.Dependency;
import com.android.systemui.HardwareUiLayout;
import com.android.systemui.Interpolators;
import com.android.systemui.Interpolators;
import com.android.systemui.R;
import com.android.systemui.R;
import com.android.systemui.colorextraction.SysuiColorExtractor;
import com.android.systemui.colorextraction.SysuiColorExtractor;
@@ -96,8 +98,7 @@ import java.util.List;
 *
 *
 * Methods ending in "H" must be called on the (ui) handler.
 * Methods ending in "H" must be called on the (ui) handler.
 */
 */
public class VolumeDialogImpl implements VolumeDialog, TunerService.Tunable,
public class VolumeDialogImpl implements VolumeDialog, TunerService.Tunable {
        ColorExtractor.OnColorsChangedListener {
    private static final String TAG = Util.logTag(VolumeDialogImpl.class);
    private static final String TAG = Util.logTag(VolumeDialogImpl.class);


    public static final String SHOW_FULL_ZEN = "sysui_show_full_zen";
    public static final String SHOW_FULL_ZEN = "sysui_show_full_zen";
@@ -107,8 +108,6 @@ public class VolumeDialogImpl implements VolumeDialog, TunerService.Tunable,


    private final Context mContext;
    private final Context mContext;
    private final H mHandler = new H();
    private final H mHandler = new H();
    private final GradientDrawable mGradientDrawable;
    private final ColorExtractor mColorExtractor;
    private final VolumeDialogController mController;
    private final VolumeDialogController mController;


    private Window mWindow;
    private Window mWindow;
@@ -163,9 +162,6 @@ public class VolumeDialogImpl implements VolumeDialog, TunerService.Tunable,
                (AccessibilityManager) mContext.getSystemService(Context.ACCESSIBILITY_SERVICE);
                (AccessibilityManager) mContext.getSystemService(Context.ACCESSIBILITY_SERVICE);
        mActiveSliderTint = ColorStateList.valueOf(Utils.getColorAccent(mContext));
        mActiveSliderTint = ColorStateList.valueOf(Utils.getColorAccent(mContext));
        mInactiveSliderTint = loadColorStateList(R.color.volume_slider_inactive);
        mInactiveSliderTint = loadColorStateList(R.color.volume_slider_inactive);
        mGradientDrawable = new GradientDrawable(mContext);
        mGradientDrawable.setAlpha((int) (ScrimController.GRADIENT_SCRIM_ALPHA * 255));
        mColorExtractor = Dependency.get(SysuiColorExtractor.class);
    }
    }


    public void init(int windowType, Callback callback) {
    public void init(int windowType, Callback callback) {
@@ -187,7 +183,6 @@ public class VolumeDialogImpl implements VolumeDialog, TunerService.Tunable,
    @Override
    @Override
    public void destroy() {
    public void destroy() {
        mController.removeCallback(mControllerCallbackH);
        mController.removeCallback(mControllerCallbackH);
        mColorExtractor.removeOnColorsChangedListener(this);
    }
    }


    private void initDialog() {
    private void initDialog() {
@@ -198,44 +193,55 @@ public class VolumeDialogImpl implements VolumeDialog, TunerService.Tunable,
        mShowing = false;
        mShowing = false;
        mWindow = mDialog.getWindow();
        mWindow = mDialog.getWindow();
        mWindow.requestFeature(Window.FEATURE_NO_TITLE);
        mWindow.requestFeature(Window.FEATURE_NO_TITLE);
        mWindow.setBackgroundDrawable(mGradientDrawable);
        mWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        mWindow.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
        mWindow.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
        mWindow.addFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
        mWindow.addFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
                | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
                | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
                | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
                | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
                | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
                | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH);
                | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH
        Point displaySize = new Point();
                | WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
        mContext.getDisplay().getRealSize(displaySize);
        mDialog.setCanceledOnTouchOutside(true);
        mDialog.setCanceledOnTouchOutside(true);
        final Resources res = mContext.getResources();
        final Resources res = mContext.getResources();
        final WindowManager.LayoutParams lp = mWindow.getAttributes();
        lp.type = mWindowType;
        lp.format = PixelFormat.TRANSLUCENT;
        lp.setTitle(VolumeDialogImpl.class.getSimpleName());
        lp.gravity = Gravity.TOP | Gravity.CENTER_HORIZONTAL;
        lp.y = res.getDimensionPixelSize(R.dimen.volume_offset_top);
        lp.gravity = Gravity.TOP;
        lp.windowAnimations = -1;
        mWindow.setAttributes(lp);
        mWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING);
        mWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING);


        mDialog.setContentView(R.layout.volume_dialog_wrapped);
        mDialog.setContentView(R.layout.volume_dialog);
        mDialogView = mDialog.findViewById(R.id.volume_dialog);
        mDialogView = (ViewGroup) mDialog.findViewById(R.id.volume_dialog);
        mDialogView.setOnHoverListener((v, event) -> {
        mDialogView.setOnHoverListener(new View.OnHoverListener() {
            @Override
            public boolean onHover(View v, MotionEvent event) {
                int action = event.getActionMasked();
                int action = event.getActionMasked();
                mHovering = (action == MotionEvent.ACTION_HOVER_ENTER)
                mHovering = (action == MotionEvent.ACTION_HOVER_ENTER)
                        || (action == MotionEvent.ACTION_HOVER_MOVE);
                        || (action == MotionEvent.ACTION_HOVER_MOVE);
                rescheduleTimeoutH();
                rescheduleTimeoutH();
                return true;
                return true;
            }
        });
        });


        mColorExtractor.addOnColorsChangedListener(this);
        mGradientDrawable.setScreenSize(displaySize.x, displaySize.y);

        mDialogContentView = mDialog.findViewById(R.id.volume_dialog_content);
        mDialogContentView = mDialog.findViewById(R.id.volume_dialog_content);
        mDialogRowsView = mDialogContentView.findViewById(R.id.volume_dialog_rows);
        mDialogRowsView = mDialogContentView.findViewById(R.id.volume_dialog_rows);
        mExpanded = false;
        mExpanded = false;
        mExpandButton = mDialogView.findViewById(R.id.volume_expand_button);
        mExpandButton = (ImageButton) mDialogView.findViewById(R.id.volume_expand_button);
        mExpandButton.setOnClickListener(mClickExpand);
        mExpandButton.setOnClickListener(mClickExpand);


        mExpandButton.setVisibility(
        mExpandButton.setVisibility(
                AudioSystem.isSingleVolume(mContext) ? View.GONE : View.VISIBLE);
                AudioSystem.isSingleVolume(mContext) ? View.GONE : View.VISIBLE);
        updateWindowWidthH();
        updateExpandButtonH();
        updateExpandButtonH();


        mMotion = new VolumeDialogMotion(mDialog, (View) mDialogView.getParent(),
        mMotion = new VolumeDialogMotion(mDialog, mDialogView, mDialogContentView, mExpandButton,
                mDialogContentView, mExpandButton, mGradientDrawable, animating -> {
                new VolumeDialogMotion.Callback() {
                    @Override
                    public void onAnimatingChanged(boolean animating) {
                        if (animating) return;
                        if (animating) return;
                        if (mPendingStateChanged) {
                        if (mPendingStateChanged) {
                            mHandler.sendEmptyMessage(H.STATE_CHANGED);
                            mHandler.sendEmptyMessage(H.STATE_CHANGED);
@@ -245,6 +251,7 @@ public class VolumeDialogImpl implements VolumeDialog, TunerService.Tunable,
                            mHandler.sendEmptyMessage(H.RECHECK_ALL);
                            mHandler.sendEmptyMessage(H.RECHECK_ALL);
                            mPendingRecheckAll = false;
                            mPendingRecheckAll = false;
                        }
                        }
                    }
                });
                });


        if (mRows.isEmpty()) {
        if (mRows.isEmpty()) {
@@ -268,20 +275,11 @@ public class VolumeDialogImpl implements VolumeDialog, TunerService.Tunable,
            addExistingRows();
            addExistingRows();
        }
        }
        mExpandButtonAnimationDuration = res.getInteger(R.integer.volume_expand_animation_duration);
        mExpandButtonAnimationDuration = res.getInteger(R.integer.volume_expand_animation_duration);
        mZenFooter = mDialog.findViewById(R.id.volume_zen_footer);
        mZenFooter = (ZenFooter) mDialog.findViewById(R.id.volume_zen_footer);
        mZenFooter.init(mZenModeController);
        mZenFooter.init(mZenModeController);
        mZenPanel = mDialog.findViewById(R.id.tuner_zen_mode_panel);
        mZenPanel = (TunerZenModePanel) mDialog.findViewById(R.id.tuner_zen_mode_panel);
        mZenPanel.init(mZenModeController);
        mZenPanel.init(mZenModeController);
        mZenPanel.setCallback(mZenPanelCallback);
        mZenPanel.setCallback(mZenPanelCallback);

        final WindowManager.LayoutParams lp = mWindow.getAttributes();
        lp.width = MATCH_PARENT;
        lp.height = MATCH_PARENT;
        lp.type = mWindowType;
        lp.format = PixelFormat.TRANSLUCENT;
        lp.setTitle(VolumeDialogImpl.class.getSimpleName());
        lp.windowAnimations = -1;
        mWindow.setAttributes(lp);
    }
    }


    @Override
    @Override
@@ -295,6 +293,20 @@ public class VolumeDialogImpl implements VolumeDialog, TunerService.Tunable,
        return ColorStateList.valueOf(mContext.getColor(colorResId));
        return ColorStateList.valueOf(mContext.getColor(colorResId));
    }
    }


    private void updateWindowWidthH() {
        final ViewGroup.LayoutParams lp = mDialogView.getLayoutParams();
        final DisplayMetrics dm = mContext.getResources().getDisplayMetrics();
        if (D.BUG) Log.d(TAG, "updateWindowWidth dm.w=" + dm.widthPixels);
        int w = dm.widthPixels;
        final int max = mContext.getResources()
                .getDimensionPixelSize(R.dimen.volume_dialog_panel_width);
        if (w > max) {
            w = max;
        }
        lp.width = w;
        mDialogView.setLayoutParams(lp);
    }

    public void setStreamImportant(int stream, boolean important) {
    public void setStreamImportant(int stream, boolean important) {
        mHandler.obtainMessage(H.SET_STREAM_IMPORTANT, stream, important ? 1 : 0).sendToTarget();
        mHandler.obtainMessage(H.SET_STREAM_IMPORTANT, stream, important ? 1 : 0).sendToTarget();
    }
    }
@@ -478,10 +490,6 @@ public class VolumeDialogImpl implements VolumeDialog, TunerService.Tunable,
        rescheduleTimeoutH();
        rescheduleTimeoutH();
        if (mShowing) return;
        if (mShowing) return;
        mShowing = true;
        mShowing = true;
        ColorExtractor.GradientColors colors = mColorExtractor.getColors(
                mKeyguard.isKeyguardLocked() ? WallpaperManager.FLAG_LOCK
                        : WallpaperManager.FLAG_SYSTEM);
        mGradientDrawable.setColors(colors, false);
        mMotion.startShow();
        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);
@@ -539,8 +547,10 @@ public class VolumeDialogImpl implements VolumeDialog, TunerService.Tunable,
    }
    }


    private void updateDialogBottomMarginH() {
    private void updateDialogBottomMarginH() {
        final long diff = System.currentTimeMillis() - mCollapseTime;
        final boolean collapsing = mCollapseTime != 0 && diff < getConservativeCollapseDuration();
        final ViewGroup.MarginLayoutParams mlp = (MarginLayoutParams) mDialogView.getLayoutParams();
        final ViewGroup.MarginLayoutParams mlp = (MarginLayoutParams) mDialogView.getLayoutParams();
        final int bottomMargin =
        final int bottomMargin = collapsing ? mDialogContentView.getHeight() :
                mContext.getResources().getDimensionPixelSize(R.dimen.volume_dialog_margin_bottom);
                mContext.getResources().getDimensionPixelSize(R.dimen.volume_dialog_margin_bottom);
        if (bottomMargin != mlp.bottomMargin) {
        if (bottomMargin != mlp.bottomMargin) {
            if (D.BUG) Log.d(TAG, "bottomMargin " + mlp.bottomMargin + " -> " + bottomMargin);
            if (D.BUG) Log.d(TAG, "bottomMargin " + mlp.bottomMargin + " -> " + bottomMargin);
@@ -570,7 +580,7 @@ public class VolumeDialogImpl implements VolumeDialog, TunerService.Tunable,
        TransitionManager.endTransitions(mDialogView);
        TransitionManager.endTransitions(mDialogView);
        final VolumeRow activeRow = getActiveRow();
        final VolumeRow activeRow = getActiveRow();
        if (!dismissing) {
        if (!dismissing) {
            mWindow.setLayout(mWindow.getAttributes().width, MATCH_PARENT);
            mWindow.setLayout(mWindow.getAttributes().width, ViewGroup.LayoutParams.MATCH_PARENT);
            TransitionManager.beginDelayedTransition(mDialogView, getTransition());
            TransitionManager.beginDelayedTransition(mDialogView, getTransition());
        }
        }
        updateRowsH(activeRow);
        updateRowsH(activeRow);
@@ -632,7 +642,7 @@ public class VolumeDialogImpl implements VolumeDialog, TunerService.Tunable,
            final boolean isActive = row == activeRow;
            final boolean isActive = row == activeRow;
            final boolean shouldBeVisible = shouldBeVisibleH(row, isActive);
            final boolean shouldBeVisible = shouldBeVisibleH(row, isActive);
            Util.setVisOrGone(row.view, shouldBeVisible);
            Util.setVisOrGone(row.view, shouldBeVisible);
            Util.setVisOrGone(row.header, shouldBeVisible && mExpanded);
            Util.setVisOrGone(row.header, shouldBeVisible);
            if (row.view.isShown()) {
            if (row.view.isShown()) {
                updateVolumeRowSliderTintH(row, isActive);
                updateVolumeRowSliderTintH(row, isActive);
            }
            }
@@ -689,18 +699,12 @@ public class VolumeDialogImpl implements VolumeDialog, TunerService.Tunable,
        final boolean visible = mState.zenMode != Global.ZEN_MODE_OFF
        final boolean visible = mState.zenMode != Global.ZEN_MODE_OFF
                && (mAudioManager.isStreamAffectedByRingerMode(mActiveStream) || mExpanded)
                && (mAudioManager.isStreamAffectedByRingerMode(mActiveStream) || mExpanded)
                && !mZenPanel.isEditing();
                && !mZenPanel.isEditing();

        TransitionManager.beginDelayedTransition(mDialogView, getTransition());
        if (wasVisible != visible) {
        if (wasVisible != visible && !visible) {
            mZenFooter.update();
            prepareForCollapse();
            if (visible) {
                HardwareUiLayout.get(mZenFooter).setDivisionView(mZenFooter);
            } else {
                mHandler.postDelayed(() ->
                                HardwareUiLayout.get(mZenFooter).setDivisionView(mZenFooter),
                        mExpandButtonAnimationDuration);
        }
        }
        Util.setVisOrGone(mZenFooter, visible);
        Util.setVisOrGone(mZenFooter, visible);
        }
        mZenFooter.update();


        final boolean fullWasVisible = mZenPanel.getVisibility() == View.VISIBLE;
        final boolean fullWasVisible = mZenPanel.getVisibility() == View.VISIBLE;
        final boolean fullVisible = mShowFullZen && !visible;
        final boolean fullVisible = mShowFullZen && !visible;
@@ -960,7 +964,8 @@ public class VolumeDialogImpl implements VolumeDialog, TunerService.Tunable,


            @Override
            @Override
            public void onTransitionEnd(Transition transition) {
            public void onTransitionEnd(Transition transition) {
                mWindow.setLayout(MATCH_PARENT, MATCH_PARENT);
                mWindow.setLayout(
                        mWindow.getAttributes().width, ViewGroup.LayoutParams.WRAP_CONTENT);
            }
            }


            @Override
            @Override
@@ -969,7 +974,8 @@ public class VolumeDialogImpl implements VolumeDialog, TunerService.Tunable,


            @Override
            @Override
            public void onTransitionPause(Transition transition) {
            public void onTransitionPause(Transition transition) {
                mWindow.setLayout(MATCH_PARENT, MATCH_PARENT);
                mWindow.setLayout(
                        mWindow.getAttributes().width, ViewGroup.LayoutParams.WRAP_CONTENT);
            }
            }


            @Override
            @Override
@@ -1021,6 +1027,7 @@ public class VolumeDialogImpl implements VolumeDialog, TunerService.Tunable,
                initDialog();
                initDialog();
                mDensity = density;
                mDensity = density;
            }
            }
            updateWindowWidthH();
            mConfigurableTexts.update();
            mConfigurableTexts.update();
            mZenFooter.onConfigurationChanged();
            mZenFooter.onConfigurationChanged();
        }
        }
@@ -1076,26 +1083,10 @@ public class VolumeDialogImpl implements VolumeDialog, TunerService.Tunable,
            if (mExpandButtonAnimationRunning) 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);
            if (!newExpand) {
                HardwareUiLayout.get(mDialogContentView).setCollapse();
            }
            updateExpandedH(newExpand, false /* dismissing */);
            updateExpandedH(newExpand, false /* dismissing */);
        }
        }
    };
    };


    @Override
    public void onColorsChanged(ColorExtractor extractor, int which) {
        if (mKeyguard.isKeyguardLocked()) {
            if ((WallpaperManager.FLAG_LOCK & which) != 0) {
                mGradientDrawable.setColors(extractor.getColors(WallpaperManager.FLAG_LOCK));
            }
        } else {
            if ((WallpaperManager.FLAG_SYSTEM & which) != 0) {
                mGradientDrawable.setColors(extractor.getColors(WallpaperManager.FLAG_SYSTEM));
            }
        }
    }

    private final class H extends Handler {
    private final class H extends Handler {
        private static final int SHOW = 1;
        private static final int SHOW = 1;
        private static final int DISMISS = 2;
        private static final int DISMISS = 2;
@@ -1167,8 +1158,8 @@ public class VolumeDialogImpl implements VolumeDialog, TunerService.Tunable,
            event.setPackageName(mContext.getPackageName());
            event.setPackageName(mContext.getPackageName());


            ViewGroup.LayoutParams params = getWindow().getAttributes();
            ViewGroup.LayoutParams params = getWindow().getAttributes();
            boolean isFullScreen = (params.width == MATCH_PARENT) &&
            boolean isFullScreen = (params.width == ViewGroup.LayoutParams.MATCH_PARENT) &&
                    (params.height == MATCH_PARENT);
                    (params.height == ViewGroup.LayoutParams.MATCH_PARENT);
            event.setFullScreen(isFullScreen);
            event.setFullScreen(isFullScreen);


            if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) {
            if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) {
+30 −27
Original line number Original line Diff line number Diff line
@@ -13,6 +13,7 @@
 * See the License for the specific language governing permissions and
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * limitations under the License.
 */
 */

package com.android.systemui.volume;
package com.android.systemui.volume;


import android.animation.Animator;
import android.animation.Animator;
@@ -41,10 +42,8 @@ public class VolumeDialogMotion {
    private final View mDialogView;
    private final View mDialogView;
    private final ViewGroup mContents;  // volume rows + zen footer
    private final ViewGroup mContents;  // volume rows + zen footer
    private final View mChevron;
    private final View mChevron;
    private final Drawable mBackground;
    private final Handler mHandler = new Handler();
    private final Handler mHandler = new Handler();
    private final Callback mCallback;
    private final Callback mCallback;
    private final int mBackgroundTargetAlpha;


    private boolean mAnimating;  // show or dismiss animation is running
    private boolean mAnimating;  // show or dismiss animation is running
    private boolean mShowing;  // show animation is running
    private boolean mShowing;  // show animation is running
@@ -53,14 +52,12 @@ public class VolumeDialogMotion {
    private ValueAnimator mContentsPositionAnimator;
    private ValueAnimator mContentsPositionAnimator;


    public VolumeDialogMotion(Dialog dialog, View dialogView, ViewGroup contents, View chevron,
    public VolumeDialogMotion(Dialog dialog, View dialogView, ViewGroup contents, View chevron,
            Drawable background, Callback callback) {
            Callback callback) {
        mDialog = dialog;
        mDialog = dialog;
        mDialogView = dialogView;
        mDialogView = dialogView;
        mContents = contents;
        mContents = contents;
        mChevron = chevron;
        mChevron = chevron;
        mCallback = callback;
        mCallback = callback;
        mBackground = background;
        mBackgroundTargetAlpha = mBackground.getAlpha();
        mDialog.setOnDismissListener(new OnDismissListener() {
        mDialog.setOnDismissListener(new OnDismissListener() {
            @Override
            @Override
            public void onDismiss(DialogInterface dialog) {
            public void onDismiss(DialogInterface dialog) {
@@ -71,9 +68,8 @@ public class VolumeDialogMotion {
            @Override
            @Override
            public void onShow(DialogInterface dialog) {
            public void onShow(DialogInterface dialog) {
                if (D.BUG) Log.d(TAG, "mDialog.onShow");
                if (D.BUG) Log.d(TAG, "mDialog.onShow");
                final int w = mDialogView.getWidth() / 4;
                final int h = mDialogView.getHeight();
                mDialogView.setTranslationX(w);
                mDialogView.setTranslationY(-h);
                mBackground.setAlpha(0);
                startShowAnimation();
                startShowAnimation();
            }
            }
        });
        });
@@ -122,7 +118,7 @@ public class VolumeDialogMotion {
    }
    }


    private int chevronDistance() {
    private int chevronDistance() {
        return 0;
        return mChevron.getHeight() / 6;
    }
    }


    private int chevronPosY() {
    private int chevronPosY() {
@@ -133,29 +129,26 @@ public class VolumeDialogMotion {
    private void startShowAnimation() {
    private void startShowAnimation() {
        if (D.BUG) Log.d(TAG, "startShowAnimation");
        if (D.BUG) Log.d(TAG, "startShowAnimation");
        mDialogView.animate()
        mDialogView.animate()
                .translationX(0)
                .translationY(0)
                .translationY(0)
                .alpha(1)
                .setDuration(scaledDuration(300))
                .setDuration(scaledDuration(300))
                .setInterpolator(new LogDecelerateInterpolator())
                .setInterpolator(new LogDecelerateInterpolator())
                .setListener(null)
                .setListener(null)
                .setUpdateListener(animation -> {
                .setUpdateListener(animation -> {
                    mBackground.setAlpha(
                            (int) (animation.getAnimatedFraction() * mBackgroundTargetAlpha));
                    if (mChevronPositionAnimator != null) {
                    if (mChevronPositionAnimator != null) {
                        final float v = (Float) mChevronPositionAnimator.getAnimatedValue();
                        final float v = (Float) mChevronPositionAnimator.getAnimatedValue();
                        if (mChevronPositionAnimator == null) return;
                        if (mChevronPositionAnimator == null) return;
                        // reposition chevron
                        // reposition chevron
                        final int posY = chevronPosY();
                        final int posY = chevronPosY();
                        mChevron.setTranslationY(posY + v + -mDialogView.getTranslationY());
                    }
                    }
                })
                })
                .withEndAction(new Runnable() {
                .withEndAction(new Runnable() {
                    @Override
                    @Override
                    public void run() {
                    public void run() {
                        mBackground.setAlpha(mBackgroundTargetAlpha);
                        if (mChevronPositionAnimator == null) return;
                        if (mChevronPositionAnimator == null) return;
                        // reposition chevron
                        // reposition chevron
                        final int posY = chevronPosY();
                        final int posY = chevronPosY();
                        mChevron.setTranslationY(posY + -mDialogView.getTranslationY());
                    }
                    }
                })
                })
                .start();
                .start();
@@ -171,13 +164,19 @@ public class VolumeDialogMotion {
                if (D.BUG) Log.d(TAG, "show.onAnimationEnd");
                if (D.BUG) Log.d(TAG, "show.onAnimationEnd");
                setShowing(false);
                setShowing(false);
            }
            }

            @Override
            @Override
            public void onAnimationCancel(Animator animation) {
            public void onAnimationCancel(Animator animation) {
                if (D.BUG) Log.d(TAG, "show.onAnimationCancel");
                if (D.BUG) Log.d(TAG, "show.onAnimationCancel");
                mCancelled = true;
                mCancelled = true;
            }
            }
        });
        });
        mContentsPositionAnimator.addUpdateListener(new AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                float v = (Float) animation.getAnimatedValue();
                mContents.setTranslationY(v + -mDialogView.getTranslationY());
            }
        });
        mContentsPositionAnimator.setInterpolator(new LogDecelerateInterpolator());
        mContentsPositionAnimator.setInterpolator(new LogDecelerateInterpolator());
        mContentsPositionAnimator.start();
        mContentsPositionAnimator.start();


@@ -219,30 +218,34 @@ public class VolumeDialogMotion {
            setShowing(false);
            setShowing(false);
        }
        }
        mDialogView.animate()
        mDialogView.animate()
                .translationX(mDialogView.getWidth() / 4)
                .translationY(-mDialogView.getHeight())
                .alpha(0)
                .setDuration(scaledDuration(250))
                .setDuration(scaledDuration(250))
                .setInterpolator(new LogAccelerateInterpolator())
                .setInterpolator(new LogAccelerateInterpolator())
                .setUpdateListener(animation -> {
                .setUpdateListener(new AnimatorUpdateListener() {
                    final float v = 1 - mChevronPositionAnimator.getAnimatedFraction();
                    @Override
                    mBackground.setAlpha((int) (v * mBackgroundTargetAlpha));
                    public void onAnimationUpdate(ValueAnimator animation) {
                        mContents.setTranslationY(-mDialogView.getTranslationY());
                        final int posY = chevronPosY();
                        mChevron.setTranslationY(posY + -mDialogView.getTranslationY());
                    }
                })
                })
                .setListener(new AnimatorListenerAdapter() {
                .setListener(new AnimatorListenerAdapter() {
                    private boolean mCancelled;
                    private boolean mCancelled;

                    @Override
                    @Override
                    public void onAnimationEnd(Animator animation) {
                    public void onAnimationEnd(Animator animation) {
                        if (mCancelled) return;
                        if (mCancelled) return;
                        if (D.BUG) Log.d(TAG, "dismiss.onAnimationEnd");
                        if (D.BUG) Log.d(TAG, "dismiss.onAnimationEnd");
                        mHandler.postDelayed(() -> {
                        mHandler.postDelayed(new Runnable() {
                            @Override
                            public void run() {
                                if (D.BUG) Log.d(TAG, "mDialog.dismiss()");
                                if (D.BUG) Log.d(TAG, "mDialog.dismiss()");
                                mDialog.dismiss();
                                mDialog.dismiss();
                                onComplete.run();
                                onComplete.run();
                                setDismissing(false);
                                setDismissing(false);
                            }
                        }, PRE_DISMISS_DELAY);
                        }, PRE_DISMISS_DELAY);


                    }
                    }

                    @Override
                    @Override
                    public void onAnimationCancel(Animator animation) {
                    public void onAnimationCancel(Animator animation) {
                        if (D.BUG) Log.d(TAG, "dismiss.onAnimationCancel");
                        if (D.BUG) Log.d(TAG, "dismiss.onAnimationCancel");