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

Commit 0a905650 authored by Vinit Nayak's avatar Vinit Nayak Committed by Android (Google) Code Review
Browse files

Merge "Add overview taskbar split support for 3P launcher" into tm-qpr-dev

parents 4ffc7126 f4e7e5aa
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -44,6 +44,17 @@ public class FallbackTaskbarUIController extends TaskbarUIController {
                    getRecentsView().setTaskLaunchListener(toState == RecentsState.DEFAULT
                            ? (() -> animateToRecentsState(RecentsState.BACKGROUND_APP)) : null);
                }

                @Override
                public void onStateTransitionComplete(RecentsState finalState) {
                    boolean finalStateDefault = finalState == RecentsState.DEFAULT;
                    // TODO(b/268120202) Taskbar shows up on 3P home, currently we don't go to
                    //  overview from 3P home. Either implement that or it'll change w/ contextual?
                    boolean disallowLongClick = finalState == RecentsState.OVERVIEW_SPLIT_SELECT;
                    Utilities.setOverviewDragState(mControllers,
                            finalStateDefault /*disallowGlobalDrag*/, disallowLongClick,
                            finalStateDefault /*allowInitialSplitSelection*/);
                }
            };

    public FallbackTaskbarUIController(RecentsActivity recentsActivity) {
+4 −7
Original line number Diff line number Diff line
@@ -119,14 +119,11 @@ import java.util.StringJoiner;
                    mLauncherState = finalState;
                    updateStateForFlag(FLAG_TRANSITION_STATE_RUNNING, false);
                    applyState();
                    boolean disallowGlobalDrag = finalState instanceof OverviewState;
                    boolean finalStateOverview = finalState instanceof OverviewState;
                    boolean disallowLongClick = finalState == LauncherState.OVERVIEW_SPLIT_SELECT;
                    mControllers.taskbarDragController.setDisallowGlobalDrag(disallowGlobalDrag);
                    mControllers.taskbarDragController.setDisallowLongClick(disallowLongClick);
                    mControllers.taskbarAllAppsController.setDisallowGlobalDrag(disallowGlobalDrag);
                    mControllers.taskbarAllAppsController.setDisallowLongClick(disallowLongClick);
                    mControllers.taskbarPopupController.setAllowInitialSplitSelection(
                            disallowGlobalDrag);
                    com.android.launcher3.taskbar.Utilities.setOverviewDragState(
                            mControllers, finalStateOverview /*disallowGlobalDrag*/,
                            disallowLongClick, finalStateOverview /*allowInitialSplitSelection*/);
                }
            };

+14 −0
Original line number Diff line number Diff line
@@ -30,4 +30,18 @@ public final class Utilities {
            str.add(flagName);
        }
    }

    /**
     * Sets drag, long-click, and split selection behavior on 1P and 3P launchers with Taskbar
     */
    static void setOverviewDragState(TaskbarControllers controllers,
            boolean disallowGlobalDrag, boolean disallowLongClick,
            boolean allowInitialSplitSelection) {
        controllers.taskbarDragController.setDisallowGlobalDrag(disallowGlobalDrag);
        controllers.taskbarDragController.setDisallowLongClick(disallowLongClick);
        controllers.taskbarAllAppsController.setDisallowGlobalDrag(disallowGlobalDrag);
        controllers.taskbarAllAppsController.setDisallowLongClick(disallowLongClick);
        controllers.taskbarPopupController.setAllowInitialSplitSelection(
                allowInitialSplitSelection);
    }
}
+83 −0
Original line number Diff line number Diff line
/*
 *  Copyright (C) 2023 The Android Open Source Project
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 */

package com.android.launcher3.taskbar

import androidx.test.runner.AndroidJUnit4
import com.android.launcher3.statemanager.StateManager
import com.android.quickstep.RecentsActivity
import com.android.quickstep.fallback.RecentsState
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.ArgumentCaptor
import org.mockito.Mock
import org.mockito.Mockito.times
import org.mockito.Mockito.verify
import org.mockito.MockitoAnnotations.initMocks
import org.mockito.Mockito.`when` as whenever

@RunWith(AndroidJUnit4::class)
class FallbackTaskbarUIControllerTest : TaskbarBaseTestCase() {

    lateinit var fallbackTaskbarUIController: FallbackTaskbarUIController
    lateinit var stateListener: StateManager.StateListener<RecentsState>

    @Mock
    lateinit var recentsActivity: RecentsActivity
    @Mock
    lateinit var stateManager: StateManager<RecentsState>

    @Before
    override fun setup() {
        super.setup()
        whenever(recentsActivity.stateManager).thenReturn(stateManager)
        fallbackTaskbarUIController = FallbackTaskbarUIController(recentsActivity)

        // Capture registered state listener to send events to in our tests
        val captor = ArgumentCaptor.forClass(StateManager.StateListener::class.java)
        fallbackTaskbarUIController.init(taskbarControllers)
        verify(stateManager).addStateListener(captor.capture())
        stateListener = captor.value as StateManager.StateListener<RecentsState>
    }

    @Test
    fun stateTransitionComplete_stateDefault() {
        stateListener.onStateTransitionComplete(RecentsState.DEFAULT)
        // verify dragging disabled
        verify(taskbarDragController, times(1)).setDisallowGlobalDrag(true)
        verify(taskbarAllAppsController, times(1)).setDisallowGlobalDrag(true)
        // verify long click enabled
        verify(taskbarDragController, times(1)).setDisallowLongClick(false)
        verify(taskbarAllAppsController, times(1)).setDisallowLongClick(false)
        // verify split selection enabled
        verify(taskbarPopupController, times(1)).setAllowInitialSplitSelection(true)
    }

    @Test
    fun stateTransitionComplete_stateSplitSelect() {
        stateListener.onStateTransitionComplete(RecentsState.OVERVIEW_SPLIT_SELECT)
        // verify dragging disabled
        verify(taskbarDragController, times(1)).setDisallowGlobalDrag(false)
        verify(taskbarAllAppsController, times(1)).setDisallowGlobalDrag(false)
        // verify long click enabled
        verify(taskbarDragController, times(1)).setDisallowLongClick(true)
        verify(taskbarAllAppsController, times(1)).setDisallowLongClick(true)
        // verify split selection enabled
        verify(taskbarPopupController, times(1)).setAllowInitialSplitSelection(false)
    }
}
 No newline at end of file
+2 −2
Original line number Diff line number Diff line
@@ -54,7 +54,7 @@ abstract class TaskbarBaseTestCase {
    @Mock lateinit var taskbarEduTooltipController: TaskbarEduTooltipController
    @Mock lateinit var keyboardQuickSwitchController: KeyboardQuickSwitchController

    lateinit var mTaskbarControllers: TaskbarControllers
    lateinit var taskbarControllers: TaskbarControllers

    @Before
    open fun setup() {
@@ -66,7 +66,7 @@ abstract class TaskbarBaseTestCase {
         * includes that method to allow mocking it.
         */
        MockitoAnnotations.initMocks(this)
        mTaskbarControllers =
        taskbarControllers =
            TaskbarControllers(
                taskbarActivityContext,
                taskbarDragController,