Stash desktop apps on home gesture or taskbar home button press
When we detect the home gesture or tap on home button in taskbar, check if desktop apps are visible. If they are, signal WMShell to stash the desktop apps. Flag: persist.wm.debug.desktop_mode_2 Bug: 261234402 Test: have gesture nav enabled, put an app on desktop and swipe up to home, verify toast is shown, and next app launches to desktop Test: have 3-button nav enabled, put an app on desktop and press home, verify toast is shown, and next app launches to desktop Change-Id: I824e640bfafa20cb3451cbd8f035fe9dca18094f
This commit is contained in:
@@ -15,14 +15,22 @@
|
||||
*/
|
||||
package com.android.launcher3.statehandlers;
|
||||
|
||||
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
|
||||
|
||||
import android.os.RemoteException;
|
||||
import android.os.SystemProperties;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.android.launcher3.Launcher;
|
||||
import com.android.launcher3.LauncherState;
|
||||
import com.android.launcher3.statemanager.StatefulActivity;
|
||||
import com.android.launcher3.uioverrides.QuickstepLauncher;
|
||||
import com.android.quickstep.SystemUiProxy;
|
||||
import com.android.wm.shell.desktopmode.IDesktopTaskListener;
|
||||
|
||||
/**
|
||||
* Controls the visibility of the workspace and the resumed / paused state when desktop mode
|
||||
@@ -39,10 +47,44 @@ public class DesktopVisibilityController {
|
||||
private boolean mInOverviewState;
|
||||
private boolean mGestureInProgress;
|
||||
|
||||
@Nullable
|
||||
private IDesktopTaskListener mDesktopTaskListener;
|
||||
|
||||
public DesktopVisibilityController(Launcher launcher) {
|
||||
mLauncher = launcher;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a listener with System UI to receive updates about desktop tasks state
|
||||
*/
|
||||
public void registerSystemUiListener() {
|
||||
mDesktopTaskListener = new IDesktopTaskListener.Stub() {
|
||||
@Override
|
||||
public void onVisibilityChanged(int displayId, boolean visible) throws RemoteException {
|
||||
// TODO(b/261234402): move visibility from sysui state to listener
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStashedChanged(int displayId, boolean stashed) throws RemoteException {
|
||||
// TODO(b/261234402): show a persistent toast
|
||||
MAIN_EXECUTOR.execute(() -> {
|
||||
if (stashed && displayId == mLauncher.getDisplayId()) {
|
||||
Toast.makeText(mLauncher, "Adding app to Desktop",
|
||||
Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
SystemUiProxy.INSTANCE.get(mLauncher).setDesktopTaskListener(mDesktopTaskListener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear listener from System UI that was set with {@link #registerSystemUiListener()}
|
||||
*/
|
||||
public void unregisterSystemUiListener() {
|
||||
SystemUiProxy.INSTANCE.get(mLauncher).setDesktopTaskListener(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether desktop mode is supported.
|
||||
*/
|
||||
@@ -130,6 +172,15 @@ public class DesktopVisibilityController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle launcher moving to home due to home gesture or home button press.
|
||||
*/
|
||||
public void onHomeActionTriggered() {
|
||||
if (areFreeformTasksVisible()) {
|
||||
SystemUiProxy.INSTANCE.get(mLauncher).stashDesktopApps(mLauncher.getDisplayId());
|
||||
}
|
||||
}
|
||||
|
||||
private void setLauncherViewsVisibility(int visibility) {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "setLauncherViewsVisibility: visibility=" + visibility);
|
||||
|
||||
Reference in New Issue
Block a user