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

Commit 37a4e048 authored by Shuming Hao's avatar Shuming Hao Committed by Android (Google) Code Review
Browse files

Merge "Fix Desktop to Split position in portrait mode" into main

parents 2c4238a3 74580173
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;
@@ -884,7 +885,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,