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/Android.bp b/Android.bp
index c9c3be8..bdd6b43 100644
--- a/Android.bp
+++ b/Android.bp
@@ -130,7 +130,7 @@
android_library {
name: "Launcher3CommonDepsLib",
srcs: ["src_build_config/**/*.java"],
- static_libs: ["Launcher3ResLib"],
+ static_libs: ["Launcher3ResLib", "org.lineageos.platform"],
sdk_version: "current",
min_sdk_version: min_launcher3_sdk_version,
manifest: "AndroidManifest-common.xml",
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java
index 06262c0..1c2ebb8 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java
@@ -51,6 +51,8 @@
import com.android.systemui.unfold.UnfoldTransitionProgressProvider;
import com.android.systemui.unfold.util.ScopedUnfoldTransitionProgressProvider;
+import lineageos.providers.LineageSettings;
+
import java.io.PrintWriter;
/**
@@ -64,11 +66,15 @@
private static final Uri NAV_BAR_KIDS_MODE = Settings.Secure.getUriFor(
Settings.Secure.NAV_BAR_KIDS_MODE);
+ private static final Uri ENABLE_TASKBAR_URI = LineageSettings.System.getUriFor(
+ LineageSettings.System.ENABLE_TASKBAR);
+
private final Context mContext;
private final DisplayController mDisplayController;
private final TaskbarNavButtonController mNavButtonController;
private final SettingsCache.OnChangeListener mUserSetupCompleteListener;
private final SettingsCache.OnChangeListener mNavBarKidsModeListener;
+ private final SettingsCache.OnChangeListener mEnableTaskBarListener;
private final ComponentCallbacks mComponentCallbacks;
private final SimpleBroadcastReceiver mShutdownReceiver;
@@ -113,6 +119,16 @@
SystemUiProxy.INSTANCE.get(mContext), new Handler());
mUserSetupCompleteListener = isUserSetupComplete -> recreateTaskbar();
mNavBarKidsModeListener = isNavBarKidsMode -> recreateTaskbar();
+ mEnableTaskBarListener = isTaskBarEnabled -> {
+ // Create the illusion of this taking effect immediately
+ // Also needed because TaskbarManager inits before SystemUiProxy on start
+ boolean enabled = LineageSettings.System.getInt(mContext.getContentResolver(),
+ LineageSettings.System.ENABLE_TASKBAR, 0) == 1;
+ SystemUiProxy.INSTANCE.get(mContext).setTaskbarEnabled(enabled);
+
+ // Restart launcher
+ System.exit(0);
+ };
// TODO(b/227669780): Consolidate this w/ DisplayController callbacks
mComponentCallbacks = new ComponentCallbacks() {
private Configuration mOldConfig = mContext.getResources().getConfiguration();
@@ -170,6 +186,8 @@
mUserSetupCompleteListener);
SettingsCache.INSTANCE.get(mContext).register(NAV_BAR_KIDS_MODE,
mNavBarKidsModeListener);
+ SettingsCache.INSTANCE.get(mContext).register(ENABLE_TASKBAR_URI,
+ mEnableTaskBarListener);
mContext.registerComponentCallbacks(mComponentCallbacks);
mShutdownReceiver.register(mContext, Intent.ACTION_SHUTDOWN);
@@ -268,9 +286,10 @@
boolean isTaskBarEnabled = dp != 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 39d8b54..b76b9de 100644
--- a/quickstep/src/com/android/quickstep/SystemUiProxy.java
+++ b/quickstep/src/com/android/quickstep/SystemUiProxy.java
@@ -443,6 +443,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 b276397..1b448e0 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -46,6 +46,8 @@
import com.android.launcher3.util.DisplayController.Info;
import com.android.launcher3.util.WindowBounds;
+import lineageos.providers.LineageSettings;
+
import java.io.PrintWriter;
import java.util.List;
@@ -261,7 +263,9 @@
isTablet = info.isTablet(windowBounds);
isPhone = !isTablet;
isTwoPanels = isTablet && useTwoPanels;
- isTaskbarPresent = isTablet && ApiWrapper.TASKBAR_DRAWN_IN_PROCESS;
+ boolean isTaskBarEnabled = LineageSettings.System.getInt(context.getContentResolver(),
+ LineageSettings.System.ENABLE_TASKBAR, isTablet ? 1 : 0) == 1;
+ isTaskbarPresent = isTaskBarEnabled && ApiWrapper.TASKBAR_DRAWN_IN_PROCESS;
// Some more constants.
context = getContext(context, info, isVerticalBarLayout() || (isTablet && isLandscape)