From 8e4c0b7afb8f5f0c4a4641104460f1791afe3691 Mon Sep 17 00:00:00 2001 From: Priyanka Advani Date: Wed, 10 Apr 2024 21:31:07 +0000 Subject: [PATCH 1/2] Revert "fixing tests to match new abstraction" Revert submission 26414135-RecentsViewContainer Reason for revert: Probable culprit for b/333767026. Will be verifying through ABTD for confirmation and before submitting the revert. Reverted changes: /q/submissionid:26414135-RecentsViewContainer Change-Id: Ibafc66cf3677d24e7912d55cb45c948cb6519df7 --- .../quickstep/AbstractQuickStepTest.java | 6 ++--- .../quickstep/DesktopSystemShortcutTest.kt | 3 +-- .../quickstep/TaplOverviewIconTest.java | 3 +-- .../com/android/quickstep/TaskViewTest.java | 3 +-- .../android/launcher3/LauncherIntentTest.java | 2 +- .../allapps/TaplAllAppsIconsWorkingTest.java | 3 +-- .../allapps/TaplKeyboardFocusTest.java | 3 +-- .../allapps/TaplOpenCloseAllAppsTest.java | 3 +-- .../appiconmenu/TaplAppIconMenuTest.java | 2 +- .../celllayout/TaplReorderWidgetsTest.java | 3 +-- .../compat/TaplPromiseIconUiTest.java | 2 +- .../launcher3/dragging/TaplDragTest.java | 3 +-- .../dragging/TaplUninstallRemoveTest.java | 4 +-- .../launcher3/ui/AbstractLauncherUiTest.java | 26 +++++++++---------- .../launcher3/ui/PortraitLandscapeRunner.java | 10 +++---- .../launcher3/ui/TaplTestsLauncher3Test.java | 3 +-- .../launcher3/ui/TaplWorkProfileTest.java | 3 +-- .../ui/widget/TaplAddConfigWidgetTest.java | 2 +- .../ui/widget/TaplAddWidgetTest.java | 3 +-- .../ui/widget/TaplBindWidgetTest.java | 3 +-- .../ui/widget/TaplRequestPinItemTest.java | 2 +- .../ui/widget/TaplWidgetPickerTest.java | 2 +- .../ui/workspace/TaplThemeIconsTest.java | 3 +-- .../workspace/TaplTwoPanelWorkspaceTest.java | 2 +- .../ui/workspace/TaplWorkspaceTest.java | 2 +- 25 files changed, 43 insertions(+), 58 deletions(-) diff --git a/quickstep/tests/src/com/android/quickstep/AbstractQuickStepTest.java b/quickstep/tests/src/com/android/quickstep/AbstractQuickStepTest.java index 44c23ba9a2..6a48b772a4 100644 --- a/quickstep/tests/src/com/android/quickstep/AbstractQuickStepTest.java +++ b/quickstep/tests/src/com/android/quickstep/AbstractQuickStepTest.java @@ -23,9 +23,9 @@ import android.os.SystemProperties; import androidx.test.uiautomator.By; import androidx.test.uiautomator.Until; +import com.android.launcher3.Launcher; import com.android.launcher3.tapl.LaunchedAppState; import com.android.launcher3.ui.AbstractLauncherUiTest; -import com.android.launcher3.uioverrides.QuickstepLauncher; import com.android.quickstep.views.RecentsView; import org.junit.rules.RuleChain; @@ -34,7 +34,7 @@ import org.junit.rules.TestRule; /** * Base class for all instrumentation tests that deal with Quickstep. */ -public abstract class AbstractQuickStepTest extends AbstractLauncherUiTest { +public abstract class AbstractQuickStepTest extends AbstractLauncherUiTest { public static final boolean ENABLE_SHELL_TRANSITIONS = SystemProperties.getBoolean("persist.wm.debug.shell_transit", true); @Override @@ -46,7 +46,7 @@ public abstract class AbstractQuickStepTest extends AbstractLauncherUiTest { +public class TaplOverviewIconTest extends AbstractLauncherUiTest { private static final String CALCULATOR_APP_PACKAGE = resolveSystemApp(Intent.CATEGORY_APP_CALCULATOR); diff --git a/quickstep/tests/src/com/android/quickstep/TaskViewTest.java b/quickstep/tests/src/com/android/quickstep/TaskViewTest.java index 8eec9034ca..d744194d42 100644 --- a/quickstep/tests/src/com/android/quickstep/TaskViewTest.java +++ b/quickstep/tests/src/com/android/quickstep/TaskViewTest.java @@ -35,7 +35,6 @@ import android.view.MotionEvent; import androidx.test.filters.SmallTest; import com.android.launcher3.statemanager.StatefulActivity; -import com.android.launcher3.uioverrides.QuickstepLauncher; import com.android.quickstep.util.BorderAnimator; import com.android.quickstep.views.TaskView; @@ -48,7 +47,7 @@ import org.mockito.MockitoAnnotations; public class TaskViewTest { @Mock - private QuickstepLauncher mContext; + private StatefulActivity mContext; @Mock private Resources mResource; @Mock diff --git a/tests/src/com/android/launcher3/LauncherIntentTest.java b/tests/src/com/android/launcher3/LauncherIntentTest.java index aeeb42a363..d1110c3c7a 100644 --- a/tests/src/com/android/launcher3/LauncherIntentTest.java +++ b/tests/src/com/android/launcher3/LauncherIntentTest.java @@ -34,7 +34,7 @@ import org.junit.runner.RunWith; @LargeTest @RunWith(AndroidJUnit4.class) -public class LauncherIntentTest extends AbstractLauncherUiTest { +public class LauncherIntentTest extends AbstractLauncherUiTest { public final Intent allAppsIntent = new Intent(Intent.ACTION_ALL_APPS); diff --git a/tests/src/com/android/launcher3/allapps/TaplAllAppsIconsWorkingTest.java b/tests/src/com/android/launcher3/allapps/TaplAllAppsIconsWorkingTest.java index 0b233e5492..10e9f8abb1 100644 --- a/tests/src/com/android/launcher3/allapps/TaplAllAppsIconsWorkingTest.java +++ b/tests/src/com/android/launcher3/allapps/TaplAllAppsIconsWorkingTest.java @@ -18,7 +18,6 @@ package com.android.launcher3.allapps; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -import com.android.launcher3.Launcher; import com.android.launcher3.LauncherState; import com.android.launcher3.tapl.AppIcon; import com.android.launcher3.tapl.HomeAllApps; @@ -31,7 +30,7 @@ import org.junit.Test; * The test runs in Out of process (Oop) and in process. * Makes sure the basic behaviors of Icons on AllApps are working. */ -public class TaplAllAppsIconsWorkingTest extends AbstractLauncherUiTest { +public class TaplAllAppsIconsWorkingTest extends AbstractLauncherUiTest { /** * Makes sure we can launch an icon from All apps diff --git a/tests/src/com/android/launcher3/allapps/TaplKeyboardFocusTest.java b/tests/src/com/android/launcher3/allapps/TaplKeyboardFocusTest.java index 20684eb5ef..0360470215 100644 --- a/tests/src/com/android/launcher3/allapps/TaplKeyboardFocusTest.java +++ b/tests/src/com/android/launcher3/allapps/TaplKeyboardFocusTest.java @@ -26,7 +26,6 @@ import android.view.KeyEvent; import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.SmallTest; -import com.android.launcher3.Launcher; import com.android.launcher3.LauncherState; import com.android.launcher3.tapl.HomeAllApps; import com.android.launcher3.ui.AbstractLauncherUiTest; @@ -38,7 +37,7 @@ import org.junit.runner.RunWith; @SmallTest @RunWith(AndroidJUnit4.class) -public class TaplKeyboardFocusTest extends AbstractLauncherUiTest { +public class TaplKeyboardFocusTest extends AbstractLauncherUiTest { @Test public void testAllAppsFocusApp() { diff --git a/tests/src/com/android/launcher3/allapps/TaplOpenCloseAllAppsTest.java b/tests/src/com/android/launcher3/allapps/TaplOpenCloseAllAppsTest.java index f3f6fa5614..e462c4f9b1 100644 --- a/tests/src/com/android/launcher3/allapps/TaplOpenCloseAllAppsTest.java +++ b/tests/src/com/android/launcher3/allapps/TaplOpenCloseAllAppsTest.java @@ -28,7 +28,6 @@ import android.platform.test.annotations.PlatinumTest; import androidx.test.filters.FlakyTest; import androidx.test.platform.app.InstrumentationRegistry; -import com.android.launcher3.Launcher; import com.android.launcher3.LauncherState; import com.android.launcher3.tapl.AllApps; import com.android.launcher3.ui.AbstractLauncherUiTest; @@ -41,7 +40,7 @@ import org.junit.Test; * Test that we can open and close the all apps in multiple situations. * The test runs in Out of process (Oop) and in process. */ -public class TaplOpenCloseAllAppsTest extends AbstractLauncherUiTest { +public class TaplOpenCloseAllAppsTest extends AbstractLauncherUiTest { public static final String READ_DEVICE_CONFIG_PERMISSION = "android.permission.READ_DEVICE_CONFIG"; diff --git a/tests/src/com/android/launcher3/appiconmenu/TaplAppIconMenuTest.java b/tests/src/com/android/launcher3/appiconmenu/TaplAppIconMenuTest.java index 55d3252843..c69d1b9988 100644 --- a/tests/src/com/android/launcher3/appiconmenu/TaplAppIconMenuTest.java +++ b/tests/src/com/android/launcher3/appiconmenu/TaplAppIconMenuTest.java @@ -38,7 +38,7 @@ import org.junit.Test; * Tests the AppIconMenu (the menu that appears when you long press an app icon) and also make sure * we can launch a shortcut from it. */ -public class TaplAppIconMenuTest extends AbstractLauncherUiTest { +public class TaplAppIconMenuTest extends AbstractLauncherUiTest { private boolean isOptionsPopupVisible(Launcher launcher) { final ArrowPopup popup = launcher.getOptionsPopup(); diff --git a/tests/src/com/android/launcher3/celllayout/TaplReorderWidgetsTest.java b/tests/src/com/android/launcher3/celllayout/TaplReorderWidgetsTest.java index 389d027dc1..1b036453ce 100644 --- a/tests/src/com/android/launcher3/celllayout/TaplReorderWidgetsTest.java +++ b/tests/src/com/android/launcher3/celllayout/TaplReorderWidgetsTest.java @@ -30,7 +30,6 @@ import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.SmallTest; import com.android.launcher3.InvariantDeviceProfile; -import com.android.launcher3.Launcher; import com.android.launcher3.LauncherAppState; import com.android.launcher3.MultipageCellLayout; import com.android.launcher3.celllayout.board.CellLayoutBoard; @@ -60,7 +59,7 @@ import java.util.Map; @SmallTest @RunWith(AndroidJUnit4.class) -public class TaplReorderWidgetsTest extends AbstractLauncherUiTest { +public class TaplReorderWidgetsTest extends AbstractLauncherUiTest { @Rule public ShellCommandRule mGrantWidgetRule = ShellCommandRule.grantWidgetBind(); diff --git a/tests/src/com/android/launcher3/compat/TaplPromiseIconUiTest.java b/tests/src/com/android/launcher3/compat/TaplPromiseIconUiTest.java index 1500538633..7ed0fa5b8f 100644 --- a/tests/src/com/android/launcher3/compat/TaplPromiseIconUiTest.java +++ b/tests/src/com/android/launcher3/compat/TaplPromiseIconUiTest.java @@ -52,7 +52,7 @@ import java.util.UUID; */ @LargeTest @RunWith(AndroidJUnit4.class) -public class TaplPromiseIconUiTest extends AbstractLauncherUiTest { +public class TaplPromiseIconUiTest extends AbstractLauncherUiTest { @Rule public final CheckFlagsRule mCheckFlagsRule = diff --git a/tests/src/com/android/launcher3/dragging/TaplDragTest.java b/tests/src/com/android/launcher3/dragging/TaplDragTest.java index d64d096c72..bf1ba39fef 100644 --- a/tests/src/com/android/launcher3/dragging/TaplDragTest.java +++ b/tests/src/com/android/launcher3/dragging/TaplDragTest.java @@ -33,7 +33,6 @@ import android.os.SystemClock; import android.platform.test.annotations.PlatinumTest; import android.util.Log; -import com.android.launcher3.Launcher; import com.android.launcher3.tapl.Folder; import com.android.launcher3.tapl.FolderIcon; import com.android.launcher3.tapl.HomeAllApps; @@ -58,7 +57,7 @@ import org.junit.Test; * * Can drag an icon from AllApps into the workspace * * Can drag an icon on the Workspace to other positions of the Workspace. */ -public class TaplDragTest extends AbstractLauncherUiTest { +public class TaplDragTest extends AbstractLauncherUiTest { /** * Adds two icons to the Workspace and combines them into a folder, then makes sure the icons diff --git a/tests/src/com/android/launcher3/dragging/TaplUninstallRemoveTest.java b/tests/src/com/android/launcher3/dragging/TaplUninstallRemoveTest.java index df71ec09d4..e21309f0e5 100644 --- a/tests/src/com/android/launcher3/dragging/TaplUninstallRemoveTest.java +++ b/tests/src/com/android/launcher3/dragging/TaplUninstallRemoveTest.java @@ -17,6 +17,7 @@ package com.android.launcher3.dragging; import static com.android.launcher3.testing.shared.TestProtocol.ICON_MISSING; import static com.android.launcher3.testing.shared.TestProtocol.UIOBJECT_STALE_ELEMENT; +import static com.android.launcher3.ui.AbstractLauncherUiTest.initialize; import static com.android.launcher3.util.TestConstants.AppNames.DUMMY_APP_NAME; import static com.android.launcher3.util.TestConstants.AppNames.GMAIL_APP_NAME; import static com.android.launcher3.util.TestConstants.AppNames.MAPS_APP_NAME; @@ -31,7 +32,6 @@ import android.graphics.Point; import android.platform.test.annotations.PlatinumTest; import android.util.Log; -import com.android.launcher3.Launcher; import com.android.launcher3.tapl.HomeAllApps; import com.android.launcher3.tapl.HomeAppIcon; import com.android.launcher3.tapl.Workspace; @@ -51,7 +51,7 @@ import java.util.Map; * Test runs in Out of process (Oop) and In process (Ipc) * Test the behaviour of uninstalling and removing apps both from AllApps, Workspace and Hotseat. */ -public class TaplUninstallRemoveTest extends AbstractLauncherUiTest { +public class TaplUninstallRemoveTest extends AbstractLauncherUiTest { /** * Deletes app both built-in and user-installed from the Workspace and makes sure it's no longer diff --git a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java index 71090836bb..d8635f9071 100644 --- a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java +++ b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java @@ -95,7 +95,7 @@ import java.util.function.Supplier; /** * Base class for all instrumentation tests providing various utility methods. */ -public abstract class AbstractLauncherUiTest { +public abstract class AbstractLauncherUiTest { public static final long DEFAULT_ACTIVITY_TIMEOUT = TimeUnit.SECONDS.toMillis(10); public static final long DEFAULT_BROADCAST_TIMEOUT_SECS = 5; @@ -251,7 +251,7 @@ public abstract class AbstractLauncherUiTest { final ViewCaptureRule viewCaptureRule = new ViewCaptureRule( Launcher.ACTIVITY_TRACKER::getCreatedActivity); final RuleChain inner = RuleChain - .outerRule(new PortraitLandscapeRunner(this)) + .outerRule(new PortraitLandscapeRunner(this)) .around(new FailureWatcher(mLauncher, viewCaptureRule::getViewCaptureData)) // .around(viewCaptureRule) // b/315482167 .around(new TestIsolationRule(mLauncher, true)); @@ -426,12 +426,12 @@ public abstract class AbstractLauncherUiTest { } } - protected T getFromLauncher(Function f) { + protected T getFromLauncher(Function f) { if (!TestHelpers.isInLauncherProcess()) return null; return getOnUiThread(() -> f.apply(Launcher.ACTIVITY_TRACKER.getCreatedActivity())); } - protected void executeOnLauncher(Consumer f) { + protected void executeOnLauncher(Consumer f) { getFromLauncher(launcher -> { f.accept(launcher); return null; @@ -441,7 +441,7 @@ public abstract class AbstractLauncherUiTest { // Execute an action on Launcher, but forgive it when launcher is null. // Launcher can be null if teardown is happening after a failed setup step where launcher // activity failed to be created. - protected void executeOnLauncherInTearDown(Consumer f) { + protected void executeOnLauncherInTearDown(Consumer f) { executeOnLauncher(launcher -> { if (launcher != null) f.accept(launcher); }); @@ -469,20 +469,20 @@ public abstract class AbstractLauncherUiTest { // Cannot be used in TaplTests after injecting any gesture using Tapl because this can hide // flakiness. protected void waitForLauncherCondition(String - message, Function condition) { + message, Function condition) { waitForLauncherCondition(message, condition, DEFAULT_ACTIVITY_TIMEOUT); } // Cannot be used in TaplTests after injecting any gesture using Tapl because this can hide // flakiness. - protected O getOnceNotNull(String message, Function f) { + protected T getOnceNotNull(String message, Function f) { return getOnceNotNull(message, f, DEFAULT_ACTIVITY_TIMEOUT); } // Cannot be used in TaplTests after injecting any gesture using Tapl because this can hide // flakiness. protected void waitForLauncherCondition( - String message, Function condition, long timeout) { + String message, Function condition, long timeout) { verifyKeyguardInvisible(); if (!TestHelpers.isInLauncherProcess()) return; Wait.atMost(message, () -> getFromLauncher(condition), timeout, mLauncher); @@ -490,7 +490,7 @@ public abstract class AbstractLauncherUiTest { // Cannot be used in TaplTests after injecting any gesture using Tapl because this can hide // flakiness. - protected T getOnceNotNull(String message, Function f, long timeout) { + protected T getOnceNotNull(String message, Function f, long timeout) { if (!TestHelpers.isInLauncherProcess()) return null; final Object[] output = new Object[1]; @@ -506,7 +506,7 @@ public abstract class AbstractLauncherUiTest { // flakiness. protected void waitForLauncherCondition( String message, - Runnable testThreadAction, Function condition, + Runnable testThreadAction, Function condition, long timeout) { if (!TestHelpers.isInLauncherProcess()) return; Wait.atMost(message, () -> { @@ -648,7 +648,7 @@ public abstract class AbstractLauncherUiTest { "Launcher still active", launcher -> launcher == null, DEFAULT_UI_TIMEOUT); } - protected boolean isInLaunchedApp(LAUNCHER_TYPE launcher) { + protected boolean isInLaunchedApp(Launcher launcher) { return launcher == null || !launcher.hasBeenResumed(); } @@ -658,11 +658,11 @@ public abstract class AbstractLauncherUiTest { launcher -> launcher.getStateManager().getState() == state.get()); } - protected int getAllAppsScroll(LAUNCHER_TYPE launcher) { + protected int getAllAppsScroll(Launcher launcher) { return launcher.getAppsView().getActiveRecyclerView().computeVerticalScrollOffset(); } - protected void onLauncherActivityClose(LAUNCHER_TYPE launcher) { + protected void onLauncherActivityClose(Launcher launcher) { } protected HomeAppIcon createShortcutInCenterIfNotExist(String name) { diff --git a/tests/src/com/android/launcher3/ui/PortraitLandscapeRunner.java b/tests/src/com/android/launcher3/ui/PortraitLandscapeRunner.java index c4e74f20fa..fabe3f71e7 100644 --- a/tests/src/com/android/launcher3/ui/PortraitLandscapeRunner.java +++ b/tests/src/com/android/launcher3/ui/PortraitLandscapeRunner.java @@ -3,7 +3,6 @@ package com.android.launcher3.ui; import android.util.Log; import android.view.Surface; -import com.android.launcher3.Launcher; import com.android.launcher3.tapl.TestHelpers; import com.android.launcher3.util.rule.FailureWatcher; @@ -15,12 +14,11 @@ import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import java.util.Objects; import java.util.concurrent.TimeUnit; -public class PortraitLandscapeRunner implements TestRule { +public class PortraitLandscapeRunner implements TestRule { private static final String TAG = "PortraitLandscapeRunner"; - private AbstractLauncherUiTest mTest; + private AbstractLauncherUiTest mTest; // Annotation for tests that need to be run in portrait and landscape modes. @Retention(RetentionPolicy.RUNTIME) @@ -28,7 +26,7 @@ public class PortraitLandscapeRunner implements public @interface PortraitLandscape { } - public PortraitLandscapeRunner(AbstractLauncherUiTest test) { + public PortraitLandscapeRunner(AbstractLauncherUiTest test) { mTest = test; } @@ -49,7 +47,7 @@ public class PortraitLandscapeRunner implements mTest.mDevice.pressHome(); mTest.waitForLauncherCondition("Launcher activity wasn't created", - Objects::nonNull, + launcher -> launcher != null, TimeUnit.SECONDS.toMillis(20)); mTest.executeOnLauncher(launcher -> diff --git a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3Test.java b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3Test.java index 342eedf2be..6780ed57b7 100644 --- a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3Test.java +++ b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3Test.java @@ -22,14 +22,13 @@ import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; import com.android.launcher3.util.rule.ScreenRecordRule.ScreenRecord; -import com.android.launcher3.Launcher; import org.junit.Test; import org.junit.runner.RunWith; @LargeTest @RunWith(AndroidJUnit4.class) -public class TaplTestsLauncher3Test extends AbstractLauncherUiTest { +public class TaplTestsLauncher3Test extends AbstractLauncherUiTest { @ScreenRecord // b/322823478 @Test diff --git a/tests/src/com/android/launcher3/ui/TaplWorkProfileTest.java b/tests/src/com/android/launcher3/ui/TaplWorkProfileTest.java index cccda88bbe..eb1f49ff11 100644 --- a/tests/src/com/android/launcher3/ui/TaplWorkProfileTest.java +++ b/tests/src/com/android/launcher3/ui/TaplWorkProfileTest.java @@ -35,7 +35,6 @@ import androidx.recyclerview.widget.RecyclerView.ViewHolder; import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.LargeTest; -import com.android.launcher3.Launcher; import com.android.launcher3.LauncherPrefs; import com.android.launcher3.R; import com.android.launcher3.allapps.ActivityAllAppsContainerView; @@ -59,7 +58,7 @@ import java.util.function.Predicate; @LargeTest @RunWith(AndroidJUnit4.class) -public class TaplWorkProfileTest extends AbstractLauncherUiTest { +public class TaplWorkProfileTest extends AbstractLauncherUiTest { private static final int WORK_PAGE = ActivityAllAppsContainerView.AdapterHolder.WORK; diff --git a/tests/src/com/android/launcher3/ui/widget/TaplAddConfigWidgetTest.java b/tests/src/com/android/launcher3/ui/widget/TaplAddConfigWidgetTest.java index e6e02b49ac..1db60144dc 100644 --- a/tests/src/com/android/launcher3/ui/widget/TaplAddConfigWidgetTest.java +++ b/tests/src/com/android/launcher3/ui/widget/TaplAddConfigWidgetTest.java @@ -52,7 +52,7 @@ import org.junit.runner.RunWith; */ @LargeTest @RunWith(AndroidJUnit4.class) -public class TaplAddConfigWidgetTest extends AbstractLauncherUiTest { +public class TaplAddConfigWidgetTest extends AbstractLauncherUiTest { @Rule public ShellCommandRule mGrantWidgetRule = ShellCommandRule.grantWidgetBind(); diff --git a/tests/src/com/android/launcher3/ui/widget/TaplAddWidgetTest.java b/tests/src/com/android/launcher3/ui/widget/TaplAddWidgetTest.java index 7845dec4a3..6c243294c3 100644 --- a/tests/src/com/android/launcher3/ui/widget/TaplAddWidgetTest.java +++ b/tests/src/com/android/launcher3/ui/widget/TaplAddWidgetTest.java @@ -25,7 +25,6 @@ import android.platform.test.annotations.PlatinumTest; import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.LargeTest; -import com.android.launcher3.Launcher; import com.android.launcher3.celllayout.FavoriteItemsTransaction; import com.android.launcher3.tapl.Widget; import com.android.launcher3.tapl.WidgetResizeFrame; @@ -47,7 +46,7 @@ import org.junit.runner.RunWith; */ @LargeTest @RunWith(AndroidJUnit4.class) -public class TaplAddWidgetTest extends AbstractLauncherUiTest { +public class TaplAddWidgetTest extends AbstractLauncherUiTest { @Rule public ShellCommandRule mGrantWidgetRule = ShellCommandRule.grantWidgetBind(); diff --git a/tests/src/com/android/launcher3/ui/widget/TaplBindWidgetTest.java b/tests/src/com/android/launcher3/ui/widget/TaplBindWidgetTest.java index 28d1faa5e7..e69cb4ce62 100644 --- a/tests/src/com/android/launcher3/ui/widget/TaplBindWidgetTest.java +++ b/tests/src/com/android/launcher3/ui/widget/TaplBindWidgetTest.java @@ -43,7 +43,6 @@ import android.widget.RemoteViews; import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.LargeTest; -import com.android.launcher3.Launcher; import com.android.launcher3.LauncherAppState; import com.android.launcher3.LauncherModel; import com.android.launcher3.LauncherSettings; @@ -77,7 +76,7 @@ import java.util.function.Consumer; */ @LargeTest @RunWith(AndroidJUnit4.class) -public class TaplBindWidgetTest extends AbstractLauncherUiTest { +public class TaplBindWidgetTest extends AbstractLauncherUiTest { @Rule public ShellCommandRule mGrantWidgetRule = ShellCommandRule.grantWidgetBind(); diff --git a/tests/src/com/android/launcher3/ui/widget/TaplRequestPinItemTest.java b/tests/src/com/android/launcher3/ui/widget/TaplRequestPinItemTest.java index 74047f0d01..90a6d22f38 100644 --- a/tests/src/com/android/launcher3/ui/widget/TaplRequestPinItemTest.java +++ b/tests/src/com/android/launcher3/ui/widget/TaplRequestPinItemTest.java @@ -59,7 +59,7 @@ import java.util.UUID; */ @LargeTest @RunWith(AndroidJUnit4.class) -public class TaplRequestPinItemTest extends AbstractLauncherUiTest { +public class TaplRequestPinItemTest extends AbstractLauncherUiTest { @Rule public ShellCommandRule mGrantWidgetRule = ShellCommandRule.grantWidgetBind(); diff --git a/tests/src/com/android/launcher3/ui/widget/TaplWidgetPickerTest.java b/tests/src/com/android/launcher3/ui/widget/TaplWidgetPickerTest.java index 79724e1189..4acdddc7e2 100644 --- a/tests/src/com/android/launcher3/ui/widget/TaplWidgetPickerTest.java +++ b/tests/src/com/android/launcher3/ui/widget/TaplWidgetPickerTest.java @@ -43,7 +43,7 @@ import org.junit.runner.RunWith; */ @MediumTest @RunWith(AndroidJUnit4.class) -public class TaplWidgetPickerTest extends AbstractLauncherUiTest { +public class TaplWidgetPickerTest extends AbstractLauncherUiTest { // b/325377690 : To get the log printed where DOWN key event is getting lost from TAPL. @Rule public final TestRule mEnableInputTransportPublisherRule = createEnableInputTransportPublisherRule(); diff --git a/tests/src/com/android/launcher3/ui/workspace/TaplThemeIconsTest.java b/tests/src/com/android/launcher3/ui/workspace/TaplThemeIconsTest.java index d6533171d3..c60ee8c5ed 100644 --- a/tests/src/com/android/launcher3/ui/workspace/TaplThemeIconsTest.java +++ b/tests/src/com/android/launcher3/ui/workspace/TaplThemeIconsTest.java @@ -31,7 +31,6 @@ import android.view.ViewGroup; import androidx.test.filters.LargeTest; import com.android.launcher3.BubbleTextView; -import com.android.launcher3.Launcher; import com.android.launcher3.icons.ThemedIconDrawable; import com.android.launcher3.tapl.HomeAllApps; import com.android.launcher3.tapl.HomeAppIcon; @@ -50,7 +49,7 @@ import java.util.Queue; * Note running these tests will clear the workspace on the device. */ @LargeTest -public class TaplThemeIconsTest extends AbstractLauncherUiTest { +public class TaplThemeIconsTest extends AbstractLauncherUiTest { private static final String APP_NAME = "IconThemedActivity"; private static final String SHORTCUT_NAME = "Shortcut 1"; diff --git a/tests/src/com/android/launcher3/ui/workspace/TaplTwoPanelWorkspaceTest.java b/tests/src/com/android/launcher3/ui/workspace/TaplTwoPanelWorkspaceTest.java index 2ce8eef2d8..913dfa2285 100644 --- a/tests/src/com/android/launcher3/ui/workspace/TaplTwoPanelWorkspaceTest.java +++ b/tests/src/com/android/launcher3/ui/workspace/TaplTwoPanelWorkspaceTest.java @@ -55,7 +55,7 @@ import java.util.stream.Collectors; */ @LargeTest @RunWith(AndroidJUnit4.class) -public class TaplTwoPanelWorkspaceTest extends AbstractLauncherUiTest { +public class TaplTwoPanelWorkspaceTest extends AbstractLauncherUiTest { private AutoCloseable mLauncherLayout; diff --git a/tests/src/com/android/launcher3/ui/workspace/TaplWorkspaceTest.java b/tests/src/com/android/launcher3/ui/workspace/TaplWorkspaceTest.java index 9afde0db28..4edeb42fc1 100644 --- a/tests/src/com/android/launcher3/ui/workspace/TaplWorkspaceTest.java +++ b/tests/src/com/android/launcher3/ui/workspace/TaplWorkspaceTest.java @@ -37,7 +37,7 @@ import org.junit.Test; /** * Test the basic interactions of the Workspace, adding pages, moving the pages and removing pages. */ -public class TaplWorkspaceTest extends AbstractLauncherUiTest { +public class TaplWorkspaceTest extends AbstractLauncherUiTest { private AutoCloseable mLauncherLayout; From 3c713461471957c2b5a2495c219167d98f20295a Mon Sep 17 00:00:00 2001 From: Priyanka Advani Date: Wed, 10 Apr 2024 21:31:07 +0000 Subject: [PATCH 2/2] Revert "abtracting Activity from recentsView through recentsview..." Revert submission 26414135-RecentsViewContainer Reason for revert: Probable culprit for b/333767026. Will be verifying through ABTD for confirmation and before submitting the revert. Reverted changes: /q/submissionid:26414135-RecentsViewContainer Change-Id: I25775cd6531355f1dc042ddb7a8d442ee0b36e58 --- .../launcher3/model/WellbeingModel.java | 15 +- .../uioverrides/QuickstepLauncher.java | 27 +- .../states/BackgroundAppState.java | 9 +- .../states/OverviewModalTaskState.java | 6 +- .../QuickstepAtomicAnimationFactory.java | 24 +- .../NavBarToHomeTouchController.java | 1 - .../NoButtonQuickSwitchTouchController.java | 3 +- .../QuickSwitchTouchController.java | 7 +- .../TaskViewTouchController.java | 29 +- .../TransposedQuickSwitchTouchController.java | 4 +- .../TwoButtonNavbarTouchController.java | 4 +- .../android/quickstep/AbsSwipeUpHandler.java | 146 ++++--- .../quickstep/BaseActivityInterface.java | 310 +++++++++++++- .../quickstep/BaseContainerInterface.java | 377 ------------------ .../quickstep/DesktopSystemShortcut.kt | 12 +- .../quickstep/FallbackActivityInterface.java | 14 +- .../quickstep/FallbackSwipeHandler.java | 2 +- .../com/android/quickstep/GestureState.java | 16 +- .../quickstep/LauncherActivityInterface.java | 40 +- .../quickstep/LauncherSwipeHandlerV2.java | 24 +- .../quickstep/OverviewCommandHelper.java | 10 +- .../QuickstepTestInformationHandler.java | 2 +- .../android/quickstep/RecentsActivity.java | 14 +- .../android/quickstep/RemoteTargetGluer.java | 8 +- .../quickstep/RotationTouchHelper.java | 4 +- .../quickstep/SwipeUpAnimationLogic.java | 9 +- .../quickstep/TaskAnimationManager.java | 42 +- .../android/quickstep/TaskOverlayFactory.java | 25 +- .../quickstep/TaskShortcutFactory.java | 90 ++--- .../quickstep/TouchInteractionService.java | 38 +- .../FallbackNavBarTouchController.java | 17 +- .../FallbackRecentsStateController.java | 2 - .../fallback/FallbackRecentsView.java | 32 +- .../quickstep/fallback/RecentsState.java | 20 +- .../fallback/RecentsTaskController.java | 2 +- .../AssistantInputConsumer.java | 14 +- .../OtherActivityInputConsumer.java | 4 + .../inputconsumers/OverviewInputConsumer.java | 31 +- .../ScreenPinnedInputConsumer.java | 10 +- .../AnimatorControllerWithResistance.java | 21 +- .../quickstep/util/AppPairsController.java | 8 +- .../util/InputProxyHandlerFactory.java | 16 +- .../LauncherUnfoldAnimationController.java | 6 +- .../util/RecentsAtomicAnimationFactory.java | 19 +- .../quickstep/util/RecentsOrientedState.java | 14 +- .../util/ScalingWorkspaceRevealAnim.kt | 3 +- .../util/SplitAnimationController.kt | 43 +- .../util/SplitSelectStateController.java | 24 +- .../util/SplitToWorkspaceController.java | 7 +- .../util/StaggeredWorkspaceAnim.java | 25 +- .../util/TaskRemovedDuringLaunchListener.java | 22 +- .../quickstep/util/TaskViewSimulator.java | 5 +- .../UnfoldMoveFromCenterHotseatAnimator.java | 8 +- ...UnfoldMoveFromCenterWorkspaceAnimator.java | 8 +- .../LauncherUnfoldTransitionController.kt | 4 +- .../util/unfold/UnfoldAnimationBuilder.kt | 4 +- .../quickstep/views/ClearAllButton.java | 6 +- .../quickstep/views/DesktopAppSelectView.java | 9 +- .../quickstep/views/DesktopTaskView.java | 10 +- .../views/DigitalWellBeingToast.java | 36 +- .../views/FloatingAppPairBackground.kt | 97 ++--- .../quickstep/views/FloatingTaskView.java | 64 +-- .../quickstep/views/FloatingWidgetView.java | 8 +- .../quickstep/views/GroupedTaskView.java | 14 +- .../quickstep/views/LauncherRecentsView.java | 64 ++- .../android/quickstep/views/RecentsView.java | 178 ++++----- .../views/SplitInstructionsView.java | 25 +- .../android/quickstep/views/TaskMenuView.java | 43 +- .../quickstep/views/TaskMenuViewWithArrow.kt | 19 +- .../quickstep/views/TaskThumbnailView.java | 9 +- .../com/android/quickstep/views/TaskView.java | 39 +- .../util/SplitSelectStateControllerTest.kt | 3 +- .../launcher3/BaseDraggingActivity.java | 2 + .../launcher3/popup/RemoteActionShortcut.java | 12 +- .../SecondaryDisplayLauncher.java | 5 + .../quickstep/views/RecentsViewContainer.java | 168 -------- 76 files changed, 1106 insertions(+), 1386 deletions(-) delete mode 100644 quickstep/src/com/android/quickstep/BaseContainerInterface.java delete mode 100644 src/com/android/quickstep/views/RecentsViewContainer.java diff --git a/quickstep/src/com/android/launcher3/model/WellbeingModel.java b/quickstep/src/com/android/launcher3/model/WellbeingModel.java index ee1c6004dd..3d04cb6828 100644 --- a/quickstep/src/com/android/launcher3/model/WellbeingModel.java +++ b/quickstep/src/com/android/launcher3/model/WellbeingModel.java @@ -44,6 +44,7 @@ import androidx.annotation.MainThread; import androidx.annotation.Nullable; import androidx.annotation.WorkerThread; +import com.android.launcher3.BaseDraggingActivity; import com.android.launcher3.R; import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.popup.RemoteActionShortcut; @@ -52,7 +53,6 @@ import com.android.launcher3.util.BgObjectWithLooper; import com.android.launcher3.util.MainThreadInitializedObject; import com.android.launcher3.util.Preconditions; import com.android.launcher3.util.SimpleBroadcastReceiver; -import com.android.launcher3.views.ActivityContext; import java.util.Arrays; import java.util.HashMap; @@ -147,7 +147,7 @@ public final class WellbeingModel extends BgObjectWithLooper { @MainThread private SystemShortcut getShortcutForApp(String packageName, int userId, - Context context, ItemInfo info, View originalView) { + BaseDraggingActivity activity, ItemInfo info, View originalView) { Preconditions.assertUIThread(); // Work profile apps are not recognized by digital wellbeing. if (userId != UserHandle.myUserId()) { @@ -171,7 +171,7 @@ public final class WellbeingModel extends BgObjectWithLooper { "getShortcutForApp [" + packageName + "]: action: '" + action.getTitle() + "'"); } - return new RemoteActionShortcut(action, context, info, originalView); + return new RemoteActionShortcut(action, activity, info, originalView); } } @@ -305,10 +305,9 @@ public final class WellbeingModel extends BgObjectWithLooper { /** * Shortcut factory for generating wellbeing action */ - public static final SystemShortcut.Factory SHORTCUT_FACTORY = - (context, info, originalView) -> - (info.getTargetComponent() == null) ? null - : INSTANCE.get(originalView.getContext()).getShortcutForApp( + public static final SystemShortcut.Factory SHORTCUT_FACTORY = + (activity, info, originalView) -> (info.getTargetComponent() == null) ? null + : INSTANCE.get(activity).getShortcutForApp( info.getTargetComponent().getPackageName(), info.user.getIdentifier(), - originalView.getContext(), info, originalView); + activity, info, originalView); } diff --git a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java index 6c05bfe752..6013797955 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java +++ b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java @@ -181,7 +181,6 @@ import com.android.quickstep.util.unfold.ProxyUnfoldTransitionProvider; import com.android.quickstep.views.FloatingTaskView; import com.android.quickstep.views.OverviewActionsView; import com.android.quickstep.views.RecentsView; -import com.android.quickstep.views.RecentsViewContainer; import com.android.quickstep.views.TaskView; import com.android.systemui.shared.recents.model.Task; import com.android.systemui.shared.system.ActivityManagerWrapper; @@ -205,7 +204,7 @@ import java.util.function.BiConsumer; import java.util.function.Predicate; import java.util.stream.Stream; -public class QuickstepLauncher extends Launcher implements RecentsViewContainer { +public class QuickstepLauncher extends Launcher { private static final boolean TRACE_LAYOUTS = SystemProperties.getBoolean("persist.debug.trace_layouts", false); private static final String TRACE_RELAYOUT_CLASS = @@ -219,8 +218,7 @@ public class QuickstepLauncher extends Launcher implements RecentsViewContainer private DepthController mDepthController; private @Nullable DesktopVisibilityController mDesktopVisibilityController; private QuickstepTransitionManager mAppTransitionManager; - - private OverviewActionsView mActionsView; + private OverviewActionsView mActionsView; private TISBindHelper mTISBindHelper; private @Nullable LauncherTaskbarUIController mTaskbarUIController; // Will be updated when dragging from taskbar. @@ -246,16 +244,12 @@ public class QuickstepLauncher extends Launcher implements RecentsViewContainer private boolean mIsPredictiveBackToHomeInProgress; - public static QuickstepLauncher getLauncher(Context context) { - return fromContext(context); - } - @Override protected void setupViews() { super.setupViews(); mActionsView = findViewById(R.id.overview_actions_view); - RecentsView overviewPanel = getOverviewPanel(); + RecentsView overviewPanel = getOverviewPanel(); SystemUiProxy systemUiProxy = SystemUiProxy.INSTANCE.get(this); mSplitSelectStateController = new SplitSelectStateController(this, mHandler, getStateManager(), @@ -1061,9 +1055,8 @@ public class QuickstepLauncher extends Launcher implements RecentsViewContainer .playPlaceholderDismissAnim(this, splitDismissEvent); } - @Override - public OverviewActionsView getActionsView() { - return mActionsView; + public T getActionsView() { + return (T) mActionsView; } @Override @@ -1376,25 +1369,25 @@ public class QuickstepLauncher extends Launcher implements RecentsViewContainer } private static final class LauncherTaskViewController extends - TaskViewTouchController { + TaskViewTouchController { - LauncherTaskViewController(QuickstepLauncher activity) { + LauncherTaskViewController(Launcher activity) { super(activity); } @Override protected boolean isRecentsInteractive() { - return mContainer.isInState(OVERVIEW) || mContainer.isInState(OVERVIEW_MODAL_TASK); + return mActivity.isInState(OVERVIEW) || mActivity.isInState(OVERVIEW_MODAL_TASK); } @Override protected boolean isRecentsModal() { - return mContainer.isInState(OVERVIEW_MODAL_TASK); + return mActivity.isInState(OVERVIEW_MODAL_TASK); } @Override protected void onUserControlledAnimationCreated(AnimatorPlaybackController animController) { - mContainer.getStateManager().setCurrentUserControlledAnimation(animController); + mActivity.getStateManager().setCurrentUserControlledAnimation(animController); } } diff --git a/quickstep/src/com/android/launcher3/uioverrides/states/BackgroundAppState.java b/quickstep/src/com/android/launcher3/uioverrides/states/BackgroundAppState.java index 7fa121dadb..3ffad70365 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/states/BackgroundAppState.java +++ b/quickstep/src/com/android/launcher3/uioverrides/states/BackgroundAppState.java @@ -22,6 +22,7 @@ import static com.android.quickstep.TaskAnimationManager.ENABLE_SHELL_TRANSITION import android.content.Context; import android.graphics.Color; +import com.android.launcher3.BaseDraggingActivity; import com.android.launcher3.DeviceProfile; import com.android.launcher3.Launcher; import com.android.launcher3.allapps.AllAppsTransitionController; @@ -62,7 +63,7 @@ public class BackgroundAppState extends OverviewState { @Override public float[] getOverviewScaleAndOffset(Launcher launcher) { - return getOverviewScaleAndOffsetForBackgroundState(launcher.getOverviewPanel()); + return getOverviewScaleAndOffsetForBackgroundState(launcher); } @Override @@ -124,7 +125,9 @@ public class BackgroundAppState extends OverviewState { } public static float[] getOverviewScaleAndOffsetForBackgroundState( - RecentsView recentsView) { - return new float[] {recentsView.getMaxScaleForFullScreen(), NO_OFFSET}; + BaseDraggingActivity activity) { + return new float[] { + ((RecentsView) activity.getOverviewPanel()).getMaxScaleForFullScreen(), + NO_OFFSET}; } } diff --git a/quickstep/src/com/android/launcher3/uioverrides/states/OverviewModalTaskState.java b/quickstep/src/com/android/launcher3/uioverrides/states/OverviewModalTaskState.java index 3c291e6095..c63eaebc89 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/states/OverviewModalTaskState.java +++ b/quickstep/src/com/android/launcher3/uioverrides/states/OverviewModalTaskState.java @@ -20,6 +20,7 @@ import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_OVERV import android.content.Context; import android.graphics.Rect; +import com.android.launcher3.BaseDraggingActivity; import com.android.launcher3.Flags; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherState; @@ -50,7 +51,7 @@ public class OverviewModalTaskState extends OverviewState { @Override public float[] getOverviewScaleAndOffset(Launcher launcher) { - return getOverviewScaleAndOffsetForModalState(launcher.getOverviewPanel()); + return getOverviewScaleAndOffsetForModalState(launcher); } @Override @@ -71,7 +72,8 @@ public class OverviewModalTaskState extends OverviewState { return super.isTaskbarStashed(launcher); } - public static float[] getOverviewScaleAndOffsetForModalState(RecentsView recentsView) { + public static float[] getOverviewScaleAndOffsetForModalState(BaseDraggingActivity activity) { + RecentsView recentsView = activity.getOverviewPanel(); Rect taskSize = recentsView.getSelectedTaskBounds(); Rect modalTaskSize = new Rect(); recentsView.getModalTaskSize(modalTaskSize); diff --git a/quickstep/src/com/android/launcher3/uioverrides/states/QuickstepAtomicAnimationFactory.java b/quickstep/src/com/android/launcher3/uioverrides/states/QuickstepAtomicAnimationFactory.java index 0368f3a86d..b40186819f 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/states/QuickstepAtomicAnimationFactory.java +++ b/quickstep/src/com/android/launcher3/uioverrides/states/QuickstepAtomicAnimationFactory.java @@ -94,7 +94,7 @@ public class QuickstepAtomicAnimationFactory extends @Override public void prepareForAtomicAnimation(LauncherState fromState, LauncherState toState, StateAnimationConfig config) { - RecentsView overview = mContainer.getOverviewPanel(); + RecentsView overview = mActivity.getOverviewPanel(); if ((fromState == OVERVIEW || fromState == OVERVIEW_SPLIT_SELECT) && toState == NORMAL) { overview.switchToScreenshot(() -> overview.finishRecentsAnimation(true /* toRecents */, null)); @@ -118,7 +118,7 @@ public class QuickstepAtomicAnimationFactory extends config.setInterpolator(ANIM_WORKSPACE_SCALE, DECELERATE); config.setInterpolator(ANIM_WORKSPACE_FADE, ACCELERATE); - if (DisplayController.getNavigationMode(mContainer).hasGestures + if (DisplayController.getNavigationMode(mActivity).hasGestures && overview.getTaskViewCount() > 0) { // Overview is going offscreen, so keep it at its current scale and opacity. config.setInterpolator(ANIM_OVERVIEW_SCALE, FINAL_FRAME); @@ -136,7 +136,7 @@ public class QuickstepAtomicAnimationFactory extends config.duration = Math.max(config.duration, scrollDuration); // Sync scroll so that it ends before or at the same time as the taskbar animation. - if (mContainer.getDeviceProfile().isTaskbarPresent) { + if (mActivity.getDeviceProfile().isTaskbarPresent) { config.duration = Math.min( config.duration, QuickstepTransitionManager.getTaskbarToHomeDuration()); } @@ -147,7 +147,7 @@ public class QuickstepAtomicAnimationFactory extends config.setInterpolator(ANIM_OVERVIEW_FADE, DECELERATE_1_7); } - Workspace workspace = mContainer.getWorkspace(); + Workspace workspace = mActivity.getWorkspace(); // Start from a higher workspace scale, but only if we're invisible so we don't jump. boolean isWorkspaceVisible = workspace.getVisibility() == VISIBLE; if (isWorkspaceVisible) { @@ -160,7 +160,7 @@ public class QuickstepAtomicAnimationFactory extends workspace.setScaleX(WORKSPACE_PREPARE_SCALE); workspace.setScaleY(WORKSPACE_PREPARE_SCALE); } - Hotseat hotseat = mContainer.getHotseat(); + Hotseat hotseat = mActivity.getHotseat(); boolean isHotseatVisible = hotseat.getVisibility() == VISIBLE && hotseat.getAlpha() > 0; if (!isHotseatVisible) { hotseat.setScaleX(WORKSPACE_PREPARE_SCALE); @@ -168,7 +168,7 @@ public class QuickstepAtomicAnimationFactory extends } } else if ((fromState == NORMAL || fromState == HINT_STATE || fromState == HINT_STATE_TWO_BUTTON) && toState == OVERVIEW) { - if (DisplayController.getNavigationMode(mContainer).hasGestures) { + if (DisplayController.getNavigationMode(mActivity).hasGestures) { config.setInterpolator(ANIM_WORKSPACE_SCALE, fromState == NORMAL ? ACCELERATE : OVERSHOOT_1_2); config.setInterpolator(ANIM_WORKSPACE_TRANSLATE, ACCELERATE); @@ -201,18 +201,18 @@ public class QuickstepAtomicAnimationFactory extends } else if (fromState == HINT_STATE && toState == NORMAL) { config.setInterpolator(ANIM_DEPTH, DECELERATE_3); if (mHintToNormalDuration == -1) { - ValueAnimator va = getWorkspaceSpringScaleAnimator(mContainer, - mContainer.getWorkspace(), - toState.getWorkspaceScaleAndTranslation(mContainer).scale); + ValueAnimator va = getWorkspaceSpringScaleAnimator(mActivity, + mActivity.getWorkspace(), + toState.getWorkspaceScaleAndTranslation(mActivity).scale); mHintToNormalDuration = (int) va.getDuration(); } config.duration = Math.max(config.duration, mHintToNormalDuration); } else if (fromState == ALL_APPS && toState == NORMAL) { - AllAppsSwipeController.applyAllAppsToNormalConfig(mContainer, config); + AllAppsSwipeController.applyAllAppsToNormalConfig(mActivity, config); } else if (fromState == NORMAL && toState == ALL_APPS) { - AllAppsSwipeController.applyNormalToAllAppsAnimConfig(mContainer, config); + AllAppsSwipeController.applyNormalToAllAppsAnimConfig(mActivity, config); } else if (fromState == OVERVIEW && toState == OVERVIEW_SPLIT_SELECT) { - SplitAnimationTimings timings = mContainer.getDeviceProfile().isTablet + SplitAnimationTimings timings = mActivity.getDeviceProfile().isTablet ? SplitAnimationTimings.TABLET_OVERVIEW_TO_SPLIT : SplitAnimationTimings.PHONE_OVERVIEW_TO_SPLIT; config.setInterpolator(ANIM_OVERVIEW_ACTIONS_FADE, clampToProgress(LINEAR, diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NavBarToHomeTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NavBarToHomeTouchController.java index 615e3e326e..e8b508168d 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NavBarToHomeTouchController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NavBarToHomeTouchController.java @@ -47,7 +47,6 @@ import com.android.launcher3.compat.AccessibilityManagerCompat; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.statemanager.StateManager; import com.android.launcher3.touch.SingleAxisSwipeDetector; -import com.android.launcher3.uioverrides.QuickstepLauncher; import com.android.launcher3.util.DisplayController; import com.android.launcher3.util.TouchController; import com.android.quickstep.TaskUtils; diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java index 5a19ed42db..8ef35c06eb 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java @@ -84,6 +84,7 @@ import com.android.quickstep.util.AnimatorControllerWithResistance; import com.android.quickstep.util.LayoutUtils; import com.android.quickstep.util.MotionPauseDetector; import com.android.quickstep.util.WorkspaceRevealAnim; +import com.android.quickstep.views.LauncherRecentsView; import com.android.quickstep.views.RecentsView; import com.android.systemui.shared.system.InteractionJankMonitorWrapper; @@ -107,7 +108,7 @@ public class NoButtonQuickSwitchTouchController implements TouchController, private final float mMaxYProgress; private final MotionPauseDetector mMotionPauseDetector; private final float mMotionPauseMinDisplacement; - private final RecentsView mRecentsView; + private final LauncherRecentsView mRecentsView; protected final AnimatorListener mClearStateOnCancelListener = newCancelListener(this::clearState); diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/QuickSwitchTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/QuickSwitchTouchController.java index 05a55d0856..de73630666 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/QuickSwitchTouchController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/QuickSwitchTouchController.java @@ -38,12 +38,12 @@ import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_O import android.view.MotionEvent; +import com.android.launcher3.Launcher; import com.android.launcher3.LauncherState; import com.android.launcher3.Utilities; import com.android.launcher3.states.StateAnimationConfig; import com.android.launcher3.touch.AbstractStateChangeTouchController; import com.android.launcher3.touch.SingleAxisSwipeDetector; -import com.android.launcher3.uioverrides.QuickstepLauncher; import com.android.launcher3.util.DisplayController; import com.android.launcher3.util.NavigationMode; import com.android.quickstep.SystemUiProxy; @@ -58,12 +58,11 @@ public class QuickSwitchTouchController extends AbstractStateChangeTouchControll protected final RecentsView mOverviewPanel; - public QuickSwitchTouchController(QuickstepLauncher launcher) { + public QuickSwitchTouchController(Launcher launcher) { this(launcher, SingleAxisSwipeDetector.HORIZONTAL); } - protected QuickSwitchTouchController(QuickstepLauncher l, - SingleAxisSwipeDetector.Direction dir) { + protected QuickSwitchTouchController(Launcher l, SingleAxisSwipeDetector.Direction dir) { super(l, dir); mOverviewPanel = l.getOverviewPanel(); } diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/TaskViewTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/TaskViewTouchController.java index 300d697fff..e9f2d4f019 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/TaskViewTouchController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/TaskViewTouchController.java @@ -21,7 +21,6 @@ import static com.android.launcher3.touch.SingleAxisSwipeDetector.DIRECTION_BOTH import android.animation.Animator; import android.animation.AnimatorListenerAdapter; -import android.content.Context; import android.os.VibrationEffect; import android.view.MotionEvent; import android.view.View; @@ -29,6 +28,7 @@ import android.view.animation.Interpolator; import com.android.app.animation.Interpolators; import com.android.launcher3.AbstractFloatingView; +import com.android.launcher3.BaseDraggingActivity; import com.android.launcher3.LauncherAnimUtils; import com.android.launcher3.R; import com.android.launcher3.Utilities; @@ -44,13 +44,12 @@ import com.android.launcher3.views.BaseDragLayer; import com.android.quickstep.orientation.RecentsPagedOrientationHandler; import com.android.quickstep.util.VibrationConstants; import com.android.quickstep.views.RecentsView; -import com.android.quickstep.views.RecentsViewContainer; import com.android.quickstep.views.TaskView; /** * Touch controller for handling task view card swipes */ -public abstract class TaskViewTouchController +public abstract class TaskViewTouchController extends AnimatorListenerAdapter implements TouchController, SingleAxisSwipeDetector.Listener { @@ -64,7 +63,7 @@ public abstract class TaskViewTouchController, Q extends RecentsView, S extends BaseState> extends SwipeUpAnimationLogic implements OnApplyWindowInsetsListener, RecentsAnimationCallbacks.RecentsAnimationListener { @@ -171,7 +171,7 @@ public abstract class AbsSwipeUpHandler mContainerInterface; + protected final BaseActivityInterface mActivityInterface; protected final InputConsumerProxy mInputConsumerProxy; protected final ActivityInitListener mActivityInitListener; // Callbacks to be made once the recents animation starts @@ -182,7 +182,7 @@ public abstract class AbsSwipeUpHandler { ActiveGestureLog.INSTANCE.addLog("Launcher destroyed", LAUNCHER_DESTROYED); mRecentsView = null; - mContainer = null; + mActivity = null; mStateCallback.clearState(STATE_LAUNCHER_PRESENT); }; @@ -347,9 +347,8 @@ public abstract class AbsSwipeUpHandler { if (mRecentsView == null) { @@ -359,7 +358,7 @@ public abstract class AbsSwipeUpHandler { endRunningWindowAnim(mGestureState.getEndTarget() == HOME /* cancel */); endLauncherTransitionController(); - }, new InputProxyHandlerFactory(mContainerInterface, mGestureState)); + }, new InputProxyHandlerFactory(mActivityInterface, mGestureState)); mTaskAnimationManager = taskAnimationManager; mTouchTimeMs = touchTimeMs; mContinuingLastGesture = continuingLastGesture; @@ -376,8 +375,8 @@ public abstract class AbsSwipeUpHandler { - mAnimationFactory = mContainerInterface.prepareRecentsUI(mDeviceState, + mAnimationFactory = mActivityInterface.prepareRecentsUI(mDeviceState, mWasLauncherAlreadyVisible, this::onAnimatorPlaybackControllerCreated); maybeUpdateRecentsAttachedState(false /* animate */); if (mGestureState.getEndTarget() != null) { @@ -586,14 +585,14 @@ public abstract class AbsSwipeUpHandler dragLayer.getViewTreeObserver().removeOnDrawListener(this)); - if (container != mContainer) { + if (activity != mActivity) { return; } @@ -616,7 +615,7 @@ public abstract class AbsSwipeUpHandler { mDeviceState.getRotationTouchHelper() .onEndTargetCalculated(mGestureState.getEndTarget(), - mContainerInterface); + mActivityInterface); }); notifyGestureStarted(); } private void onDeferredActivityLaunch() { - mContainerInterface.switchRunningTaskViewToScreenshot( + mActivityInterface.switchRunningTaskViewToScreenshot( null, () -> { mTaskAnimationManager.finishRunningRecentsAnimation(true /* toHome */); }); @@ -707,7 +706,7 @@ public abstract class AbsSwipeUpHandler, - ACTIVITY_TYPE extends StatefulActivity & RecentsViewContainer> extends - BaseContainerInterface { + ACTIVITY_TYPE extends StatefulActivity> { + + public final boolean rotationSupportedByActivity; + private final STATE_TYPE mBackgroundState; private STATE_TYPE mTargetState; @@ -81,7 +100,7 @@ public abstract class BaseActivityInterface callback); + + public abstract ActivityInitListener createActivityInitListener( + Predicate onInitListener); + + /** + * Sets a callback to be run when an activity launch happens while launcher is not yet resumed. + */ + public void setOnDeferredActivityLaunchCallback(Runnable r) {} + @Nullable - public abstract ACTIVITY_TYPE getCreatedContainer(); + public abstract ACTIVITY_TYPE getCreatedActivity(); @Nullable public DepthController getDepthController() { return null; } + @Nullable + public DesktopVisibilityController getDesktopVisibilityController() { + return null; + } + + @Nullable + public abstract TaskbarUIController getTaskbarController(); + public final boolean isResumed() { - ACTIVITY_TYPE activity = getCreatedContainer(); + ACTIVITY_TYPE activity = getCreatedActivity(); return activity != null && activity.hasBeenResumed(); } public final boolean isStarted() { - ACTIVITY_TYPE activity = getCreatedContainer(); + ACTIVITY_TYPE activity = getCreatedActivity(); return activity != null && activity.isStarted(); } @@ -130,6 +177,14 @@ public abstract class BaseActivityInterface thumbnailDatas, Runnable runnable) { - ACTIVITY_TYPE activity = getCreatedContainer(); + ACTIVITY_TYPE activity = getCreatedActivity(); if (activity == null) { return; } @@ -162,9 +231,230 @@ public abstract class BaseActivityInterface callback) { mCallback = callback; - mActivity = getCreatedContainer(); + mActivity = getCreatedActivity(); mStartState = mActivity.getStateManager().getState(); } diff --git a/quickstep/src/com/android/quickstep/BaseContainerInterface.java b/quickstep/src/com/android/quickstep/BaseContainerInterface.java deleted file mode 100644 index 99551834f1..0000000000 --- a/quickstep/src/com/android/quickstep/BaseContainerInterface.java +++ /dev/null @@ -1,377 +0,0 @@ -/* - * Copyright (C) 2024 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.quickstep; - -import static com.android.app.animation.Interpolators.INSTANT; -import static com.android.app.animation.Interpolators.LINEAR; -import static com.android.launcher3.LauncherAnimUtils.VIEW_BACKGROUND_COLOR; -import static com.android.quickstep.GestureState.GestureEndTarget.LAST_TASK; -import static com.android.quickstep.GestureState.GestureEndTarget.RECENTS; - -import android.animation.Animator; -import android.animation.ObjectAnimator; -import android.content.Context; -import android.content.res.Resources; -import android.graphics.Color; -import android.graphics.PointF; -import android.graphics.Rect; -import android.view.Gravity; -import android.view.MotionEvent; -import android.view.RemoteAnimationTarget; -import android.view.View; - -import androidx.annotation.Nullable; - -import com.android.launcher3.DeviceProfile; -import com.android.launcher3.Flags; -import com.android.launcher3.R; -import com.android.launcher3.statehandlers.DesktopVisibilityController; -import com.android.launcher3.statemanager.BaseState; -import com.android.launcher3.taskbar.TaskbarUIController; -import com.android.launcher3.touch.PagedOrientationHandler; -import com.android.launcher3.util.DisplayController; -import com.android.launcher3.views.ScrimView; -import com.android.quickstep.orientation.RecentsPagedOrientationHandler; -import com.android.quickstep.util.ActivityInitListener; -import com.android.quickstep.util.AnimatorControllerWithResistance; -import com.android.quickstep.views.RecentsView; -import com.android.quickstep.views.RecentsViewContainer; -import com.android.systemui.shared.recents.model.ThumbnailData; - -import java.util.HashMap; -import java.util.function.Consumer; -import java.util.function.Predicate; - -public abstract class BaseContainerInterface, - CONTAINER_TYPE extends RecentsViewContainer> { - - public boolean rotationSupportedByActivity = false; - - @Nullable - public abstract CONTAINER_TYPE getCreatedContainer(); - - public abstract boolean isInLiveTileMode(); - - public abstract void onAssistantVisibilityChanged(float assistantVisibility); - - public abstract boolean allowMinimizeSplitScreen(); - - public abstract boolean isResumed(); - - public abstract boolean isStarted(); - public abstract boolean deferStartingActivity(RecentsAnimationDeviceState deviceState, - MotionEvent ev); - - /** @return whether to allow going to All Apps from Overview. */ - public abstract boolean allowAllAppsFromOverview(); - - /** - * Returns the color of the scrim behind overview when at rest in this state. - * Return {@link Color#TRANSPARENT} for no scrim. - */ - protected abstract int getOverviewScrimColorForState(CONTAINER_TYPE container, - STATE_TYPE state); - - public abstract int getSwipeUpDestinationAndLength( - DeviceProfile dp, Context context, Rect outRect, - RecentsPagedOrientationHandler orientationHandler); - - @Nullable - public abstract TaskbarUIController getTaskbarController(); - - public abstract BaseActivityInterface.AnimationFactory prepareRecentsUI( - RecentsAnimationDeviceState deviceState, boolean activityVisible, - Consumer callback); - - public abstract ActivityInitListener createActivityInitListener( - Predicate onInitListener); - /** - * Returns the expected STATE_TYPE from the provided GestureEndTarget. - */ - public abstract STATE_TYPE stateFromGestureEndTarget(GestureState.GestureEndTarget endTarget); - - public abstract void switchRunningTaskViewToScreenshot(HashMap thumbnailDatas, Runnable runnable); - - public abstract void closeOverlay(); - - public abstract Rect getOverviewWindowBounds( - Rect homeBounds, RemoteAnimationTarget target); - - public abstract void onLaunchTaskFailed(); - - public abstract void onExitOverview(RotationTouchHelper deviceState, - Runnable exitRunnable); - - /** Called when the animation to home has fully settled. */ - public void onSwipeUpToHomeComplete(RecentsAnimationDeviceState deviceState) {} - - /** - * Sets a callback to be run when an activity launch happens while launcher is not yet resumed. - */ - public void setOnDeferredActivityLaunchCallback(Runnable r) {} - /** - * @return Whether the gesture in progress should be cancelled. - */ - public boolean shouldCancelCurrentGesture() { - return false; - } - - @Nullable - public DesktopVisibilityController getDesktopVisibilityController() { - return null; - } - - /** - * Called when the gesture ends and the animation starts towards the given target. Used to add - * an optional additional animation with the same duration. - */ - public @Nullable Animator getParallelAnimationToLauncher( - GestureState.GestureEndTarget endTarget, long duration, - RecentsAnimationCallbacks callbacks) { - if (endTarget == RECENTS) { - CONTAINER_TYPE container = getCreatedContainer(); - if (container == null) { - return null; - } - RecentsView recentsView = container.getOverviewPanel(); - STATE_TYPE state = stateFromGestureEndTarget(endTarget); - ScrimView scrimView = container.getScrimView(); - ObjectAnimator anim = ObjectAnimator.ofArgb(scrimView, VIEW_BACKGROUND_COLOR, - getOverviewScrimColorForState(container, state)); - anim.setDuration(duration); - anim.setInterpolator(recentsView == null || !recentsView.isKeyboardTaskFocusPending() - ? LINEAR : INSTANT); - return anim; - } - return null; - } - - /** - * Called when the animation to the target has finished, but right before updating the state. - * @return A View that needs to draw before ending the recents animation to LAST_TASK. - * (This is a hack to ensure Taskbar draws its background first to avoid flickering.) - */ - public @Nullable View onSettledOnEndTarget(GestureState.GestureEndTarget endTarget) { - TaskbarUIController taskbarUIController = getTaskbarController(); - if (taskbarUIController != null) { - taskbarUIController.setSystemGestureInProgress(false); - return taskbarUIController.getRootView(); - } - return null; - } - - /** - * Called when the current gesture transition is cancelled. - * @param activityVisible Whether the user can see the changes we make here, so try to animate. - * @param endTarget If the gesture ended before we got cancelled, where we were headed. - */ - public void onTransitionCancelled(boolean activityVisible, - @Nullable GestureState.GestureEndTarget endTarget) { - RecentsViewContainer container = getCreatedContainer(); - if (container == null) { - return; - } - RecentsView recentsView = container.getOverviewPanel(); - BaseState startState = recentsView.getStateManager().getRestState(); - if (endTarget != null) { - // We were on our way to this state when we got canceled, end there instead. - startState = stateFromGestureEndTarget(endTarget); - DesktopVisibilityController controller = getDesktopVisibilityController(); - if (controller != null && controller.areDesktopTasksVisible() - && endTarget == LAST_TASK) { - // When we are cancelling the transition and going back to last task, move to - // rest state instead when desktop tasks are visible. - // If a fullscreen task is visible, launcher goes to normal state when the - // activity is stopped. This does not happen when desktop tasks are visible - // on top of launcher. Force the launcher state to rest state here. - startState = recentsView.getStateManager().getRestState(); - // Do not animate the transition - activityVisible = false; - } - } - recentsView.getStateManager().goToState(startState, activityVisible); - } - - public final void calculateTaskSize(Context context, DeviceProfile dp, Rect outRect, - PagedOrientationHandler orientedState) { - if (dp.isTablet) { - if (Flags.enableGridOnlyOverview()) { - calculateGridTaskSize(context, dp, outRect, orientedState); - } else { - calculateFocusTaskSize(context, dp, outRect); - } - } else { - Resources res = context.getResources(); - float maxScale = res.getFloat(R.dimen.overview_max_scale); - int taskMargin = dp.overviewTaskMarginPx; - calculateTaskSizeInternal( - context, - dp, - dp.overviewTaskThumbnailTopMarginPx, - dp.getOverviewActionsClaimedSpace(), - res.getDimensionPixelSize(R.dimen.overview_minimum_next_prev_size) + taskMargin, - maxScale, - Gravity.CENTER, - outRect); - } - } - - /** - * Calculates the taskView size for carousel during app to overview animation on tablets. - */ - public final void calculateCarouselTaskSize(Context context, DeviceProfile dp, Rect outRect, - PagedOrientationHandler orientedState) { - if (dp.isTablet && dp.isGestureMode) { - Resources res = context.getResources(); - float minScale = res.getFloat(R.dimen.overview_carousel_min_scale); - Rect gridRect = new Rect(); - calculateGridSize(dp, context, gridRect); - calculateTaskSizeInternal(context, dp, gridRect, minScale, Gravity.CENTER | Gravity.TOP, - outRect); - } else { - calculateTaskSize(context, dp, outRect, orientedState); - } - } - - private void calculateFocusTaskSize(Context context, DeviceProfile dp, Rect outRect) { - Resources res = context.getResources(); - float maxScale = res.getFloat(R.dimen.overview_max_scale); - Rect gridRect = new Rect(); - calculateGridSize(dp, context, gridRect); - calculateTaskSizeInternal(context, dp, gridRect, maxScale, Gravity.CENTER, outRect); - } - - private void calculateTaskSizeInternal(Context context, DeviceProfile dp, int claimedSpaceAbove, - int claimedSpaceBelow, int minimumHorizontalPadding, float maxScale, int gravity, - Rect outRect) { - Rect insets = dp.getInsets(); - - Rect potentialTaskRect = new Rect(0, 0, dp.widthPx, dp.heightPx); - potentialTaskRect.inset(insets.left, insets.top, insets.right, insets.bottom); - potentialTaskRect.inset( - minimumHorizontalPadding, - claimedSpaceAbove, - minimumHorizontalPadding, - claimedSpaceBelow); - - calculateTaskSizeInternal(context, dp, potentialTaskRect, maxScale, gravity, outRect); - } - - private void calculateTaskSizeInternal(Context context, DeviceProfile dp, - Rect potentialTaskRect, float targetScale, int gravity, Rect outRect) { - PointF taskDimension = getTaskDimension(context, dp); - - float scale = Math.min( - potentialTaskRect.width() / taskDimension.x, - potentialTaskRect.height() / taskDimension.y); - scale = Math.min(scale, targetScale); - int outWidth = Math.round(scale * taskDimension.x); - int outHeight = Math.round(scale * taskDimension.y); - - Gravity.apply(gravity, outWidth, outHeight, potentialTaskRect, outRect); - } - - private static PointF getTaskDimension(Context context, DeviceProfile dp) { - PointF dimension = new PointF(); - getTaskDimension(context, dp, dimension); - return dimension; - } - - /** - * Gets the dimension of the task in the current system state. - */ - public static void getTaskDimension(Context context, DeviceProfile dp, PointF out) { - out.x = dp.widthPx; - out.y = dp.heightPx; - if (dp.isTablet && !DisplayController.isTransientTaskbar(context)) { - out.y -= dp.taskbarHeight; - } - } - - /** - * Calculates the overview grid size for the provided device configuration. - */ - public final void calculateGridSize(DeviceProfile dp, Context context, Rect outRect) { - Rect insets = dp.getInsets(); - int topMargin = dp.overviewTaskThumbnailTopMarginPx; - int bottomMargin = dp.getOverviewActionsClaimedSpace(); - if (dp.isTaskbarPresent && Flags.enableGridOnlyOverview()) { - topMargin += context.getResources().getDimensionPixelSize( - R.dimen.overview_top_margin_grid_only); - bottomMargin += context.getResources().getDimensionPixelSize( - R.dimen.overview_bottom_margin_grid_only); - } - int sideMargin = dp.overviewGridSideMargin; - - outRect.set(0, 0, dp.widthPx, dp.heightPx); - outRect.inset(Math.max(insets.left, sideMargin), insets.top + topMargin, - Math.max(insets.right, sideMargin), Math.max(insets.bottom, bottomMargin)); - } - - /** - * Calculates the overview grid non-focused task size for the provided device configuration. - */ - public final void calculateGridTaskSize(Context context, DeviceProfile dp, Rect outRect, - PagedOrientationHandler orientedState) { - Resources res = context.getResources(); - Rect potentialTaskRect = new Rect(); - if (Flags.enableGridOnlyOverview()) { - calculateGridSize(dp, context, potentialTaskRect); - } else { - calculateFocusTaskSize(context, dp, potentialTaskRect); - } - - float rowHeight = (potentialTaskRect.height() + dp.overviewTaskThumbnailTopMarginPx - - dp.overviewRowSpacing) / 2f; - - PointF taskDimension = getTaskDimension(context, dp); - float scale = (rowHeight - dp.overviewTaskThumbnailTopMarginPx) / taskDimension.y; - int outWidth = Math.round(scale * taskDimension.x); - int outHeight = Math.round(scale * taskDimension.y); - - int gravity = Gravity.TOP; - gravity |= orientedState.getRecentsRtlSetting(res) ? Gravity.RIGHT : Gravity.LEFT; - Gravity.apply(gravity, outWidth, outHeight, potentialTaskRect, outRect); - } - - /** - * Calculates the modal taskView size for the provided device configuration - */ - public final void calculateModalTaskSize(Context context, DeviceProfile dp, Rect outRect, - PagedOrientationHandler orientedState) { - calculateTaskSize(context, dp, outRect, orientedState); - boolean isGridOnlyOverview = dp.isTablet && Flags.enableGridOnlyOverview(); - int claimedSpaceBelow = isGridOnlyOverview - ? dp.overviewActionsTopMarginPx + dp.overviewActionsHeight + dp.stashedTaskbarHeight - : (dp.heightPx - outRect.bottom - dp.getInsets().bottom); - int minimumHorizontalPadding = 0; - if (!isGridOnlyOverview) { - float maxScale = context.getResources().getFloat(R.dimen.overview_modal_max_scale); - minimumHorizontalPadding = - Math.round((dp.availableWidthPx - outRect.width() * maxScale) / 2); - } - calculateTaskSizeInternal( - context, - dp, - dp.overviewTaskMarginPx, - claimedSpaceBelow, - minimumHorizontalPadding, - 1f /*maxScale*/, - Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM, - outRect); - } -} diff --git a/quickstep/src/com/android/quickstep/DesktopSystemShortcut.kt b/quickstep/src/com/android/quickstep/DesktopSystemShortcut.kt index aa0f728b8b..8c71d925e4 100644 --- a/quickstep/src/com/android/quickstep/DesktopSystemShortcut.kt +++ b/quickstep/src/com/android/quickstep/DesktopSystemShortcut.kt @@ -18,24 +18,24 @@ package com.android.quickstep import android.view.View import com.android.launcher3.AbstractFloatingViewHelper +import com.android.launcher3.BaseDraggingActivity import com.android.launcher3.R import com.android.launcher3.logging.StatsLogManager.LauncherEvent import com.android.launcher3.popup.SystemShortcut import com.android.quickstep.views.RecentsView -import com.android.quickstep.views.RecentsViewContainer import com.android.quickstep.views.TaskView.TaskIdAttributeContainer import com.android.window.flags.Flags /** A menu item, "Desktop", that allows the user to bring the current app into Desktop Windowing. */ class DesktopSystemShortcut( - container: RecentsViewContainer, + activity: BaseDraggingActivity, private val mTaskContainer: TaskIdAttributeContainer, abstractFloatingViewHelper: AbstractFloatingViewHelper ) : - SystemShortcut( + SystemShortcut( R.drawable.ic_caption_desktop_button_foreground, R.string.recent_task_option_desktop, - container, + activity, mTaskContainer.itemInfo, mTaskContainer.taskView, abstractFloatingViewHelper @@ -59,7 +59,7 @@ class DesktopSystemShortcut( ): TaskShortcutFactory { return object : TaskShortcutFactory { override fun getShortcuts( - container: RecentsViewContainer, + activity: BaseDraggingActivity, taskContainer: TaskIdAttributeContainer ): List? { return if (!Flags.enableDesktopWindowingMode()) null @@ -67,7 +67,7 @@ class DesktopSystemShortcut( else listOf( DesktopSystemShortcut( - container, + activity, taskContainer, abstractFloatingViewHelper ) diff --git a/quickstep/src/com/android/quickstep/FallbackActivityInterface.java b/quickstep/src/com/android/quickstep/FallbackActivityInterface.java index 9e896fddc5..27e8726975 100644 --- a/quickstep/src/com/android/quickstep/FallbackActivityInterface.java +++ b/quickstep/src/com/android/quickstep/FallbackActivityInterface.java @@ -96,13 +96,13 @@ public final class FallbackActivityInterface extends @Nullable @Override - public RecentsActivity getCreatedContainer() { + public RecentsActivity getCreatedActivity() { return RecentsActivity.ACTIVITY_TRACKER.getCreatedActivity(); } @Override public FallbackTaskbarUIController getTaskbarController() { - RecentsActivity activity = getCreatedContainer(); + RecentsActivity activity = getCreatedActivity(); if (activity == null) { return null; } @@ -112,7 +112,7 @@ public final class FallbackActivityInterface extends @Nullable @Override public RecentsView getVisibleRecentsView() { - RecentsActivity activity = getCreatedContainer(); + RecentsActivity activity = getCreatedActivity(); if (activity != null) { if (activity.hasBeenResumed() || isInLiveTileMode()) { return activity.getOverviewPanel(); @@ -154,7 +154,7 @@ public final class FallbackActivityInterface extends @Override public void onExitOverview(RotationTouchHelper deviceState, Runnable exitRunnable) { - final StateManager stateManager = getCreatedContainer().getStateManager(); + final StateManager stateManager = getCreatedActivity().getStateManager(); if (stateManager.getState() == HOME) { exitRunnable.run(); notifyRecentsOfOrientation(deviceState); @@ -177,7 +177,7 @@ public final class FallbackActivityInterface extends @Override public boolean isInLiveTileMode() { - RecentsActivity activity = getCreatedContainer(); + RecentsActivity activity = getCreatedActivity(); return activity != null && activity.getStateManager().getState() == DEFAULT && activity.isStarted(); } @@ -185,7 +185,7 @@ public final class FallbackActivityInterface extends @Override public void onLaunchTaskFailed() { // TODO: probably go back to overview instead. - RecentsActivity activity = getCreatedContainer(); + RecentsActivity activity = getCreatedActivity(); if (activity == null) { return; } @@ -209,7 +209,7 @@ public final class FallbackActivityInterface extends private void notifyRecentsOfOrientation(RotationTouchHelper rotationTouchHelper) { // reset layout on swipe to home - RecentsView recentsView = getCreatedContainer().getOverviewPanel(); + RecentsView recentsView = getCreatedActivity().getOverviewPanel(); recentsView.setLayoutRotation(rotationTouchHelper.getCurrentActiveRotation(), rotationTouchHelper.getDisplayRotation()); } diff --git a/quickstep/src/com/android/quickstep/FallbackSwipeHandler.java b/quickstep/src/com/android/quickstep/FallbackSwipeHandler.java index 92cdf72c73..b42eb067e4 100644 --- a/quickstep/src/com/android/quickstep/FallbackSwipeHandler.java +++ b/quickstep/src/com/android/quickstep/FallbackSwipeHandler.java @@ -223,7 +223,7 @@ public class FallbackSwipeHandler extends public AnimatorPlaybackController createActivityAnimationToHome() { // copied from {@link LauncherSwipeHandlerV2.LauncherHomeAnimationFactory} long accuracy = 2 * Math.max(mDp.widthPx, mDp.heightPx); - return mContainer.getStateManager().createAnimationToNewWorkspace( + return mActivity.getStateManager().createAnimationToNewWorkspace( RecentsState.HOME, accuracy, StateAnimationConfig.SKIP_ALL_ANIMATIONS); } } diff --git a/quickstep/src/com/android/quickstep/GestureState.java b/quickstep/src/com/android/quickstep/GestureState.java index 6b33c0aacb..d02909c527 100644 --- a/quickstep/src/com/android/quickstep/GestureState.java +++ b/quickstep/src/com/android/quickstep/GestureState.java @@ -37,10 +37,10 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.android.launcher3.statemanager.BaseState; +import com.android.launcher3.statemanager.StatefulActivity; import com.android.quickstep.TopTaskTracker.CachedTaskInfo; import com.android.quickstep.util.ActiveGestureErrorDetector; import com.android.quickstep.util.ActiveGestureLog; -import com.android.quickstep.views.RecentsViewContainer; import com.android.systemui.shared.recents.model.ThumbnailData; import java.io.PrintWriter; @@ -151,7 +151,7 @@ public class GestureState implements RecentsAnimationCallbacks.RecentsAnimationL // Needed to interact with the current activity private final Intent mHomeIntent; private final Intent mOverviewIntent; - private final BaseContainerInterface mContainerInterface; + private final BaseActivityInterface mActivityInterface; private final MultiStateCallback mStateCallback; private final int mGestureId; @@ -189,7 +189,7 @@ public class GestureState implements RecentsAnimationCallbacks.RecentsAnimationL public GestureState(OverviewComponentObserver componentObserver, int gestureId) { mHomeIntent = componentObserver.getHomeIntent(); mOverviewIntent = componentObserver.getOverviewIntent(); - mContainerInterface = componentObserver.getActivityInterface(); + mActivityInterface = componentObserver.getActivityInterface(); mStateCallback = new MultiStateCallback( STATE_NAMES.toArray(new String[0]), GestureState::getTrackedEventForState); mGestureId = gestureId; @@ -198,7 +198,7 @@ public class GestureState implements RecentsAnimationCallbacks.RecentsAnimationL public GestureState(GestureState other) { mHomeIntent = other.mHomeIntent; mOverviewIntent = other.mOverviewIntent; - mContainerInterface = other.mContainerInterface; + mActivityInterface = other.mActivityInterface; mStateCallback = other.mStateCallback; mGestureId = other.mGestureId; mRunningTask = other.mRunningTask; @@ -212,7 +212,7 @@ public class GestureState implements RecentsAnimationCallbacks.RecentsAnimationL // Do nothing, only used for initializing the gesture state prior to user unlock mHomeIntent = new Intent(); mOverviewIntent = new Intent(); - mContainerInterface = null; + mActivityInterface = null; mStateCallback = new MultiStateCallback( STATE_NAMES.toArray(new String[0]), GestureState::getTrackedEventForState); mGestureId = -1; @@ -268,9 +268,9 @@ public class GestureState implements RecentsAnimationCallbacks.RecentsAnimationL /** * @return the interface to the activity handing the UI updates for this gesture. */ - public , T extends RecentsViewContainer> - BaseContainerInterface getContainerInterface() { - return mContainerInterface; + public , + T extends StatefulActivity> BaseActivityInterface getActivityInterface() { + return mActivityInterface; } /** diff --git a/quickstep/src/com/android/quickstep/LauncherActivityInterface.java b/quickstep/src/com/android/quickstep/LauncherActivityInterface.java index 7655c5913e..7c17e4ee7a 100644 --- a/quickstep/src/com/android/quickstep/LauncherActivityInterface.java +++ b/quickstep/src/com/android/quickstep/LauncherActivityInterface.java @@ -36,6 +36,7 @@ import androidx.annotation.UiThread; import com.android.launcher3.DeviceProfile; import com.android.launcher3.Flags; +import com.android.launcher3.Launcher; import com.android.launcher3.LauncherAnimUtils; import com.android.launcher3.LauncherInitListener; import com.android.launcher3.LauncherState; @@ -85,7 +86,7 @@ public final class LauncherActivityInterface extends @Override public void onSwipeUpToHomeComplete(RecentsAnimationDeviceState deviceState) { - QuickstepLauncher launcher = getCreatedContainer(); + Launcher launcher = getCreatedActivity(); if (launcher == null) { return; } @@ -102,7 +103,7 @@ public final class LauncherActivityInterface extends @Override public void onAssistantVisibilityChanged(float visibility) { - QuickstepLauncher launcher = getCreatedContainer(); + Launcher launcher = getCreatedActivity(); if (launcher == null) { return; } @@ -144,7 +145,7 @@ public final class LauncherActivityInterface extends @Override public void setOnDeferredActivityLaunchCallback(Runnable r) { - QuickstepLauncher launcher = getCreatedContainer(); + Launcher launcher = getCreatedActivity(); if (launcher == null) { return; } @@ -153,14 +154,14 @@ public final class LauncherActivityInterface extends @Nullable @Override - public QuickstepLauncher getCreatedContainer() { + public QuickstepLauncher getCreatedActivity() { return QuickstepLauncher.ACTIVITY_TRACKER.getCreatedActivity(); } @Nullable @Override public DepthController getDepthController() { - QuickstepLauncher launcher = getCreatedContainer(); + QuickstepLauncher launcher = getCreatedActivity(); if (launcher == null) { return null; } @@ -170,7 +171,7 @@ public final class LauncherActivityInterface extends @Nullable @Override public DesktopVisibilityController getDesktopVisibilityController() { - QuickstepLauncher launcher = getCreatedContainer(); + QuickstepLauncher launcher = getCreatedActivity(); if (launcher == null) { return null; } @@ -180,7 +181,7 @@ public final class LauncherActivityInterface extends @Nullable @Override public LauncherTaskbarUIController getTaskbarController() { - QuickstepLauncher launcher = getCreatedContainer(); + QuickstepLauncher launcher = getCreatedActivity(); if (launcher == null) { return null; } @@ -190,7 +191,7 @@ public final class LauncherActivityInterface extends @Nullable @Override public RecentsView getVisibleRecentsView() { - QuickstepLauncher launcher = getVisibleLauncher(); + Launcher launcher = getVisibleLauncher(); RecentsView recentsView = launcher != null && launcher.getStateManager().getState().overviewUi ? launcher.getOverviewPanel() : null; @@ -204,8 +205,8 @@ public final class LauncherActivityInterface extends @Nullable @UiThread - private QuickstepLauncher getVisibleLauncher() { - QuickstepLauncher launcher = getCreatedContainer(); + private Launcher getVisibleLauncher() { + Launcher launcher = getCreatedActivity(); if (launcher == null) { return null; } @@ -221,7 +222,7 @@ public final class LauncherActivityInterface extends @Override public boolean switchToRecentsIfVisible(Animator.AnimatorListener animatorListener) { - QuickstepLauncher launcher = getVisibleLauncher(); + Launcher launcher = getVisibleLauncher(); if (launcher == null) { return false; } @@ -242,7 +243,7 @@ public final class LauncherActivityInterface extends @Override public void onExitOverview(RotationTouchHelper deviceState, Runnable exitRunnable) { - final StateManager stateManager = getCreatedContainer().getStateManager(); + final StateManager stateManager = getCreatedActivity().getStateManager(); stateManager.addStateListener( new StateManager.StateListener() { @Override @@ -259,7 +260,7 @@ public final class LauncherActivityInterface extends private void notifyRecentsOfOrientation(RotationTouchHelper rotationTouchHelper) { // reset layout on swipe to home - RecentsView recentsView = getCreatedContainer().getOverviewPanel(); + RecentsView recentsView = getCreatedActivity().getOverviewPanel(); recentsView.setLayoutRotation(rotationTouchHelper.getCurrentActiveRotation(), rotationTouchHelper.getDisplayRotation()); } @@ -278,12 +279,12 @@ public final class LauncherActivityInterface extends public boolean allowAllAppsFromOverview() { return FeatureFlags.ENABLE_ALL_APPS_FROM_OVERVIEW.get() // If floating search bar would not show in overview, don't allow all apps gesture. - && OVERVIEW.areElementsVisible(getCreatedContainer(), FLOATING_SEARCH_BAR); + && OVERVIEW.areElementsVisible(getCreatedActivity(), FLOATING_SEARCH_BAR); } @Override public boolean isInLiveTileMode() { - QuickstepLauncher launcher = getCreatedContainer(); + Launcher launcher = getCreatedActivity(); return launcher != null && launcher.getStateManager().getState() == OVERVIEW @@ -293,7 +294,7 @@ public final class LauncherActivityInterface extends @Override public void onLaunchTaskFailed() { - QuickstepLauncher launcher = getCreatedContainer(); + Launcher launcher = getCreatedActivity(); if (launcher == null) { return; } @@ -303,7 +304,7 @@ public final class LauncherActivityInterface extends @Override public void closeOverlay() { super.closeOverlay(); - QuickstepLauncher launcher = getCreatedContainer(); + Launcher launcher = getCreatedActivity(); if (launcher == null) { return; } @@ -336,8 +337,9 @@ public final class LauncherActivityInterface extends } @Override - protected int getOverviewScrimColorForState(QuickstepLauncher activity, LauncherState state) { - return state.getWorkspaceScrimColor(activity); + protected int getOverviewScrimColorForState(QuickstepLauncher launcher, + LauncherState state) { + return state.getWorkspaceScrimColor(launcher); } @Override diff --git a/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java b/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java index 6647057776..f678bea778 100644 --- a/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java +++ b/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java @@ -75,7 +75,7 @@ public class LauncherSwipeHandlerV2 extends protected HomeAnimationFactory createHomeAnimationFactory(ArrayList launchCookies, long duration, boolean isTargetTranslucent, boolean appCanEnterPip, RemoteAnimationTarget runningTaskTarget) { - if (mContainer == null) { + if (mActivity == null) { mStateCallback.addChangeListener(STATE_LAUNCHER_PRESENT | STATE_HANDLER_INVALIDATED, isPresent -> mRecentsView.startHome()); return new HomeAnimationFactory() { @@ -91,9 +91,9 @@ public class LauncherSwipeHandlerV2 extends boolean canUseWorkspaceView = workspaceView != null && workspaceView.isAttachedToWindow() && workspaceView.getHeight() > 0; - mContainer.getRootView().setForceHideBackArrow(true); + mActivity.getRootView().setForceHideBackArrow(true); if (!TaskAnimationManager.ENABLE_SHELL_TRANSITIONS) { - mContainer.setHintUserWillBeActive(); + mActivity.setHintUserWillBeActive(); } if (!canUseWorkspaceView || appCanEnterPip || mIsSwipeForSplit) { @@ -108,10 +108,10 @@ public class LauncherSwipeHandlerV2 extends private HomeAnimationFactory createIconHomeAnimationFactory(View workspaceView) { RectF iconLocation = new RectF(); - FloatingIconView floatingIconView = getFloatingIconView(mContainer, workspaceView, null, - mContainer.getTaskbarUIController() == null + FloatingIconView floatingIconView = getFloatingIconView(mActivity, workspaceView, null, + mActivity.getTaskbarUIController() == null ? null - : mContainer.getTaskbarUIController().findMatchingView(workspaceView), + : mActivity.getTaskbarUIController().findMatchingView(workspaceView), true /* hideOriginal */, iconLocation, false /* isOpening */); // We want the window alpha to be 0 once this threshold is met, so that the @@ -171,7 +171,7 @@ public class LauncherSwipeHandlerV2 extends Size windowSize = new Size(crop.width(), crop.height()); int fallbackBackgroundColor = FloatingWidgetView.getDefaultBackgroundColor(mContext, runningTaskTarget); - FloatingWidgetView floatingWidgetView = FloatingWidgetView.getFloatingWidgetView(mContainer, + FloatingWidgetView floatingWidgetView = FloatingWidgetView.getFloatingWidgetView(mActivity, hostView, backgroundLocation, windowSize, tvs.getCurrentCornerRadius(), isTargetTranslucent, fallbackBackgroundColor); @@ -248,7 +248,7 @@ public class LauncherSwipeHandlerV2 extends } } - return mContainer.getFirstMatchForAppClose(launchCookieItemId, + return mActivity.getFirstMatchForAppClose(launchCookieItemId, runningTaskView.getTask().key.getComponent().getPackageName(), UserHandle.of(runningTaskView.getTask().key.userId), false /* supportsAllAppsState */); @@ -292,18 +292,18 @@ public class LauncherSwipeHandlerV2 extends // Return an empty APC here since we have an non-user controlled animation // to home. long accuracy = 2 * Math.max(mDp.widthPx, mDp.heightPx); - return mContainer.getStateManager().createAnimationToNewWorkspace( + return mActivity.getStateManager().createAnimationToNewWorkspace( NORMAL, accuracy, StateAnimationConfig.SKIP_ALL_ANIMATIONS); } @Override public void playAtomicAnimation(float velocity) { if (enableScalingRevealHomeAnimation()) { - if (mContainer != null) { - new ScalingWorkspaceRevealAnim(mContainer).start(); + if (mActivity != null) { + new ScalingWorkspaceRevealAnim(mActivity).start(); } } else { - new StaggeredWorkspaceAnim(mContainer, velocity, true /* animateOverviewScrim */, + new StaggeredWorkspaceAnim(mActivity, velocity, true /* animateOverviewScrim */, getViewIgnoredInWorkspaceRevealAnimation()) .start(); } diff --git a/quickstep/src/com/android/quickstep/OverviewCommandHelper.java b/quickstep/src/com/android/quickstep/OverviewCommandHelper.java index 68923eeccb..0db50bfe2d 100644 --- a/quickstep/src/com/android/quickstep/OverviewCommandHelper.java +++ b/quickstep/src/com/android/quickstep/OverviewCommandHelper.java @@ -40,7 +40,6 @@ import com.android.launcher3.util.RunnableList; import com.android.quickstep.RecentsAnimationCallbacks.RecentsAnimationListener; import com.android.quickstep.util.ActiveGestureLog; import com.android.quickstep.views.RecentsView; -import com.android.quickstep.views.RecentsViewContainer; import com.android.quickstep.views.TaskView; import com.android.systemui.shared.recents.model.ThumbnailData; import com.android.systemui.shared.system.InteractionJankMonitorWrapper; @@ -192,8 +191,7 @@ public class OverviewCommandHelper { * Executes the task and returns true if next task can be executed. If false, then the next * task is deferred until {@link #scheduleNextTask} is called */ - private & RecentsViewContainer> boolean executeCommand( - CommandInfo cmd) { + private > boolean executeCommand(CommandInfo cmd) { if (mWaitForToggleCommandComplete && cmd.type == TYPE_TOGGLE) { return true; } @@ -202,7 +200,7 @@ public class OverviewCommandHelper { RecentsView visibleRecentsView = activityInterface.getVisibleRecentsView(); RecentsView createdRecentsView; if (visibleRecentsView == null) { - T activity = activityInterface.getCreatedContainer(); + T activity = activityInterface.getCreatedActivity(); createdRecentsView = activity == null ? null : activity.getOverviewPanel(); DeviceProfile dp = activity == null ? null : activity.getDeviceProfile(); TaskbarUIController uiController = activityInterface.getTaskbarController(); @@ -298,7 +296,7 @@ public class OverviewCommandHelper { return false; } - final T activity = activityInterface.getCreatedContainer(); + final T activity = activityInterface.getCreatedActivity(); if (activity != null) { InteractionJankMonitorWrapper.begin( activity.getRootView(), @@ -329,7 +327,7 @@ public class OverviewCommandHelper { interactionHandler.onGestureCancelled(); cmd.removeListener(this); - T createdActivity = activityInterface.getCreatedContainer(); + T createdActivity = activityInterface.getCreatedActivity(); if (createdActivity == null) { return; } diff --git a/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java b/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java index dfbae657dd..c3a4351d7b 100644 --- a/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java +++ b/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java @@ -208,7 +208,7 @@ public class QuickstepTestInformationHandler extends TestInformationHandler { RecentsAnimationDeviceState rads = new RecentsAnimationDeviceState(mContext); OverviewComponentObserver observer = new OverviewComponentObserver(mContext, rads); try { - return observer.getActivityInterface().getCreatedContainer(); + return observer.getActivityInterface().getCreatedActivity(); } finally { observer.onDestroy(); rads.destroy(); diff --git a/quickstep/src/com/android/quickstep/RecentsActivity.java b/quickstep/src/com/android/quickstep/RecentsActivity.java index f57f4c8440..81ab6bedcc 100644 --- a/quickstep/src/com/android/quickstep/RecentsActivity.java +++ b/quickstep/src/com/android/quickstep/RecentsActivity.java @@ -33,7 +33,6 @@ import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorSet; import android.app.ActivityOptions; -import android.content.Context; import android.content.Intent; import android.content.res.Configuration; import android.os.Bundle; @@ -86,7 +85,6 @@ import com.android.quickstep.util.SplitSelectStateController; import com.android.quickstep.util.TISBindHelper; import com.android.quickstep.views.OverviewActionsView; import com.android.quickstep.views.RecentsView; -import com.android.quickstep.views.RecentsViewContainer; import com.android.quickstep.views.TaskView; import java.io.FileDescriptor; @@ -97,8 +95,7 @@ import java.util.List; * A recents activity that shows the recently launched tasks as swipable task cards. * See {@link com.android.quickstep.views.RecentsView}. */ -public final class RecentsActivity extends StatefulActivity implements - RecentsViewContainer { +public final class RecentsActivity extends StatefulActivity { private static final String TAG = "RecentsActivity"; public static final ActivityTracker ACTIVITY_TRACKER = @@ -112,7 +109,7 @@ public final class RecentsActivity extends StatefulActivity implem private RecentsDragLayer mDragLayer; private ScrimView mScrimView; private FallbackRecentsView mFallbackRecentsView; - private OverviewActionsView mActionsView; + private OverviewActionsView mActionsView; private TISBindHelper mTISBindHelper; private @Nullable FallbackTaskbarUIController mTaskbarUIController; @@ -227,12 +224,11 @@ public final class RecentsActivity extends StatefulActivity implem } @Override - public FallbackRecentsView getOverviewPanel() { - return mFallbackRecentsView; + public T getOverviewPanel() { + return (T) mFallbackRecentsView; } - @Override - public OverviewActionsView getActionsView() { + public OverviewActionsView getActionsView() { return mActionsView; } diff --git a/quickstep/src/com/android/quickstep/RemoteTargetGluer.java b/quickstep/src/com/android/quickstep/RemoteTargetGluer.java index 7f2adedbca..856e8af27e 100644 --- a/quickstep/src/com/android/quickstep/RemoteTargetGluer.java +++ b/quickstep/src/com/android/quickstep/RemoteTargetGluer.java @@ -57,7 +57,7 @@ public class RemoteTargetGluer { /** * Use this constructor if remote targets are split-screen independent */ - public RemoteTargetGluer(Context context, BaseContainerInterface sizingStrategy, + public RemoteTargetGluer(Context context, BaseActivityInterface sizingStrategy, RemoteAnimationTargets targets, boolean forDesktop) { init(context, sizingStrategy, targets.apps.length, forDesktop); } @@ -66,7 +66,7 @@ public class RemoteTargetGluer { * Use this constructor if you want the number of handles created to match the number of active * running tasks */ - public RemoteTargetGluer(Context context, BaseContainerInterface sizingStrategy) { + public RemoteTargetGluer(Context context, BaseActivityInterface sizingStrategy) { DesktopVisibilityController desktopVisibilityController = LauncherActivityInterface.INSTANCE.getDesktopVisibilityController(); if (desktopVisibilityController != null) { @@ -84,13 +84,13 @@ public class RemoteTargetGluer { init(context, sizingStrategy, DEFAULT_NUM_HANDLES, false /* forDesktop */); } - private void init(Context context, BaseContainerInterface sizingStrategy, int numHandles, + private void init(Context context, BaseActivityInterface sizingStrategy, int numHandles, boolean forDesktop) { mRemoteTargetHandles = createHandles(context, sizingStrategy, numHandles, forDesktop); } private RemoteTargetHandle[] createHandles(Context context, - BaseContainerInterface sizingStrategy, int numHandles, boolean forDesktop) { + BaseActivityInterface sizingStrategy, int numHandles, boolean forDesktop) { RemoteTargetHandle[] handles = new RemoteTargetHandle[numHandles]; for (int i = 0; i < numHandles; i++) { TaskViewSimulator tvs = new TaskViewSimulator(context, sizingStrategy); diff --git a/quickstep/src/com/android/quickstep/RotationTouchHelper.java b/quickstep/src/com/android/quickstep/RotationTouchHelper.java index bf50d7022d..2d47097671 100644 --- a/quickstep/src/com/android/quickstep/RotationTouchHelper.java +++ b/quickstep/src/com/android/quickstep/RotationTouchHelper.java @@ -345,14 +345,14 @@ public class RotationTouchHelper implements DisplayInfoChangeListener { } void onEndTargetCalculated(GestureState.GestureEndTarget endTarget, - BaseContainerInterface containerInterface) { + BaseActivityInterface activityInterface) { if (endTarget == GestureState.GestureEndTarget.RECENTS) { mInOverview = true; if (!mTaskListFrozen) { // If we're in landscape w/o ever quickswitching, show the navbar in landscape enableMultipleRegions(true); } - containerInterface.onExitOverview(this, mExitOverviewRunnable); + activityInterface.onExitOverview(this, mExitOverviewRunnable); } else if (endTarget == GestureState.GestureEndTarget.HOME || endTarget == GestureState.GestureEndTarget.ALL_APPS) { enableMultipleRegions(false); diff --git a/quickstep/src/com/android/quickstep/SwipeUpAnimationLogic.java b/quickstep/src/com/android/quickstep/SwipeUpAnimationLogic.java index 5ff978746c..b920c10d05 100644 --- a/quickstep/src/com/android/quickstep/SwipeUpAnimationLogic.java +++ b/quickstep/src/com/android/quickstep/SwipeUpAnimationLogic.java @@ -86,7 +86,7 @@ public abstract class SwipeUpAnimationLogic implements updateIsGestureForSplit(TopTaskTracker.INSTANCE.get(context) .getRunningSplitTaskIds().length); - mTargetGluer = new RemoteTargetGluer(mContext, mGestureState.getContainerInterface()); + mTargetGluer = new RemoteTargetGluer(mContext, mGestureState.getActivityInterface()); mRemoteTargetHandles = mTargetGluer.getRemoteTargetHandles(); runActionOnRemoteHandles(remoteTargetHandle -> remoteTargetHandle.getTaskViewSimulator().getOrientationState().update( @@ -97,10 +97,9 @@ public abstract class SwipeUpAnimationLogic implements protected void initTransitionEndpoints(DeviceProfile dp) { mDp = dp; - mTransitionDragLength = mGestureState.getContainerInterface() - .getSwipeUpDestinationAndLength(dp, mContext, TEMP_RECT, - mRemoteTargetHandles[0].getTaskViewSimulator().getOrientationState() - .getOrientationHandler()); + mTransitionDragLength = mGestureState.getActivityInterface().getSwipeUpDestinationAndLength( + dp, mContext, TEMP_RECT, mRemoteTargetHandles[0].getTaskViewSimulator() + .getOrientationState().getOrientationHandler()); mDragLengthFactor = (float) dp.heightPx / mTransitionDragLength; for (RemoteTargetHandle remoteHandle : mRemoteTargetHandles) { diff --git a/quickstep/src/com/android/quickstep/TaskAnimationManager.java b/quickstep/src/com/android/quickstep/TaskAnimationManager.java index 3b1ed4662a..4e62d60d2c 100644 --- a/quickstep/src/com/android/quickstep/TaskAnimationManager.java +++ b/quickstep/src/com/android/quickstep/TaskAnimationManager.java @@ -77,11 +77,10 @@ public class TaskAnimationManager implements RecentsAnimationCallbacks.RecentsAn mLiveTileRestartListener); return; } - BaseContainerInterface containerInterface = mLastGestureState.getContainerInterface(); - if (containerInterface.isInLiveTileMode() - && containerInterface.getCreatedContainer() != null) { - RecentsView recentsView = containerInterface.getCreatedContainer() - .getOverviewPanel(); + BaseActivityInterface activityInterface = mLastGestureState.getActivityInterface(); + if (activityInterface.isInLiveTileMode() + && activityInterface.getCreatedActivity() != null) { + RecentsView recentsView = activityInterface.getCreatedActivity().getOverviewPanel(); if (recentsView != null) { recentsView.launchSideTaskInLiveTileModeForRestartedApp(task.taskId); TaskStackChangeListeners.getInstance().unregisterTaskStackListener( @@ -136,10 +135,10 @@ public class TaskAnimationManager implements RecentsAnimationCallbacks.RecentsAn cleanUpRecentsAnimation(mCallbacks); } - final BaseContainerInterface containerInterface = gestureState.getContainerInterface(); + final BaseActivityInterface activityInterface = gestureState.getActivityInterface(); mLastGestureState = gestureState; RecentsAnimationCallbacks newCallbacks = new RecentsAnimationCallbacks( - SystemUiProxy.INSTANCE.get(mCtx), containerInterface.allowMinimizeSplitScreen()); + SystemUiProxy.INSTANCE.get(mCtx), activityInterface.allowMinimizeSplitScreen()); mCallbacks = newCallbacks; mCallbacks.addListener(new RecentsAnimationCallbacks.RecentsAnimationListener() { @Override @@ -209,18 +208,17 @@ public class TaskAnimationManager implements RecentsAnimationCallbacks.RecentsAn @Override public void onTasksAppeared(RemoteAnimationTarget[] appearedTaskTargets) { RemoteAnimationTarget appearedTaskTarget = appearedTaskTargets[0]; - BaseContainerInterface containerInterface = - mLastGestureState.getContainerInterface(); + BaseActivityInterface activityInterface = mLastGestureState.getActivityInterface(); for (RemoteAnimationTarget compat : appearedTaskTargets) { if (compat.windowConfiguration.getActivityType() == ACTIVITY_TYPE_HOME - && containerInterface.getCreatedContainer() instanceof RecentsActivity + && activityInterface.getCreatedActivity() instanceof RecentsActivity && DisplayController.getNavigationMode(mCtx) != NO_BUTTON) { // The only time we get onTasksAppeared() in button navigation with a // 3p launcher is if the user goes to overview first, and in this case we // can immediately finish the transition RecentsView recentsView = - containerInterface.getCreatedContainer().getOverviewPanel(); + activityInterface.getCreatedActivity().getOverviewPanel(); if (recentsView != null) { recentsView.finishRecentsAnimation(true, null); } @@ -234,12 +232,12 @@ public class TaskAnimationManager implements RecentsAnimationCallbacks.RecentsAn if (nonAppTargets == null) { nonAppTargets = new RemoteAnimationTarget[0]; } - if ((containerInterface.isInLiveTileMode() + if ((activityInterface.isInLiveTileMode() || mLastGestureState.getEndTarget() == RECENTS || isNonRecentsStartedTasksAppeared(appearedTaskTargets)) - && containerInterface.getCreatedContainer() != null) { + && activityInterface.getCreatedActivity() != null) { RecentsView recentsView = - containerInterface.getCreatedContainer().getOverviewPanel(); + activityInterface.getCreatedActivity().getOverviewPanel(); if (recentsView != null) { ActiveGestureLog.INSTANCE.addLog( new ActiveGestureLog.CompoundString("Launching side task id=") @@ -274,13 +272,13 @@ public class TaskAnimationManager implements RecentsAnimationCallbacks.RecentsAn @Override public boolean onSwitchToScreenshot(Runnable onFinished) { - if (!containerInterface.isInLiveTileMode() - || containerInterface.getCreatedContainer() == null) { + if (!activityInterface.isInLiveTileMode() + || activityInterface.getCreatedActivity() == null) { // No need to switch since tile is already a screenshot. onFinished.run(); } else { final RecentsView recentsView = - containerInterface.getCreatedContainer().getOverviewPanel(); + activityInterface.getCreatedActivity().getOverviewPanel(); if (recentsView != null) { recentsView.switchToScreenshot(onFinished); } else { @@ -297,7 +295,7 @@ public class TaskAnimationManager implements RecentsAnimationCallbacks.RecentsAn if (ENABLE_SHELL_TRANSITIONS) { final ActivityOptions options = ActivityOptions.makeBasic(); // Use regular (non-transient) launch for all apps page to control IME. - if (!containerInterface.allowAllAppsFromOverview()) { + if (!activityInterface.allowAllAppsFromOverview()) { options.setTransientLaunch(); } options.setSourceInfo(ActivityOptions.SourceInfo.TYPE_RECENTS_ANIMATION, eventTime); @@ -334,10 +332,10 @@ public class TaskAnimationManager implements RecentsAnimationCallbacks.RecentsAn if (mLastGestureState == null) { return; } - BaseContainerInterface containerInterface = mLastGestureState.getContainerInterface(); - if (containerInterface.isInLiveTileMode() - && containerInterface.getCreatedContainer() != null) { - RecentsView recentsView = containerInterface.getCreatedContainer().getOverviewPanel(); + BaseActivityInterface activityInterface = mLastGestureState.getActivityInterface(); + if (activityInterface.isInLiveTileMode() + && activityInterface.getCreatedActivity() != null) { + RecentsView recentsView = activityInterface.getCreatedActivity().getOverviewPanel(); if (recentsView != null) { recentsView.switchToScreenshot(null, () -> recentsView.finishRecentsAnimation(true /* toRecents */, diff --git a/quickstep/src/com/android/quickstep/TaskOverlayFactory.java b/quickstep/src/com/android/quickstep/TaskOverlayFactory.java index 18b8e3e0f5..64c4ff45ad 100644 --- a/quickstep/src/com/android/quickstep/TaskOverlayFactory.java +++ b/quickstep/src/com/android/quickstep/TaskOverlayFactory.java @@ -33,6 +33,7 @@ import androidx.annotation.NonNull; import androidx.annotation.RequiresApi; import com.android.launcher3.BaseActivity; +import com.android.launcher3.BaseDraggingActivity; import com.android.launcher3.Flags; import com.android.launcher3.R; import com.android.launcher3.model.data.ItemInfo; @@ -45,7 +46,6 @@ import com.android.quickstep.util.RecentsOrientedState; import com.android.quickstep.views.GroupedTaskView; import com.android.quickstep.views.OverviewActionsView; import com.android.quickstep.views.RecentsView; -import com.android.quickstep.views.RecentsViewContainer; import com.android.quickstep.views.TaskThumbnailView; import com.android.quickstep.views.TaskView; import com.android.quickstep.views.TaskView.TaskIdAttributeContainer; @@ -63,15 +63,14 @@ public class TaskOverlayFactory implements ResourceBasedOverride { public static List getEnabledShortcuts(TaskView taskView, TaskIdAttributeContainer taskContainer) { final ArrayList shortcuts = new ArrayList<>(); - final RecentsViewContainer container = - RecentsViewContainer.containerFromContext(taskView.getContext()); + final BaseDraggingActivity activity = BaseActivity.fromContext(taskView.getContext()); boolean hasMultipleTasks = taskView.getTaskIds()[1] != -1; for (TaskShortcutFactory menuOption : MENU_OPTIONS) { if (hasMultipleTasks && !menuOption.showForSplitscreen()) { continue; } - List menuShortcuts = menuOption.getShortcuts(container, taskContainer); + List menuShortcuts = menuOption.getShortcuts(activity, taskContainer); if (menuShortcuts == null) { continue; } @@ -80,7 +79,7 @@ public class TaskOverlayFactory implements ResourceBasedOverride { RecentsOrientedState orientedState = taskView.getRecentsView().getPagedViewOrientedState(); boolean canLauncherRotate = orientedState.isRecentsActivityRotationAllowed(); boolean isInLandscape = orientedState.getTouchRotation() != ROTATION_0; - boolean isTablet = container.getDeviceProfile().isTablet; + boolean isTablet = activity.getDeviceProfile().isTablet; boolean isGridOnlyOverview = isTablet && Flags.enableGridOnlyOverview(); // Add overview actions to the menu when: @@ -89,7 +88,7 @@ public class TaskOverlayFactory implements ResourceBasedOverride { if (!hasMultipleTasks && ((!canLauncherRotate && isInLandscape) || isGridOnlyOverview)) { // Add screenshot action to task menu. List screenshotShortcuts = TaskShortcutFactory.SCREENSHOT - .getShortcuts(container, taskContainer); + .getShortcuts(activity, taskContainer); if (screenshotShortcuts != null) { shortcuts.addAll(screenshotShortcuts); } @@ -98,7 +97,7 @@ public class TaskOverlayFactory implements ResourceBasedOverride { // or in grid-only overview. if (orientedState.getDisplayRotation() == ROTATION_0 || isGridOnlyOverview) { List modalShortcuts = TaskShortcutFactory.MODAL - .getShortcuts(container, taskContainer); + .getShortcuts(activity, taskContainer); if (modalShortcuts != null) { shortcuts.addAll(modalShortcuts); } @@ -256,9 +255,9 @@ public class TaskOverlayFactory implements ResourceBasedOverride { /** * Gets the system shortcut for the screenshot that will be added to the task menu. */ - public SystemShortcut getScreenshotShortcut(RecentsViewContainer container, + public SystemShortcut getScreenshotShortcut(BaseDraggingActivity activity, ItemInfo iteminfo, View originalView) { - return new ScreenshotSystemShortcut(container, iteminfo, originalView); + return new ScreenshotSystemShortcut(activity, iteminfo, originalView); } /** @@ -306,13 +305,13 @@ public class TaskOverlayFactory implements ResourceBasedOverride { private class ScreenshotSystemShortcut extends SystemShortcut { - private final RecentsViewContainer mContainer; + private final BaseDraggingActivity mActivity; - ScreenshotSystemShortcut(RecentsViewContainer container, ItemInfo itemInfo, + ScreenshotSystemShortcut(BaseDraggingActivity activity, ItemInfo itemInfo, View originalView) { - super(R.drawable.ic_screenshot, R.string.action_screenshot, container, itemInfo, + super(R.drawable.ic_screenshot, R.string.action_screenshot, activity, itemInfo, originalView); - mContainer = container; + mActivity = activity; } @Override diff --git a/quickstep/src/com/android/quickstep/TaskShortcutFactory.java b/quickstep/src/com/android/quickstep/TaskShortcutFactory.java index 9d10ac146c..5e970f1bd7 100644 --- a/quickstep/src/com/android/quickstep/TaskShortcutFactory.java +++ b/quickstep/src/com/android/quickstep/TaskShortcutFactory.java @@ -22,6 +22,7 @@ import static android.content.Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_SYSTEM_SHORTCUT_FREE_FORM_TAP; import static com.android.window.flags.Flags.enableDesktopWindowingMode; +import android.app.Activity; import android.app.ActivityOptions; import android.graphics.Bitmap; import android.graphics.Color; @@ -38,6 +39,7 @@ import android.window.SplashScreen; import androidx.annotation.Nullable; +import com.android.launcher3.BaseDraggingActivity; import com.android.launcher3.DeviceProfile; import com.android.launcher3.R; import com.android.launcher3.config.FeatureFlags; @@ -48,11 +50,9 @@ import com.android.launcher3.popup.SystemShortcut; import com.android.launcher3.popup.SystemShortcut.AppInfo; import com.android.launcher3.util.InstantAppResolver; import com.android.launcher3.util.SplitConfigurationOptions.SplitPositionOption; -import com.android.launcher3.views.ActivityContext; import com.android.quickstep.orientation.RecentsPagedOrientationHandler; import com.android.quickstep.views.GroupedTaskView; import com.android.quickstep.views.RecentsView; -import com.android.quickstep.views.RecentsViewContainer; import com.android.quickstep.views.TaskThumbnailView; import com.android.quickstep.views.TaskView; import com.android.quickstep.views.TaskView.TaskIdAttributeContainer; @@ -74,7 +74,7 @@ import java.util.stream.Collectors; */ public interface TaskShortcutFactory { @Nullable - default List getShortcuts(RecentsViewContainer container, + default List getShortcuts(BaseDraggingActivity activity, TaskIdAttributeContainer taskContainer) { return null; } @@ -94,7 +94,7 @@ public interface TaskShortcutFactory { TaskShortcutFactory APP_INFO = new TaskShortcutFactory() { @Override - public List getShortcuts(RecentsViewContainer container, + public List getShortcuts(BaseDraggingActivity activity, TaskIdAttributeContainer taskContainer) { TaskView taskView = taskContainer.getTaskView(); AppInfo.SplitAccessibilityInfo accessibilityInfo = @@ -102,7 +102,7 @@ public interface TaskShortcutFactory { TaskUtils.getTitle(taskView.getContext(), taskContainer.getTask()), taskContainer.getA11yNodeId() ); - return Collections.singletonList(new AppInfo(container, taskContainer.getItemInfo(), + return Collections.singletonList(new AppInfo(activity, taskContainer.getItemInfo(), taskView, accessibilityInfo)); } @@ -116,9 +116,9 @@ public interface TaskShortcutFactory { private final TaskView mTaskView; private final SplitPositionOption mSplitPositionOption; - public SplitSelectSystemShortcut(RecentsViewContainer container, TaskView taskView, + public SplitSelectSystemShortcut(BaseDraggingActivity target, TaskView taskView, SplitPositionOption option) { - super(option.iconResId, option.textResId, container, taskView.getItemInfo(), taskView); + super(option.iconResId, option.textResId, target, taskView.getItemInfo(), taskView); mTaskView = taskView; mSplitPositionOption = option; } @@ -133,13 +133,12 @@ public interface TaskShortcutFactory { * A menu item, "Save app pair", that allows the user to preserve the current app combination as * one persistent icon on the Home screen, allowing for quick split screen launching. */ - class SaveAppPairSystemShortcut extends SystemShortcut { + class SaveAppPairSystemShortcut extends SystemShortcut { private final GroupedTaskView mTaskView; - - public SaveAppPairSystemShortcut(RecentsViewContainer container, GroupedTaskView taskView, - int iconResId) { - super(iconResId, R.string.save_app_pair, container, + public SaveAppPairSystemShortcut(BaseDraggingActivity activity, GroupedTaskView taskView, + int iconResId) { + super(iconResId, R.string.save_app_pair, activity, taskView.getItemInfo(), taskView); mTaskView = taskView; } @@ -152,7 +151,7 @@ public interface TaskShortcutFactory { } } - class FreeformSystemShortcut extends SystemShortcut { + class FreeformSystemShortcut extends SystemShortcut { private static final String TAG = "FreeformSystemShortcut"; private Handler mHandler; @@ -162,14 +161,14 @@ public interface TaskShortcutFactory { private final TaskView mTaskView; private final LauncherEvent mLauncherEvent; - public FreeformSystemShortcut(int iconRes, int textRes, RecentsViewContainer container, + public FreeformSystemShortcut(int iconRes, int textRes, BaseDraggingActivity activity, TaskIdAttributeContainer taskContainer, LauncherEvent launcherEvent) { - super(iconRes, textRes, container, taskContainer.getItemInfo(), + super(iconRes, textRes, activity, taskContainer.getItemInfo(), taskContainer.getTaskView()); mLauncherEvent = launcherEvent; mHandler = new Handler(Looper.getMainLooper()); mTaskView = taskContainer.getTaskView(); - mRecentsView = container.getOverviewPanel(); + mRecentsView = activity.getOverviewPanel(); mThumbnailView = taskContainer.getThumbnailView(); } @@ -253,11 +252,11 @@ public interface TaskShortcutFactory { } } - private ActivityOptions makeLaunchOptions(RecentsViewContainer container) { + private ActivityOptions makeLaunchOptions(Activity activity) { ActivityOptions activityOptions = ActivityOptions.makeBasic(); activityOptions.setLaunchWindowingMode(WINDOWING_MODE_FREEFORM); // Arbitrary bounds only because freeform is in dev mode right now - final View decorView = container.getWindow().getDecorView(); + final View decorView = activity.getWindow().getDecorView(); final WindowInsets insets = decorView.getRootWindowInsets(); final Rect r = new Rect(0, 0, decorView.getWidth() / 2, decorView.getHeight() / 2); r.offsetTo(insets.getSystemWindowInsetLeft() + 50, @@ -278,9 +277,9 @@ public interface TaskShortcutFactory { */ TaskShortcutFactory SPLIT_SELECT = new TaskShortcutFactory() { @Override - public List getShortcuts(RecentsViewContainer container, + public List getShortcuts(BaseDraggingActivity activity, TaskIdAttributeContainer taskContainer) { - DeviceProfile deviceProfile = container.getDeviceProfile(); + DeviceProfile deviceProfile = activity.getDeviceProfile(); final Task task = taskContainer.getTask(); final int intentFlags = task.key.baseIntent.getFlags(); final TaskView taskView = taskContainer.getTaskView(); @@ -292,7 +291,7 @@ public interface TaskShortcutFactory { !deviceProfile.isTaskbarPresent && recentsView.getTaskViewCount() < 2; boolean isTaskSplitNotSupported = !task.isDockable || (intentFlags & FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS) != 0; - boolean hideForExistingMultiWindow = container.getDeviceProfile().isMultiWindowMode; + boolean hideForExistingMultiWindow = activity.getDeviceProfile().isMultiWindowMode; boolean isFocusedTask = deviceProfile.isTablet && taskView.isFocusedTask(); boolean isTaskInExpectedScrollPosition = recentsView.isTaskInExpectedScrollPosition(recentsView.indexOfChild(taskView)); @@ -305,7 +304,7 @@ public interface TaskShortcutFactory { return orientationHandler.getSplitPositionOptions(deviceProfile) .stream() .map((Function) option -> - new SplitSelectSystemShortcut(container, taskView, option)) + new SplitSelectSystemShortcut(activity, taskView, option)) .collect(Collectors.toList()); } }; @@ -313,9 +312,9 @@ public interface TaskShortcutFactory { TaskShortcutFactory SAVE_APP_PAIR = new TaskShortcutFactory() { @Nullable @Override - public List getShortcuts(RecentsViewContainer container, + public List getShortcuts(BaseDraggingActivity activity, TaskIdAttributeContainer taskContainer) { - DeviceProfile deviceProfile = container.getDeviceProfile(); + DeviceProfile deviceProfile = activity.getDeviceProfile(); final TaskView taskView = taskContainer.getTaskView(); final RecentsView recentsView = taskView.getRecentsView(); boolean isLargeTileFocusedTask = deviceProfile.isTablet && taskView.isFocusedTask(); @@ -349,8 +348,7 @@ public interface TaskShortcutFactory { : R.drawable.ic_save_app_pair_up_down; return Collections.singletonList( - new SaveAppPairSystemShortcut(container, - (GroupedTaskView) taskView, iconResId)); + new SaveAppPairSystemShortcut(activity, (GroupedTaskView) taskView, iconResId)); } @Override @@ -361,25 +359,25 @@ public interface TaskShortcutFactory { TaskShortcutFactory FREE_FORM = new TaskShortcutFactory() { @Override - public List getShortcuts(RecentsViewContainer container, + public List getShortcuts(BaseDraggingActivity activity, TaskIdAttributeContainer taskContainer) { final Task task = taskContainer.getTask(); if (!task.isDockable) { return null; } - if (!isAvailable(container)) { + if (!isAvailable(activity, task.key.displayId)) { return null; } return Collections.singletonList(new FreeformSystemShortcut( R.drawable.ic_caption_desktop_button_foreground, - R.string.recent_task_option_freeform, container, taskContainer, + R.string.recent_task_option_freeform, activity, taskContainer, LAUNCHER_SYSTEM_SHORTCUT_FREE_FORM_TAP)); } - private boolean isAvailable(RecentsViewContainer container) { + private boolean isAvailable(BaseDraggingActivity activity, int displayId) { return Settings.Global.getInt( - container.asContext().getContentResolver(), + activity.getContentResolver(), Settings.Global.DEVELOPMENT_ENABLE_FREEFORM_WINDOWS_SUPPORT, 0) != 0 && !enableDesktopWindowingMode(); } @@ -387,9 +385,9 @@ public interface TaskShortcutFactory { TaskShortcutFactory PIN = new TaskShortcutFactory() { @Override - public List getShortcuts(RecentsViewContainer container, + public List getShortcuts(BaseDraggingActivity activity, TaskIdAttributeContainer taskContainer) { - if (!SystemUiProxy.INSTANCE.get(container.asContext()).isActive()) { + if (!SystemUiProxy.INSTANCE.get(activity).isActive()) { return null; } if (!ActivityManagerWrapper.getInstance().isScreenPinningEnabled()) { @@ -399,17 +397,17 @@ public interface TaskShortcutFactory { // We shouldn't be able to pin while an app is locked. return null; } - return Collections.singletonList(new PinSystemShortcut(container, taskContainer)); + return Collections.singletonList(new PinSystemShortcut(activity, taskContainer)); } }; - class PinSystemShortcut extends SystemShortcut { + class PinSystemShortcut extends SystemShortcut { private static final String TAG = "PinSystemShortcut"; private final TaskView mTaskView; - public PinSystemShortcut(RecentsViewContainer target, + public PinSystemShortcut(BaseDraggingActivity target, TaskIdAttributeContainer taskContainer) { super(R.drawable.ic_pin, R.string.recent_task_option_pin, target, taskContainer.getItemInfo(), taskContainer.getTaskView()); @@ -419,7 +417,7 @@ public interface TaskShortcutFactory { @Override public void onClick(View view) { if (mTaskView.launchTaskAnimated() != null) { - SystemUiProxy.INSTANCE.get(mTarget.asContext()).startScreenPinning( + SystemUiProxy.INSTANCE.get(mTarget).startScreenPinning( mTaskView.getTask().key.id); } dismissTaskMenuView(); @@ -430,12 +428,12 @@ public interface TaskShortcutFactory { TaskShortcutFactory INSTALL = new TaskShortcutFactory() { @Override - public List getShortcuts(RecentsViewContainer container, + public List getShortcuts(BaseDraggingActivity activity, TaskIdAttributeContainer taskContainer) { Task t = taskContainer.getTask(); - return InstantAppResolver.newInstance(container.asContext()).isInstantApp( + return InstantAppResolver.newInstance(activity).isInstantApp( t.getTopComponent().getPackageName(), t.getKey().userId) - ? Collections.singletonList(new SystemShortcut.Install(container, + ? Collections.singletonList(new SystemShortcut.Install(activity, taskContainer.getItemInfo(), taskContainer.getTaskView())) : null; } @@ -443,10 +441,10 @@ public interface TaskShortcutFactory { TaskShortcutFactory WELLBEING = new TaskShortcutFactory() { @Override - public List getShortcuts(RecentsViewContainer container, + public List getShortcuts(BaseDraggingActivity activity, TaskIdAttributeContainer taskContainer) { - SystemShortcut wellbeingShortcut = - WellbeingModel.SHORTCUT_FACTORY.getShortcut(container, + SystemShortcut wellbeingShortcut = + WellbeingModel.SHORTCUT_FACTORY.getShortcut(activity, taskContainer.getItemInfo(), taskContainer.getTaskView()); return createSingletonShortcutList(wellbeingShortcut); } @@ -454,11 +452,11 @@ public interface TaskShortcutFactory { TaskShortcutFactory SCREENSHOT = new TaskShortcutFactory() { @Override - public List getShortcuts(RecentsViewContainer container, + public List getShortcuts(BaseDraggingActivity activity, TaskIdAttributeContainer taskContainer) { SystemShortcut screenshotShortcut = taskContainer.getThumbnailView().getTaskOverlay() - .getScreenshotShortcut(container, taskContainer.getItemInfo(), + .getScreenshotShortcut(activity, taskContainer.getItemInfo(), taskContainer.getTaskView()); return createSingletonShortcutList(screenshotShortcut); } @@ -466,7 +464,7 @@ public interface TaskShortcutFactory { TaskShortcutFactory MODAL = new TaskShortcutFactory() { @Override - public List getShortcuts(RecentsViewContainer container, + public List getShortcuts(BaseDraggingActivity activity, TaskIdAttributeContainer taskContainer) { SystemShortcut modalStateSystemShortcut = taskContainer.getThumbnailView().getTaskOverlay() diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java index 5564b1873d..8f1bf3478f 100644 --- a/quickstep/src/com/android/quickstep/TouchInteractionService.java +++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java @@ -120,7 +120,6 @@ import com.android.quickstep.util.ActiveGestureLog; import com.android.quickstep.util.ActiveGestureLog.CompoundString; import com.android.quickstep.util.AssistStateManager; import com.android.quickstep.util.AssistUtils; -import com.android.quickstep.views.RecentsViewContainer; import com.android.systemui.shared.recents.IOverviewProxy; import com.android.systemui.shared.recents.ISystemUiProxy; import com.android.systemui.shared.system.ActivityManagerWrapper; @@ -318,7 +317,7 @@ public class TouchInteractionService extends Service { public void enterStageSplitFromRunningApp(boolean leftOrTop) { executeForTouchInteractionService(tis -> { StatefulActivity activity = - tis.mOverviewComponentObserver.getActivityInterface().getCreatedContainer(); + tis.mOverviewComponentObserver.getActivityInterface().getCreatedActivity(); if (activity != null) { activity.enterStageSplitFromRunningApp(leftOrTop); } @@ -595,7 +594,7 @@ public class TouchInteractionService extends Service { mAllAppsActionManager.setHomeAndOverviewSame(isHomeAndOverviewSame); StatefulActivity newOverviewActivity = mOverviewComponentObserver.getActivityInterface() - .getCreatedContainer(); + .getCreatedActivity(); if (newOverviewActivity != null) { mTaskbarManager.setActivity(newOverviewActivity); } @@ -829,8 +828,8 @@ public class TouchInteractionService extends Service { } } - boolean cancelGesture = mGestureState.getContainerInterface() != null - && mGestureState.getContainerInterface().shouldCancelCurrentGesture(); + boolean cancelGesture = mGestureState.getActivityInterface() != null + && mGestureState.getActivityInterface().shouldCancelCurrentGesture(); boolean cleanUpConsumer = (action == ACTION_UP || action == ACTION_CANCEL || cancelGesture) && mConsumer != null && !mConsumer.getActiveConsumerInHierarchy().isConsumerDetachedFromGesture(); @@ -1147,7 +1146,7 @@ public class TouchInteractionService extends Service { TopTaskTracker.CachedTaskInfo runningTask = gestureState.getRunningTask(); // Use overview input consumer for sharesheets on top of home. - boolean forceOverviewInputConsumer = gestureState.getContainerInterface().isStarted() + boolean forceOverviewInputConsumer = gestureState.getActivityInterface().isStarted() && runningTask != null && runningTask.isRootChooseActivity(); @@ -1171,7 +1170,7 @@ public class TouchInteractionService extends Service { // with shell-transitions, home is resumed during recents animation, so // explicitly check against recents animation too. boolean launcherResumedThroughShellTransition = - gestureState.getContainerInterface().isResumed() + gestureState.getActivityInterface().isResumed() && !previousGestureState.isRecentsAnimationRunning(); // If a task fragment within Launcher is resumed boolean launcherChildActivityResumed = useActivityOverlay() @@ -1181,7 +1180,7 @@ public class TouchInteractionService extends Service { && !launcherResumedThroughShellTransition && !previousGestureState.isRecentsAnimationRunning(); - if (gestureState.getContainerInterface().isInLiveTileMode()) { + if (gestureState.getActivityInterface().isInLiveTileMode()) { return createOverviewInputConsumer( previousGestureState, gestureState, @@ -1229,7 +1228,7 @@ public class TouchInteractionService extends Service { final AbsSwipeUpHandler.Factory factory = getSwipeUpHandlerFactory(); final boolean shouldDefer = !mOverviewComponentObserver.isHomeAndOverviewSame() - || gestureState.getContainerInterface().deferStartingActivity(mDeviceState, event); + || gestureState.getActivityInterface().deferStartingActivity(mDeviceState, event); final boolean disableHorizontalSwipe = mDeviceState.isInExclusionRegion(event); return new OtherActivityInputConsumer(this, mDeviceState, mTaskAnimationManager, gestureState, shouldDefer, this::onConsumerInactive, @@ -1263,19 +1262,18 @@ public class TouchInteractionService extends Service { MotionEvent event, boolean forceOverviewInputConsumer, CompoundString reasonString) { - RecentsViewContainer container = gestureState.getContainerInterface().getCreatedContainer(); - if (container == null) { + StatefulActivity activity = gestureState.getActivityInterface().getCreatedActivity(); + if (activity == null) { return getDefaultInputConsumer( reasonString.append(SUBSTRING_PREFIX) .append("activity == null, trying to use default input consumer")); } - boolean hasWindowFocus = container.getRootView().hasWindowFocus(); + boolean hasWindowFocus = activity.getRootView().hasWindowFocus(); boolean isPreviousGestureAnimatingToLauncher = previousGestureState.isRunningAnimationToLauncher() || mDeviceState.isPredictiveBackToHomeInProgress(); - boolean isInLiveTileMode = gestureState.getContainerInterface().isInLiveTileMode(); - + boolean isInLiveTileMode = gestureState.getActivityInterface().isInLiveTileMode(); reasonString.append(SUBSTRING_PREFIX) .append(hasWindowFocus ? "activity has window focus" @@ -1289,14 +1287,14 @@ public class TouchInteractionService extends Service { || isInLiveTileMode) { reasonString.append(SUBSTRING_PREFIX) .append("overview should have focus, using OverviewInputConsumer"); - return new OverviewInputConsumer(gestureState, container, mInputMonitorCompat, + return new OverviewInputConsumer(gestureState, activity, mInputMonitorCompat, false /* startingInActivityBounds */); } else { reasonString.append(SUBSTRING_PREFIX).append( "overview shouldn't have focus, using OverviewWithoutFocusInputConsumer"); final boolean disableHorizontalSwipe = mDeviceState.isInExclusionRegion(event); - return new OverviewWithoutFocusInputConsumer(container.asContext(), mDeviceState, - gestureState, mInputMonitorCompat, disableHorizontalSwipe); + return new OverviewWithoutFocusInputConsumer(activity, mDeviceState, gestureState, + mInputMonitorCompat, disableHorizontalSwipe); } } @@ -1369,7 +1367,7 @@ public class TouchInteractionService extends Service { mOverviewComponentObserver.getActivityInterface(); final Intent overviewIntent = new Intent( mOverviewComponentObserver.getOverviewIntentIgnoreSysUiState()); - if (activityInterface.getCreatedContainer() != null && fromInit) { + if (activityInterface.getCreatedActivity() != null && fromInit) { // The activity has been created before the initialization of overview service. It is // usually happens when booting or launcher is the top activity, so we should already // have the latest state. @@ -1391,7 +1389,7 @@ public class TouchInteractionService extends Service { } final BaseActivityInterface activityInterface = mOverviewComponentObserver.getActivityInterface(); - final BaseDraggingActivity activity = activityInterface.getCreatedContainer(); + final BaseDraggingActivity activity = activityInterface.getCreatedActivity(); if (activity == null || activity.isStarted()) { // We only care about the existing background activity. return; @@ -1441,7 +1439,7 @@ public class TouchInteractionService extends Service { DisplayController.INSTANCE.get(this).dump(pw); pw.println("TouchState:"); BaseDraggingActivity createdOverviewActivity = mOverviewComponentObserver == null ? null - : mOverviewComponentObserver.getActivityInterface().getCreatedContainer(); + : mOverviewComponentObserver.getActivityInterface().getCreatedActivity(); boolean resumed = mOverviewComponentObserver != null && mOverviewComponentObserver.getActivityInterface().isResumed(); pw.println(" createdOverviewActivity=" + createdOverviewActivity); diff --git a/quickstep/src/com/android/quickstep/fallback/FallbackNavBarTouchController.java b/quickstep/src/com/android/quickstep/fallback/FallbackNavBarTouchController.java index ec531d8028..69de3b0f98 100644 --- a/quickstep/src/com/android/quickstep/fallback/FallbackNavBarTouchController.java +++ b/quickstep/src/com/android/quickstep/fallback/FallbackNavBarTouchController.java @@ -24,9 +24,9 @@ import com.android.launcher3.Utilities; import com.android.launcher3.util.DisplayController; import com.android.launcher3.util.NavigationMode; import com.android.launcher3.util.TouchController; +import com.android.quickstep.RecentsActivity; import com.android.quickstep.util.NavBarPosition; import com.android.quickstep.util.TriggerSwipeUpTouchTracker; -import com.android.quickstep.views.RecentsViewContainer; /** * In 0-button mode, intercepts swipe up from the nav bar on FallbackRecentsView to go home. @@ -34,18 +34,17 @@ import com.android.quickstep.views.RecentsViewContainer; public class FallbackNavBarTouchController implements TouchController, TriggerSwipeUpTouchTracker.OnSwipeUpListener { - private final RecentsViewContainer mContainer; + private final RecentsActivity mActivity; @Nullable private final TriggerSwipeUpTouchTracker mTriggerSwipeUpTracker; - public FallbackNavBarTouchController(RecentsViewContainer container) { - mContainer = container; - NavigationMode sysUINavigationMode = - DisplayController.getNavigationMode(mContainer.asContext()); + public FallbackNavBarTouchController(RecentsActivity activity) { + mActivity = activity; + NavigationMode sysUINavigationMode = DisplayController.getNavigationMode(mActivity); if (sysUINavigationMode == NavigationMode.NO_BUTTON) { NavBarPosition navBarPosition = new NavBarPosition(sysUINavigationMode, - DisplayController.INSTANCE.get(mContainer.asContext()).getInfo()); - mTriggerSwipeUpTracker = new TriggerSwipeUpTouchTracker(mContainer.asContext(), + DisplayController.INSTANCE.get(mActivity).getInfo()); + mTriggerSwipeUpTracker = new TriggerSwipeUpTouchTracker(mActivity, true /* disableHorizontalSwipe */, navBarPosition, this); } else { mTriggerSwipeUpTracker = null; @@ -76,6 +75,6 @@ public class FallbackNavBarTouchController implements TouchController, @Override public void onSwipeUp(boolean wasFling, PointF finalVelocity) { - mContainer.getOverviewPanel().startHome(); + mActivity.getOverviewPanel().startHome(); } } diff --git a/quickstep/src/com/android/quickstep/fallback/FallbackRecentsStateController.java b/quickstep/src/com/android/quickstep/fallback/FallbackRecentsStateController.java index 2e76356b5d..69eaf6afd8 100644 --- a/quickstep/src/com/android/quickstep/fallback/FallbackRecentsStateController.java +++ b/quickstep/src/com/android/quickstep/fallback/FallbackRecentsStateController.java @@ -49,9 +49,7 @@ import com.android.launcher3.states.StateAnimationConfig; import com.android.launcher3.util.MultiPropertyFactory; import com.android.quickstep.RecentsActivity; import com.android.quickstep.views.ClearAllButton; -import com.android.quickstep.views.OverviewActionsView; import com.android.quickstep.views.RecentsView; -import com.android.quickstep.views.RecentsViewContainer; /** * State controller for fallback recents activity diff --git a/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java b/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java index d881a1f735..32d8be988c 100644 --- a/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java +++ b/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java @@ -36,7 +36,6 @@ import com.android.launcher3.anim.PendingAnimation; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.desktop.DesktopRecentsTransitionController; import com.android.launcher3.logging.StatsLogManager; -import com.android.launcher3.statemanager.StateManager; import com.android.launcher3.statemanager.StateManager.StateListener; import com.android.launcher3.util.SplitConfigurationOptions; import com.android.launcher3.util.SplitConfigurationOptions.SplitSelectSource; @@ -68,7 +67,7 @@ public class FallbackRecentsView extends RecentsView getStateManager() { - return mContainer.getStateManager(); + return mActivity.canStartHomeSafely(); } /** @@ -216,10 +210,10 @@ public class FallbackRecentsView extends RecentsView { /** * For this state, what color scrim should be drawn behind overview. */ - public int getScrimColor(Context context) { - return hasFlag(FLAG_SCRIM) - ? Themes.getAttrColor(context, R.attr.overviewScrimColor) + public int getScrimColor(RecentsActivity activity) { + return hasFlag(FLAG_SCRIM) ? Themes.getAttrColor(activity, R.attr.overviewScrimColor) : Color.TRANSPARENT; } - public float[] getOverviewScaleAndOffset(RecentsViewContainer container) { + public float[] getOverviewScaleAndOffset(RecentsActivity activity) { return new float[] { NO_SCALE, NO_OFFSET }; } @@ -163,8 +161,8 @@ public class RecentsState implements BaseState { } @Override - public float[] getOverviewScaleAndOffset(RecentsViewContainer container) { - return getOverviewScaleAndOffsetForModalState(container.getOverviewPanel()); + public float[] getOverviewScaleAndOffset(RecentsActivity activity) { + return getOverviewScaleAndOffsetForModalState(activity); } } @@ -174,8 +172,8 @@ public class RecentsState implements BaseState { } @Override - public float[] getOverviewScaleAndOffset(RecentsViewContainer container) { - return getOverviewScaleAndOffsetForBackgroundState(container.getOverviewPanel()); + public float[] getOverviewScaleAndOffset(RecentsActivity activity) { + return getOverviewScaleAndOffsetForBackgroundState(activity); } } @@ -185,7 +183,7 @@ public class RecentsState implements BaseState { } @Override - public float[] getOverviewScaleAndOffset(RecentsViewContainer container) { + public float[] getOverviewScaleAndOffset(RecentsActivity activity) { return new float[] { NO_SCALE, 1 }; } } diff --git a/quickstep/src/com/android/quickstep/fallback/RecentsTaskController.java b/quickstep/src/com/android/quickstep/fallback/RecentsTaskController.java index 2cb398cfff..db4927a0d1 100644 --- a/quickstep/src/com/android/quickstep/fallback/RecentsTaskController.java +++ b/quickstep/src/com/android/quickstep/fallback/RecentsTaskController.java @@ -26,7 +26,7 @@ public class RecentsTaskController extends TaskViewTouchController mOnCompleteCallback; @@ -132,6 +135,7 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC mTaskAnimationManager = taskAnimationManager; mGestureState = gestureState; mHandlerFactory = handlerFactory; + mActivityInterface = mGestureState.getActivityInterface(); mMotionPauseDetector = new MotionPauseDetector(base, false, mNavBarPosition.isLeftEdge() || mNavBarPosition.isRightEdge() diff --git a/quickstep/src/com/android/quickstep/inputconsumers/OverviewInputConsumer.java b/quickstep/src/com/android/quickstep/inputconsumers/OverviewInputConsumer.java index bb8d1d7d33..7d3a860b23 100644 --- a/quickstep/src/com/android/quickstep/inputconsumers/OverviewInputConsumer.java +++ b/quickstep/src/com/android/quickstep/inputconsumers/OverviewInputConsumer.java @@ -28,24 +28,24 @@ import androidx.annotation.Nullable; import com.android.launcher3.Utilities; import com.android.launcher3.statemanager.BaseState; +import com.android.launcher3.statemanager.StatefulActivity; import com.android.launcher3.testing.TestLogging; import com.android.launcher3.testing.shared.TestProtocol; import com.android.launcher3.views.BaseDragLayer; -import com.android.quickstep.BaseContainerInterface; +import com.android.quickstep.BaseActivityInterface; import com.android.quickstep.GestureState; import com.android.quickstep.InputConsumer; import com.android.quickstep.TaskUtils; -import com.android.quickstep.views.RecentsViewContainer; import com.android.systemui.shared.system.InputMonitorCompat; /** * Input consumer for handling touch on the recents/Launcher activity. */ -public class OverviewInputConsumer, T extends RecentsViewContainer> +public class OverviewInputConsumer, T extends StatefulActivity> implements InputConsumer { - private final T mContainer; - private final BaseContainerInterface mContainerInterface; + private final T mActivity; + private final BaseActivityInterface mActivityInterface; private final BaseDragLayer mTarget; private final InputMonitorCompat mInputMonitor; @@ -56,14 +56,14 @@ public class OverviewInputConsumer, T extends RecentsView private boolean mHasSetTouchModeForFirstDPadEvent; private boolean mIsWaitingForAttachToWindow; - public OverviewInputConsumer(GestureState gestureState, T container, + public OverviewInputConsumer(GestureState gestureState, T activity, @Nullable InputMonitorCompat inputMonitor, boolean startingInActivityBounds) { - mContainer = container; + mActivity = activity; mInputMonitor = inputMonitor; mStartingInActivityBounds = startingInActivityBounds; - mContainerInterface = gestureState.getContainerInterface(); + mActivityInterface = gestureState.getActivityInterface(); - mTarget = container.getDragLayer(); + mTarget = activity.getDragLayer(); mTarget.getLocationOnScreen(mLocationOnScreen); } @@ -91,7 +91,7 @@ public class OverviewInputConsumer, T extends RecentsView if (!mTargetHandledTouch && handled) { mTargetHandledTouch = true; if (!mStartingInActivityBounds) { - mContainerInterface.closeOverlay(); + mActivityInterface.closeOverlay(); TaskUtils.closeSystemWindowsAsync(CLOSE_SYSTEM_WINDOWS_REASON_RECENTS); } if (mInputMonitor != null) { @@ -100,13 +100,13 @@ public class OverviewInputConsumer, T extends RecentsView } } if (mHasSetTouchModeForFirstDPadEvent) { - mContainer.getRootView().clearFocus(); + mActivity.getRootView().clearFocus(); } } @Override public void onHoverEvent(MotionEvent ev) { - mContainer.dispatchGenericMotionEvent(ev); + mActivity.dispatchGenericMotionEvent(ev); } @Override @@ -115,8 +115,7 @@ public class OverviewInputConsumer, T extends RecentsView case KeyEvent.KEYCODE_VOLUME_DOWN: case KeyEvent.KEYCODE_VOLUME_UP: case KeyEvent.KEYCODE_VOLUME_MUTE: - MediaSessionManager mgr = mContainer.asContext() - .getSystemService(MediaSessionManager.class); + MediaSessionManager mgr = mActivity.getSystemService(MediaSessionManager.class); mgr.dispatchVolumeKeyEventAsSystemService(ev, AudioManager.USE_DEFAULT_STREAM_TYPE); break; @@ -125,7 +124,7 @@ public class OverviewInputConsumer, T extends RecentsView if (mHasSetTouchModeForFirstDPadEvent) { break; } - View viewRoot = mContainer.getRootView(); + View viewRoot = mActivity.getRootView(); if (viewRoot.isAttachedToWindow()) { setTouchModeChanged(viewRoot); break; @@ -151,7 +150,7 @@ public class OverviewInputConsumer, T extends RecentsView default: break; } - mContainer.dispatchKeyEvent(ev); + mActivity.dispatchKeyEvent(ev); } private void setTouchModeChanged(@NonNull View viewRoot) { diff --git a/quickstep/src/com/android/quickstep/inputconsumers/ScreenPinnedInputConsumer.java b/quickstep/src/com/android/quickstep/inputconsumers/ScreenPinnedInputConsumer.java index d73c23ff51..a8bf333567 100644 --- a/quickstep/src/com/android/quickstep/inputconsumers/ScreenPinnedInputConsumer.java +++ b/quickstep/src/com/android/quickstep/inputconsumers/ScreenPinnedInputConsumer.java @@ -19,12 +19,12 @@ import android.content.Context; import android.view.HapticFeedbackConstants; import android.view.MotionEvent; +import com.android.launcher3.BaseDraggingActivity; import com.android.launcher3.R; import com.android.quickstep.GestureState; import com.android.quickstep.InputConsumer; import com.android.quickstep.SystemUiProxy; import com.android.quickstep.util.MotionPauseDetector; -import com.android.quickstep.views.RecentsViewContainer; /** * An input consumer that detects swipe up and hold to exit screen pinning mode. @@ -44,10 +44,10 @@ public class ScreenPinnedInputConsumer implements InputConsumer { mMotionPauseDetector = new MotionPauseDetector(context, true /* makePauseHarderToTrigger*/); mMotionPauseDetector.setOnMotionPauseListener(() -> { SystemUiProxy.INSTANCE.get(context).stopScreenPinning(); - RecentsViewContainer container = gestureState.getContainerInterface() - .getCreatedContainer(); - if (container != null) { - container.getRootView().performHapticFeedback( + BaseDraggingActivity launcherActivity = gestureState.getActivityInterface() + .getCreatedActivity(); + if (launcherActivity != null) { + launcherActivity.getRootView().performHapticFeedback( HapticFeedbackConstants.LONG_PRESS, HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING); } diff --git a/quickstep/src/com/android/quickstep/util/AnimatorControllerWithResistance.java b/quickstep/src/com/android/quickstep/util/AnimatorControllerWithResistance.java index c9647f596e..561e951362 100644 --- a/quickstep/src/com/android/quickstep/util/AnimatorControllerWithResistance.java +++ b/quickstep/src/com/android/quickstep/util/AnimatorControllerWithResistance.java @@ -39,12 +39,12 @@ import com.android.launcher3.Utilities; import com.android.launcher3.anim.AnimatorPlaybackController; import com.android.launcher3.anim.PendingAnimation; import com.android.launcher3.statemanager.StateManager; +import com.android.launcher3.statemanager.StatefulActivity; import com.android.launcher3.states.StateAnimationConfig; import com.android.launcher3.touch.AllAppsSwipeController; import com.android.quickstep.DeviceConfigWrapper; import com.android.quickstep.orientation.RecentsPagedOrientationHandler; import com.android.quickstep.views.RecentsView; -import com.android.quickstep.views.RecentsViewContainer; /** * Controls an animation that can go beyond progress = 1, at which point resistance should be @@ -158,12 +158,11 @@ public class AnimatorControllerWithResistance { PendingAnimation resistAnim = createRecentsResistanceAnim(params); // Apply All Apps animation during the resistance animation. - if (recentsOrientedState.getContainerInterface().allowAllAppsFromOverview()) { - RecentsViewContainer container = - recentsOrientedState.getContainerInterface().getCreatedContainer(); - if (container != null) { - RecentsView recentsView = container.getOverviewPanel(); - StateManager stateManager = recentsView.getStateManager(); + if (recentsOrientedState.getActivityInterface().allowAllAppsFromOverview()) { + StatefulActivity activity = + recentsOrientedState.getActivityInterface().getCreatedActivity(); + if (activity != null) { + StateManager stateManager = activity.getStateManager(); if (stateManager.isInStableState(LauncherState.BACKGROUND_APP) && stateManager.isInTransition()) { @@ -186,7 +185,7 @@ public class AnimatorControllerWithResistance { private static float getAllAppsThreshold(Context context, RecentsOrientedState recentsOrientedState, DeviceProfile dp) { int transitionDragLength = - recentsOrientedState.getContainerInterface().getSwipeUpDestinationAndLength( + recentsOrientedState.getActivityInterface().getSwipeUpDestinationAndLength( dp, context, TEMP_RECT, recentsOrientedState.getOrientationHandler()); float dragLengthFactor = (float) dp.heightPx / transitionDragLength; @@ -204,7 +203,7 @@ public class AnimatorControllerWithResistance { Rect startRect = new Rect(); RecentsPagedOrientationHandler orientationHandler = params.recentsOrientedState .getOrientationHandler(); - params.recentsOrientedState.getContainerInterface() + params.recentsOrientedState.getActivityInterface() .calculateTaskSize(params.context, params.dp, startRect, orientationHandler); long distanceToCover = startRect.bottom; PendingAnimation resistAnim = params.resistAnim != null @@ -304,14 +303,14 @@ public class AnimatorControllerWithResistance { this.translationProperty = translationProperty; if (dp.isTablet) { resistanceParams = - recentsOrientedState.getContainerInterface().allowAllAppsFromOverview() + recentsOrientedState.getActivityInterface().allowAllAppsFromOverview() ? RecentsResistanceParams.FROM_APP_TO_ALL_APPS_TABLET : enableGridOnlyOverview() ? RecentsResistanceParams.FROM_APP_TABLET_GRID_ONLY : RecentsResistanceParams.FROM_APP_TABLET; } else { resistanceParams = - recentsOrientedState.getContainerInterface().allowAllAppsFromOverview() + recentsOrientedState.getActivityInterface().allowAllAppsFromOverview() ? RecentsResistanceParams.FROM_APP_TO_ALL_APPS : RecentsResistanceParams.FROM_APP; } diff --git a/quickstep/src/com/android/quickstep/util/AppPairsController.java b/quickstep/src/com/android/quickstep/util/AppPairsController.java index 3f0657123f..3ed3e40ca7 100644 --- a/quickstep/src/com/android/quickstep/util/AppPairsController.java +++ b/quickstep/src/com/android/quickstep/util/AppPairsController.java @@ -42,6 +42,7 @@ import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; import com.android.internal.jank.Cuj; +import com.android.launcher3.Launcher; import com.android.launcher3.LauncherAppState; import com.android.launcher3.LauncherSettings; import com.android.launcher3.accessibility.LauncherAccessibilityDelegate; @@ -55,10 +56,8 @@ import com.android.launcher3.model.data.AppPairInfo; import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.model.data.WorkspaceItemInfo; import com.android.launcher3.taskbar.TaskbarActivityContext; -import com.android.launcher3.uioverrides.QuickstepLauncher; import com.android.launcher3.util.ComponentKey; import com.android.launcher3.util.SplitConfigurationOptions.StagePosition; -import com.android.launcher3.views.ActivityContext; import com.android.quickstep.SystemUiProxy; import com.android.quickstep.TopTaskTracker; import com.android.quickstep.views.GroupedTaskView; @@ -160,7 +159,7 @@ public class AppPairsController { }); MAIN_EXECUTOR.execute(() -> { LauncherAccessibilityDelegate delegate = - QuickstepLauncher.getLauncher(mContext).getAccessibilityDelegate(); + Launcher.getLauncher(mContext).getAccessibilityDelegate(); if (delegate != null) { delegate.addToWorkspace(newAppPair, true, (success) -> { if (success) { @@ -239,8 +238,7 @@ public class AppPairsController { return null; } - AllAppsStore appsStore = ActivityContext.lookupContext(mContext) - .getAppsView().getAppsStore(); + AllAppsStore appsStore = Launcher.getLauncher(mContext).getAppsView().getAppsStore(); // Lookup by ComponentKey AppInfo appInfo = appsStore.getApp(key); diff --git a/quickstep/src/com/android/quickstep/util/InputProxyHandlerFactory.java b/quickstep/src/com/android/quickstep/util/InputProxyHandlerFactory.java index 843619de78..8209c09304 100644 --- a/quickstep/src/com/android/quickstep/util/InputProxyHandlerFactory.java +++ b/quickstep/src/com/android/quickstep/util/InputProxyHandlerFactory.java @@ -17,11 +17,11 @@ package com.android.quickstep.util; import androidx.annotation.UiThread; -import com.android.quickstep.BaseContainerInterface; +import com.android.launcher3.statemanager.StatefulActivity; +import com.android.quickstep.BaseActivityInterface; import com.android.quickstep.GestureState; import com.android.quickstep.InputConsumer; import com.android.quickstep.inputconsumers.OverviewInputConsumer; -import com.android.quickstep.views.RecentsViewContainer; import java.util.function.Supplier; @@ -31,13 +31,13 @@ import java.util.function.Supplier; */ public class InputProxyHandlerFactory implements Supplier { - private final BaseContainerInterface mContainerInterface; + private final BaseActivityInterface mActivityInterface; private final GestureState mGestureState; @UiThread - public InputProxyHandlerFactory(BaseContainerInterface activityInterface, + public InputProxyHandlerFactory(BaseActivityInterface activityInterface, GestureState gestureState) { - mContainerInterface = activityInterface; + mActivityInterface = activityInterface; mGestureState = gestureState; } @@ -46,8 +46,8 @@ public class InputProxyHandlerFactory implements Supplier { */ @Override public InputConsumer get() { - RecentsViewContainer container = mContainerInterface.getCreatedContainer(); - return container == null ? InputConsumer.NO_OP - : new OverviewInputConsumer(mGestureState, container, null, true); + StatefulActivity activity = mActivityInterface.getCreatedActivity(); + return activity == null ? InputConsumer.NO_OP + : new OverviewInputConsumer(mGestureState, activity, null, true); } } diff --git a/quickstep/src/com/android/quickstep/util/LauncherUnfoldAnimationController.java b/quickstep/src/com/android/quickstep/util/LauncherUnfoldAnimationController.java index 4474f3355c..61ba5ace65 100644 --- a/quickstep/src/com/android/quickstep/util/LauncherUnfoldAnimationController.java +++ b/quickstep/src/com/android/quickstep/util/LauncherUnfoldAnimationController.java @@ -30,9 +30,9 @@ import androidx.core.view.OneShotPreDrawListener; import com.android.launcher3.DeviceProfile; import com.android.launcher3.DeviceProfile.OnDeviceProfileChangeListener; import com.android.launcher3.Hotseat; +import com.android.launcher3.Launcher; import com.android.launcher3.Workspace; import com.android.launcher3.config.FeatureFlags; -import com.android.launcher3.uioverrides.QuickstepLauncher; import com.android.launcher3.util.HorizontalInsettableView; import com.android.quickstep.SystemUiProxy; import com.android.quickstep.util.unfold.LauncherJankMonitorTransitionProgressListener; @@ -56,7 +56,7 @@ public class LauncherUnfoldAnimationController implements OnDeviceProfileChangeL private static final FloatProperty HOTSEAT_SCALE_PROPERTY = HOTSEAT_SCALE_PROPERTY_FACTORY.get(SCALE_INDEX_UNFOLD_ANIMATION); - private final QuickstepLauncher mLauncher; + private final Launcher mLauncher; private final ScopedUnfoldTransitionProgressProvider mProgressProvider; private final NaturalRotationUnfoldProgressProvider mNaturalOrientationProgressProvider; private final UnfoldMoveFromCenterHotseatAnimator mUnfoldMoveFromCenterHotseatAnimator; @@ -73,7 +73,7 @@ public class LauncherUnfoldAnimationController implements OnDeviceProfileChangeL private HorizontalInsettableView mQsbInsettable; public LauncherUnfoldAnimationController( - QuickstepLauncher launcher, + Launcher launcher, WindowManager windowManager, UnfoldTransitionProgressProvider unfoldTransitionProgressProvider, RotationChangeProvider rotationChangeProvider) { diff --git a/quickstep/src/com/android/quickstep/util/RecentsAtomicAnimationFactory.java b/quickstep/src/com/android/quickstep/util/RecentsAtomicAnimationFactory.java index 0b05c2e7c1..1d008da5b3 100644 --- a/quickstep/src/com/android/quickstep/util/RecentsAtomicAnimationFactory.java +++ b/quickstep/src/com/android/quickstep/util/RecentsAtomicAnimationFactory.java @@ -19,40 +19,39 @@ import static com.android.quickstep.views.RecentsView.ADJACENT_PAGE_HORIZONTAL_O import android.animation.Animator; import android.animation.ObjectAnimator; -import android.content.Context; import androidx.dynamicanimation.animation.DynamicAnimation; import com.android.launcher3.anim.SpringAnimationBuilder; import com.android.launcher3.statemanager.StateManager.AtomicAnimationFactory; +import com.android.launcher3.statemanager.StatefulActivity; import com.android.quickstep.views.RecentsView; -import com.android.quickstep.views.RecentsViewContainer; -public class RecentsAtomicAnimationFactory extends AtomicAnimationFactory { +public class RecentsAtomicAnimationFactory + extends AtomicAnimationFactory { public static final int INDEX_RECENTS_FADE_ANIM = AtomicAnimationFactory.NEXT_INDEX + 0; public static final int INDEX_RECENTS_TRANSLATE_X_ANIM = AtomicAnimationFactory.NEXT_INDEX + 1; private static final int MY_ANIM_COUNT = 2; - protected final CONTAINER mContainer; + protected final ACTIVITY_TYPE mActivity; - public RecentsAtomicAnimationFactory(CONTAINER container) { + public RecentsAtomicAnimationFactory(ACTIVITY_TYPE activity) { super(MY_ANIM_COUNT); - mContainer = container; + mActivity = activity; } @Override public Animator createStateElementAnimation(int index, float... values) { switch (index) { case INDEX_RECENTS_FADE_ANIM: - ObjectAnimator alpha = ObjectAnimator.ofFloat(mContainer.getOverviewPanel(), + ObjectAnimator alpha = ObjectAnimator.ofFloat(mActivity.getOverviewPanel(), RecentsView.CONTENT_ALPHA, values); return alpha; case INDEX_RECENTS_TRANSLATE_X_ANIM: { - RecentsView rv = mContainer.getOverviewPanel(); - return new SpringAnimationBuilder(mContainer) + RecentsView rv = mActivity.getOverviewPanel(); + return new SpringAnimationBuilder(mActivity) .setMinimumVisibleChange(DynamicAnimation.MIN_VISIBLE_CHANGE_SCALE) .setDampingRatio(0.8f) .setStiffness(250) diff --git a/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java b/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java index 9335e7e475..cba628b817 100644 --- a/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java +++ b/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java @@ -50,7 +50,7 @@ import com.android.launcher3.testing.shared.TestProtocol; import com.android.launcher3.touch.PagedOrientationHandler; import com.android.launcher3.util.DisplayController; import com.android.launcher3.util.SettingsCache; -import com.android.quickstep.BaseContainerInterface; +import com.android.quickstep.BaseActivityInterface; import com.android.quickstep.SystemUiProxy; import com.android.quickstep.TaskAnimationManager; import com.android.quickstep.orientation.RecentsPagedOrientationHandler; @@ -118,7 +118,7 @@ public class RecentsOrientedState implements | FLAG_SWIPE_UP_NOT_RUNNING; private final Context mContext; - private final BaseContainerInterface mContainerInterface; + private final BaseActivityInterface mActivityInterface; private final OrientationEventListener mOrientationListener; private final SettingsCache mSettingsCache; private final SettingsCache.OnChangeListener mRotationChangeListener = @@ -138,10 +138,10 @@ public class RecentsOrientedState implements * is enabled * @see #setRotationWatcherEnabled(boolean) */ - public RecentsOrientedState(Context context, BaseContainerInterface containerInterface, + public RecentsOrientedState(Context context, BaseActivityInterface activityInterface, IntConsumer rotationChangeListener) { mContext = context; - mContainerInterface = containerInterface; + mActivityInterface = activityInterface; mOrientationListener = new OrientationEventListener(context) { @Override public void onOrientationChanged(int degrees) { @@ -153,7 +153,7 @@ public class RecentsOrientedState implements } }; - mFlags = mContainerInterface.rotationSupportedByActivity + mFlags = mActivityInterface.rotationSupportedByActivity ? FLAG_MULTIPLE_ORIENTATION_SUPPORTED_BY_ACTIVITY : 0; mFlags |= FLAG_SWIPE_UP_NOT_RUNNING; @@ -161,8 +161,8 @@ public class RecentsOrientedState implements initFlags(); } - public BaseContainerInterface getContainerInterface() { - return mContainerInterface; + public BaseActivityInterface getActivityInterface() { + return mActivityInterface; } /** diff --git a/quickstep/src/com/android/quickstep/util/ScalingWorkspaceRevealAnim.kt b/quickstep/src/com/android/quickstep/util/ScalingWorkspaceRevealAnim.kt index 48c2407e33..33736adc82 100644 --- a/quickstep/src/com/android/quickstep/util/ScalingWorkspaceRevealAnim.kt +++ b/quickstep/src/com/android/quickstep/util/ScalingWorkspaceRevealAnim.kt @@ -20,6 +20,7 @@ import android.view.View import com.android.app.animation.Interpolators import com.android.app.animation.Interpolators.EMPHASIZED import com.android.app.animation.Interpolators.LINEAR +import com.android.launcher3.Launcher import com.android.launcher3.LauncherAnimUtils.HOTSEAT_SCALE_PROPERTY_FACTORY import com.android.launcher3.LauncherAnimUtils.SCALE_INDEX_WORKSPACE_STATE import com.android.launcher3.LauncherAnimUtils.WORKSPACE_SCALE_PROPERTY_FACTORY @@ -38,7 +39,7 @@ import com.android.quickstep.views.RecentsView * Creates an animation where the workspace and hotseat fade in while revealing from the center of * the screen outwards radially. This is used in conjunction with the swipe up to home animation. */ -class ScalingWorkspaceRevealAnim(launcher: QuickstepLauncher) { +class ScalingWorkspaceRevealAnim(launcher: Launcher) { companion object { private const val FADE_DURATION_MS = 200L private const val SCALE_DURATION_MS = 1000L diff --git a/quickstep/src/com/android/quickstep/util/SplitAnimationController.kt b/quickstep/src/com/android/quickstep/util/SplitAnimationController.kt index 9e45380d10..a2d3859135 100644 --- a/quickstep/src/com/android/quickstep/util/SplitAnimationController.kt +++ b/quickstep/src/com/android/quickstep/util/SplitAnimationController.kt @@ -41,6 +41,7 @@ import androidx.annotation.VisibleForTesting import com.android.app.animation.Interpolators import com.android.launcher3.DeviceProfile import com.android.launcher3.Flags.enableOverviewIconMenu +import com.android.launcher3.Launcher import com.android.launcher3.QuickstepTransitionManager import com.android.launcher3.Utilities import com.android.launcher3.anim.PendingAnimation @@ -49,8 +50,8 @@ import com.android.launcher3.config.FeatureFlags import com.android.launcher3.logging.StatsLogManager.EventEnum import com.android.launcher3.statehandlers.DepthController import com.android.launcher3.statemanager.StateManager +import com.android.launcher3.statemanager.StatefulActivity import com.android.launcher3.taskbar.TaskbarActivityContext -import com.android.launcher3.uioverrides.QuickstepLauncher import com.android.launcher3.util.MultiPropertyFactory.MULTI_PROPERTY_VALUE import com.android.launcher3.util.SplitConfigurationOptions.SplitSelectSource import com.android.launcher3.views.BaseDragLayer @@ -60,7 +61,6 @@ import com.android.quickstep.views.FloatingTaskView import com.android.quickstep.views.GroupedTaskView import com.android.quickstep.views.IconAppChipView import com.android.quickstep.views.RecentsView -import com.android.quickstep.views.RecentsViewContainer import com.android.quickstep.views.SplitInstructionsView import com.android.quickstep.views.TaskThumbnailView import com.android.quickstep.views.TaskView @@ -269,12 +269,12 @@ class SplitAnimationController(val splitSelectStateController: SplitSelectStateC } /** Does not play any animation if user is not currently in split selection state. */ - fun playPlaceholderDismissAnim(container: RecentsViewContainer, splitDismissEvent: EventEnum) { + fun playPlaceholderDismissAnim(launcher: StatefulActivity<*>, splitDismissEvent: EventEnum) { if (!splitSelectStateController.isSplitSelectActive) { return } - val anim = createPlaceholderDismissAnim(container, splitDismissEvent, null /*duration*/) + val anim = createPlaceholderDismissAnim(launcher, splitDismissEvent, null /*duration*/) anim.start() } @@ -283,18 +283,18 @@ class SplitAnimationController(val splitSelectStateController: SplitSelectStateC * for why split is being dismissed */ fun createPlaceholderDismissAnim( - container: RecentsViewContainer, + launcher: StatefulActivity<*>, splitDismissEvent: EventEnum, duration: Long? ): AnimatorSet { val animatorSet = AnimatorSet() duration?.let { animatorSet.duration = it } - val recentsView: RecentsView<*, *> = container.getOverviewPanel() + val recentsView: RecentsView<*, *> = launcher.getOverviewPanel() val floatingTask: FloatingTaskView = splitSelectStateController.firstFloatingTaskView ?: return animatorSet // We are in split selection state currently, transitioning to another state - val dragLayer: BaseDragLayer<*> = container.dragLayer + val dragLayer: BaseDragLayer<*> = launcher.dragLayer val onScreenRectF = RectF() Utilities.getBoundsForViewInDragLayer( dragLayer, @@ -320,7 +320,7 @@ class SplitAnimationController(val splitSelectStateController: SplitSelectStateC floatingTask, onScreenRectF, floatingTask.stagePosition, - container.deviceProfile + launcher.deviceProfile ) ) ) @@ -329,7 +329,7 @@ class SplitAnimationController(val splitSelectStateController: SplitSelectStateC override fun onAnimationEnd(animation: Animator) { splitSelectStateController.resetState() safeRemoveViewFromDragLayer( - container, + launcher, splitSelectStateController.splitInstructionsView ) } @@ -343,11 +343,11 @@ class SplitAnimationController(val splitSelectStateController: SplitSelectStateC * Returns a [PendingAnimation] to animate in the chip to instruct a user to select a second app * for splitscreen */ - fun getShowSplitInstructionsAnim(container: RecentsViewContainer): PendingAnimation { - safeRemoveViewFromDragLayer(container, splitSelectStateController.splitInstructionsView) - val splitInstructionsView = SplitInstructionsView.getSplitInstructionsView(container) + fun getShowSplitInstructionsAnim(launcher: StatefulActivity<*>): PendingAnimation { + safeRemoveViewFromDragLayer(launcher, splitSelectStateController.splitInstructionsView) + val splitInstructionsView = SplitInstructionsView.getSplitInstructionsView(launcher) splitSelectStateController.splitInstructionsView = splitInstructionsView - val timings = AnimUtils.getDeviceOverviewToSplitTimings(container.deviceProfile.isTablet) + val timings = AnimUtils.getDeviceOverviewToSplitTimings(launcher.deviceProfile.isTablet) val anim = PendingAnimation(100 /*duration */) splitInstructionsView.alpha = 0f anim.setViewAlpha( @@ -374,8 +374,8 @@ class SplitAnimationController(val splitSelectStateController: SplitSelectStateC } /** Removes the split instructions view from [launcher] drag layer. */ - fun removeSplitInstructionsView(container: RecentsViewContainer) { - safeRemoveViewFromDragLayer(container, splitSelectStateController.splitInstructionsView) + fun removeSplitInstructionsView(launcher: StatefulActivity<*>) { + safeRemoveViewFromDragLayer(launcher, splitSelectStateController.splitInstructionsView) } /** @@ -384,23 +384,22 @@ class SplitAnimationController(val splitSelectStateController: SplitSelectStateC * TODO(b/276361926): Remove the [resetCallback] option once contextual launches */ fun playAnimPlaceholderToFullscreen( - container: RecentsViewContainer, + launcher: StatefulActivity<*>, view: View, resetCallback: Optional ) { val stagedTaskView = view as FloatingTaskView - val isTablet: Boolean = container.deviceProfile.isTablet + val isTablet: Boolean = launcher.deviceProfile.isTablet val duration = if (isTablet) SplitAnimationTimings.TABLET_CONFIRM_DURATION else SplitAnimationTimings.PHONE_CONFIRM_DURATION - val pendingAnimation = PendingAnimation(duration.toLong()) val firstTaskStartingBounds = Rect() val firstTaskEndingBounds = Rect() stagedTaskView.getBoundsOnScreen(firstTaskStartingBounds) - container.dragLayer.getBoundsOnScreen(firstTaskEndingBounds) + launcher.dragLayer.getBoundsOnScreen(firstTaskEndingBounds) splitSelectStateController.setLaunchingFirstAppFullscreen() stagedTaskView.addConfirmAnimation( @@ -590,7 +589,7 @@ class SplitAnimationController(val splitSelectStateController: SplitSelectStateC } // Else we are in Launcher and can launch with the full icon stretch-and-split animation. - val launcher = QuickstepLauncher.getLauncher(launchingIconView.context) + val launcher = Launcher.getLauncher(launchingIconView.context) val dp = launcher.deviceProfile // Create an AnimatorSet that will run both shell and launcher transitions together @@ -924,9 +923,9 @@ class SplitAnimationController(val splitSelectStateController: SplitSelectStateC animator.start() } - private fun safeRemoveViewFromDragLayer(container: RecentsViewContainer, view: View?) { + private fun safeRemoveViewFromDragLayer(launcher: StatefulActivity<*>, view: View?) { if (view != null) { - container.dragLayer.removeView(view) + launcher.dragLayer.removeView(view) } } } diff --git a/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java b/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java index c9aa30d80f..bff5a259c7 100644 --- a/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java +++ b/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java @@ -72,6 +72,7 @@ import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; import com.android.internal.logging.InstanceId; +import com.android.launcher3.Launcher; import com.android.launcher3.R; import com.android.launcher3.anim.PendingAnimation; import com.android.launcher3.apppairs.AppPairIcon; @@ -81,9 +82,9 @@ import com.android.launcher3.logging.StatsLogManager; import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.statehandlers.DepthController; import com.android.launcher3.statemanager.StateManager; +import com.android.launcher3.statemanager.StatefulActivity; import com.android.launcher3.testing.TestLogging; import com.android.launcher3.testing.shared.TestProtocol; -import com.android.launcher3.uioverrides.QuickstepLauncher; import com.android.launcher3.util.BackPressHandler; import com.android.launcher3.util.ComponentKey; import com.android.launcher3.util.SplitConfigurationOptions.StagePosition; @@ -99,7 +100,6 @@ import com.android.quickstep.TaskAnimationManager; import com.android.quickstep.views.FloatingTaskView; import com.android.quickstep.views.GroupedTaskView; import com.android.quickstep.views.RecentsView; -import com.android.quickstep.views.RecentsViewContainer; import com.android.quickstep.views.SplitInstructionsView; import com.android.systemui.animation.RemoteAnimationRunnerCompat; import com.android.systemui.shared.recents.model.Task; @@ -121,7 +121,7 @@ import java.util.function.Consumer; public class SplitSelectStateController { private static final String TAG = "SplitSelectStateCtor"; - private RecentsViewContainer mContainer; + private StatefulActivity mContext; private final Handler mHandler; private final RecentsModel mRecentTasksModel; @Nullable @@ -179,7 +179,7 @@ public class SplitSelectStateController { public void onBackInvoked() { // When exiting from split selection, leave current context to go to // homescreen as well - getSplitAnimationController().playPlaceholderDismissAnim(mContainer, + getSplitAnimationController().playPlaceholderDismissAnim(mContext, LAUNCHER_SPLIT_SELECTION_EXIT_HOME); if (mActivityBackCallback != null) { mActivityBackCallback.run(); @@ -187,11 +187,11 @@ public class SplitSelectStateController { } }; - public SplitSelectStateController(RecentsViewContainer container, Handler handler, + public SplitSelectStateController(StatefulActivity context, Handler handler, StateManager stateManager, DepthController depthController, StatsLogManager statsLogManager, SystemUiProxy systemUiProxy, RecentsModel recentsModel, Runnable activityBackCallback) { - mContainer = container; + mContext = context; mHandler = handler; mStatsLogManager = statsLogManager; mSystemUiProxy = systemUiProxy; @@ -200,12 +200,12 @@ public class SplitSelectStateController { mRecentTasksModel = recentsModel; mActivityBackCallback = activityBackCallback; mSplitAnimationController = new SplitAnimationController(this); - mAppPairsController = new AppPairsController(mContainer.asContext(), this, statsLogManager); - mSplitSelectDataHolder = new SplitSelectDataHolder(mContainer.asContext()); + mAppPairsController = new AppPairsController(context, this, statsLogManager); + mSplitSelectDataHolder = new SplitSelectDataHolder(mContext); } public void onDestroy() { - mContainer = null; + mContext = null; mActivityBackCallback = null; mAppPairsController.onDestroy(); mSplitSelectDataHolder.onDestroy(); @@ -646,7 +646,7 @@ public class SplitSelectStateController { } } - public void initSplitFromDesktopController(QuickstepLauncher launcher) { + public void initSplitFromDesktopController(Launcher launcher) { initSplitFromDesktopController(new SplitFromDesktopController(launcher)); } @@ -955,7 +955,7 @@ public class SplitSelectStateController { public class SplitFromDesktopController { private static final String TAG = "SplitFromDesktopController"; - private final QuickstepLauncher mLauncher; + private final Launcher mLauncher; private final OverviewComponentObserver mOverviewComponentObserver; private final int mSplitPlaceholderSize; private final int mSplitPlaceholderInset; @@ -963,7 +963,7 @@ public class SplitSelectStateController { private ISplitSelectListener mSplitSelectListener; private Drawable mAppIcon; - public SplitFromDesktopController(QuickstepLauncher launcher) { + public SplitFromDesktopController(Launcher launcher) { mLauncher = launcher; RecentsAnimationDeviceState deviceState = new RecentsAnimationDeviceState( launcher.getApplicationContext()); diff --git a/quickstep/src/com/android/quickstep/util/SplitToWorkspaceController.java b/quickstep/src/com/android/quickstep/util/SplitToWorkspaceController.java index 2cd421aac3..16d707bb10 100644 --- a/quickstep/src/com/android/quickstep/util/SplitToWorkspaceController.java +++ b/quickstep/src/com/android/quickstep/util/SplitToWorkspaceController.java @@ -35,6 +35,7 @@ import android.view.View; import com.android.internal.jank.Cuj; import com.android.launcher3.DeviceProfile; +import com.android.launcher3.Launcher; import com.android.launcher3.LauncherAppState; import com.android.launcher3.R; import com.android.launcher3.anim.PendingAnimation; @@ -45,7 +46,6 @@ import com.android.launcher3.model.data.AppPairInfo; import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.model.data.PackageItemInfo; import com.android.launcher3.model.data.WorkspaceItemInfo; -import com.android.launcher3.uioverrides.QuickstepLauncher; import com.android.quickstep.views.FloatingTaskView; import com.android.quickstep.views.RecentsView; import com.android.systemui.shared.system.InteractionJankMonitorWrapper; @@ -53,14 +53,13 @@ import com.android.systemui.shared.system.InteractionJankMonitorWrapper; /** Handles when the stage split lands on the home screen. */ public class SplitToWorkspaceController { - private final QuickstepLauncher mLauncher; + private final Launcher mLauncher; private final SplitSelectStateController mController; private final int mHalfDividerSize; private final IconCache mIconCache; - public SplitToWorkspaceController(QuickstepLauncher launcher, - SplitSelectStateController controller) { + public SplitToWorkspaceController(Launcher launcher, SplitSelectStateController controller) { mLauncher = launcher; mController = controller; mIconCache = LauncherAppState.getInstanceNoCreate().getIconCache(); diff --git a/quickstep/src/com/android/quickstep/util/StaggeredWorkspaceAnim.java b/quickstep/src/com/android/quickstep/util/StaggeredWorkspaceAnim.java index 997a842dc2..d6d6a119bd 100644 --- a/quickstep/src/com/android/quickstep/util/StaggeredWorkspaceAnim.java +++ b/quickstep/src/com/android/quickstep/util/StaggeredWorkspaceAnim.java @@ -38,6 +38,7 @@ import androidx.annotation.Nullable; import com.android.launcher3.CellLayout; import com.android.launcher3.DeviceProfile; import com.android.launcher3.Hotseat; +import com.android.launcher3.Launcher; import com.android.launcher3.LauncherState; import com.android.launcher3.QuickstepTransitionManager; import com.android.launcher3.R; @@ -74,13 +75,13 @@ public class StaggeredWorkspaceAnim { private final AnimatorSet mAnimators = new AnimatorSet(); private final @Nullable View mIgnoredView; - public StaggeredWorkspaceAnim(QuickstepLauncher launcher, float velocity, - boolean animateOverviewScrim, @Nullable View ignoredView) { + public StaggeredWorkspaceAnim(Launcher launcher, float velocity, boolean animateOverviewScrim, + @Nullable View ignoredView) { this(launcher, velocity, animateOverviewScrim, ignoredView, true); } - public StaggeredWorkspaceAnim(QuickstepLauncher launcher, float velocity, - boolean animateOverviewScrim, @Nullable View ignoredView, boolean staggerWorkspace) { + public StaggeredWorkspaceAnim(Launcher launcher, float velocity, boolean animateOverviewScrim, + @Nullable View ignoredView, boolean staggerWorkspace) { prepareToAnimate(launcher, animateOverviewScrim); mIgnoredView = ignoredView; @@ -123,8 +124,7 @@ public class StaggeredWorkspaceAnim { for (int i = hotseatIcons.getChildCount() - 1; i >= 0; i--) { View child = hotseatIcons.getChildAt(i); CellLayoutLayoutParams lp = ((CellLayoutLayoutParams) child.getLayoutParams()); - addStaggeredAnimationForView(child, lp.getCellY() + 1, - totalRows, duration); + addStaggeredAnimationForView(child, lp.getCellY() + 1, totalRows, duration); } } else { final int hotseatRow, qsbRow; @@ -194,8 +194,7 @@ public class StaggeredWorkspaceAnim { for (int i = itemsContainer.getChildCount() - 1; i >= 0; i--) { View child = itemsContainer.getChildAt(i); CellLayoutLayoutParams lp = ((CellLayoutLayoutParams) child.getLayoutParams()); - addStaggeredAnimationForView(child, lp.getCellY() + lp.cellVSpan, - totalRows, duration); + addStaggeredAnimationForView(child, lp.getCellY() + lp.cellVSpan, totalRows, duration); } mAnimators.addListener(new AnimatorListenerAdapter() { @@ -210,7 +209,7 @@ public class StaggeredWorkspaceAnim { /** * Setup workspace with 0 duration to prepare for our staggered animation. */ - private void prepareToAnimate(QuickstepLauncher launcher, boolean animateOverviewScrim) { + private void prepareToAnimate(Launcher launcher, boolean animateOverviewScrim) { StateAnimationConfig config = new StateAnimationConfig(); config.animFlags = SKIP_OVERVIEW | SKIP_DEPTH_CONTROLLER | SKIP_SCRIM; config.duration = 0; @@ -295,10 +294,12 @@ public class StaggeredWorkspaceAnim { mAnimators.play(alpha); } - private void addDepthAnimationForState(QuickstepLauncher launcher, LauncherState state, - long duration) { + private void addDepthAnimationForState(Launcher launcher, LauncherState state, long duration) { + if (!(launcher instanceof QuickstepLauncher)) { + return; + } PendingAnimation builder = new PendingAnimation(duration); - DepthController depthController = launcher.getDepthController(); + DepthController depthController = ((QuickstepLauncher) launcher).getDepthController(); depthController.setStateWithAnimation(state, new StateAnimationConfig(), builder); mAnimators.play(builder.buildAnim()); } diff --git a/quickstep/src/com/android/quickstep/util/TaskRemovedDuringLaunchListener.java b/quickstep/src/com/android/quickstep/util/TaskRemovedDuringLaunchListener.java index 89d8cc48ce..cdadd711a8 100644 --- a/quickstep/src/com/android/quickstep/util/TaskRemovedDuringLaunchListener.java +++ b/quickstep/src/com/android/quickstep/util/TaskRemovedDuringLaunchListener.java @@ -24,8 +24,8 @@ import static com.android.launcher3.BaseActivity.EVENT_STOPPED; import androidx.annotation.NonNull; +import com.android.launcher3.BaseActivity; import com.android.quickstep.RecentsModel; -import com.android.quickstep.views.RecentsViewContainer; /** * This class tracks the failure of a task launch through the TaskView.launchTask() call, in an @@ -38,7 +38,7 @@ import com.android.quickstep.views.RecentsViewContainer; */ public class TaskRemovedDuringLaunchListener { - private RecentsViewContainer mContainer; + private BaseActivity mActivity; private int mLaunchedTaskId = INVALID_TASK_ID; private Runnable mTaskLaunchFailedCallback = null; @@ -49,16 +49,16 @@ public class TaskRemovedDuringLaunchListener { * Registers a failure listener callback if it detects a scenario in which an app launch * failed before the transition finished. */ - public void register(RecentsViewContainer container, int launchedTaskId, + public void register(BaseActivity activity, int launchedTaskId, @NonNull Runnable taskLaunchFailedCallback) { // The normal task launch case, Launcher stops and updates its state correctly - container.addEventCallback(EVENT_STOPPED, mUnregisterCallback); + activity.addEventCallback(EVENT_STOPPED, mUnregisterCallback); // The transition hasn't finished but Launcher was resumed, check if the launch failed - container.addEventCallback(EVENT_RESUMED, mResumeCallback); + activity.addEventCallback(EVENT_RESUMED, mResumeCallback); // If we somehow don't get any of the above signals, then just unregister this listener - container.addEventCallback(EVENT_DESTROYED, mUnregisterCallback); + activity.addEventCallback(EVENT_DESTROYED, mUnregisterCallback); - mContainer = container; + mActivity = activity; mLaunchedTaskId = launchedTaskId; mTaskLaunchFailedCallback = taskLaunchFailedCallback; } @@ -67,11 +67,11 @@ public class TaskRemovedDuringLaunchListener { * Unregisters the failure listener. */ private void unregister() { - mContainer.removeEventCallback(EVENT_STOPPED, mUnregisterCallback); - mContainer.removeEventCallback(EVENT_RESUMED, mResumeCallback); - mContainer.removeEventCallback(EVENT_DESTROYED, mUnregisterCallback); + mActivity.removeEventCallback(EVENT_STOPPED, mUnregisterCallback); + mActivity.removeEventCallback(EVENT_RESUMED, mResumeCallback); + mActivity.removeEventCallback(EVENT_DESTROYED, mUnregisterCallback); - mContainer = null; + mActivity = null; mLaunchedTaskId = INVALID_TASK_ID; mTaskLaunchFailedCallback = null; } diff --git a/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java b/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java index fcb865f10d..1152de2750 100644 --- a/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java +++ b/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java @@ -51,7 +51,6 @@ import com.android.launcher3.anim.PendingAnimation; import com.android.launcher3.util.SplitConfigurationOptions.SplitBounds; import com.android.launcher3.util.TraceHelper; import com.android.quickstep.BaseActivityInterface; -import com.android.quickstep.BaseContainerInterface; import com.android.quickstep.TaskAnimationManager; import com.android.quickstep.util.SurfaceTransaction.SurfaceProperties; import com.android.quickstep.views.TaskView.FullscreenDrawParams; @@ -71,7 +70,7 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy { private final float[] mTempPoint = new float[2]; private final Context mContext; - private final BaseContainerInterface mSizeStrategy; + private final BaseActivityInterface mSizeStrategy; @NonNull private RecentsOrientedState mOrientationState; @@ -123,7 +122,7 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy { private int mTaskRectTranslationX; private int mTaskRectTranslationY; - public TaskViewSimulator(Context context, BaseContainerInterface sizeStrategy) { + public TaskViewSimulator(Context context, BaseActivityInterface sizeStrategy) { mContext = context; mSizeStrategy = sizeStrategy; diff --git a/quickstep/src/com/android/quickstep/util/UnfoldMoveFromCenterHotseatAnimator.java b/quickstep/src/com/android/quickstep/util/UnfoldMoveFromCenterHotseatAnimator.java index 4aea1b8282..c8141b4642 100644 --- a/quickstep/src/com/android/quickstep/util/UnfoldMoveFromCenterHotseatAnimator.java +++ b/quickstep/src/com/android/quickstep/util/UnfoldMoveFromCenterHotseatAnimator.java @@ -20,7 +20,7 @@ import android.view.ViewGroup; import android.view.WindowManager; import com.android.launcher3.Hotseat; -import com.android.launcher3.uioverrides.QuickstepLauncher; +import com.android.launcher3.Launcher; import com.android.systemui.unfold.updates.RotationChangeProvider; /** @@ -28,10 +28,10 @@ import com.android.systemui.unfold.updates.RotationChangeProvider; */ public class UnfoldMoveFromCenterHotseatAnimator extends BaseUnfoldMoveFromCenterAnimator { - private final QuickstepLauncher mLauncher; + private final Launcher mLauncher; - public UnfoldMoveFromCenterHotseatAnimator(QuickstepLauncher launcher, - WindowManager windowManager, RotationChangeProvider rotationChangeProvider) { + public UnfoldMoveFromCenterHotseatAnimator(Launcher launcher, WindowManager windowManager, + RotationChangeProvider rotationChangeProvider) { super(windowManager, rotationChangeProvider); mLauncher = launcher; } diff --git a/quickstep/src/com/android/quickstep/util/UnfoldMoveFromCenterWorkspaceAnimator.java b/quickstep/src/com/android/quickstep/util/UnfoldMoveFromCenterWorkspaceAnimator.java index 0ec3ae05d7..c05b38f5f2 100644 --- a/quickstep/src/com/android/quickstep/util/UnfoldMoveFromCenterWorkspaceAnimator.java +++ b/quickstep/src/com/android/quickstep/util/UnfoldMoveFromCenterWorkspaceAnimator.java @@ -19,9 +19,9 @@ import android.view.View; import android.view.WindowManager; import com.android.launcher3.CellLayout; +import com.android.launcher3.Launcher; import com.android.launcher3.ShortcutAndWidgetContainer; import com.android.launcher3.Workspace; -import com.android.launcher3.uioverrides.QuickstepLauncher; import com.android.systemui.unfold.updates.RotationChangeProvider; /** @@ -29,10 +29,10 @@ import com.android.systemui.unfold.updates.RotationChangeProvider; */ public class UnfoldMoveFromCenterWorkspaceAnimator extends BaseUnfoldMoveFromCenterAnimator { - private final QuickstepLauncher mLauncher; + private final Launcher mLauncher; - public UnfoldMoveFromCenterWorkspaceAnimator(QuickstepLauncher launcher, - WindowManager windowManager, RotationChangeProvider rotationChangeProvider) { + public UnfoldMoveFromCenterWorkspaceAnimator(Launcher launcher, WindowManager windowManager, + RotationChangeProvider rotationChangeProvider) { super(windowManager, rotationChangeProvider); mLauncher = launcher; } diff --git a/quickstep/src/com/android/quickstep/util/unfold/LauncherUnfoldTransitionController.kt b/quickstep/src/com/android/quickstep/util/unfold/LauncherUnfoldTransitionController.kt index 09563f5527..54d317d564 100644 --- a/quickstep/src/com/android/quickstep/util/unfold/LauncherUnfoldTransitionController.kt +++ b/quickstep/src/com/android/quickstep/util/unfold/LauncherUnfoldTransitionController.kt @@ -21,15 +21,15 @@ import android.view.Surface import com.android.launcher3.Alarm import com.android.launcher3.DeviceProfile import com.android.launcher3.DeviceProfile.OnDeviceProfileChangeListener +import com.android.launcher3.Launcher import com.android.launcher3.anim.PendingAnimation import com.android.launcher3.config.FeatureFlags -import com.android.launcher3.uioverrides.QuickstepLauncher import com.android.launcher3.util.ActivityLifecycleCallbacksAdapter import com.android.systemui.unfold.UnfoldTransitionProgressProvider.TransitionProgressListener /** Controls animations that are happening during unfolding foldable devices */ class LauncherUnfoldTransitionController( - private val launcher: QuickstepLauncher, + private val launcher: Launcher, private val progressProvider: ProxyUnfoldTransitionProvider ) : OnDeviceProfileChangeListener, ActivityLifecycleCallbacksAdapter, TransitionProgressListener { diff --git a/quickstep/src/com/android/quickstep/util/unfold/UnfoldAnimationBuilder.kt b/quickstep/src/com/android/quickstep/util/unfold/UnfoldAnimationBuilder.kt index 2f90ee760e..d2c4728362 100644 --- a/quickstep/src/com/android/quickstep/util/unfold/UnfoldAnimationBuilder.kt +++ b/quickstep/src/com/android/quickstep/util/unfold/UnfoldAnimationBuilder.kt @@ -20,6 +20,7 @@ import android.view.ViewGroup import com.android.app.animation.Interpolators.LINEAR import com.android.app.animation.Interpolators.clampToProgress import com.android.launcher3.CellLayout +import com.android.launcher3.Launcher import com.android.launcher3.LauncherAnimUtils.HOTSEAT_SCALE_PROPERTY_FACTORY import com.android.launcher3.LauncherAnimUtils.SCALE_INDEX_UNFOLD_ANIMATION import com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_X @@ -27,7 +28,6 @@ import com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_Y import com.android.launcher3.LauncherAnimUtils.WORKSPACE_SCALE_PROPERTY_FACTORY import com.android.launcher3.Workspace import com.android.launcher3.anim.PendingAnimation -import com.android.launcher3.uioverrides.QuickstepLauncher import com.android.launcher3.util.HorizontalInsettableView private typealias ViewGroupAction = (ViewGroup, Boolean) -> Unit @@ -112,7 +112,7 @@ object UnfoldAnimationBuilder { * Builds an animation for the unfold experience and adds it to the provided PendingAnimation */ fun buildUnfoldAnimation( - launcher: QuickstepLauncher, + launcher: Launcher, isVerticalFold: Boolean, screenSize: Point, anim: PendingAnimation diff --git a/quickstep/src/com/android/quickstep/views/ClearAllButton.java b/quickstep/src/com/android/quickstep/views/ClearAllButton.java index b8afd9ddd9..acda2e153d 100644 --- a/quickstep/src/com/android/quickstep/views/ClearAllButton.java +++ b/quickstep/src/com/android/quickstep/views/ClearAllButton.java @@ -68,7 +68,7 @@ public class ClearAllButton extends Button { } }; - private final RecentsViewContainer mContainer; + private final StatefulActivity mActivity; private float mScrollAlpha = 1; private float mContentAlpha = 1; private float mVisibilityAlpha = 1; @@ -92,7 +92,7 @@ public class ClearAllButton extends Button { public ClearAllButton(Context context, AttributeSet attrs) { super(context, attrs); mIsRtl = getLayoutDirection() == LAYOUT_DIRECTION_RTL; - mContainer = RecentsViewContainer.containerFromContext(context); + mActivity = StatefulActivity.fromContext(context); if (Flags.enableFocusOutline()) { TypedArray styledAttrs = context.obtainStyledAttributes(attrs, @@ -326,7 +326,7 @@ public class ClearAllButton extends Button { * Get the Y translation that is set in the original layout position, before scrolling. */ private float getOriginalTranslationY() { - DeviceProfile deviceProfile = mContainer.getDeviceProfile(); + DeviceProfile deviceProfile = mActivity.getDeviceProfile(); if (deviceProfile.isTablet) { if (enableGridOnlyOverview()) { return (getRecentsView().getLastComputedTaskSize().height() diff --git a/quickstep/src/com/android/quickstep/views/DesktopAppSelectView.java b/quickstep/src/com/android/quickstep/views/DesktopAppSelectView.java index 6a9a268334..a5be142235 100644 --- a/quickstep/src/com/android/quickstep/views/DesktopAppSelectView.java +++ b/quickstep/src/com/android/quickstep/views/DesktopAppSelectView.java @@ -33,7 +33,6 @@ import androidx.annotation.Nullable; import com.android.launcher3.Launcher; import com.android.launcher3.R; import com.android.launcher3.Utilities; -import com.android.launcher3.uioverrides.QuickstepLauncher; /** * Floating view show on launcher home screen that notifies the user that an app will be launched to @@ -48,7 +47,7 @@ public class DesktopAppSelectView extends LinearLayout { private static final int SHOW_CONTENT_ALPHA_DURATION = 83; private static final int HIDE_DURATION = 83; - private final RecentsViewContainer mContainer; + private final Launcher mLauncher; private View mText; private View mCloseButton; @@ -72,7 +71,7 @@ public class DesktopAppSelectView extends LinearLayout { public DesktopAppSelectView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); - mContainer = RecentsViewContainer.containerFromContext(context); + mLauncher = Launcher.getLauncher(context); } /** @@ -105,7 +104,7 @@ public class DesktopAppSelectView extends LinearLayout { } private void show() { - mContainer.getDragLayer().addView(this); + mLauncher.getDragLayer().addView(this); // Set up initial values getBackground().setAlpha(0); @@ -164,7 +163,7 @@ public class DesktopAppSelectView extends LinearLayout { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); - mContainer.getDragLayer().removeView(DesktopAppSelectView.this); + mLauncher.getDragLayer().removeView(DesktopAppSelectView.this); mHideAnimation = null; } }); diff --git a/quickstep/src/com/android/quickstep/views/DesktopTaskView.java b/quickstep/src/com/android/quickstep/views/DesktopTaskView.java index 78b17632a3..10b4168601 100644 --- a/quickstep/src/com/android/quickstep/views/DesktopTaskView.java +++ b/quickstep/src/com/android/quickstep/views/DesktopTaskView.java @@ -118,7 +118,7 @@ public class DesktopTaskView extends TaskView { mBackgroundView = findViewById(R.id.background); int topMarginPx = - mContainer.getDeviceProfile().overviewTaskThumbnailTopMarginPx; + mActivity.getDeviceProfile().overviewTaskThumbnailTopMarginPx; FrameLayout.LayoutParams params = (LayoutParams) mBackgroundView.getLayoutParams(); params.topMargin = topMarginPx; mBackgroundView.setLayoutParams(params); @@ -303,7 +303,7 @@ public class DesktopTaskView extends TaskView { @Override protected void setThumbnailOrientation(RecentsOrientedState orientationState) { - DeviceProfile deviceProfile = mContainer.getDeviceProfile(); + DeviceProfile deviceProfile = mActivity.getDeviceProfile(); int thumbnailTopMargin = deviceProfile.overviewTaskThumbnailTopMarginPx; LayoutParams snapshotParams = (LayoutParams) mSnapshotView.getLayoutParams(); @@ -420,7 +420,7 @@ public class DesktopTaskView extends TaskView { setMeasuredDimension(containerWidth, containerHeight); - int thumbnailTopMarginPx = mContainer.getDeviceProfile().overviewTaskThumbnailTopMarginPx; + int thumbnailTopMarginPx = mActivity.getDeviceProfile().overviewTaskThumbnailTopMarginPx; containerHeight -= thumbnailTopMarginPx; int thumbnails = mSnapshotViewMap.size(); @@ -428,8 +428,8 @@ public class DesktopTaskView extends TaskView { return; } - int windowWidth = mContainer.getDeviceProfile().widthPx; - int windowHeight = mContainer.getDeviceProfile().heightPx; + int windowWidth = mActivity.getDeviceProfile().widthPx; + int windowHeight = mActivity.getDeviceProfile().heightPx; float scaleWidth = containerWidth / (float) windowWidth; float scaleHeight = containerHeight / (float) windowHeight; diff --git a/quickstep/src/com/android/quickstep/views/DigitalWellBeingToast.java b/quickstep/src/com/android/quickstep/views/DigitalWellBeingToast.java index 8fa5375739..840382d141 100644 --- a/quickstep/src/com/android/quickstep/views/DigitalWellBeingToast.java +++ b/quickstep/src/com/android/quickstep/views/DigitalWellBeingToast.java @@ -45,6 +45,8 @@ import androidx.annotation.IntDef; import androidx.annotation.Nullable; import androidx.annotation.StringRes; +import com.android.launcher3.BaseActivity; +import com.android.launcher3.BaseDraggingActivity; import com.android.launcher3.DeviceProfile; import com.android.launcher3.R; import com.android.launcher3.Utilities; @@ -81,7 +83,7 @@ public final class DigitalWellBeingToast { private static final String TAG = DigitalWellBeingToast.class.getSimpleName(); - private final RecentsViewContainer mContainer; + private final BaseDraggingActivity mActivity; private final TaskView mTaskView; private final LauncherApps mLauncherApps; @@ -100,10 +102,10 @@ public final class DigitalWellBeingToast { private float mSplitOffsetTranslationY; private float mSplitOffsetTranslationX; - public DigitalWellBeingToast(RecentsViewContainer container, TaskView taskView) { - mContainer = container; + public DigitalWellBeingToast(BaseDraggingActivity activity, TaskView taskView) { + mActivity = activity; mTaskView = taskView; - mLauncherApps = container.asContext().getSystemService(LauncherApps.class); + mLauncherApps = activity.getSystemService(LauncherApps.class); } private void setNoLimit() { @@ -118,10 +120,9 @@ public final class DigitalWellBeingToast { mAppUsageLimitTimeMs = appUsageLimitTimeMs; mAppRemainingTimeMs = appRemainingTimeMs; mHasLimit = true; - TextView toast = mContainer.getViewCache().getView(R.layout.digital_wellbeing_toast, - mContainer.asContext(), mTaskView); - toast.setText(prefixTextWithIcon(mContainer.asContext(), R.drawable.ic_hourglass_top, - getText())); + TextView toast = mActivity.getViewCache().getView(R.layout.digital_wellbeing_toast, + mActivity, mTaskView); + toast.setText(prefixTextWithIcon(mActivity, R.drawable.ic_hourglass_top, getText())); toast.setOnClickListener(this::openAppUsageSettings); replaceBanner(toast); @@ -169,14 +170,14 @@ public final class DigitalWellBeingToast { public void setSplitConfiguration(SplitBounds splitBounds) { mSplitBounds = splitBounds; if (mSplitBounds == null - || !mContainer.getDeviceProfile().isTablet + || !mActivity.getDeviceProfile().isTablet || mTaskView.isFocusedTask()) { mSplitBannerConfig = SPLIT_BANNER_FULLSCREEN; return; } // For portrait grid only height of task changes, not width. So we keep the text the same - if (!mContainer.getDeviceProfile().isLeftRightSplit) { + if (!mActivity.getDeviceProfile().isLeftRightSplit) { mSplitBannerConfig = SPLIT_GRID_BANNER_LARGE; return; } @@ -225,7 +226,7 @@ public final class DigitalWellBeingToast { // Use a specific string for usage less than one minute but non-zero. if (duration.compareTo(Duration.ZERO) > 0) { - return mContainer.asContext().getString(durationLessThanOneMinuteStringId); + return mActivity.getString(durationLessThanOneMinuteStringId); } // Otherwise, return 0-minute string. @@ -249,7 +250,7 @@ public final class DigitalWellBeingToast { R.string.shorter_duration_less_than_one_minute, false /* forceFormatWidth */); if (forContentDesc || mSplitBannerConfig == SPLIT_BANNER_FULLSCREEN) { - return mContainer.asContext().getString( + return mActivity.getString( R.string.time_left_for_app, readableDuration); } @@ -269,12 +270,11 @@ public final class DigitalWellBeingToast { mTask.getTopComponent().getPackageName()).addFlags( Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); try { - final RecentsViewContainer container = - RecentsViewContainer.containerFromContext(view.getContext()); + final BaseActivity activity = BaseActivity.fromContext(view.getContext()); final ActivityOptions options = ActivityOptions.makeScaleUpAnimation( view, 0, 0, view.getWidth(), view.getHeight()); - container.asContext().startActivity(intent, options.toBundle()); + activity.startActivity(intent, options.toBundle()); // TODO: add WW logging on the app usage settings click. } catch (ActivityNotFoundException e) { @@ -286,7 +286,7 @@ public final class DigitalWellBeingToast { private String getContentDescriptionForTask( Task task, long appUsageLimitTimeMs, long appRemainingTimeMs) { return appUsageLimitTimeMs >= 0 && appRemainingTimeMs >= 0 ? - mContainer.asContext().getString( + mActivity.getString( R.string.task_contents_description_with_remaining_time, task.titleDescription, getText(appRemainingTimeMs, true /* forContentDesc */)) : @@ -303,7 +303,7 @@ public final class DigitalWellBeingToast { mBanner.setOutlineProvider(mOldBannerOutlineProvider); mTaskView.removeView(mBanner); mBanner.setOnClickListener(null); - mContainer.getViewCache().recycleView(R.layout.digital_wellbeing_toast, mBanner); + mActivity.getViewCache().recycleView(R.layout.digital_wellbeing_toast, mBanner); } } @@ -318,7 +318,7 @@ public final class DigitalWellBeingToast { private void setupAndAddBanner() { FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) mBanner.getLayoutParams(); - DeviceProfile deviceProfile = mContainer.getDeviceProfile(); + DeviceProfile deviceProfile = mActivity.getDeviceProfile(); layoutParams.bottomMargin = ((ViewGroup.MarginLayoutParams) mTaskView.getThumbnail().getLayoutParams()).bottomMargin; RecentsPagedOrientationHandler orientationHandler = mTaskView.getPagedOrientationHandler(); diff --git a/quickstep/src/com/android/quickstep/views/FloatingAppPairBackground.kt b/quickstep/src/com/android/quickstep/views/FloatingAppPairBackground.kt index 0d49309d1c..1c1e1674e5 100644 --- a/quickstep/src/com/android/quickstep/views/FloatingAppPairBackground.kt +++ b/quickstep/src/com/android/quickstep/views/FloatingAppPairBackground.kt @@ -26,6 +26,7 @@ import android.graphics.drawable.Drawable import android.os.Build import android.view.animation.Interpolator import com.android.app.animation.Interpolators +import com.android.launcher3.Launcher import com.android.launcher3.R import com.android.launcher3.Utilities import com.android.quickstep.util.AnimUtils @@ -54,7 +55,7 @@ class FloatingAppPairBackground( private val ARRAY_OF_ZEROES = FloatArray(8) } - private val container: RecentsViewContainer + private val launcher: Launcher private val backgroundPaint = Paint(Paint.ANTI_ALIAS_FLAG) // Animation interpolators @@ -69,15 +70,15 @@ class FloatingAppPairBackground( private val desiredSplitRatio: Float init { - container = RecentsViewContainer.containerFromContext(context) - val dp = container.deviceProfile + launcher = Launcher.getLauncher(context) + val dp = launcher.deviceProfile // Set up background paint color val ta = context.theme.obtainStyledAttributes(R.styleable.FolderIconPreview) backgroundPaint.style = Paint.Style.FILL backgroundPaint.color = ta.getColor(R.styleable.FolderIconPreview_folderPreviewColor, 0) ta.recycle() // Set up timings and interpolators - val timings = AnimUtils.getDeviceAppPairLaunchTimings(container.deviceProfile.isTablet) + val timings = AnimUtils.getDeviceAppPairLaunchTimings(launcher.deviceProfile.isTablet) expandXInterpolator = Interpolators.clampToProgress( timings.getStagedRectScaleXInterpolator(), @@ -104,9 +105,9 @@ class FloatingAppPairBackground( ) // Find device-specific measurements - deviceCornerRadius = QuickStepContract.getWindowCornerRadius(container.asContext()) + deviceCornerRadius = QuickStepContract.getWindowCornerRadius(launcher) deviceHalfDividerSize = - container.asContext().resources.getDimensionPixelSize(R.dimen.multi_window_task_divider_size) / 2f + launcher.resources.getDimensionPixelSize(R.dimen.multi_window_task_divider_size) / 2f val dividerCenterPos = dividerPos + deviceHalfDividerSize desiredSplitRatio = if (dp.isLeftRightSplit) dividerCenterPos / dp.widthPx @@ -114,7 +115,7 @@ class FloatingAppPairBackground( } override fun draw(canvas: Canvas) { - if (container.deviceProfile.isLeftRightSplit) { + if (launcher.deviceProfile.isLeftRightSplit) { drawLeftRightSplit(canvas) } else { drawTopBottomSplit(canvas) @@ -149,37 +150,39 @@ class FloatingAppPairBackground( val dividerCenterPos = width * desiredSplitRatio // The left half of the background image - val leftSide = RectF(0f, 0f, dividerCenterPos - changingDividerSize, height) + val leftSide = RectF( + 0f, + 0f, + dividerCenterPos - changingDividerSize, + height + ) // The right half of the background image - val rightSide = RectF(dividerCenterPos + changingDividerSize, 0f, width, height) + val rightSide = RectF( + dividerCenterPos + changingDividerSize, + 0f, + width, + height + ) // Draw background drawCustomRoundedRect( canvas, leftSide, floatArrayOf( - cornerRadiusX, - cornerRadiusY, - changingInnerRadiusX, - changingInnerRadiusY, - changingInnerRadiusX, - changingInnerRadiusY, - cornerRadiusX, - cornerRadiusY, + cornerRadiusX, cornerRadiusY, + changingInnerRadiusX, changingInnerRadiusY, + changingInnerRadiusX, changingInnerRadiusY, + cornerRadiusX, cornerRadiusY ) ) drawCustomRoundedRect( canvas, rightSide, floatArrayOf( - changingInnerRadiusX, - changingInnerRadiusY, - cornerRadiusX, - cornerRadiusY, - cornerRadiusX, - cornerRadiusY, - changingInnerRadiusX, - changingInnerRadiusY, + changingInnerRadiusX, changingInnerRadiusY, + cornerRadiusX, cornerRadiusY, + cornerRadiusX, cornerRadiusY, + changingInnerRadiusX, changingInnerRadiusY ) ) @@ -247,37 +250,39 @@ class FloatingAppPairBackground( val dividerCenterPos = height * desiredSplitRatio // The top half of the background image - val topSide = RectF(0f, 0f, width, dividerCenterPos - changingDividerSize) + val topSide = RectF( + 0f, + 0f, + width, + dividerCenterPos - changingDividerSize + ) // The bottom half of the background image - val bottomSide = RectF(0f, dividerCenterPos + changingDividerSize, width, height) + val bottomSide = RectF( + 0f, + dividerCenterPos + changingDividerSize, + width, + height + ) // Draw background drawCustomRoundedRect( canvas, topSide, floatArrayOf( - cornerRadiusX, - cornerRadiusY, - cornerRadiusX, - cornerRadiusY, - changingInnerRadiusX, - changingInnerRadiusY, - changingInnerRadiusX, - changingInnerRadiusY + cornerRadiusX, cornerRadiusY, + cornerRadiusX, cornerRadiusY, + changingInnerRadiusX, changingInnerRadiusY, + changingInnerRadiusX, changingInnerRadiusY ) ) drawCustomRoundedRect( canvas, bottomSide, floatArrayOf( - changingInnerRadiusX, - changingInnerRadiusY, - changingInnerRadiusX, - changingInnerRadiusY, - cornerRadiusX, - cornerRadiusY, - cornerRadiusX, - cornerRadiusY + changingInnerRadiusX, changingInnerRadiusY, + changingInnerRadiusX, changingInnerRadiusY, + cornerRadiusX, cornerRadiusY, + cornerRadiusX, cornerRadiusY ) ) @@ -333,10 +338,8 @@ class FloatingAppPairBackground( // Fallback rectangle with uniform rounded corners val scaleFactorX = floatingView.scaleX val scaleFactorY = floatingView.scaleY - val cornerRadiusX = - QuickStepContract.getWindowCornerRadius(container.asContext()) / scaleFactorX - val cornerRadiusY = - QuickStepContract.getWindowCornerRadius(container.asContext()) / scaleFactorY + val cornerRadiusX = QuickStepContract.getWindowCornerRadius(launcher) / scaleFactorX + val cornerRadiusY = QuickStepContract.getWindowCornerRadius(launcher) / scaleFactorY c.drawRoundRect(rect, cornerRadiusX, cornerRadiusY, backgroundPaint) } } diff --git a/quickstep/src/com/android/quickstep/views/FloatingTaskView.java b/quickstep/src/com/android/quickstep/views/FloatingTaskView.java index e479c16200..18922a6fb3 100644 --- a/quickstep/src/com/android/quickstep/views/FloatingTaskView.java +++ b/quickstep/src/com/android/quickstep/views/FloatingTaskView.java @@ -36,10 +36,12 @@ import android.widget.FrameLayout; import androidx.annotation.Nullable; import com.android.launcher3.AbstractFloatingView; +import com.android.launcher3.BaseActivity; import com.android.launcher3.InsettableFrameLayout; import com.android.launcher3.R; import com.android.launcher3.Utilities; import com.android.launcher3.anim.PendingAnimation; +import com.android.launcher3.statemanager.StatefulActivity; import com.android.launcher3.taskbar.TaskbarActivityContext; import com.android.launcher3.util.SplitConfigurationOptions; import com.android.launcher3.views.BaseDragLayer; @@ -52,7 +54,7 @@ import com.android.systemui.shared.system.QuickStepContract; /** * Create an instance via - * {@link #getFloatingTaskView(RecentsViewContainer, View, Bitmap, Drawable, RectF)} to + * {@link #getFloatingTaskView(StatefulActivity, View, Bitmap, Drawable, RectF)} to * which will have the thumbnail from the provided existing TaskView overlaying the taskview itself. * * Can then animate the taskview using @@ -65,32 +67,32 @@ public class FloatingTaskView extends FrameLayout { public static final FloatProperty PRIMARY_TRANSLATE_OFFSCREEN = new FloatProperty("floatingTaskPrimaryTranslateOffscreen") { - @Override - public void setValue(FloatingTaskView view, float translation) { - ((RecentsView) view.mContainer.getOverviewPanel()).getPagedOrientationHandler() - .setFloatingTaskPrimaryTranslation( - view, - translation, - view.mContainer.getDeviceProfile() - ); - } + @Override + public void setValue(FloatingTaskView view, float translation) { + ((RecentsView) view.mActivity.getOverviewPanel()).getPagedOrientationHandler() + .setFloatingTaskPrimaryTranslation( + view, + translation, + view.mActivity.getDeviceProfile() + ); + } - @Override - public Float get(FloatingTaskView view) { - return ((RecentsView) view.mContainer.getOverviewPanel()) - .getPagedOrientationHandler() - .getFloatingTaskPrimaryTranslation( - view, - view.mContainer.getDeviceProfile() - ); - } - }; + @Override + public Float get(FloatingTaskView view) { + return ((RecentsView) view.mActivity.getOverviewPanel()) + .getPagedOrientationHandler() + .getFloatingTaskPrimaryTranslation( + view, + view.mActivity.getDeviceProfile() + ); + } + }; private int mSplitHolderSize; private FloatingTaskThumbnailView mThumbnailView; private SplitPlaceholderView mSplitPlaceholderView; private RectF mStartingPosition; - private final RecentsViewContainer mContainer; + private final StatefulActivity mActivity; private final boolean mIsRtl; private final FullscreenDrawParams mFullscreenParams; private RecentsPagedOrientationHandler mOrientationHandler; @@ -108,7 +110,7 @@ public class FloatingTaskView extends FrameLayout { public FloatingTaskView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); - mContainer = RecentsViewContainer.containerFromContext(context); + mActivity = BaseActivity.fromContext(context); mIsRtl = Utilities.isRtl(getResources()); mFullscreenParams = new FullscreenDrawParams(context); @@ -124,7 +126,7 @@ public class FloatingTaskView extends FrameLayout { mSplitPlaceholderView.setAlpha(0); } - private void init(RecentsViewContainer launcher, View originalView, @Nullable Bitmap thumbnail, + private void init(StatefulActivity launcher, View originalView, @Nullable Bitmap thumbnail, Drawable icon, RectF positionOut) { mStartingPosition = positionOut; updateInitialPositionForView(originalView); @@ -151,7 +153,7 @@ public class FloatingTaskView extends FrameLayout { * Configures and returns a an instance of {@link FloatingTaskView} initially matching the * appearance of {@code originalView}. */ - public static FloatingTaskView getFloatingTaskView(RecentsViewContainer launcher, + public static FloatingTaskView getFloatingTaskView(StatefulActivity launcher, View originalView, @Nullable Bitmap thumbnail, Drawable icon, RectF positionOut) { final ViewGroup dragLayer = launcher.getDragLayer(); final FloatingTaskView floatingView = (FloatingTaskView) launcher.getLayoutInflater() @@ -177,13 +179,13 @@ public class FloatingTaskView extends FrameLayout { originalView.getBoundsOnScreen(mTmpRect); mStartingPosition.set(mTmpRect); int[] dragLayerPositionRelativeToScreen = - mContainer.getDragLayer().getLocationOnScreen(); + mActivity.getDragLayer().getLocationOnScreen(); mStartingPosition.offset( -dragLayerPositionRelativeToScreen[0], -dragLayerPositionRelativeToScreen[1]); } else { Rect viewBounds = new Rect(0, 0, originalView.getWidth(), originalView.getHeight()); - Utilities.getBoundsForViewInDragLayer(mContainer.getDragLayer(), originalView, + Utilities.getBoundsForViewInDragLayer(mActivity.getDragLayer(), originalView, viewBounds, false /* ignoreTransform */, null /* recycle */, mStartingPosition); } @@ -233,7 +235,7 @@ public class FloatingTaskView extends FrameLayout { // Position the floating view exactly on top of the original lp.topMargin = Math.round(pos.top); if (mIsRtl) { - lp.setMarginStart(mContainer.getDeviceProfile().widthPx - Math.round(pos.right)); + lp.setMarginStart(mActivity.getDeviceProfile().widthPx - Math.round(pos.right)); } else { lp.setMarginStart(Math.round(pos.left)); } @@ -250,7 +252,7 @@ public class FloatingTaskView extends FrameLayout { */ public void addStagingAnimation(PendingAnimation animation, RectF startingBounds, Rect endBounds, boolean fadeWithThumbnail, boolean isStagedTask) { - boolean isTablet = mContainer.getDeviceProfile().isTablet; + boolean isTablet = mActivity.getDeviceProfile().isTablet; boolean splittingFromOverview = fadeWithThumbnail; SplitAnimationTimings timings; @@ -274,7 +276,7 @@ public class FloatingTaskView extends FrameLayout { public void addConfirmAnimation(PendingAnimation animation, RectF startingBounds, Rect endBounds, boolean fadeWithThumbnail, boolean isStagedTask) { SplitAnimationTimings timings = - AnimUtils.getDeviceSplitToConfirmTimings(mContainer.getDeviceProfile().isTablet); + AnimUtils.getDeviceSplitToConfirmTimings(mActivity.getDeviceProfile().isTablet); addAnimation(animation, startingBounds, endBounds, fadeWithThumbnail, isStagedTask, timings); @@ -289,7 +291,7 @@ public class FloatingTaskView extends FrameLayout { Rect endBounds, boolean fadeWithThumbnail, boolean isStagedTask, SplitAnimationTimings timings) { mFullscreenParams.setIsStagedTask(isStagedTask); - final BaseDragLayer dragLayer = mContainer.getDragLayer(); + final BaseDragLayer dragLayer = mActivity.getDragLayer(); int[] dragLayerBounds = new int[2]; dragLayer.getLocationOnScreen(dragLayerBounds); SplitOverlayProperties prop = new SplitOverlayProperties(endBounds, @@ -389,7 +391,7 @@ public class FloatingTaskView extends FrameLayout { mOrientationHandler.updateSplitIconParams(iconView, onScreenRectCenterX, onScreenRectCenterY, mFullscreenParams.mScaleX, mFullscreenParams.mScaleY, iconView.getDrawableWidth(), iconView.getDrawableHeight(), - mContainer.getDeviceProfile(), mStagePosition); + mActivity.getDeviceProfile(), mStagePosition); } public int getStagePosition() { diff --git a/quickstep/src/com/android/quickstep/views/FloatingWidgetView.java b/quickstep/src/com/android/quickstep/views/FloatingWidgetView.java index 4dde635da7..486fc2cf08 100644 --- a/quickstep/src/com/android/quickstep/views/FloatingWidgetView.java +++ b/quickstep/src/com/android/quickstep/views/FloatingWidgetView.java @@ -33,10 +33,10 @@ import android.widget.FrameLayout; import androidx.annotation.Nullable; +import com.android.launcher3.Launcher; import com.android.launcher3.R; import com.android.launcher3.Utilities; import com.android.launcher3.dragndrop.DragLayer; -import com.android.launcher3.uioverrides.QuickstepLauncher; import com.android.launcher3.util.Themes; import com.android.launcher3.views.FloatingView; import com.android.launcher3.views.ListenerView; @@ -49,7 +49,7 @@ public class FloatingWidgetView extends FrameLayout implements AnimatorListener, OnGlobalLayoutListener, FloatingView { private static final Matrix sTmpMatrix = new Matrix(); - private final QuickstepLauncher mLauncher; + private final Launcher mLauncher; private final ListenerView mListenerView; private final FloatingWidgetBackgroundView mBackgroundView; private final RectF mBackgroundOffset = new RectF(); @@ -80,7 +80,7 @@ public class FloatingWidgetView extends FrameLayout implements AnimatorListener, public FloatingWidgetView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); - mLauncher = QuickstepLauncher.getLauncher(context); + mLauncher = Launcher.getLauncher(context); mListenerView = new ListenerView(context, attrs); mBackgroundView = new FloatingWidgetBackgroundView(context, attrs, defStyleAttr); addView(mBackgroundView); @@ -283,7 +283,7 @@ public class FloatingWidgetView extends FrameLayout implements AnimatorListener, * @param windowSize the size of the window when launched * @param windowCornerRadius the corner radius of the window */ - public static FloatingWidgetView getFloatingWidgetView(QuickstepLauncher launcher, + public static FloatingWidgetView getFloatingWidgetView(Launcher launcher, LauncherAppWidgetHostView originalView, RectF widgetBackgroundPosition, Size windowSize, float windowCornerRadius, boolean appTargetsAreTranslucent, int fallbackBackgroundColor) { diff --git a/quickstep/src/com/android/quickstep/views/GroupedTaskView.java b/quickstep/src/com/android/quickstep/views/GroupedTaskView.java index 9e1c856455..259927d4e7 100644 --- a/quickstep/src/com/android/quickstep/views/GroupedTaskView.java +++ b/quickstep/src/com/android/quickstep/views/GroupedTaskView.java @@ -41,11 +41,11 @@ import com.android.systemui.shared.recents.utilities.PreviewPositionHelper; import com.android.systemui.shared.system.InteractionJankMonitorWrapper; import com.android.wm.shell.common.split.SplitScreenConstants.PersistentSnapPosition; -import kotlin.Unit; - import java.util.HashMap; import java.util.function.Consumer; +import kotlin.Unit; + /** * TaskView that contains and shows thumbnails for not one, BUT TWO(!!) tasks * @@ -81,7 +81,7 @@ public class GroupedTaskView extends TaskView { public GroupedTaskView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); - mDigitalWellBeingToast2 = new DigitalWellBeingToast(mContainer, this); + mDigitalWellBeingToast2 = new DigitalWellBeingToast(mActivity, this); } @Override @@ -356,7 +356,7 @@ public class GroupedTaskView extends TaskView { if (initSplitTaskId == INVALID_TASK_ID) { getPagedOrientationHandler().measureGroupedTaskViewThumbnailBounds(mSnapshotView, mSnapshotView2, widthSize, heightSize, mSplitBoundsConfig, - mContainer.getDeviceProfile(), getLayoutDirection() == LAYOUT_DIRECTION_RTL); + mActivity.getDeviceProfile(), getLayoutDirection() == LAYOUT_DIRECTION_RTL); // Should we be having a separate translation step apart from the measuring above? // The following only applies to large screen for now, but for future reference // we'd want to abstract this out in PagedViewHandlers to get the primary/secondary @@ -373,7 +373,7 @@ public class GroupedTaskView extends TaskView { container.getThumbnailView().measure(widthMeasureSpec, View.MeasureSpec.makeMeasureSpec( heightSize - - mContainer.getDeviceProfile().overviewTaskThumbnailTopMarginPx, + mActivity.getDeviceProfile().overviewTaskThumbnailTopMarginPx, MeasureSpec.EXACTLY)); } if (!enableOverviewIconMenu()) { @@ -392,7 +392,7 @@ public class GroupedTaskView extends TaskView { @Override public void setOrientationState(RecentsOrientedState orientationState) { - DeviceProfile deviceProfile = mContainer.getDeviceProfile(); + DeviceProfile deviceProfile = mActivity.getDeviceProfile(); if (enableOverviewIconMenu() && mSplitBoundsConfig != null) { ViewGroup.LayoutParams layoutParams = getLayoutParams(); Pair groupedTaskViewSizes = @@ -425,7 +425,7 @@ public class GroupedTaskView extends TaskView { return; } - DeviceProfile deviceProfile = mContainer.getDeviceProfile(); + DeviceProfile deviceProfile = mActivity.getDeviceProfile(); int taskIconHeight = deviceProfile.overviewTaskIconSizePx; boolean isRtl = getLayoutDirection() == LAYOUT_DIRECTION_RTL; diff --git a/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java b/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java index 06c2aa3804..352ebfe7b0 100644 --- a/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java +++ b/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java @@ -72,7 +72,7 @@ public class LauncherRecentsView extends RecentsView getStateManager() { - return mContainer.getStateManager(); + return mActivity.canStartHomeSafely(); } @Override protected void onTaskLaunchAnimationEnd(boolean success) { if (success) { - getStateManager().moveToRestState(); + mActivity.getStateManager().moveToRestState(); } else { - LauncherState state = getStateManager().getState(); - mContainer.getAllAppsController().setState(state); + LauncherState state = mActivity.getStateManager().getState(); + mActivity.getAllAppsController().setState(state); } super.onTaskLaunchAnimationEnd(success); } @@ -120,14 +115,14 @@ public class LauncherRecentsView extends RecentsView : the container that should host recents view - * @param : the type of base state that will be used */ - -public abstract class RecentsView, STATE_TYPE extends BaseState> extends PagedView implements Insettable, TaskThumbnailCache.HighResLoadingState.HighResLoadingStateChangedCallback, TaskVisualsChangeListener { @@ -446,7 +444,7 @@ public abstract class RecentsView mSizeStrategy; + protected final BaseActivityInterface mSizeStrategy; @Nullable protected RecentsAnimationController mRecentsAnimationController; @Nullable @@ -483,7 +481,7 @@ public abstract class RecentsView { - Animator animatorFade = getStateManager().createStateElementAnimation( + Animator animatorFade = mActivity.getStateManager().createStateElementAnimation( RecentsAtomicAnimationFactory.INDEX_RECENTS_FADE_ANIM, 1f, 0f); - Animator animatorAppear = getStateManager().createStateElementAnimation( + Animator animatorAppear = mActivity.getStateManager().createStateElementAnimation( RecentsAtomicAnimationFactory.INDEX_RECENTS_FADE_ANIM, 0f, 1f); animatorFade.addListener(new AnimatorListenerAdapter() { @Override @@ -1091,13 +1089,13 @@ public abstract class RecentsView remoteTargetHandle.getTransformParams() .setSyncTransactionApplier(mSyncTransactionApplier)); RecentsModel.INSTANCE.get(getContext()).addThumbnailChangeListener(this); - mIPipAnimationListener.setActivityAndRecentsView(mContainer, this); + mIPipAnimationListener.setActivityAndRecentsView(mActivity, this); SystemUiProxy.INSTANCE.get(getContext()).setPipAnimationListener( mIPipAnimationListener); mOrientationState.initListeners(); @@ -1112,7 +1110,7 @@ public abstract class RecentsView remoteTargetHandle.getTransformParams() @@ -1252,7 +1250,7 @@ public abstract class RecentsView= 0; --i) { RemoteAnimationTarget app = apps[i]; - float dx = mContainer.getDeviceProfile().widthPx * (1 - percent) / 2 + float dx = mActivity.getDeviceProfile().widthPx * (1 - percent) / 2 + app.screenSpaceBounds.left * percent; - float dy = mContainer.getDeviceProfile().heightPx * (1 - percent) / 2 + float dy = mActivity.getDeviceProfile().heightPx * (1 - percent) / 2 + app.screenSpaceBounds.top * percent; matrix.setScale(percent, percent); matrix.postTranslate(dx, dy); @@ -1297,7 +1295,7 @@ public abstract class RecentsView 0) { @@ -1498,7 +1496,7 @@ public abstract class RecentsView getStateManager(); - public void reset() { setCurrentTask(-1); mCurrentPageScrollDiff = 0; @@ -2623,7 +2619,7 @@ public abstract class RecentsView { setLayoutRotation(newRotation, mOrientationState.getDisplayRotation()); - mContainer.getDragLayer().recreateControllers(); + mActivity.getDragLayer().recreateControllers(); setRecentsChangedOrientation(false).start(); })); pa.start(); @@ -2652,7 +2648,7 @@ public abstract class RecentsView endState = mSizeStrategy.stateFromGestureEndTarget(endTarget); - if (endState.displayOverviewTasksAsGrid(mContainer.getDeviceProfile())) { + if (endState.displayOverviewTasksAsGrid(mActivity.getDeviceProfile())) { TaskView runningTaskView = getRunningTaskView(); float runningTaskPrimaryGridTranslation = 0; float runningTaskSecondaryGridTranslation = 0; @@ -2936,7 +2932,7 @@ public abstract class RecentsView mSplitSelectStateController.getSplitAnimationController(). - playAnimPlaceholderToFullscreen(mContainer, view, + playAnimPlaceholderToFullscreen(mActivity, view, Optional.of(() -> resetFromSplitSelectionState()))); // SplitInstructionsView: animate in safeRemoveDragLayerView(mSplitSelectStateController.getSplitInstructionsView()); SplitInstructionsView splitInstructionsView = - SplitInstructionsView.getSplitInstructionsView(mContainer); + SplitInstructionsView.getSplitInstructionsView(mActivity); splitInstructionsView.setAlpha(0); anim.setViewAlpha(splitInstructionsView, 1, clampToProgress(LINEAR, timings.getInstructionsContainerFadeInStartOffset(), @@ -3451,7 +3447,7 @@ public abstract class RecentsView mContainer.getDisplay().getRotation()); + "RecentsView.updateRecentsRotation", () -> mActivity.getDisplay().getRotation()); mOrientationState.setRecentsRotation(rotation); } @@ -4424,14 +4420,14 @@ public abstract class RecentsView{ @@ -4832,14 +4828,14 @@ public abstract class RecentsView, FloatProperty> taskViewsFloat = orientationHandler.getSplitSelectTaskOffset( TASK_PRIMARY_SPLIT_TRANSLATION, TASK_SECONDARY_SPLIT_TRANSLATION, - mContainer.getDeviceProfile()); + mActivity.getDeviceProfile()); taskViewsFloat.first.set(this, getSplitSelectTranslation()); taskViewsFloat.second.set(this, 0f); @@ -5124,10 +5120,10 @@ public abstract class RecentsView UPDATE_SYSUI_FLAGS_THRESHOLD) { - mContainer.getSystemUiController().updateUiState( + mActivity.getSystemUiController().updateUiState( UI_STATE_FULLSCREEN_TASK, targetSysUiFlags); } else { - mContainer.getSystemUiController().updateUiState(UI_STATE_FULLSCREEN_TASK, 0); + mActivity.getSystemUiController().updateUiState(UI_STATE_FULLSCREEN_TASK, 0); } // Passing the threshold from taskview to fullscreen app will vibrate @@ -5189,7 +5185,7 @@ public abstract class RecentsView extends + private static class PinnedStackAnimationListener extends IPipAnimationListener.Stub { @Nullable private T mActivity; @@ -6208,7 +6204,7 @@ public abstract class RecentsView mContainer.setLocusContext(id, Bundle.EMPTY)); + UI_HELPER_EXECUTOR.post(() -> mActivity.setLocusContext(id, Bundle.EMPTY)); } /** diff --git a/quickstep/src/com/android/quickstep/views/SplitInstructionsView.java b/quickstep/src/com/android/quickstep/views/SplitInstructionsView.java index a56d51e515..a3e5a35fbb 100644 --- a/quickstep/src/com/android/quickstep/views/SplitInstructionsView.java +++ b/quickstep/src/com/android/quickstep/views/SplitInstructionsView.java @@ -43,7 +43,6 @@ import com.android.launcher3.statemanager.BaseState; import com.android.launcher3.statemanager.StateManager; import com.android.launcher3.statemanager.StatefulActivity; import com.android.launcher3.states.StateAnimationConfig; - import com.android.quickstep.util.SplitSelectStateController; /** @@ -58,7 +57,7 @@ public class SplitInstructionsView extends LinearLayout { private static final float BOUNCE_HEIGHT = 20; private static final int DURATION_DEFAULT_SPLIT_DISMISS = 350; - private final RecentsViewContainer mContainer; + private final StatefulActivity mLauncher; public boolean mIsCurrentlyAnimating = false; public static final FloatProperty UNFOLD = @@ -97,13 +96,13 @@ public class SplitInstructionsView extends LinearLayout { public SplitInstructionsView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); - mContainer = RecentsViewContainer.containerFromContext(context); + mLauncher = (StatefulActivity) context; } - public static SplitInstructionsView getSplitInstructionsView(RecentsViewContainer container) { - ViewGroup dragLayer = container.getDragLayer(); + public static SplitInstructionsView getSplitInstructionsView(StatefulActivity launcher) { + ViewGroup dragLayer = launcher.getDragLayer(); final SplitInstructionsView splitInstructionsView = - (SplitInstructionsView) container.getLayoutInflater().inflate( + (SplitInstructionsView) launcher.getLayoutInflater().inflate( R.layout.split_instructions_view, dragLayer, false @@ -140,12 +139,12 @@ public class SplitInstructionsView extends LinearLayout { } private void exitSplitSelection() { - RecentsView recentsView = mContainer.getOverviewPanel(); - SplitSelectStateController splitSelectController = recentsView.getSplitSelectController(); + SplitSelectStateController splitSelectController = + ((RecentsView) mLauncher.getOverviewPanel()).getSplitSelectController(); - StateManager stateManager = recentsView.getStateManager(); + StateManager stateManager = mLauncher.getStateManager(); BaseState startState = stateManager.getState(); - long duration = startState.getTransitionDuration(mContainer.asContext(), false); + long duration = startState.getTransitionDuration(mLauncher, false); if (duration == 0) { // Case where we're in contextual on workspace (NORMAL), which by default has 0 // transition duration @@ -156,7 +155,7 @@ public class SplitInstructionsView extends LinearLayout { AnimatorSet stateAnim = stateManager.createAtomicAnimation( startState, NORMAL, config); AnimatorSet dismissAnim = splitSelectController.getSplitAnimationController() - .createPlaceholderDismissAnim(mContainer, + .createPlaceholderDismissAnim(mLauncher, LAUNCHER_SPLIT_SELECTION_EXIT_CANCEL_BUTTON, duration); stateAnim.play(dismissAnim); stateManager.setCurrentAnimation(stateAnim, NORMAL); @@ -164,10 +163,10 @@ public class SplitInstructionsView extends LinearLayout { } void ensureProperRotation() { - ((RecentsView) mContainer.getOverviewPanel()).getPagedOrientationHandler() + ((RecentsView) mLauncher.getOverviewPanel()).getPagedOrientationHandler() .setSplitInstructionsParams( this, - mContainer.getDeviceProfile(), + mLauncher.getDeviceProfile(), getMeasuredHeight(), getMeasuredWidth() ); diff --git a/quickstep/src/com/android/quickstep/views/TaskMenuView.java b/quickstep/src/com/android/quickstep/views/TaskMenuView.java index fcbb45b9e2..956dd263a2 100644 --- a/quickstep/src/com/android/quickstep/views/TaskMenuView.java +++ b/quickstep/src/com/android/quickstep/views/TaskMenuView.java @@ -46,6 +46,7 @@ import androidx.annotation.Nullable; import com.android.app.animation.Interpolators; import com.android.launcher3.AbstractFloatingView; +import com.android.launcher3.BaseDraggingActivity; import com.android.launcher3.DeviceProfile; import com.android.launcher3.R; import com.android.launcher3.anim.AnimationSuccessListener; @@ -68,7 +69,7 @@ public class TaskMenuView extends AbstractFloatingView { private static final int REVEAL_OPEN_DURATION = enableOverviewIconMenu() ? 417 : 150; private static final int REVEAL_CLOSE_DURATION = enableOverviewIconMenu() ? 333 : 100; - private RecentsViewContainer mContainer; + private BaseDraggingActivity mActivity; private TextView mTaskName; @Nullable private AnimatorSet mOpenCloseAnimator; @@ -88,7 +89,7 @@ public class TaskMenuView extends AbstractFloatingView { public TaskMenuView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); - mContainer = RecentsViewContainer.containerFromContext(context); + mActivity = BaseDraggingActivity.fromContext(context); setClipToOutline(true); } @@ -102,7 +103,7 @@ public class TaskMenuView extends AbstractFloatingView { @Override public boolean onControllerInterceptTouchEvent(MotionEvent ev) { if (ev.getAction() == MotionEvent.ACTION_DOWN) { - BaseDragLayer dl = mContainer.getDragLayer(); + BaseDragLayer dl = mActivity.getDragLayer(); if (!dl.isEventOverView(this, ev)) { // TODO: log this once we have a new container type for it? close(true); @@ -140,7 +141,7 @@ public class TaskMenuView extends AbstractFloatingView { @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { if (!(enableOverviewIconMenu() - && ((RecentsView) mContainer.getOverviewPanel()).isOnGridBottomRow(mTaskView))) { + && ((RecentsView) mActivity.getOverviewPanel()).isOnGridBottomRow(mTaskView))) { // TODO(b/326952853): Cap menu height for grid bottom row in a way that doesn't break // additionalTranslationY. int maxMenuHeight = calculateMaxHeight(); @@ -165,10 +166,10 @@ public class TaskMenuView extends AbstractFloatingView { public static boolean showForTask(TaskIdAttributeContainer taskContainer, @Nullable Runnable onClosingStartCallback) { - RecentsViewContainer container = RecentsViewContainer.containerFromContext( + BaseDraggingActivity activity = BaseDraggingActivity.fromContext( taskContainer.getTaskView().getContext()); - final TaskMenuView taskMenuView = (TaskMenuView) container.getLayoutInflater().inflate( - R.layout.task_menu, container.getDragLayer(), false); + final TaskMenuView taskMenuView = (TaskMenuView) activity.getLayoutInflater().inflate( + R.layout.task_menu, activity.getDragLayer(), false); taskMenuView.setOnClosingStartCallback(onClosingStartCallback); return taskMenuView.populateAndShowForTask(taskContainer); } @@ -181,7 +182,7 @@ public class TaskMenuView extends AbstractFloatingView { if (isAttachedToWindow()) { return false; } - mContainer.getDragLayer().addView(this); + mActivity.getDragLayer().addView(this); mTaskView = taskContainer.getTaskView(); mTaskContainer = taskContainer; if (!populateAndLayoutMenu()) { @@ -214,7 +215,7 @@ public class TaskMenuView extends AbstractFloatingView { } private void addMenuOption(SystemShortcut menuOption) { - LinearLayout menuOptionView = (LinearLayout) mContainer.getLayoutInflater().inflate( + LinearLayout menuOptionView = (LinearLayout) mActivity.getLayoutInflater().inflate( R.layout.task_view_menu_option, this, false); if (enableOverviewIconMenu()) { ((GradientDrawable) menuOptionView.getBackground()).setCornerRadius(0); @@ -223,7 +224,7 @@ public class TaskMenuView extends AbstractFloatingView { menuOptionView.findViewById(R.id.icon), menuOptionView.findViewById(R.id.text)); LayoutParams lp = (LayoutParams) menuOptionView.getLayoutParams(); mTaskView.getPagedOrientationHandler().setLayoutParamsForTaskMenuOptionItem(lp, - menuOptionView, mContainer.getDeviceProfile()); + menuOptionView, mActivity.getDeviceProfile()); // Set an onClick listener on each menu option. The onClick method is responsible for // ending LiveTile mode on the thumbnail if needed. menuOptionView.setOnClickListener(menuOption::onClick); @@ -231,19 +232,19 @@ public class TaskMenuView extends AbstractFloatingView { } private void orientAroundTaskView(TaskIdAttributeContainer taskContainer) { - RecentsView recentsView = mContainer.getOverviewPanel(); + RecentsView recentsView = mActivity.getOverviewPanel(); RecentsPagedOrientationHandler orientationHandler = recentsView.getPagedOrientationHandler(); measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED); // Get Position - DeviceProfile deviceProfile = mContainer.getDeviceProfile(); - mContainer.getDragLayer().getDescendantRectRelativeToSelf( + DeviceProfile deviceProfile = mActivity.getDeviceProfile(); + mActivity.getDragLayer().getDescendantRectRelativeToSelf( enableOverviewIconMenu() ? getIconView().findViewById(R.id.icon_view_menu_anchor) : taskContainer.getThumbnailView(), sTempRect); - Rect insets = mContainer.getDragLayer().getInsets(); + Rect insets = mActivity.getDragLayer().getInsets(); BaseDragLayer.LayoutParams params = (BaseDragLayer.LayoutParams) getLayoutParams(); params.width = orientationHandler.getTaskMenuWidth(taskContainer.getThumbnailView(), deviceProfile, taskContainer.getStagePosition()); @@ -324,12 +325,12 @@ public class TaskMenuView extends AbstractFloatingView { IconAppChipView iconAppChip = (IconAppChipView) mTaskContainer.getIconView().asView(); float additionalTranslationY = 0; - if (((RecentsView) mContainer.getOverviewPanel()).isOnGridBottomRow(mTaskView)) { + if (((RecentsView) mActivity.getOverviewPanel()).isOnGridBottomRow(mTaskView)) { // Animate menu up for enough room to display full menu when task on bottom row. float menuBottom = getHeight() + mMenuTranslationYBeforeOpen; float taskBottom = mTaskView.getHeight() + mTaskView.getPersistentTranslationY(); - float taskbarTop = mContainer.getDeviceProfile().heightPx - - mContainer.getDeviceProfile().getOverviewActionsClaimedSpaceBelow(); + float taskbarTop = mActivity.getDeviceProfile().heightPx + - mActivity.getDeviceProfile().getOverviewActionsClaimedSpaceBelow(); float midpoint = (taskBottom + taskbarTop) / 2f; additionalTranslationY = -Math.max(menuBottom - midpoint, 0); } @@ -344,11 +345,11 @@ public class TaskMenuView extends AbstractFloatingView { menuTranslationYAnim.setInterpolator(EMPHASIZED); float additionalTranslationX = 0; - if (mContainer.getDeviceProfile().isLandscape + if (mActivity.getDeviceProfile().isLandscape && mTaskContainer.getStagePosition() == STAGE_POSITION_BOTTOM_OR_RIGHT) { // Animate menu and icon when split task would display off the side of the screen. additionalTranslationX = Math.max( - getTranslationX() + getWidth() - (mContainer.getDeviceProfile().widthPx + getTranslationX() + getWidth() - (mActivity.getDeviceProfile().widthPx - getResources().getDimensionPixelSize( R.dimen.task_menu_edge_padding) * 2), 0); } @@ -409,7 +410,7 @@ public class TaskMenuView extends AbstractFloatingView { private void closeComplete() { testLogD(TEST_TAPL_OVERVIEW_ACTIONS_MENU_FAILURE, "TaskMenuView.java.closeComplete"); mIsOpen = false; - mContainer.getDragLayer().removeView(this); + mActivity.getDragLayer().removeView(this); mRevealAnimator = null; } @@ -432,7 +433,7 @@ public class TaskMenuView extends AbstractFloatingView { private int calculateMaxHeight() { float taskInsetMargin = getResources().getDimension(R.dimen.task_card_margin); return mTaskView.getPagedOrientationHandler().getTaskMenuHeight(taskInsetMargin, - mContainer.getDeviceProfile(), getTranslationX(), getTranslationY()); + mActivity.getDeviceProfile(), getTranslationX(), getTranslationY()); } private void setOnClosingStartCallback(Runnable onClosingStartCallback) { diff --git a/quickstep/src/com/android/quickstep/views/TaskMenuViewWithArrow.kt b/quickstep/src/com/android/quickstep/views/TaskMenuViewWithArrow.kt index c124f03228..dcf681c345 100644 --- a/quickstep/src/com/android/quickstep/views/TaskMenuViewWithArrow.kt +++ b/quickstep/src/com/android/quickstep/views/TaskMenuViewWithArrow.kt @@ -29,6 +29,7 @@ import android.view.View import android.view.ViewGroup import android.widget.FrameLayout import android.widget.LinearLayout +import com.android.launcher3.BaseDraggingActivity import com.android.launcher3.DeviceProfile import com.android.launcher3.InsettableFrameLayout import com.android.launcher3.R @@ -39,22 +40,24 @@ import com.android.launcher3.util.Themes import com.android.quickstep.TaskOverlayFactory import com.android.quickstep.views.TaskView.TaskIdAttributeContainer -class TaskMenuViewWithArrow : ArrowPopup where T : RecentsViewContainer, T : Context { +class TaskMenuViewWithArrow : ArrowPopup { companion object { const val TAG = "TaskMenuViewWithArrow" - fun showForTask( + fun showForTask( taskContainer: TaskIdAttributeContainer, alignedOptionIndex: Int = 0 - ): Boolean where T : RecentsViewContainer, T : Context { - val container: RecentsViewContainer = - RecentsViewContainer.containerFromContext(taskContainer.taskView.context) + ): Boolean { + val activity = + BaseDraggingActivity.fromContext( + taskContainer.taskView.context + ) val taskMenuViewWithArrow = - container.layoutInflater.inflate( + activity.layoutInflater.inflate( R.layout.task_menu_with_arrow, - container.dragLayer, + activity.dragLayer, false - ) as TaskMenuViewWithArrow + ) as TaskMenuViewWithArrow<*> return taskMenuViewWithArrow.populateAndShowForTask(taskContainer, alignedOptionIndex) } diff --git a/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java b/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java index 7e4673939a..077247b09a 100644 --- a/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java +++ b/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java @@ -48,6 +48,7 @@ import androidx.annotation.Nullable; import androidx.annotation.RequiresApi; import androidx.core.graphics.ColorUtils; +import com.android.launcher3.BaseActivity; import com.android.launcher3.DeviceProfile; import com.android.launcher3.Utilities; import com.android.launcher3.util.MainThreadInitializedObject; @@ -121,7 +122,7 @@ public class TaskThumbnailView extends View { } }; - private final RecentsViewContainer mContainer; + private final BaseActivity mActivity; @Nullable private TaskOverlay mOverlay; private final Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); @@ -170,7 +171,7 @@ public class TaskThumbnailView extends View { mBackgroundPaint.setColor(Color.WHITE); mSplashBackgroundPaint.setColor(Color.WHITE); mClearPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR)); - mContainer = RecentsViewContainer.containerFromContext(context); + mActivity = BaseActivity.fromContext(context); // Initialize with placeholder value. It is overridden later by TaskView mFullscreenParams = TEMP_PARAMS.get(context); @@ -307,7 +308,7 @@ public class TaskThumbnailView extends View { RectF boundsInBitmapSpace = new RectF(); boundsToBitmapSpace.mapRect(boundsInBitmapSpace, viewRect); - DeviceProfile dp = mContainer.getDeviceProfile(); + DeviceProfile dp = mActivity.getDeviceProfile(); int bottomInset = dp.isTablet ? Math.round(bitmapRect.bottom - boundsInBitmapSpace.bottom) : 0; return Insets.of(0, 0, 0, bottomInset); @@ -548,7 +549,7 @@ public class TaskThumbnailView extends View { } private void updateThumbnailMatrix() { - DeviceProfile dp = mContainer.getDeviceProfile(); + DeviceProfile dp = mActivity.getDeviceProfile(); mPreviewPositionHelper.setOrientationChanged(false); if (mBitmapShader != null && mThumbnailData != null) { mPreviewRect.set(0, 0, mThumbnailData.thumbnail.getWidth(), diff --git a/quickstep/src/com/android/quickstep/views/TaskView.java b/quickstep/src/com/android/quickstep/views/TaskView.java index ec571154a0..5338d814bf 100644 --- a/quickstep/src/com/android/quickstep/views/TaskView.java +++ b/quickstep/src/com/android/quickstep/views/TaskView.java @@ -87,6 +87,7 @@ import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.model.data.WorkspaceItemInfo; import com.android.launcher3.pm.UserCache; import com.android.launcher3.popup.SystemShortcut; +import com.android.launcher3.statemanager.StatefulActivity; import com.android.launcher3.testing.TestLogging; import com.android.launcher3.testing.shared.TestProtocol; import com.android.launcher3.util.ActivityOptionsWrapper; @@ -118,6 +119,8 @@ import com.android.systemui.shared.recents.model.ThumbnailData; import com.android.systemui.shared.system.ActivityManagerWrapper; import com.android.systemui.shared.system.QuickStepContract; +import kotlin.Unit; + import java.lang.annotation.Retention; import java.util.Arrays; import java.util.Collections; @@ -126,8 +129,6 @@ import java.util.List; import java.util.function.Consumer; import java.util.stream.Stream; -import kotlin.Unit; - /** * A task in the Recents view. */ @@ -334,7 +335,7 @@ public class TaskView extends FrameLayout implements Reusable { private float mNonGridScale = 1; private float mDismissScale = 1; protected final FullscreenDrawParams mCurrentFullscreenParams; - protected final RecentsViewContainer mContainer; + protected final StatefulActivity mActivity; // Various causes of changing primary translation, which we aggregate to setTranslationX/Y(). private float mDismissTranslationX; @@ -416,11 +417,11 @@ public class TaskView extends FrameLayout implements Reusable { int defStyleRes, BorderAnimator focusBorderAnimator, BorderAnimator hoverBorderAnimator) { super(context, attrs, defStyleAttr, defStyleRes); - mContainer = RecentsViewContainer.containerFromContext(context); + mActivity = StatefulActivity.fromContext(context); setOnClickListener(this::onClick); mCurrentFullscreenParams = new FullscreenDrawParams(context); - mDigitalWellBeingToast = new DigitalWellBeingToast(mContainer, this); + mDigitalWellBeingToast = new DigitalWellBeingToast(mActivity, this); boolean keyboardFocusHighlightEnabled = FeatureFlags.ENABLE_KEYBOARD_QUICK_SWITCH.get() || Flags.enableFocusOutline(); @@ -616,7 +617,7 @@ public class TaskView extends FrameLayout implements Reusable { float viewHalfHeight = view.getHeight() / 2f; tempCenterCoords[0] = viewHalfWidth; tempCenterCoords[1] = viewHalfHeight; - getDescendantCoordRelativeToAncestor(view.asView(), mContainer.getDragLayer(), + getDescendantCoordRelativeToAncestor(view.asView(), mActivity.getDragLayer(), tempCenterCoords, false); transformingTouchDelegate.setBounds( (int) (tempCenterCoords[0] - viewHalfWidth), @@ -828,7 +829,7 @@ public class TaskView extends FrameLayout implements Reusable { if (callbackList != null) { callbackList.add(() -> Log.d("b/310064698", mTask + " - onClick - launchCompleted")); } - mContainer.getStatsLogManager().logger().withItemInfo(getItemInfo()) + mActivity.getStatsLogManager().logger().withItemInfo(getItemInfo()) .log(LAUNCHER_TASK_LAUNCH_TAP); } @@ -870,7 +871,7 @@ public class TaskView extends FrameLayout implements Reusable { "TaskView.launchTaskAnimated: startActivityFromRecentsAsync"); TestLogging.recordEvent( TestProtocol.SEQUENCE_MAIN, "startActivityFromRecentsAsync", mTask); - ActivityOptionsWrapper opts = mContainer.getActivityLaunchOptions(this, null); + ActivityOptionsWrapper opts = mActivity.getActivityLaunchOptions(this, null); opts.options.setLaunchDisplayId( getDisplay() == null ? DEFAULT_DISPLAY : getDisplay().getDisplayId()); if (ActivityManagerWrapper.getInstance() @@ -928,7 +929,7 @@ public class TaskView extends FrameLayout implements Reusable { // We only listen for failures to launch in quickswitch because the during this // gesture launcher is in the background state, vs other launches which are in // the actual overview state - failureListener.register(mContainer, mTask.key.id, () -> { + failureListener.register(mActivity, mTask.key.id, () -> { notifyTaskLaunchFailed(TAG); RecentsView rv = getRecentsView(); if (rv != null) { @@ -1031,7 +1032,7 @@ public class TaskView extends FrameLayout implements Reusable { TaskViewUtils.composeRecentsLaunchAnimator( anim, this, targets.apps, targets.wallpapers, targets.nonApps, true /* launcherClosing */, - recentsView.getStateManager(), recentsView, + mActivity.getStateManager(), recentsView, recentsView.getDepthController()); anim.addListener(new AnimatorListenerAdapter() { @Override @@ -1142,12 +1143,12 @@ public class TaskView extends FrameLayout implements Reusable { return true; } - if (!mContainer.getDeviceProfile().isTablet + if (!mActivity.getDeviceProfile().isTablet && !getRecentsView().isClearAllHidden()) { getRecentsView().snapToPage(getRecentsView().indexOfChild(this)); return false; } else { - mContainer.getStatsLogManager().logger().withItemInfo(getItemInfo()) + mActivity.getStatsLogManager().logger().withItemInfo(getItemInfo()) .log(LAUNCHER_TASK_ICON_TAP_OR_LONGPRESS); return showTaskMenuWithContainer(iconView); } @@ -1156,7 +1157,7 @@ public class TaskView extends FrameLayout implements Reusable { protected boolean showTaskMenuWithContainer(TaskViewIcon iconView) { TaskIdAttributeContainer menuContainer = mTaskIdAttributeContainer[iconView == mIconView ? 0 : 1]; - DeviceProfile dp = mContainer.getDeviceProfile(); + DeviceProfile dp = mActivity.getDeviceProfile(); if (enableOverviewIconMenu() && iconView instanceof IconAppChipView) { ((IconAppChipView) iconView).revealAnim(/* isRevealing= */ true); return TaskMenuView.showForTask(menuContainer, @@ -1210,7 +1211,7 @@ public class TaskView extends FrameLayout implements Reusable { } protected void setThumbnailOrientation(RecentsOrientedState orientationState) { - DeviceProfile deviceProfile = mContainer.getDeviceProfile(); + DeviceProfile deviceProfile = mActivity.getDeviceProfile(); int thumbnailTopMargin = deviceProfile.overviewTaskThumbnailTopMarginPx; // TODO(b/271468547), we should default to setting trasnlations only on the snapshot instead @@ -1227,7 +1228,7 @@ public class TaskView extends FrameLayout implements Reusable { * Returns whether the task is part of overview grid and not being focused. */ public boolean isGridTask() { - DeviceProfile deviceProfile = mContainer.getDeviceProfile(); + DeviceProfile deviceProfile = mActivity.getDeviceProfile(); return deviceProfile.isTablet && !isFocusedTask(); } @@ -1334,7 +1335,7 @@ public class TaskView extends FrameLayout implements Reusable { @Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { super.onLayout(changed, left, top, right, bottom); - if (mContainer.getDeviceProfile().isTablet) { + if (mActivity.getDeviceProfile().isTablet) { setPivotX(getLayoutDirection() == LAYOUT_DIRECTION_RTL ? 0 : right - left); setPivotY(mSnapshotView.getTop()); } else { @@ -1691,10 +1692,10 @@ public class TaskView extends FrameLayout implements Reusable { mFullscreenProgress = progress; mIconView.setVisibility(progress < 1 ? VISIBLE : INVISIBLE); mSnapshotView.getTaskOverlay().setFullscreenProgress(progress); - RecentsView recentsView = mContainer.getOverviewPanel(); + // Animate icons and DWB banners in/out, except in QuickSwitch state, when tiles are // oversized and banner would look disproportionately large. - if (recentsView.getStateManager().getState() != BACKGROUND_APP) { + if (mActivity.getStateManager().getState() != BACKGROUND_APP) { setIconsAndBannersTransitionProgress(progress, true); } @@ -1728,7 +1729,7 @@ public class TaskView extends FrameLayout implements Reusable { float boxTranslationY; int expectedWidth; int expectedHeight; - DeviceProfile deviceProfile = mContainer.getDeviceProfile(); + DeviceProfile deviceProfile = mActivity.getDeviceProfile(); final int thumbnailPadding = deviceProfile.overviewTaskThumbnailTopMarginPx; final Rect lastComputedTaskSize = getRecentsView().getLastComputedTaskSize(); final int taskWidth = lastComputedTaskSize.width(); diff --git a/quickstep/tests/multivalentTests/src/com/android/quickstep/util/SplitSelectStateControllerTest.kt b/quickstep/tests/multivalentTests/src/com/android/quickstep/util/SplitSelectStateControllerTest.kt index 0de5f197ea..a7ed8a73b2 100644 --- a/quickstep/tests/multivalentTests/src/com/android/quickstep/util/SplitSelectStateControllerTest.kt +++ b/quickstep/tests/multivalentTests/src/com/android/quickstep/util/SplitSelectStateControllerTest.kt @@ -37,7 +37,6 @@ import com.android.launcher3.util.SplitConfigurationOptions import com.android.quickstep.RecentsModel import com.android.quickstep.SystemUiProxy import com.android.quickstep.util.SplitSelectStateController.SplitFromDesktopController -import com.android.quickstep.views.RecentsViewContainer import com.android.systemui.shared.recents.model.Task import com.android.wm.shell.common.split.SplitScreenConstants.SNAP_TO_50_50 import java.util.function.Consumer @@ -64,7 +63,7 @@ class SplitSelectStateControllerTest { private val statsLogger: StatsLogger = mock() private val stateManager: StateManager = mock() private val handler: Handler = mock() - private val context: RecentsViewContainer = mock() + private val context: StatefulActivity<*> = mock() private val recentsModel: RecentsModel = mock() private val pendingIntent: PendingIntent = mock() private val splitFromDesktopController: SplitFromDesktopController = mock() diff --git a/src/com/android/launcher3/BaseDraggingActivity.java b/src/com/android/launcher3/BaseDraggingActivity.java index cf93a79c54..1c2ed4343d 100644 --- a/src/com/android/launcher3/BaseDraggingActivity.java +++ b/src/com/android/launcher3/BaseDraggingActivity.java @@ -111,6 +111,8 @@ public abstract class BaseDraggingActivity extends BaseActivity return false; } + public abstract T getOverviewPanel(); + public abstract View getRootView(); public void returnToHomescreen() { diff --git a/src/com/android/launcher3/popup/RemoteActionShortcut.java b/src/com/android/launcher3/popup/RemoteActionShortcut.java index 0860ae5743..688da4934f 100644 --- a/src/com/android/launcher3/popup/RemoteActionShortcut.java +++ b/src/com/android/launcher3/popup/RemoteActionShortcut.java @@ -33,22 +33,22 @@ import android.widget.TextView; import android.widget.Toast; import com.android.launcher3.AbstractFloatingView; +import com.android.launcher3.BaseDraggingActivity; import com.android.launcher3.R; import com.android.launcher3.Utilities; import com.android.launcher3.model.data.ItemInfo; -import com.android.launcher3.views.ActivityContext; import java.lang.ref.WeakReference; -public class RemoteActionShortcut extends SystemShortcut { +public class RemoteActionShortcut extends SystemShortcut { private static final String TAG = "RemoteActionShortcut"; private static final boolean DEBUG = Utilities.IS_DEBUG_DEVICE; private final RemoteAction mAction; public RemoteActionShortcut(RemoteAction action, - T context, ItemInfo itemInfo, View originalView) { - super(0, R.id.action_remote_action_shortcut, context, itemInfo, originalView); + BaseDraggingActivity activity, ItemInfo itemInfo, View originalView) { + super(0, R.id.action_remote_action_shortcut, activity, itemInfo, originalView); mAction = action; } @@ -80,7 +80,7 @@ public class RemoteActionShortcut extends S mTarget.getStatsLogManager().logger().withItemInfo(mItemInfo) .log(LAUNCHER_SYSTEM_SHORTCUT_PAUSE_TAP); - final WeakReference weakTarget = new WeakReference<>(mTarget); + final WeakReference weakTarget = new WeakReference<>(mTarget); final String actionIdentity = mAction.getTitle() + ", " + mItemInfo.getTargetComponent().getPackageName(); @@ -95,7 +95,7 @@ public class RemoteActionShortcut extends S mItemInfo.getTargetComponent().getPackageName()), (pendingIntent, intent, resultCode, resultData, resultExtras) -> { if (DEBUG) Log.d(TAG, "Action is complete: " + actionIdentity); - final T target = weakTarget.get(); + final BaseDraggingActivity target = weakTarget.get(); if (resultData != null && !resultData.isEmpty()) { Log.e(TAG, "Remote action returned result: " + actionIdentity + " : " + resultData); diff --git a/src/com/android/launcher3/secondarydisplay/SecondaryDisplayLauncher.java b/src/com/android/launcher3/secondarydisplay/SecondaryDisplayLauncher.java index 0299a23382..910b0293ec 100644 --- a/src/com/android/launcher3/secondarydisplay/SecondaryDisplayLauncher.java +++ b/src/com/android/launcher3/secondarydisplay/SecondaryDisplayLauncher.java @@ -199,6 +199,11 @@ public class SecondaryDisplayLauncher extends BaseDraggingActivity return mAppsView; } + @Override + public T getOverviewPanel() { + return null; + } + @Override public View getRootView() { return mDragLayer; diff --git a/src/com/android/quickstep/views/RecentsViewContainer.java b/src/com/android/quickstep/views/RecentsViewContainer.java deleted file mode 100644 index 0c3f4f1ee5..0000000000 --- a/src/com/android/quickstep/views/RecentsViewContainer.java +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Copyright (C) 2024 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.quickstep.views; - -import android.app.Activity; -import android.content.Context; -import android.content.ContextWrapper; -import android.content.LocusId; -import android.os.Bundle; -import android.view.KeyEvent; -import android.view.MotionEvent; -import android.view.View; -import android.view.Window; - -import com.android.launcher3.BaseActivity; -import com.android.launcher3.util.SystemUiController; -import com.android.launcher3.views.ActivityContext; -import com.android.launcher3.views.ScrimView; - -/** - * Interface to be implemented by the parent view of RecentsView - */ -public interface RecentsViewContainer extends ActivityContext { - - /** - * Returns an instance of an implementation of RecentsViewContainer - * @param context will find instance of recentsViewContainer from given context. - */ - static T containerFromContext(Context context) { - if (context instanceof RecentsViewContainer) { - return (T) context; - } else if (context instanceof ContextWrapper) { - return containerFromContext(((ContextWrapper) context).getBaseContext()); - } else { - throw new IllegalArgumentException("Cannot find RecentsViewContainer in parent tree"); - } - } - - /** - * Returns {@link SystemUiController} to manage various window flags to control system UI. - */ - SystemUiController getSystemUiController(); - - /** - * Returns {@link ScrimView} - */ - ScrimView getScrimView(); - - /** - * Returns the Overview Panel as a View - */ - T getOverviewPanel(); - - /** - * Returns the RootView - */ - View getRootView(); - - /** - * Dispatches a generic motion event to the view hierarchy. - * Returns the current RecentsViewContainer as context - */ - default Context asContext() { - return (Context) this; - } - - /** - * @see Window.Callback#dispatchGenericMotionEvent(MotionEvent) - */ - boolean dispatchGenericMotionEvent(MotionEvent ev); - - /** - * @see Window.Callback#dispatchKeyEvent(KeyEvent) - */ - boolean dispatchKeyEvent(KeyEvent ev); - - /** - * Returns overview actions view as a view - */ - View getActionsView(); - - /** - * @see BaseActivity#addForceInvisibleFlag(int) - * @param flag {@link BaseActivity.InvisibilityFlags} - */ - void addForceInvisibleFlag(@BaseActivity.InvisibilityFlags int flag); - - /** - * @see BaseActivity#clearForceInvisibleFlag(int) - * @param flag {@link BaseActivity.InvisibilityFlags} - */ - void clearForceInvisibleFlag(@BaseActivity.InvisibilityFlags int flag); - - /** - * @see android.app.Activity#setLocusContext(LocusId, Bundle) - * @param id {@link LocusId} - * @param bundle {@link Bundle} - */ - void setLocusContext(LocusId id, Bundle bundle); - - /** - * @see BaseActivity#isStarted() - * @return boolean - */ - boolean isStarted(); - - /** - * @see BaseActivity#addEventCallback(int, Runnable) - * @param event {@link BaseActivity.ActivityEvent} - * @param callback runnable to be executed upon event - */ - void addEventCallback(@BaseActivity.ActivityEvent int event, Runnable callback); - - /** - * @see BaseActivity#removeEventCallback(int, Runnable) - * @param event {@link BaseActivity.ActivityEvent} - * @param callback runnable to be executed upon event - */ - void removeEventCallback(@BaseActivity.ActivityEvent int event, Runnable callback); - - /** - * @see com.android.quickstep.util.TISBindHelper#runOnBindToTouchInteractionService(Runnable) - * @param r runnable to be executed upon event - */ - void runOnBindToTouchInteractionService(Runnable r); - - /** - * @see Activity#getWindow() - * @return Window - */ - Window getWindow(); - - /** - * @see - * BaseActivity#addMultiWindowModeChangedListener(BaseActivity.MultiWindowModeChangedListener) - * @param listener {@link BaseActivity.MultiWindowModeChangedListener} - */ - void addMultiWindowModeChangedListener( - BaseActivity.MultiWindowModeChangedListener listener); - - /** - * @see - * BaseActivity#removeMultiWindowModeChangedListener( - * BaseActivity.MultiWindowModeChangedListener) - * @param listener {@link BaseActivity.MultiWindowModeChangedListener} - */ - void removeMultiWindowModeChangedListener( - BaseActivity.MultiWindowModeChangedListener listener); - - /** - * Begins transition from overview back to homescreen - */ - void returnToHomescreen(); -}