Listen for cases where touch controllers change, and update them
Otherwise we'd be stuck using the old touch controllers until DragLayer
is setup again (e.g. launcher is killed).
Bug: 77921826
Change-Id: I8aac6fc453839902cb2d99279a6bd1549ee17d79
diff --git a/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java b/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java
index a10583c..9507a36 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java
@@ -16,12 +16,11 @@
package com.android.launcher3.uioverrides;
+import static com.android.launcher3.LauncherState.ALL_APPS;
import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.LauncherState.OVERVIEW;
-import static com.android.launcher3.LauncherState.ALL_APPS;
import android.content.Context;
-import android.content.SharedPreferences;
import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.DeviceProfile;
@@ -59,6 +58,10 @@
}
}
+ public static void setOnTouchControllersChangedListener(Context context, Runnable listener) {
+ OverviewInteractionState.getInstance(context).setOnSwipeUpSettingChangedListener(listener);
+ }
+
public static StateHandler[] getStateHandler(Launcher launcher) {
return new StateHandler[] {
launcher.getAllAppsController(), launcher.getWorkspace(),
diff --git a/quickstep/src/com/android/quickstep/OverviewInteractionState.java b/quickstep/src/com/android/quickstep/OverviewInteractionState.java
index 471262b..0c24e22 100644
--- a/quickstep/src/com/android/quickstep/OverviewInteractionState.java
+++ b/quickstep/src/com/android/quickstep/OverviewInteractionState.java
@@ -15,7 +15,6 @@
*/
package com.android.quickstep;
-import static com.android.launcher3.Utilities.getPrefs;
import static com.android.systemui.shared.system.NavigationBarCompat.FLAG_DISABLE_QUICK_SCRUB;
import static com.android.systemui.shared.system.NavigationBarCompat.FLAG_DISABLE_SWIPE_UP;
import static com.android.systemui.shared.system.NavigationBarCompat.FLAG_HIDE_BACK_BUTTON;
@@ -86,6 +85,8 @@
private boolean mBackButtonVisible = true;
private boolean mSwipeUpEnabled = true;
+ private Runnable mOnSwipeUpSettingChangedListener;
+
private OverviewInteractionState(Context context) {
mUiHandler = new Handler(this::handleUiMessage);
mBgHandler = new Handler(UiThreadHelper.getBackgroundLooper(), this::handleBgMessage);
@@ -124,12 +125,19 @@
break;
case MSG_SET_SWIPE_UP_ENABLED:
mSwipeUpEnabled = msg.arg1 != 0;
+ if (mOnSwipeUpSettingChangedListener != null) {
+ mOnSwipeUpSettingChangedListener.run();
+ }
break;
}
applyFlags();
return true;
}
+ public void setOnSwipeUpSettingChangedListener(Runnable listener) {
+ mOnSwipeUpSettingChangedListener = listener;
+ }
+
@WorkerThread
private void applyFlags() {
if (mISystemUiProxy == null) {
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 90c55c9..8840860 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -18,7 +18,6 @@
import static android.content.pm.ActivityInfo.CONFIG_ORIENTATION;
import static android.content.pm.ActivityInfo.CONFIG_SCREEN_SIZE;
-
import static com.android.launcher3.LauncherAnimUtils.SPRING_LOADED_EXIT_DELAY;
import static com.android.launcher3.LauncherState.ALL_APPS;
import static com.android.launcher3.LauncherState.NORMAL;
@@ -81,7 +80,6 @@
import com.android.launcher3.dragndrop.DragController;
import com.android.launcher3.dragndrop.DragLayer;
import com.android.launcher3.dragndrop.DragView;
-import com.android.launcher3.dynamicui.WallpaperColorInfo;
import com.android.launcher3.folder.FolderIcon;
import com.android.launcher3.folder.FolderIconPreviewVerifier;
import com.android.launcher3.keyboard.CustomActionsPopup;
@@ -923,7 +921,9 @@
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
// Setup the drag layer
- mDragLayer.setup(mDragController);
+ Runnable setupDragLayer = () -> mDragLayer.setup(mDragController);
+ UiFactory.setOnTouchControllersChangedListener(this, setupDragLayer);
+ setupDragLayer.run();
mWorkspace.setup(mDragController);
// Until the workspace is bound, ensure that we keep the wallpaper offset locked to the
@@ -1327,6 +1327,8 @@
unregisterReceiver(mReceiver);
mWorkspace.removeFolderListeners();
+ UiFactory.setOnTouchControllersChangedListener(this, null);
+
// Stop callbacks from LauncherModel
// It's possible to receive onDestroy after a new Launcher activity has
// been created. In this case, don't interfere with the new Launcher.
diff --git a/src_ui_overrides/com/android/launcher3/uioverrides/UiFactory.java b/src_ui_overrides/com/android/launcher3/uioverrides/UiFactory.java
index be9d5b7..bd1a96e 100644
--- a/src_ui_overrides/com/android/launcher3/uioverrides/UiFactory.java
+++ b/src_ui_overrides/com/android/launcher3/uioverrides/UiFactory.java
@@ -16,6 +16,8 @@
package com.android.launcher3.uioverrides;
+import android.content.Context;
+
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherStateManager.StateHandler;
import com.android.launcher3.util.TouchController;
@@ -27,6 +29,8 @@
launcher.getDragController(), new AllAppsSwipeController(launcher)};
}
+ public static void setOnTouchControllersChangedListener(Context context, Runnable listener) { }
+
public static StateHandler[] getStateHandler(Launcher launcher) {
return new StateHandler[] {
launcher.getAllAppsController(), launcher.getWorkspace() };