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

Commit d70e75a5 authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Removing launcher dependency when logging quickstep interaction

as Launcher may not be ready when the touch gesture completes.

Change-Id: Ia69eb7bfb0340f7b7ce9b6c67be8851e5429f867
parent 668dd40a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -128,7 +128,7 @@ public class EdgeSwipeController extends VerticalSwipeController implements

            // Add user event logging for launcher pipeline
            int direction = Direction.UP;
            if (mLauncher.getDeviceProfile().isLandscape) {
            if (mLauncher.getDeviceProfile().isVerticalBarLayout()) {
                direction = Direction.LEFT;
                if (mLauncher.getDeviceProfile().isSeascape()) {
                    direction = Direction.RIGHT;
+1 −1
Original line number Diff line number Diff line
@@ -97,7 +97,7 @@ public class TaskSystemShortcut<T extends SystemShortcut> extends SystemShortcut

        @Override
        public View.OnClickListener getOnClickListener(Launcher launcher, TaskView taskView) {
            if (launcher.getDeviceProfile().inMultiWindowMode()) {
            if (launcher.getDeviceProfile().isMultiWindowMode) {
                return null;
            }
            final Task task  = taskView.getTask();
+20 −21
Original line number Diff line number Diff line
@@ -61,9 +61,11 @@ import com.android.launcher3.anim.AnimationSuccessListener;
import com.android.launcher3.anim.AnimatorPlaybackController;
import com.android.launcher3.anim.Interpolators;

import com.android.launcher3.logging.UserEventDispatcher;
import com.android.launcher3.userevent.nano.LauncherLogProto;
import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch;
import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Direction;
import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
import com.android.launcher3.util.TraceHelper;
import com.android.quickstep.TouchConsumer.InteractionType;
import com.android.systemui.shared.recents.model.ThumbnailData;
@@ -179,6 +181,7 @@ public class WindowTransformSwipeHandler extends BaseSwipeInteractionHandler {

    private float mCurrentDisplacement;
    private boolean mGestureStarted;
    private int mLogAction = Touch.SWIPE;

    private @InteractionType int mInteractionType = INTERACTION_NORMAL;

@@ -619,6 +622,7 @@ public class WindowTransformSwipeHandler extends BaseSwipeInteractionHandler {
        final float endShift;
        if (!isFling) {
            endShift = mCurrentShift.value >= MIN_PROGRESS_FOR_OVERVIEW ? 1 : 0;
            mLogAction = Touch.SWIPE;
        } else {
            endShift = endVelocity < 0 ? 1 : 0;
            float minFlingVelocity = res.getDimension(R.dimen.quickstep_fling_min_velocity);
@@ -630,31 +634,24 @@ public class WindowTransformSwipeHandler extends BaseSwipeInteractionHandler {
                // derivative of the scroll interpolator at zero, ie. 5.
                duration = 5 * Math.round(1000 * Math.abs(distanceToTravel / endVelocity));
            }
            mLogAction = Touch.FLING;
        }

        animateToProgress(endShift, duration);
        int direction = Direction.UP;
        if (mLauncher.getDeviceProfile().isLandscape) {
            direction = Direction.LEFT;
            if (mLauncher.getDeviceProfile().isSeascape()) {
                direction = Direction.RIGHT;
    }

    private void doLogGesture(boolean toLauncher) {
        final int direction;
        if (mDp.isVerticalBarLayout()) {
            direction = (mDp.isSeascape() ^ toLauncher) ? Direction.LEFT : Direction.RIGHT;
        } else {
            direction = toLauncher ? Direction.UP : Direction.DOWN;
        }
        int dstContainerType = LauncherLogProto.ContainerType.TASKSWITCHER;
        if (Float.compare(endShift, 0) == 0) {
            direction = Direction.DOWN;
            if (mLauncher.getDeviceProfile().isLandscape) {
                direction = Direction.RIGHT;
                if (mLauncher.getDeviceProfile().isSeascape()) {
                    direction = Direction.LEFT;
                }
            }
            dstContainerType = LauncherLogProto.ContainerType.APP;
        }
        mLauncher.getUserEventDispatcher().logStateChangeAction(
                isFling ? Touch.FLING : Touch.SWIPE, direction,
                LauncherLogProto.ContainerType.NAVBAR,
                LauncherLogProto.ContainerType.APP,

        int dstContainerType = toLauncher ? ContainerType.TASKSWITCHER : ContainerType.APP;
        UserEventDispatcher.newInstance(mContext, mDp).logStateChangeAction(
                mLogAction, direction,
                ContainerType.NAVBAR, ContainerType.APP,
                dstContainerType,
                0);
    }
@@ -676,6 +673,7 @@ public class WindowTransformSwipeHandler extends BaseSwipeInteractionHandler {
    @UiThread
    private void resumeLastTask() {
        mRecentsAnimationWrapper.finish(false /* toHome */, null);
        doLogGesture(false /* toLauncher */);
    }

    public void reset() {
@@ -736,6 +734,7 @@ public class WindowTransformSwipeHandler extends BaseSwipeInteractionHandler {
        }
        mRecentsAnimationWrapper.finish(true /* toHome */,
                () -> setStateOnUiThread(STATE_SWITCH_TO_SCREENSHOT_COMPLETE));
        doLogGesture(true /* toLauncher */);
    }

    private void setupLauncherUiAfterSwipeUpAnimation() {
+1 −2
Original line number Diff line number Diff line
@@ -48,8 +48,7 @@ public abstract class BaseActivity extends Activity {

    public final UserEventDispatcher getUserEventDispatcher() {
        if (mUserEventDispatcher == null) {
            mUserEventDispatcher = UserEventDispatcher.newInstance(this,
                    mDeviceProfile.isLandscape, isInMultiWindowModeCompat());
            mUserEventDispatcher = UserEventDispatcher.newInstance(this, mDeviceProfile);
        }
        return mUserEventDispatcher;
    }
+10 −10
Original line number Diff line number Diff line
@@ -40,7 +40,9 @@ public class DeviceProfile {
    public final boolean transposeLayoutWithOrientation;

    // Device properties in current orientation
    public final boolean isLandscape;
    private final boolean isLandscape;
    public final boolean isMultiWindowMode;

    public final int widthPx;
    public final int heightPx;
    public final int availableWidthPx;
@@ -121,10 +123,11 @@ public class DeviceProfile {

    public DeviceProfile(Context context, InvariantDeviceProfile inv,
            Point minSize, Point maxSize,
            int width, int height, boolean isLandscape) {
            int width, int height, boolean isLandscape, boolean isMultiWindowMode) {

        this.inv = inv;
        this.isLandscape = isLandscape;
        this.isMultiWindowMode = isMultiWindowMode;

        Resources res = context.getResources();
        DisplayMetrics dm = res.getDisplayMetrics();
@@ -214,7 +217,8 @@ public class DeviceProfile {

    public DeviceProfile copy(Context context) {
        Point size = new Point(availableWidthPx, availableHeightPx);
        return new DeviceProfile(context, inv, size, size, widthPx, heightPx, isLandscape);
        return new DeviceProfile(context, inv, size, size, widthPx, heightPx, isLandscape,
                isMultiWindowMode);
    }

    public DeviceProfile getMultiWindowProfile(Context context, Point mwSize) {
@@ -226,7 +230,7 @@ public class DeviceProfile {
        // and heightPx = availableHeightPx because Launcher uses the InvariantDeviceProfiles'
        // widthPx and heightPx values where it's needed.
        DeviceProfile profile = new DeviceProfile(context, inv, mwSize, mwSize, mwSize.x, mwSize.y,
                isLandscape);
                isLandscape, true);

        // If there isn't enough vertical cell padding with the labels displayed, hide the labels.
        float workspaceCellPaddingY = profile.getCellSize().y - profile.iconSizePx
@@ -288,7 +292,7 @@ public class DeviceProfile {
                + Utilities.calculateTextHeight(iconTextSizePx);
        int cellYPadding = (getCellSize().y - cellHeightPx) / 2;
        if (iconDrawablePaddingPx > cellYPadding && !isVerticalLayout
                && !inMultiWindowMode()) {
                && !isMultiWindowMode) {
            // Ensures that the label is closer to its corresponding icon. This is not an issue
            // with vertical bar layout or multi-window mode since the issue is handled separately
            // with their calls to {@link #adjustToHideWorkspaceLabels}.
@@ -503,14 +507,10 @@ public class DeviceProfile {
        }
    }

    public boolean inMultiWindowMode() {
        return this != inv.landscapeProfile && this != inv.portraitProfile;
    }

    public boolean shouldIgnoreLongPressToOverview(float touchX) {
        boolean touchedLhsEdge = mInsets.left == 0 && touchX < edgeMarginPx;
        boolean touchedRhsEdge = mInsets.right == 0 && touchX > (widthPx - edgeMarginPx);
        return !inMultiWindowMode() && (touchedLhsEdge || touchedRhsEdge);
        return !isMultiWindowMode && (touchedLhsEdge || touchedRhsEdge);
    }

    private static Context getContext(Context c, int orientation) {
Loading