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

Commit 0bbb7efe authored by Tony Huang's avatar Tony Huang
Browse files

Fix split task position behavior when landscape

On nav bar 2/3 key mode and device landscape, the top task should
always opposite to nav bar, so top task location should be right
when seascape and left when landscape.

On gesture nav mode, because the nav bar always locate bottom so
keep it behavior.

Bug: 150990456
Test: Use each gesture mode and enter split mode then check it
Change-Id: Ia46f765c43c947350ee4970ea86aa9a0d707ad7d
parent de7f0607
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -1042,7 +1042,8 @@ public class DividerView extends FrameLayout implements OnTouchListener,
        dockedTaskRect = dockedTaskRect == null ? dockedRect : dockedTaskRect;
        otherTaskRect = otherTaskRect == null ? otherRect : otherTaskRect;

        mDividerPositionX = dockedRect.right;
        mDividerPositionX = mSplitLayout.getPrimarySplitSide() == DOCKED_RIGHT
                ? otherRect.right : dockedRect.right;
        mDividerPositionY = dockedRect.bottom;

        if (DEBUG) {
+10 −1
Original line number Diff line number Diff line
@@ -101,7 +101,16 @@ public class SplitDisplayLayout {
    }

    int getPrimarySplitSide() {
        switch (mDisplayLayout.getNavigationBarPosition(mContext.getResources())) {
            case DisplayLayout.NAV_BAR_BOTTOM:
                return mDisplayLayout.isLandscape() ? DOCKED_LEFT : DOCKED_TOP;
            case DisplayLayout.NAV_BAR_LEFT:
                return DOCKED_RIGHT;
            case DisplayLayout.NAV_BAR_RIGHT:
                return DOCKED_LEFT;
            default:
                return DOCKED_INVALID;
        }
    }

    boolean isMinimized() {
+25 −5
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import static android.view.Surface.ROTATION_0;
import static android.view.Surface.ROTATION_270;
import static android.view.Surface.ROTATION_90;

import android.annotation.IntDef;
import android.annotation.NonNull;
import android.content.ContentResolver;
import android.content.Context;
@@ -46,16 +47,27 @@ import android.view.Surface;

import com.android.internal.R;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

/**
 * Contains information about the layout-properties of a display. This refers to internal layout
 * like insets/cutout/rotation. In general, this can be thought of as the System-UI analog to
 * DisplayPolicy.
 */
public class DisplayLayout {
    @IntDef(prefix = { "NAV_BAR_" }, value = {
            NAV_BAR_LEFT,
            NAV_BAR_RIGHT,
            NAV_BAR_BOTTOM,
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface NavBarPosition {}

    // Navigation bar position values
    private static final int NAV_BAR_LEFT = 1 << 0;
    private static final int NAV_BAR_RIGHT = 1 << 1;
    private static final int NAV_BAR_BOTTOM = 1 << 2;
    public static final int NAV_BAR_LEFT = 1 << 0;
    public static final int NAV_BAR_RIGHT = 1 << 1;
    public static final int NAV_BAR_BOTTOM = 1 << 2;

    private int mUiMode;
    private int mWidth;
@@ -213,6 +225,14 @@ public class DisplayLayout {
        outBounds.inset(mStableInsets);
    }

    /**
     * Gets navigation bar position for this layout
     * @return Navigation bar position for this layout.
     */
    public @NavBarPosition int getNavigationBarPosition(Resources res) {
        return navigationBarPosition(res, mWidth, mHeight, mRotation);
    }

    /**
     * Rotates bounds as if parentBounds and bounds are a group. The group is rotated by `delta`
     * 90-degree counter-clockwise increments. This assumes that parentBounds is at 0,0 and
@@ -437,8 +457,8 @@ public class DisplayLayout {
    }

    /** Retrieve navigation bar position from resources based on rotation and size. */
    public static int navigationBarPosition(Resources res, int displayWidth, int displayHeight,
            int rotation) {
    public static @NavBarPosition int navigationBarPosition(Resources res, int displayWidth,
            int displayHeight, int rotation) {
        boolean navBarCanMove = displayWidth != displayHeight && res.getBoolean(
                com.android.internal.R.bool.config_navBarCanMove);
        if (navBarCanMove && displayWidth > displayHeight) {