From 06e0d80d15d98ca075905b71a2e9a8893109cc2f Mon Sep 17 00:00:00 2001 From: Matthew Ng Date: Thu, 25 Apr 2019 17:21:16 -0700 Subject: [PATCH] Added back code removed earlier from OverviewInterationState Change: ag/7199900 Test: manual Fixes: 129497226 Change-Id: Ibf0b1d4ade8ef5a2f0ceb545df505e9de419ec50 (cherry picked from commit cad531248e639a60fd3f0ce89b8fdbeb82cb8ea5) --- .../quickstep/OverviewInteractionState.java | 30 +++++++++++++++++-- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/quickstep/src/com/android/quickstep/OverviewInteractionState.java b/quickstep/src/com/android/quickstep/OverviewInteractionState.java index 6c7bc776c0..79d922c240 100644 --- a/quickstep/src/com/android/quickstep/OverviewInteractionState.java +++ b/quickstep/src/com/android/quickstep/OverviewInteractionState.java @@ -21,12 +21,13 @@ import android.os.Message; import android.os.RemoteException; 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.UiThreadHelper; import com.android.systemui.shared.recents.ISystemUiProxy; import androidx.annotation.WorkerThread; -import com.android.systemui.shared.system.QuickStepContract; /** * Sets alpha for the back button @@ -35,9 +36,11 @@ public class OverviewInteractionState { 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. public static final MainThreadInitializedObject 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_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 mUiHandler = new Handler(this::handleUiMessage); mBgHandler = new Handler(UiThreadHelper.getBackgroundLooper(), this::handleBgMessage); + + onNavigationModeChanged(SysUINavigationMode.INSTANCE.get(context) + .addModeChangeListener(this::onNavigationModeChanged)); } public float getBackButtonAlpha() { @@ -65,7 +71,7 @@ public class OverviewInteractionState { } public void setBackButtonAlpha(float alpha, boolean animate) { - if (QuickStepContract.isLegacyMode(SysUINavigationMode.getMode(mContext).resValue)) { + if (!modeSupportsGestures()) { alpha = 1; } 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); } } + + 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; + } }