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

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

Merge "Fixing insets mapping in 3-button and 2-button mode" into ub-launcher3-qt-dev

parents 06892dcf 7a39b1bc
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -21,10 +21,12 @@ import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY;

import android.view.View;

import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherStateManager.StateHandler;
import com.android.launcher3.Utilities;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.graphics.RotationMode;
import com.android.launcher3.uioverrides.touchcontrollers.LandscapeEdgeSwipeController;
import com.android.launcher3.uioverrides.touchcontrollers.LandscapeStatesTouchController;
import com.android.launcher3.uioverrides.touchcontrollers.PortraitStatesTouchController;
@@ -102,4 +104,8 @@ public abstract class RecentsUiFactory {
     * @param launcher the launcher activity
     */
    public static void onLauncherStateOrResumeChanged(Launcher launcher) {}

    public static RotationMode getRotationMode(DeviceProfile dp) {
        return RotationMode.NORMAL;
    }
}
+79 −2
Original line number Diff line number Diff line
@@ -20,6 +20,11 @@ import static android.view.View.VISIBLE;
import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY;
import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.LauncherState.OVERVIEW;
import static com.android.quickstep.SysUINavigationMode.Mode.NO_BUTTON;

import android.content.Context;
import android.graphics.Rect;
import android.view.Gravity;

