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

Commit 74580173 authored by Shuming Hao's avatar Shuming Hao
Browse files

Fix Desktop to Split position in portrait mode

In portait mode, split from desktop app handle bar has wrong split
position. This CL fixes the bug.

Test: manual
Bug: 424285525
Flag: EXEMPT bugfix
Change-Id: I048f35b39928e6f351363c1890e041599a09ed7e
parent 6024882b
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ import android.app.IActivityManager;
import android.app.IActivityTaskManager;
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.graphics.Point;
import android.graphics.PointF;
import android.graphics.Rect;
@@ -878,7 +879,13 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel,
        if (decoration == null) {
            return;
        }
        mDesktopTasksController.requestSplit(decoration.mTaskInfo, false /* leftOrTop */);

        final int orientation = mContext.getResources().getConfiguration().orientation;
        // Set leftOrTop as True to split to the top in portrait mode.
        // Set leftOrTop as False to split to the right in landscape mode.
        boolean leftOrTop = orientation == Configuration.ORIENTATION_PORTRAIT;

        mDesktopTasksController.requestSplit(decoration.mTaskInfo, leftOrTop);
        mDesktopModeUiEventLogger.log(decoration.mTaskInfo,
                DesktopUiEventEnum.DESKTOP_WINDOW_APP_HANDLE_MENU_TAP_TO_SPLIT_SCREEN);
    }
+25 −1
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import android.content.ComponentName
import android.content.Context
import android.content.Intent
import android.content.Intent.ACTION_MAIN
import android.content.res.Configuration
import android.graphics.PointF
import android.graphics.Rect
import android.graphics.Region
@@ -773,7 +774,30 @@ class DesktopModeWindowDecorViewModelTests : DesktopModeWindowDecorViewModelTest
    }

    @Test
    fun testDecor_onClickToSplitScreen_requestsSplit() {
    fun testDecor_onClickToSplitScreen_inPortrait_requestsSplitToTop() {
        // GIVEN the device is in portrait orientation
        val resources = spyContext.resources
        val configuration = resources.configuration
        configuration.orientation = Configuration.ORIENTATION_PORTRAIT

        val windowDecorationActionsCaptor = argumentCaptor<WindowDecorationActions>()
        val decor = createOpenTaskDecoration(
            windowingMode = WINDOWING_MODE_MULTI_WINDOW,
            windowDecorationActions = windowDecorationActionsCaptor
        )

        windowDecorationActionsCaptor.firstValue.onToSplitScreen(decor.mTaskInfo.taskId)

        verify(mockDesktopTasksController).requestSplit(decor.mTaskInfo, leftOrTop = true)
    }

    @Test
    fun testDecor_onClickToSplitScreen_inLandscape_requestsSplitToSide() {
        // GIVEN the device is in landscape orientation
        val resources = spyContext.resources
        val configuration = resources.configuration
        configuration.orientation = Configuration.ORIENTATION_LANDSCAPE

        val windowDecorationActionsCaptor = argumentCaptor<WindowDecorationActions>()
        val decor = createOpenTaskDecoration(
            windowingMode = WINDOWING_MODE_MULTI_WINDOW,