Added back code removed earlier from OverviewInterationState

Change: ag/7199900

Test: manual
Fixes: 129497226
Change-Id: Ibf0b1d4ade8ef5a2f0ceb545df505e9de419ec50
(cherry picked from commit cad531248e)
This commit is contained in:
Matthew Ng 2019-04-25 17:21:16 -07:00
parent a0d542b046
commit 06e0d80d15
1 changed files with 27 additions and 3 deletions

View File

@ -21,12 +21,13 @@ import android.os.Message;
import android.os.RemoteException; import android.os.RemoteException;
import android.util.Log; import android.util.Log;
import com.android.launcher3.Utilities;
import com.android.launcher3.allapps.DiscoveryBounce;
import com.android.launcher3.util.MainThreadInitializedObject; import com.android.launcher3.util.MainThreadInitializedObject;
import com.android.launcher3.util.UiThreadHelper; import com.android.launcher3.util.UiThreadHelper;
import com.android.systemui.shared.recents.ISystemUiProxy; import com.android.systemui.shared.recents.ISystemUiProxy;
import androidx.annotation.WorkerThread; import androidx.annotation.WorkerThread;
import com.android.systemui.shared.system.QuickStepContract;
/** /**
* Sets alpha for the back button * Sets alpha for the back button
@ -35,9 +36,11 @@ public class OverviewInteractionState {
private static final String TAG = "OverviewFlags"; private static final String TAG = "OverviewFlags";
private static final String HAS_ENABLED_QUICKSTEP_ONCE = "launcher.has_enabled_quickstep_once";
// We do not need any synchronization for this variable as its only written on UI thread. // We do not need any synchronization for this variable as its only written on UI thread.
public static final MainThreadInitializedObject<OverviewInteractionState> INSTANCE = public static final MainThreadInitializedObject<OverviewInteractionState> INSTANCE =
new MainThreadInitializedObject<>((c) -> new OverviewInteractionState(c)); new MainThreadInitializedObject<>(OverviewInteractionState::new);
private static final int MSG_SET_PROXY = 200; private static final int MSG_SET_PROXY = 200;
private static final int MSG_SET_BACK_BUTTON_ALPHA = 201; private static final int MSG_SET_BACK_BUTTON_ALPHA = 201;
@ -58,6 +61,9 @@ public class OverviewInteractionState {
// For example, send back alpha on uihandler to avoid flickering when setting its visibility // For example, send back alpha on uihandler to avoid flickering when setting its visibility
mUiHandler = new Handler(this::handleUiMessage); mUiHandler = new Handler(this::handleUiMessage);
mBgHandler = new Handler(UiThreadHelper.getBackgroundLooper(), this::handleBgMessage); mBgHandler = new Handler(UiThreadHelper.getBackgroundLooper(), this::handleBgMessage);
onNavigationModeChanged(SysUINavigationMode.INSTANCE.get(context)
.addModeChangeListener(this::onNavigationModeChanged));
} }
public float getBackButtonAlpha() { public float getBackButtonAlpha() {
@ -65,7 +71,7 @@ public class OverviewInteractionState {
} }
public void setBackButtonAlpha(float alpha, boolean animate) { public void setBackButtonAlpha(float alpha, boolean animate) {
if (QuickStepContract.isLegacyMode(SysUINavigationMode.getMode(mContext).resValue)) { if (!modeSupportsGestures()) {
alpha = 1; alpha = 1;
} }
mUiHandler.removeMessages(MSG_SET_BACK_BUTTON_ALPHA); mUiHandler.removeMessages(MSG_SET_BACK_BUTTON_ALPHA);
@ -108,4 +114,22 @@ public class OverviewInteractionState {
Log.w(TAG, "Unable to update overview back button alpha", e); Log.w(TAG, "Unable to update overview back button alpha", e);
} }
} }
private void onNavigationModeChanged(SysUINavigationMode.Mode mode) {
resetHomeBounceSeenOnQuickstepEnabledFirstTime();
}
private void resetHomeBounceSeenOnQuickstepEnabledFirstTime() {
if (modeSupportsGestures() && !Utilities.getPrefs(mContext).getBoolean(
HAS_ENABLED_QUICKSTEP_ONCE, true)) {
Utilities.getPrefs(mContext).edit()
.putBoolean(HAS_ENABLED_QUICKSTEP_ONCE, true)
.putBoolean(DiscoveryBounce.HOME_BOUNCE_SEEN, false)
.apply();
}
}
private boolean modeSupportsGestures() {
return SysUINavigationMode.getMode(mContext).hasGestures;
}
} }