import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Launcher;
@@ -28,6 +33,7 @@ import com.android.launcher3.LauncherStateManager.StateHandler;
import com.android.launcher3.Utilities;
import com.android.launcher3.anim.AnimatorPlaybackController;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.graphics.RotationMode;
import com.android.launcher3.uioverrides.touchcontrollers.FlingAndHoldTouchController;
import com.android.launcher3.uioverrides.touchcontrollers.LandscapeEdgeSwipeController;
import com.android.launcher3.uioverrides.touchcontrollers.NavBarToHomeTouchController;
@@ -58,12 +64,83 @@ public abstract class RecentsUiFactory {
    // Scale recents takes before animating in
    private static final float RECENTS_PREPARE_SCALE = 1.33f;

    public static RotationMode ROTATION_LANDSCAPE = new RotationMode(-90) {
        @Override
        public void mapRect(int left, int top, int right, int bottom, Rect out) {
            out.left = top;
            out.top = right;
            out.right = bottom;
            out.bottom = left;
        }

        @Override
        public void mapInsets(Context context, Rect insets, Rect out) {
            if (SysUINavigationMode.getMode(context) == NO_BUTTON) {
                out.set(insets);
            } else {
                out.top = Math.max(insets.top, insets.left);
                out.bottom = insets.right;
                out.left = insets.bottom;
                out.right = 0;
            }
        }
    };

    public static RotationMode ROTATION_SEASCAPE = new RotationMode(90) {
        @Override
        public void mapRect(int left, int top, int right, int bottom, Rect out) {
            out.left = bottom;
            out.top = left;
            out.right = top;
            out.bottom = right;
        }

        @Override
        public void mapInsets(Context context, Rect insets, Rect out) {
            if (SysUINavigationMode.getMode(context) == NO_BUTTON) {
                out.set(insets);
            } else {
                out.top = Math.max(insets.top, insets.right);
                out.bottom = insets.left;
                out.right = insets.bottom;
                out.left = 0;
            }
        }

        @Override
        public int toNaturalGravity(int absoluteGravity) {
            int horizontalGravity = absoluteGravity & Gravity.HORIZONTAL_GRAVITY_MASK;
            int verticalGravity = absoluteGravity & Gravity.VERTICAL_GRAVITY_MASK;

            if (horizontalGravity == Gravity.RIGHT) {
                horizontalGravity = Gravity.LEFT;
            } else if (horizontalGravity == Gravity.LEFT) {
                horizontalGravity = Gravity.RIGHT;
            }

            if (verticalGravity == Gravity.TOP) {
                verticalGravity = Gravity.BOTTOM;
            } else if (verticalGravity == Gravity.BOTTOM) {
                verticalGravity = Gravity.TOP;
            }

            return ((absoluteGravity & ~Gravity.HORIZONTAL_GRAVITY_MASK)
                    & ~Gravity.VERTICAL_GRAVITY_MASK)
                    | horizontalGravity | verticalGravity;
        }
    };

    public static RotationMode getRotationMode(DeviceProfile dp) {
        return !dp.isVerticalBarLayout() ? RotationMode.NORMAL
                : (dp.isSeascape() ? ROTATION_SEASCAPE : ROTATION_LANDSCAPE);
    }

    public static TouchController[] createTouchControllers(Launcher launcher) {
        Mode mode = SysUINavigationMode.getMode(launcher);

        ArrayList<TouchController> list = new ArrayList<>();
        list.add(launcher.getDragController());
        if (mode == Mode.NO_BUTTON) {
        if (mode == NO_BUTTON) {
            list.add(new QuickSwitchTouchController(launcher));
            list.add(new NavBarToHomeTouchController(launcher));
            list.add(new FlingAndHoldTouchController(launcher));
@@ -106,7 +183,7 @@ public abstract class RecentsUiFactory {
     * @param launcher the launcher activity
     */
    public static void prepareToShowOverview(Launcher launcher) {
        if (SysUINavigationMode.getMode(launcher) == Mode.NO_BUTTON) {
        if (SysUINavigationMode.getMode(launcher) == NO_BUTTON) {
            // Overview lives on the side, so doesn't scale in from above.
            return;
        }
+4 −2
Original line number Diff line number Diff line
@@ -22,6 +22,8 @@ import static android.view.MotionEvent.ACTION_POINTER_UP;
import static android.view.MotionEvent.ACTION_UP;
import static android.view.MotionEvent.INVALID_POINTER_ID;
import static com.android.launcher3.Utilities.EDGE_NAV_BAR;
import static com.android.launcher3.uioverrides.RecentsUiFactory.ROTATION_LANDSCAPE;
import static com.android.launcher3.uioverrides.RecentsUiFactory.ROTATION_SEASCAPE;
import static com.android.launcher3.util.RaceConditionTracker.ENTER;
import static com.android.launcher3.util.RaceConditionTracker.EXIT;
import static com.android.quickstep.SysUINavigationMode.Mode.NO_BUTTON;
@@ -171,8 +173,8 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC
                && !mRecentsViewDispatcher.hasConsumer()) {
            mRecentsViewDispatcher.setConsumer(mInteractionHandler.getRecentsViewDispatcher(
                    isNavBarOnLeft()
                            ? RotationMode.SEASCAPE
                            : (isNavBarOnRight() ? RotationMode.LANDSCAPE : RotationMode.NORMAL)));
                            ? ROTATION_SEASCAPE
                            : (isNavBarOnRight() ? ROTATION_LANDSCAPE : RotationMode.NORMAL)));
        }
        int edgeFlags = ev.getEdgeFlags();
        ev.setEdgeFlags(edgeFlags | EDGE_NAV_BAR);
+6 −5
Original line number Diff line number Diff line
@@ -431,8 +431,8 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
    @Override
    protected void reapplyUi() {
        if (FeatureFlags.FAKE_LANDSCAPE_UI.get()) {
            mRotationMode = mStableDeviceProfile == null ? RotationMode.NORMAL :
                    (mDeviceProfile.isSeascape() ? RotationMode.SEASCAPE : RotationMode.LANDSCAPE);
            mRotationMode = mStableDeviceProfile == null
                    ? RotationMode.NORMAL : UiFactory.getRotationMode(mDeviceProfile);
        }
        getRootView().dispatchInsets();
        getStateManager().reapplyState(true /* cancelCurrentAnimation */);
@@ -489,8 +489,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
        if (FeatureFlags.FAKE_LANDSCAPE_UI.get() && mDeviceProfile.isVerticalBarLayout()
                && !mDeviceProfile.isMultiWindowMode) {
            mStableDeviceProfile = mDeviceProfile.inv.portraitProfile;
            mRotationMode = mDeviceProfile.isSeascape()
                    ? RotationMode.SEASCAPE : RotationMode.LANDSCAPE;
            mRotationMode = UiFactory.getRotationMode(mDeviceProfile);
        } else {
            mStableDeviceProfile = null;
            mRotationMode = RotationMode.NORMAL;
@@ -503,7 +502,9 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
    public void updateInsets(Rect insets) {
        mDeviceProfile.updateInsets(insets);
        if (mStableDeviceProfile != null) {
            mStableDeviceProfile.updateInsets(insets);
            Rect r = mStableDeviceProfile.getInsets();
            mRotationMode.mapInsets(this, insets, r);
            mStableDeviceProfile.updateInsets(r);
        }
    }

+1 −1
Original line number Diff line number Diff line
@@ -302,7 +302,7 @@ public class Workspace extends PagedView<WorkspacePageIndicator>

        rotationMode.mapRect(padding, mTempRect);
        setPadding(mTempRect.left, mTempRect.top, mTempRect.right, mTempRect.bottom);
        rotationMode.mapRect(insets, mInsets);
        rotationMode.mapRect(stableGrid.getInsets(), mInsets);

        if (mWorkspaceFadeInAdjacentScreens) {
            // In landscape mode the page spacing is set to the default.
Loading