Merge "Fix regression where nav bar shows when taskbar is showing" into sc-v2-dev

This commit is contained in:
Tony Wickham
2021-06-07 21:53:38 +00:00
committed by Android (Google) Code Review
2 changed files with 34 additions and 8 deletions
@@ -27,6 +27,8 @@ import com.android.launcher3.anim.PropertySetter;
import com.android.launcher3.statemanager.StateManager;
import com.android.launcher3.states.StateAnimationConfig;
import com.android.launcher3.util.MultiValueAlpha;
import com.android.quickstep.AnimatedFloat;
import com.android.quickstep.SystemUiProxy;
/**
* StateHandler to animate Taskbar according to Launcher's state machine. Does nothing if Taskbar
@@ -39,12 +41,17 @@ public class TaskbarStateHandler implements StateManager.StateHandler<LauncherSt
// Contains Taskbar-related properties we should aniamte. If null, don't do anything.
private @Nullable MultiValueAlpha.AlphaProperty mTaskbarAlpha = null;
private AnimatedFloat mNavbarButtonAlpha = new AnimatedFloat(this::updateNavbarButtonAlpha);
public TaskbarStateHandler(BaseQuickstepLauncher launcher) {
mLauncher = launcher;
}
public void setAnimationController(MultiValueAlpha.AlphaProperty taskbarAlpha) {
mTaskbarAlpha = taskbarAlpha;
// Reapply state.
setState(mLauncher.getStateManager().getState());
updateNavbarButtonAlpha();
}
@Override
@@ -68,5 +75,14 @@ public class TaskbarStateHandler implements StateManager.StateHandler<LauncherSt
boolean isTaskbarVisible = (toState.getVisibleElements(mLauncher) & TASKBAR) != 0;
setter.setFloat(mTaskbarAlpha, MultiValueAlpha.VALUE, isTaskbarVisible ? 1f : 0f, LINEAR);
// Make the nav bar visible in states that taskbar isn't visible.
// TODO: We should draw our own handle instead of showing the nav bar.
float navbarButtonAlpha = isTaskbarVisible ? 0f : 1f;
setter.setFloat(mNavbarButtonAlpha, AnimatedFloat.VALUE, navbarButtonAlpha, LINEAR);
}
private void updateNavbarButtonAlpha() {
SystemUiProxy.INSTANCE.get(mLauncher).setNavBarButtonAlpha(mNavbarButtonAlpha.value, false);
}
}
@@ -85,6 +85,7 @@ public class SystemUiProxy implements ISystemUiProxy,
private float mLastNavButtonAlpha;
private boolean mLastNavButtonAnimate;
private boolean mHasNavButtonAlphaBeenSet = false;
private Runnable mPendingSetNavButtonAlpha = null;
// TODO(141886704): Find a way to remove this
private int mLastSystemUiStateFlags;
@@ -157,6 +158,11 @@ public class SystemUiProxy implements ISystemUiProxy,
setSmartspaceCallback(mPendingSmartspaceCallback);
mPendingSmartspaceCallback = null;
}
if (mPendingSetNavButtonAlpha != null) {
mPendingSetNavButtonAlpha.run();
mPendingSetNavButtonAlpha = null;
}
}
public void clearProxy() {
@@ -240,14 +246,18 @@ public class SystemUiProxy implements ISystemUiProxy,
boolean changed = Float.compare(alpha, mLastNavButtonAlpha) != 0
|| animate != mLastNavButtonAnimate
|| !mHasNavButtonAlphaBeenSet;
if (mSystemUiProxy != null && changed) {
mLastNavButtonAlpha = alpha;
mLastNavButtonAnimate = animate;
mHasNavButtonAlphaBeenSet = true;
try {
mSystemUiProxy.setNavBarButtonAlpha(alpha, animate);
} catch (RemoteException e) {
Log.w(TAG, "Failed call setNavBarButtonAlpha", e);
if (changed) {
if (mSystemUiProxy == null) {
mPendingSetNavButtonAlpha = () -> setNavBarButtonAlpha(alpha, animate);
} else {
mLastNavButtonAlpha = alpha;
mLastNavButtonAnimate = animate;
mHasNavButtonAlphaBeenSet = true;
try {
mSystemUiProxy.setNavBarButtonAlpha(alpha, animate);
} catch (RemoteException e) {
Log.w(TAG, "Failed call setNavBarButtonAlpha", e);
}
}
}
}