Taskbar in Desktop Windowing Mode
Test: presubmit Bug: 330146462 Flag: NONE Change-Id: Ib33f90704c3010df6a52e2a1c420960b11dbd0d4
This commit is contained in:
@@ -23,6 +23,8 @@ import static com.android.launcher3.InvariantDeviceProfile.TYPE_MULTI_DISPLAY;
|
||||
import static com.android.launcher3.InvariantDeviceProfile.TYPE_PHONE;
|
||||
import static com.android.launcher3.InvariantDeviceProfile.TYPE_TABLET;
|
||||
import static com.android.launcher3.LauncherPrefs.TASKBAR_PINNING;
|
||||
import static com.android.launcher3.LauncherPrefs.TASKBAR_PINNING_DESKTOP_MODE_KEY;
|
||||
import static com.android.launcher3.LauncherPrefs.TASKBAR_PINNING_IN_DESKTOP_MODE;
|
||||
import static com.android.launcher3.LauncherPrefs.TASKBAR_PINNING_KEY;
|
||||
import static com.android.launcher3.Utilities.dpiFromPx;
|
||||
import static com.android.launcher3.config.FeatureFlags.enableTaskbarPinning;
|
||||
@@ -88,10 +90,11 @@ public class DisplayController implements ComponentCallbacks, SafeCloseable {
|
||||
public static final int CHANGE_SUPPORTED_BOUNDS = 1 << 3;
|
||||
public static final int CHANGE_NAVIGATION_MODE = 1 << 4;
|
||||
public static final int CHANGE_TASKBAR_PINNING = 1 << 5;
|
||||
public static final int CHANGE_DESKTOP_MODE = 1 << 6;
|
||||
|
||||
public static final int CHANGE_ALL = CHANGE_ACTIVE_SCREEN | CHANGE_ROTATION
|
||||
| CHANGE_DENSITY | CHANGE_SUPPORTED_BOUNDS | CHANGE_NAVIGATION_MODE
|
||||
| CHANGE_TASKBAR_PINNING;
|
||||
| CHANGE_TASKBAR_PINNING | CHANGE_DESKTOP_MODE;
|
||||
|
||||
private static final String ACTION_OVERLAY_CHANGED = "android.intent.action.OVERLAY_CHANGED";
|
||||
private static final String TARGET_OVERLAY_PACKAGE = "android";
|
||||
@@ -145,16 +148,22 @@ public class DisplayController implements ComponentCallbacks, SafeCloseable {
|
||||
private void attachTaskbarPinningSharedPreferenceChangeListener(Context context) {
|
||||
mTaskbarPinningPreferenceChangeListener =
|
||||
(sharedPreferences, key) -> {
|
||||
if (TASKBAR_PINNING_KEY.equals(key)
|
||||
&& mInfo.mIsTaskbarPinned != LauncherPrefs.get(mContext).get(
|
||||
TASKBAR_PINNING)
|
||||
) {
|
||||
LauncherPrefs prefs = LauncherPrefs.get(mContext);
|
||||
boolean isTaskbarPinningChanged = TASKBAR_PINNING_KEY.equals(key)
|
||||
&& mInfo.mIsTaskbarPinned != prefs.get(TASKBAR_PINNING);
|
||||
boolean isTaskbarPinningDesktopModeChanged =
|
||||
TASKBAR_PINNING_DESKTOP_MODE_KEY.equals(key)
|
||||
&& mInfo.mIsTaskbarPinnedInDesktopMode != prefs.get(
|
||||
TASKBAR_PINNING_IN_DESKTOP_MODE);
|
||||
if (isTaskbarPinningChanged || isTaskbarPinningDesktopModeChanged) {
|
||||
handleInfoChange(mWindowContext.getDisplay());
|
||||
}
|
||||
};
|
||||
|
||||
LauncherPrefs.get(context).addListener(
|
||||
mTaskbarPinningPreferenceChangeListener, TASKBAR_PINNING);
|
||||
LauncherPrefs.get(context).addListener(
|
||||
mTaskbarPinningPreferenceChangeListener, TASKBAR_PINNING_IN_DESKTOP_MODE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -171,6 +180,13 @@ public class DisplayController implements ComponentCallbacks, SafeCloseable {
|
||||
return INSTANCE.get(context).getInfo().isTransientTaskbar();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles info change for desktop mode.
|
||||
*/
|
||||
public static void handleInfoChangeForDesktopMode(Context context) {
|
||||
INSTANCE.get(context).handleInfoChange(context.getDisplay());
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables transient taskbar status for tests.
|
||||
*/
|
||||
@@ -192,6 +208,8 @@ public class DisplayController implements ComponentCallbacks, SafeCloseable {
|
||||
if (enableTaskbarPinning()) {
|
||||
LauncherPrefs.get(mContext).removeListener(
|
||||
mTaskbarPinningPreferenceChangeListener, TASKBAR_PINNING);
|
||||
LauncherPrefs.get(mContext).removeListener(
|
||||
mTaskbarPinningPreferenceChangeListener, TASKBAR_PINNING_IN_DESKTOP_MODE);
|
||||
}
|
||||
if (mWindowContext != null) {
|
||||
mWindowContext.unregisterComponentCallbacks(this);
|
||||
@@ -309,9 +327,15 @@ public class DisplayController implements ComponentCallbacks, SafeCloseable {
|
||||
FileLog.w(TAG,
|
||||
"(CHANGE_SUPPORTED_BOUNDS) perDisplayBounds: " + newInfo.mPerDisplayBounds);
|
||||
}
|
||||
if (newInfo.mIsTaskbarPinned != oldInfo.mIsTaskbarPinned) {
|
||||
if ((newInfo.mIsTaskbarPinned != oldInfo.mIsTaskbarPinned)
|
||||
|| (newInfo.mIsTaskbarPinnedInDesktopMode
|
||||
!= oldInfo.mIsTaskbarPinnedInDesktopMode)) {
|
||||
change |= CHANGE_TASKBAR_PINNING;
|
||||
}
|
||||
if (newInfo.mIsInDesktopMode != oldInfo.mIsInDesktopMode) {
|
||||
change |= CHANGE_DESKTOP_MODE;
|
||||
}
|
||||
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "handleInfoChange - change: " + getChangeFlagsString(change));
|
||||
}
|
||||
@@ -355,6 +379,9 @@ public class DisplayController implements ComponentCallbacks, SafeCloseable {
|
||||
new ArrayMap<>();
|
||||
|
||||
private final boolean mIsTaskbarPinned;
|
||||
private final boolean mIsTaskbarPinnedInDesktopMode;
|
||||
|
||||
private final boolean mIsInDesktopMode;
|
||||
|
||||
public Info(Context displayInfoContext) {
|
||||
/* don't need system overrides for external displays */
|
||||
@@ -414,6 +441,9 @@ public class DisplayController implements ComponentCallbacks, SafeCloseable {
|
||||
}
|
||||
|
||||
mIsTaskbarPinned = LauncherPrefs.get(displayInfoContext).get(TASKBAR_PINNING);
|
||||
mIsTaskbarPinnedInDesktopMode = LauncherPrefs.get(displayInfoContext).get(
|
||||
TASKBAR_PINNING_IN_DESKTOP_MODE);
|
||||
mIsInDesktopMode = wmProxy.isInDesktopMode();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -430,10 +460,14 @@ public class DisplayController implements ComponentCallbacks, SafeCloseable {
|
||||
return sTransientTaskbarStatusForTests;
|
||||
}
|
||||
if (enableTaskbarPinning()) {
|
||||
if (mIsInDesktopMode) {
|
||||
return !mIsTaskbarPinnedInDesktopMode;
|
||||
}
|
||||
return !mIsTaskbarPinned;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the taskbar is pinned in gesture navigation mode.
|
||||
*/
|
||||
@@ -441,6 +475,10 @@ public class DisplayController implements ComponentCallbacks, SafeCloseable {
|
||||
return navigationMode == NavigationMode.NO_BUTTON && !isTransientTaskbar();
|
||||
}
|
||||
|
||||
public boolean isInDesktopMode() {
|
||||
return mIsInDesktopMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@code true} if the bounds represent a tablet.
|
||||
*/
|
||||
@@ -501,6 +539,7 @@ public class DisplayController implements ComponentCallbacks, SafeCloseable {
|
||||
appendFlag(result, change, CHANGE_SUPPORTED_BOUNDS, "CHANGE_SUPPORTED_BOUNDS");
|
||||
appendFlag(result, change, CHANGE_NAVIGATION_MODE, "CHANGE_NAVIGATION_MODE");
|
||||
appendFlag(result, change, CHANGE_TASKBAR_PINNING, "CHANGE_TASKBAR_VARIANT");
|
||||
appendFlag(result, change, CHANGE_DESKTOP_MODE, "CHANGE_DESKTOP_MODE");
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
@@ -516,6 +555,8 @@ public class DisplayController implements ComponentCallbacks, SafeCloseable {
|
||||
pw.println(" densityDpi=" + info.densityDpi);
|
||||
pw.println(" navigationMode=" + info.navigationMode.name());
|
||||
pw.println(" isTaskbarPinned=" + info.mIsTaskbarPinned);
|
||||
pw.println(" isTaskbarPinnedInDesktopMode=" + info.mIsTaskbarPinnedInDesktopMode);
|
||||
pw.println(" isInDesktopMode=" + info.mIsInDesktopMode);
|
||||
pw.println(" currentSize=" + info.currentSize);
|
||||
info.mPerDisplayBounds.forEach((key, value) -> pw.println(
|
||||
" perDisplayBounds - " + key + ": " + value));
|
||||
|
||||
Reference in New Issue
Block a user