Add support for toggling taskbar
- Use new API to enable/disable SysUI taskbar integration
- User-facing setting to control taskbar eligibility
- Reload by restarting (live reload would be much more complicated)
- Update SysUI integration state before reloading
Depends on frameworks/base commit:
SystemUI: Add API for runtime taskbar config
Change-Id: Id1889ca9b102f94cc0a1161f49de88428dcc0943
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java
index bbac116..26d2703 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java
@@ -105,6 +105,9 @@
private static final Uri NAV_BAR_KIDS_MODE = Settings.Secure.getUriFor(
Settings.Secure.NAV_BAR_KIDS_MODE);
+ private static final Uri ENABLE_TASKBAR_URI = Settings.System.getUriFor(
+ Settings.System.ENABLE_TASKBAR);
+
private final Context mContext;
private final @Nullable Context mNavigationBarPanelContext;
private WindowManager mWindowManager;
@@ -137,6 +140,7 @@
*/
private final OnIDPChangeListener mIdpChangeListener = c -> recreateTaskbar();
private final SettingsCache.OnChangeListener mOnSettingsChangeListener = c -> recreateTaskbar();
+ private final SettingsCache.OnChangeListener mEnableTaskBarListener;
private boolean mUserUnlocked = false;
@@ -275,6 +279,18 @@
.register(USER_SETUP_COMPLETE_URI, mOnSettingsChangeListener);
SettingsCache.INSTANCE.get(mContext)
.register(NAV_BAR_KIDS_MODE, mOnSettingsChangeListener);
+ mEnableTaskBarListener = c -> {
+ // Create the illusion of this taking effect immediately
+ // Also needed because TaskbarManager inits before SystemUiProxy on start
+ boolean enabled = Settings.System.getInt(mContext.getContentResolver(),
+ Settings.System.ENABLE_TASKBAR, 0) == 1;
+ SystemUiProxy.INSTANCE.get(mContext).setTaskbarEnabled(enabled);
+
+ // Restart launcher
+ System.exit(0);
+ };
+ SettingsCache.INSTANCE.get(mContext)
+ .register(ENABLE_TASKBAR_URI, mEnableTaskBarListener);
Log.d(TASKBAR_NOT_DESTROYED_TAG, "registering component callbacks from constructor.");
mContext.registerComponentCallbacks(mComponentCallbacks);
mShutdownReceiver.register(mContext, Intent.ACTION_SHUTDOWN);
@@ -432,9 +448,10 @@
+ " [dp != null (i.e. mUserUnlocked)]=" + (dp != null)
+ " FLAG_HIDE_NAVBAR_WINDOW=" + ENABLE_TASKBAR_NAVBAR_UNIFICATION
+ " dp.isTaskbarPresent=" + (dp == null ? "null" : dp.isTaskbarPresent));
+ SystemUiProxy sysui = SystemUiProxy.INSTANCE.get(mContext);
+ sysui.setTaskbarEnabled(isTaskbarEnabled);
if (!isTaskbarEnabled) {
- SystemUiProxy.INSTANCE.get(mContext)
- .notifyTaskbarStatus(/* visible */ false, /* stashed */ false);
+ sysui.notifyTaskbarStatus(/* visible */ false, /* stashed */ false);
return;
}
diff --git a/quickstep/src/com/android/quickstep/SystemUiProxy.java b/quickstep/src/com/android/quickstep/SystemUiProxy.java
index a8c6809..0cb04bf 100644
--- a/quickstep/src/com/android/quickstep/SystemUiProxy.java
+++ b/quickstep/src/com/android/quickstep/SystemUiProxy.java
@@ -476,6 +476,18 @@
}
@Override
+ public void setTaskbarEnabled(boolean enabled) {
+ if (mSystemUiProxy != null) {
+ try {
+ mSystemUiProxy.setTaskbarEnabled(enabled);
+ } catch (RemoteException e) {
+ Log.w(TAG, "Failed call setTaskbarEnabled with arg: " +
+ enabled, e);
+ }
+ }
+ }
+
+ @Override
public void notifyTaskbarStatus(boolean visible, boolean stashed) {
if (mSystemUiProxy != null) {
try {
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index 1ca7da9..8f5a765 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -40,6 +40,7 @@
import android.graphics.Point;
import android.graphics.PointF;
import android.graphics.Rect;
+import android.provider.Settings;
import android.util.DisplayMetrics;
import android.util.SparseArray;
import android.view.Surface;
@@ -346,7 +347,9 @@
isTablet = info.isTablet(windowBounds);
isPhone = !isTablet;
isTwoPanels = isTablet && isMultiDisplay;
- isTaskbarPresent = isTablet && ApiWrapper.TASKBAR_DRAWN_IN_PROCESS;
+ boolean isTaskBarEnabled = Settings.System.getInt(context.getContentResolver(),
+ Settings.System.ENABLE_TASKBAR, isTablet ? 1 : 0) == 1;
+ isTaskbarPresent = isTaskBarEnabled && ApiWrapper.TASKBAR_DRAWN_IN_PROCESS;
// Some more constants.
context = getContext(context, info, isVerticalBarLayout() || (isTablet && isLandscape)