mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-27 15:26:58 +00:00
Merge "Limit existing usages of nav bar button alpha to two button mode" into sc-dev
This commit is contained in:
@@ -21,6 +21,7 @@ import static com.android.launcher3.LauncherState.FLAG_HIDE_BACK_BUTTON;
|
||||
import static com.android.launcher3.LauncherState.NORMAL;
|
||||
import static com.android.launcher3.util.DisplayController.DisplayHolder.CHANGE_SIZE;
|
||||
import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR;
|
||||
import static com.android.quickstep.SysUINavigationMode.Mode.TWO_BUTTONS;
|
||||
import static com.android.systemui.shared.system.ActivityManagerWrapper.CLOSE_SYSTEM_WINDOWS_REASON_HOME_KEY;
|
||||
|
||||
import android.animation.AnimatorSet;
|
||||
@@ -79,7 +80,7 @@ public abstract class BaseQuickstepLauncher extends Launcher
|
||||
* Reusable command for applying the back button alpha on the background thread.
|
||||
*/
|
||||
public static final UiThreadHelper.AsyncCommand SET_BACK_BUTTON_ALPHA =
|
||||
(context, arg1, arg2) -> SystemUiProxy.INSTANCE.get(context).setBackButtonAlpha(
|
||||
(context, arg1, arg2) -> SystemUiProxy.INSTANCE.get(context).setNavBarButtonAlpha(
|
||||
Float.intBitsToFloat(arg1), arg2 != 0);
|
||||
|
||||
private OverviewActionsView mActionsView;
|
||||
@@ -373,8 +374,10 @@ public abstract class BaseQuickstepLauncher extends Launcher
|
||||
*/
|
||||
private void onLauncherStateOrFocusChanged() {
|
||||
boolean shouldBackButtonBeHidden = shouldBackButtonBeHidden(getStateManager().getState());
|
||||
UiThreadHelper.setBackButtonAlphaAsync(this, SET_BACK_BUTTON_ALPHA,
|
||||
shouldBackButtonBeHidden ? 0f : 1f, true /* animate */);
|
||||
if (SysUINavigationMode.getMode(this) == TWO_BUTTONS) {
|
||||
UiThreadHelper.setBackButtonAlphaAsync(this, SET_BACK_BUTTON_ALPHA,
|
||||
shouldBackButtonBeHidden ? 0f : 1f, true /* animate */);
|
||||
}
|
||||
if (getDragLayer() != null) {
|
||||
getRootView().setDisallowBackGesture(shouldBackButtonBeHidden);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.android.launcher3.statehandlers;
|
||||
|
||||
import static com.android.launcher3.anim.Interpolators.LINEAR;
|
||||
import static com.android.quickstep.AnimatedFloat.VALUE;
|
||||
import static com.android.quickstep.SysUINavigationMode.Mode.TWO_BUTTONS;
|
||||
|
||||
import com.android.launcher3.BaseQuickstepLauncher;
|
||||
import com.android.launcher3.LauncherState;
|
||||
@@ -30,7 +31,7 @@ import com.android.quickstep.SysUINavigationMode;
|
||||
import com.android.quickstep.SystemUiProxy;
|
||||
|
||||
/**
|
||||
* State handler for animating back button alpha
|
||||
* State handler for animating back button alpha in two-button nav mode.
|
||||
*/
|
||||
public class BackButtonAlphaHandler implements StateHandler<LauncherState> {
|
||||
|
||||
@@ -51,14 +52,11 @@ public class BackButtonAlphaHandler implements StateHandler<LauncherState> {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!SysUINavigationMode.getMode(mLauncher).hasGestures) {
|
||||
// If the nav mode is not gestural, then force back button alpha to be 1
|
||||
UiThreadHelper.setBackButtonAlphaAsync(mLauncher,
|
||||
BaseQuickstepLauncher.SET_BACK_BUTTON_ALPHA, 1f, true /* animate */);
|
||||
if (SysUINavigationMode.getMode(mLauncher) != TWO_BUTTONS) {
|
||||
return;
|
||||
}
|
||||
|
||||
mBackAlpha.value = SystemUiProxy.INSTANCE.get(mLauncher).getLastBackButtonAlpha();
|
||||
mBackAlpha.value = SystemUiProxy.INSTANCE.get(mLauncher).getLastNavButtonAlpha();
|
||||
animation.setFloat(mBackAlpha, VALUE,
|
||||
mLauncher.shouldBackButtonBeHidden(toState) ? 0 : 1, LINEAR);
|
||||
}
|
||||
|
||||
@@ -50,7 +50,8 @@ import com.android.wm.shell.transition.IShellTransitions;
|
||||
/**
|
||||
* Holds the reference to SystemUI.
|
||||
*/
|
||||
public class SystemUiProxy implements ISystemUiProxy {
|
||||
public class SystemUiProxy implements ISystemUiProxy,
|
||||
SysUINavigationMode.NavigationModeChangeListener {
|
||||
private static final String TAG = SystemUiProxy.class.getSimpleName();
|
||||
|
||||
public static final MainThreadInitializedObject<SystemUiProxy> INSTANCE =
|
||||
@@ -69,14 +70,20 @@ public class SystemUiProxy implements ISystemUiProxy {
|
||||
// Used to dedupe calls to SystemUI
|
||||
private int mLastShelfHeight;
|
||||
private boolean mLastShelfVisible;
|
||||
private float mLastBackButtonAlpha;
|
||||
private boolean mLastBackButtonAnimate;
|
||||
private float mLastNavButtonAlpha;
|
||||
private boolean mLastNavButtonAnimate;
|
||||
|
||||
// TODO(141886704): Find a way to remove this
|
||||
private int mLastSystemUiStateFlags;
|
||||
|
||||
public SystemUiProxy(Context context) {
|
||||
// Do nothing
|
||||
SysUINavigationMode.INSTANCE.get(context).addModeChangeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNavigationModeChanged(SysUINavigationMode.Mode newMode) {
|
||||
// Whenever the nav mode changes, force reset the nav button alpha
|
||||
setNavBarButtonAlpha(1f, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -170,28 +177,17 @@ public class SystemUiProxy implements ISystemUiProxy {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBackButtonAlpha(float alpha, boolean animate) {
|
||||
boolean changed = Float.compare(alpha, mLastBackButtonAlpha) != 0
|
||||
|| animate != mLastBackButtonAnimate;
|
||||
if (mSystemUiProxy != null && changed) {
|
||||
mLastBackButtonAlpha = alpha;
|
||||
mLastBackButtonAnimate = animate;
|
||||
try {
|
||||
mSystemUiProxy.setBackButtonAlpha(alpha, animate);
|
||||
} catch (RemoteException e) {
|
||||
Log.w(TAG, "Failed call setBackButtonAlpha", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public float getLastBackButtonAlpha() {
|
||||
return mLastBackButtonAlpha;
|
||||
public float getLastNavButtonAlpha() {
|
||||
return mLastNavButtonAlpha;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNavBarButtonAlpha(float alpha, boolean animate) {
|
||||
if (mSystemUiProxy != null) {
|
||||
boolean changed = Float.compare(alpha, mLastNavButtonAlpha) != 0
|
||||
|| animate != mLastNavButtonAnimate;
|
||||
if (mSystemUiProxy != null && changed) {
|
||||
mLastNavButtonAlpha = alpha;
|
||||
mLastNavButtonAnimate = animate;
|
||||
try {
|
||||
mSystemUiProxy.setNavBarButtonAlpha(alpha, animate);
|
||||
} catch (RemoteException e) {
|
||||
|
||||
Reference in New Issue
Block a user