Notify with onIsInDesktopModeChanged()
This CL renamed `onDesktopVisibilityChanged()` to `onIsInDesktopModeChanged()` and adds a parameter for the display ID on which the change is taking place. When the multiple desktops flags are disabled, the behavior should remain exactly as it is today; `onIsInDesktopModeChanged()` is triggered only for the `DEFAULT_DISPLAY`, and when the same old conditions occur. Bug: 394685645 Test: m Flag: com.android.window.flags.enable_multiple_desktops_frontend Flag: com.android.window.flags.enable_multiple_desktops_backend Change-Id: I31658b1b7932c787ebd430cee7e5c99bdd01e8c9
This commit is contained in:
1 parent
ad6fee6111
commit
2289c28f7f
3 files changed
+45
-18
No files matched your search
@@ -19,7 +19,9 @@ import android.content.Context
|
||||
import android.os.Debug
|
||||
import android.util.Log
|
||||
import android.util.SparseArray
|
||||
import android.view.Display.DEFAULT_DISPLAY
|
||||
import android.window.DesktopModeFlags.ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY
|
||||
import androidx.core.util.forEach
|
||||
import com.android.launcher3.LauncherState
|
||||
import com.android.launcher3.dagger.ApplicationContext
|
||||
import com.android.launcher3.dagger.LauncherAppComponent
|
||||
@@ -105,7 +107,7 @@ constructor(
|
||||
field = visibleTasksCount
|
||||
val areDesktopTasksVisibleNow = areDesktopTasksVisibleAndNotInOverview()
|
||||
if (wereDesktopTasksVisibleBefore != areDesktopTasksVisibleNow) {
|
||||
notifyDesktopVisibilityListeners(areDesktopTasksVisibleNow)
|
||||
notifyIsInDesktopModeChanged(DEFAULT_DISPLAY, areDesktopTasksVisibleNow)
|
||||
}
|
||||
|
||||
if (
|
||||
@@ -250,8 +252,23 @@ constructor(
|
||||
val wereDesktopTasksVisibleBefore = areDesktopTasksVisibleAndNotInOverview()
|
||||
inOverviewState = overviewStateEnabled
|
||||
val areDesktopTasksVisibleNow = areDesktopTasksVisibleAndNotInOverview()
|
||||
if (wereDesktopTasksVisibleBefore != areDesktopTasksVisibleNow) {
|
||||
notifyDesktopVisibilityListeners(areDesktopTasksVisibleNow)
|
||||
|
||||
if (!DesktopModeStatus.enableMultipleDesktops(context)) {
|
||||
if (wereDesktopTasksVisibleBefore != areDesktopTasksVisibleNow) {
|
||||
notifyIsInDesktopModeChanged(DEFAULT_DISPLAY, areDesktopTasksVisibleNow)
|
||||
}
|
||||
} else {
|
||||
// When overview state changes, it changes together on all displays.
|
||||
displaysDesksConfigsMap.forEach { displayId, deskConfig ->
|
||||
// Overview affects the state of desks only if desktop mode is active on this
|
||||
// display.
|
||||
if (isInDesktopMode(displayId)) {
|
||||
notifyIsInDesktopModeChanged(
|
||||
displayId,
|
||||
isInDesktopModeAndNotInOverview(displayId),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY.isTrue) {
|
||||
@@ -279,19 +296,19 @@ constructor(
|
||||
desktopVisibilityListeners.remove(listener)
|
||||
}
|
||||
|
||||
private fun notifyDesktopVisibilityListeners(areDesktopTasksVisible: Boolean) {
|
||||
if (DesktopModeStatus.enableMultipleDesktops(context)) {
|
||||
// This is triggered using the legacy way of determining the visibility of the desktop
|
||||
// mode and should not be used when the multi-desks feature is enabled.
|
||||
// (See b/394685645 for details).
|
||||
return
|
||||
private fun notifyIsInDesktopModeChanged(
|
||||
displayId: Int,
|
||||
isInDesktopModeAndNotInOverview: Boolean,
|
||||
) {
|
||||
if (DEBUG) {
|
||||
Log.d(
|
||||
TAG,
|
||||
"notifyIsInDesktopModeChanged: displayId=$displayId, isInDesktopModeAndNotInOverview=$isInDesktopModeAndNotInOverview",
|
||||
)
|
||||
}
|
||||
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "notifyDesktopVisibilityListeners: visible=$areDesktopTasksVisible")
|
||||
}
|
||||
for (listener in desktopVisibilityListeners) {
|
||||
listener.onDesktopVisibilityChanged(areDesktopTasksVisible)
|
||||
listener.onIsInDesktopModeChanged(displayId, isInDesktopModeAndNotInOverview)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -438,6 +455,8 @@ constructor(
|
||||
return
|
||||
}
|
||||
|
||||
val wasInDesktopMode = isInDesktopModeAndNotInOverview(displayId)
|
||||
|
||||
getDisplayDeskConfig(displayId).also {
|
||||
check(oldActiveDesk == it.activeDeskId) {
|
||||
"Mismatch between the Shell's oldActiveDesk: $oldActiveDesk, and Launcher's: ${it.activeDeskId}"
|
||||
@@ -447,6 +466,10 @@ constructor(
|
||||
}
|
||||
it.activeDeskId = newActiveDesk
|
||||
}
|
||||
|
||||
if (wasInDesktopMode != isInDesktopModeAndNotInOverview(displayId)) {
|
||||
notifyIsInDesktopModeChanged(displayId, !wasInDesktopMode)
|
||||
}
|
||||
}
|
||||
|
||||
/** TODO: b/333533253 - Remove after flag rollout */
|
||||
|
||||
@@ -229,8 +229,10 @@ public class DisplayController implements ComponentCallbacks,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDesktopVisibilityChanged(boolean visible) {
|
||||
notifyConfigChange();
|
||||
public void onIsInDesktopModeChanged(int displayId, boolean isInDesktopModeAndNotInOverview) {
|
||||
if (DEFAULT_DISPLAY == displayId) {
|
||||
notifyConfigChange();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -503,11 +503,13 @@ public class WindowManagerProxy {
|
||||
/** A listener for when the user enters/exits Desktop Mode. */
|
||||
public interface DesktopVisibilityListener {
|
||||
/**
|
||||
* Callback for when the user enters or exits Desktop Mode
|
||||
* Called when the desktop mode state on the display whose ID is `displayId` changes.
|
||||
*
|
||||
* @param visible whether Desktop Mode is now visible
|
||||
* @param displayId The ID of the display for which this notification is triggering.
|
||||
* @param isInDesktopModeAndNotInOverview True if a desktop is currently active on the given
|
||||
* display, and Overview is currently inactive.
|
||||
*/
|
||||
void onDesktopVisibilityChanged(boolean visible);
|
||||
void onIsInDesktopModeChanged(int displayId, boolean isInDesktopModeAndNotInOverview);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user