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

Commit 7b52e3f7 authored by Hongwei Wang's avatar Hongwei Wang Committed by Automerger Merge Worker
Browse files

Merge "Differentiate user resize and system expand" into rvc-dev am: da475145 am: 3699eb21

Change-Id: I8e54d7a63f5fba8790be84c6bbde0f596ae694c8
parents c032d21b 3699eb21
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -339,18 +339,18 @@ public class PipManager implements BasePipManager, PipTaskOrganizer.PipTransitio

    @Override
    public void onPipTransitionFinished(ComponentName activity, int direction) {
        onPipTransitionFinishedOrCanceled();
        onPipTransitionFinishedOrCanceled(direction);
    }

    @Override
    public void onPipTransitionCanceled(ComponentName activity, int direction) {
        onPipTransitionFinishedOrCanceled();
        onPipTransitionFinishedOrCanceled(direction);
    }

    private void onPipTransitionFinishedOrCanceled() {
    private void onPipTransitionFinishedOrCanceled(int direction) {
        // Re-enable touches after the animation completes
        mTouchHandler.setTouchEnabled(true);
        mTouchHandler.onPinnedStackAnimationEnded();
        mTouchHandler.onPinnedStackAnimationEnded(direction);
        mMenuController.onPinnedStackAnimationEnded();
    }

+5 −4
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@ import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.Messenger;
import android.os.RemoteException;
@@ -129,9 +130,7 @@ public class PipMenuActivity extends Activity {
                }
            };

    private Handler mHandler = new Handler();
    private Messenger mToControllerMessenger;
    private Messenger mMessenger = new Messenger(new Handler() {
    private Handler mHandler = new Handler(Looper.getMainLooper()) {
        @Override
        public void handleMessage(Message msg) {
            switch (msg.what) {
@@ -174,7 +173,9 @@ public class PipMenuActivity extends Activity {
                }
            }
        }
    });
    };
    private Messenger mToControllerMessenger;
    private Messenger mMessenger = new Messenger(mHandler);

    private final Runnable mFinishRunnable = new Runnable() {
        @Override
+7 −4
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import android.graphics.Rect;
import android.os.Bundle;
import android.os.Debug;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.Messenger;
import android.os.RemoteException;
@@ -122,7 +123,7 @@ public class PipMenuActivityController {
    private boolean mStartActivityRequested;
    private long mStartActivityRequestedTime;
    private Messenger mToActivityMessenger;
    private Handler mHandler = new Handler() {
    private Handler mHandler = new Handler(Looper.getMainLooper()) {
        @Override
        public void handleMessage(Message msg) {
            switch (msg.what) {
@@ -133,15 +134,15 @@ public class PipMenuActivityController {
                    break;
                }
                case MESSAGE_EXPAND_PIP: {
                    mListeners.forEach(l -> l.onPipExpand());
                    mListeners.forEach(Listener::onPipExpand);
                    break;
                }
                case MESSAGE_DISMISS_PIP: {
                    mListeners.forEach(l -> l.onPipDismiss());
                    mListeners.forEach(Listener::onPipDismiss);
                    break;
                }
                case MESSAGE_SHOW_MENU: {
                    mListeners.forEach(l -> l.onPipShowMenu());
                    mListeners.forEach(Listener::onPipShowMenu);
                    break;
                }
                case MESSAGE_UPDATE_ACTIVITY_CALLBACK: {
@@ -259,6 +260,8 @@ public class PipMenuActivityController {
        if (DEBUG) {
            Log.d(TAG, "showMenu() state=" + menuState
                    + " hasActivity=" + (mToActivityMessenger != null)
                    + " allowMenuTimeout=" + allowMenuTimeout
                    + " willResizeMenu=" + willResizeMenu
                    + " callers=\n" + Debug.getCallers(5, "    "));
        }

+7 −9
Original line number Diff line number Diff line
@@ -56,7 +56,6 @@ public class PipResizeGestureHandler {

    private final DisplayMetrics mDisplayMetrics = new DisplayMetrics();
    private final PipBoundsHandler mPipBoundsHandler;
    private final PipTouchHandler mPipTouchHandler;
    private final PipMotionHelper mMotionHelper;
    private final int mDisplayId;
    private final Executor mMainExecutor;
@@ -70,10 +69,10 @@ public class PipResizeGestureHandler {
    private final Rect mTmpBounds = new Rect();
    private final int mDelta;

    private boolean mAllowGesture = false;
    private boolean mAllowGesture;
    private boolean mIsAttached;
    private boolean mIsEnabled;
    private boolean mEnablePipResize;
    private boolean mEnableUserResize;

    private InputMonitor mInputMonitor;
    private InputEventReceiver mInputEventReceiver;
@@ -82,21 +81,20 @@ public class PipResizeGestureHandler {
    private int mCtrlType;

    public PipResizeGestureHandler(Context context, PipBoundsHandler pipBoundsHandler,
            PipTouchHandler pipTouchHandler, PipMotionHelper motionHelper,
            DeviceConfigProxy deviceConfig, PipTaskOrganizer pipTaskOrganizer) {
            PipMotionHelper motionHelper, DeviceConfigProxy deviceConfig,
            PipTaskOrganizer pipTaskOrganizer) {
        final Resources res = context.getResources();
        context.getDisplay().getMetrics(mDisplayMetrics);
        mDisplayId = context.getDisplayId();
        mMainExecutor = context.getMainExecutor();
        mPipBoundsHandler = pipBoundsHandler;
        mPipTouchHandler = pipTouchHandler;
        mMotionHelper = motionHelper;
        mPipTaskOrganizer = pipTaskOrganizer;

        context.getDisplay().getRealSize(mMaxSize);
        mDelta = res.getDimensionPixelSize(R.dimen.pip_resize_edge_size);

        mEnablePipResize = DeviceConfig.getBoolean(
        mEnableUserResize = DeviceConfig.getBoolean(
                DeviceConfig.NAMESPACE_SYSTEMUI,
                PIP_USER_RESIZE,
                /* defaultValue = */ true);
@@ -105,7 +103,7 @@ public class PipResizeGestureHandler {
                    @Override
                    public void onPropertiesChanged(DeviceConfig.Properties properties) {
                        if (properties.getKeyset().contains(PIP_USER_RESIZE)) {
                            mEnablePipResize = properties.getBoolean(
                            mEnableUserResize = properties.getBoolean(
                                    PIP_USER_RESIZE, /* defaultValue = */ true);
                        }
                    }
@@ -134,7 +132,7 @@ public class PipResizeGestureHandler {
    }

    private void updateIsEnabled() {
        boolean isEnabled = mIsAttached && mEnablePipResize;
        boolean isEnabled = mIsAttached && mEnableUserResize;
        if (isEnabled == mIsEnabled) {
            return;
        }
+10 −3
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.systemui.pip.phone;

import static com.android.systemui.pip.PipAnimationController.TRANSITION_DIRECTION_TO_PIP;
import static com.android.systemui.pip.phone.PipMenuActivityController.MENU_STATE_CLOSE;
import static com.android.systemui.pip.phone.PipMenuActivityController.MENU_STATE_FULL;
import static com.android.systemui.pip.phone.PipMenuActivityController.MENU_STATE_NONE;
@@ -56,6 +57,7 @@ import androidx.dynamicanimation.animation.SpringForce;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.os.logging.MetricsLoggerWrapper;
import com.android.systemui.R;
import com.android.systemui.pip.PipAnimationController;
import com.android.systemui.pip.PipBoundsHandler;
import com.android.systemui.pip.PipSnapAlgorithm;
import com.android.systemui.pip.PipTaskOrganizer;
@@ -229,7 +231,7 @@ public class PipTouchHandler {
        mMotionHelper = new PipMotionHelper(mContext, activityTaskManager, pipTaskOrganizer,
                mMenuController, mSnapAlgorithm, mFlingAnimationUtils, floatingContentCoordinator);
        mPipResizeGestureHandler =
                new PipResizeGestureHandler(context, pipBoundsHandler, this, mMotionHelper,
                new PipResizeGestureHandler(context, pipBoundsHandler, mMotionHelper,
                        deviceConfig, pipTaskOrganizer);
        mTouchState = new PipTouchState(ViewConfiguration.get(context), mHandler,
                () -> mMenuController.showMenu(MENU_STATE_FULL, mMotionHelper.getBounds(),
@@ -343,11 +345,16 @@ public class PipTouchHandler {
        mPipResizeGestureHandler.onActivityUnpinned();
    }

    public void onPinnedStackAnimationEnded() {
    public void onPinnedStackAnimationEnded(
            @PipAnimationController.TransitionDirection int direction) {
        // Always synchronize the motion helper bounds once PiP animations finish
        mMotionHelper.synchronizePinnedStackBounds();
        updateMovementBounds();
        if (direction == TRANSITION_DIRECTION_TO_PIP) {
            // updates mResizedBounds only if it's an entering PiP animation
            // mResized should be otherwise updated in setMenuState.
            mResizedBounds.set(mMotionHelper.getBounds());
        }

        if (mShowPipMenuOnAnimationEnd) {
            mMenuController.showMenu(MENU_STATE_CLOSE, mMotionHelper.getBounds(),