diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/RecentsUiFactory.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/RecentsUiFactory.java index b8e9137fbc..ff73679a91 100644 --- a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/RecentsUiFactory.java +++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/RecentsUiFactory.java @@ -63,8 +63,8 @@ public abstract class RecentsUiFactory { /** * Reusable command for applying the shelf height on the background thread. */ - public static final AsyncCommand SET_SHELF_HEIGHT = (context, visible, height) -> { - SystemUiProxy.INSTANCE.get(context).setShelfHeight(visible, (int) height); + public static final AsyncCommand SET_SHELF_HEIGHT = (context, arg1, arg2) -> { + SystemUiProxy.INSTANCE.get(context).setShelfHeight(arg1 != 0, arg2); }; public static RotationMode ROTATION_LANDSCAPE = new RotationMode(-90) { @@ -209,7 +209,7 @@ public abstract class RecentsUiFactory { DeviceProfile profile = launcher.getDeviceProfile(); boolean visible = (state == NORMAL || state == OVERVIEW) && launcher.isUserActive() && !profile.isVerticalBarLayout(); - UiThreadHelper.runAsyncCommand(launcher, SET_SHELF_HEIGHT, visible, + UiThreadHelper.runAsyncCommand(launcher, SET_SHELF_HEIGHT, visible ? 1 : 0, profile.hotseatBarSizePx); if (state == NORMAL) { launcher.getOverviewPanel().setSwipeDownShouldLaunchApp(false); diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/FlingAndHoldTouchController.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/FlingAndHoldTouchController.java index e215cfe8d3..ee2e9519e5 100644 --- a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/FlingAndHoldTouchController.java +++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/FlingAndHoldTouchController.java @@ -50,7 +50,7 @@ import com.android.launcher3.LauncherState; import com.android.launcher3.anim.AnimatorSetBuilder; import com.android.launcher3.anim.Interpolators; import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch; -import com.android.quickstep.OverviewInteractionState; +import com.android.quickstep.SystemUiProxy; import com.android.quickstep.util.MotionPauseDetector; import com.android.quickstep.views.RecentsView; @@ -120,7 +120,7 @@ public class FlingAndHoldTouchController extends PortraitStatesTouchController { * having it as part of the existing animation to the target state. */ private boolean handlingOverviewAnim() { - int stateFlags = OverviewInteractionState.INSTANCE.get(mLauncher).getSystemUiStateFlags(); + int stateFlags = SystemUiProxy.INSTANCE.get(mLauncher).getLastSystemUiStateFlags(); return mStartState == NORMAL && (stateFlags & SYSUI_STATE_OVERVIEW_DISABLED) == 0; } diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/QuickSwitchTouchController.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/QuickSwitchTouchController.java index 6576ec5737..5c3b55d6c4 100644 --- a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/QuickSwitchTouchController.java +++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/QuickSwitchTouchController.java @@ -45,9 +45,9 @@ import com.android.launcher3.touch.AbstractStateChangeTouchController; import com.android.launcher3.touch.SwipeDetector; import com.android.launcher3.userevent.nano.LauncherLogProto; import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Direction; -import com.android.quickstep.OverviewInteractionState; import com.android.quickstep.SysUINavigationMode; import com.android.quickstep.SysUINavigationMode.Mode; +import com.android.quickstep.SystemUiProxy; import com.android.quickstep.views.RecentsView; import com.android.quickstep.views.TaskView; @@ -82,7 +82,7 @@ public class QuickSwitchTouchController extends AbstractStateChangeTouchControll @Override protected LauncherState getTargetState(LauncherState fromState, boolean isDragTowardPositive) { - int stateFlags = OverviewInteractionState.INSTANCE.get(mLauncher).getSystemUiStateFlags(); + int stateFlags = SystemUiProxy.INSTANCE.get(mLauncher).getLastSystemUiStateFlags(); if ((stateFlags & SYSUI_STATE_OVERVIEW_DISABLED) != 0) { return NORMAL; } diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java index d1c63819ac..0700f7b020 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java @@ -36,6 +36,7 @@ import android.app.Service; import android.app.TaskInfo; import android.content.ComponentName; import android.content.Intent; +import android.content.SharedPreferences; import android.content.res.Configuration; import android.graphics.Region; import android.os.Build; @@ -52,6 +53,7 @@ import androidx.annotation.WorkerThread; import com.android.launcher3.BaseDraggingActivity; import com.android.launcher3.Utilities; +import com.android.launcher3.allapps.DiscoveryBounce; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.logging.UserEventDispatcher; import com.android.launcher3.model.AppLaunchTracker; @@ -68,7 +70,7 @@ import com.android.quickstep.inputconsumers.InputConsumer; import com.android.quickstep.inputconsumers.OtherActivityInputConsumer; import com.android.quickstep.inputconsumers.OverviewInputConsumer; import com.android.quickstep.inputconsumers.OverviewWithoutFocusInputConsumer; -import com.android.quickstep.inputconsumers.QuickCaptureTouchConsumer; +import com.android.quickstep.inputconsumers.QuickCaptureInputConsumer; import com.android.quickstep.inputconsumers.ResetGestureInputConsumer; import com.android.quickstep.inputconsumers.ScreenPinnedInputConsumer; import com.android.quickstep.util.ActiveGestureLog; @@ -115,6 +117,7 @@ public class TouchInteractionService extends Service implements private static final String KEY_BACK_NOTIFICATION_COUNT = "backNotificationCount"; private static final String NOTIFY_ACTION_BACK = "com.android.quickstep.action.BACK_GESTURE"; + private static final String HAS_ENABLED_QUICKSTEP_ONCE = "launcher.has_enabled_quickstep_once"; private static final int MAX_BACK_NOTIFICATION_COUNT = 3; private int mBackGestureNotificationCounter = -1; @@ -237,7 +240,6 @@ public class TouchInteractionService extends Service implements private RecentsModel mRecentsModel; private OverviewCommandHelper mOverviewCommandHelper; private OverviewComponentObserver mOverviewComponentObserver; - private OverviewInteractionState mOverviewInteractionState; private InputConsumerController mInputConsumer; private RecentsAnimationDeviceState mDeviceState; @@ -309,14 +311,13 @@ public class TouchInteractionService extends Service implements } mMode = newMode; initInputMonitor(); + resetHomeBounceSeenOnQuickstepEnabledFirstTime(); } public void onUserUnlocked() { mRecentsModel = RecentsModel.INSTANCE.get(this); mOverviewComponentObserver = new OverviewComponentObserver(this, mDeviceState); - mOverviewCommandHelper = new OverviewCommandHelper(this, mOverviewComponentObserver); - mOverviewInteractionState = OverviewInteractionState.INSTANCE.get(this); mInputConsumer = InputConsumerController.getRecentsAnimationInputConsumer(); sSwipeSharedState.setOverviewComponentObserver(mOverviewComponentObserver); @@ -328,12 +329,31 @@ public class TouchInteractionService extends Service implements // new ModelPreload().start(this); mBackGestureNotificationCounter = Math.max(0, Utilities.getDevicePrefs(this) .getInt(KEY_BACK_NOTIFICATION_COUNT, MAX_BACK_NOTIFICATION_COUNT)); + resetHomeBounceSeenOnQuickstepEnabledFirstTime(); + } + + private void resetHomeBounceSeenOnQuickstepEnabledFirstTime() { + if (!mDeviceState.isUserUnlocked() || !mMode.hasGestures) { + // Skip if not yet unlocked (can't read user shared prefs) or if the current navigation + // mode doesn't have gestures + return; + } + + // Reset home bounce seen on quick step enabled for first time + SharedPreferences sharedPrefs = Utilities.getPrefs(this); + if (!sharedPrefs.getBoolean(HAS_ENABLED_QUICKSTEP_ONCE, true)) { + sharedPrefs.edit() + .putBoolean(HAS_ENABLED_QUICKSTEP_ONCE, true) + .putBoolean(DiscoveryBounce.HOME_BOUNCE_SEEN, false) + .apply(); + } } @UiThread private void onSystemUiFlagsChanged() { if (mDeviceState.isUserUnlocked()) { - mOverviewInteractionState.setSystemUiStateFlags(mDeviceState.getSystemUiStateFlags()); + SystemUiProxy.INSTANCE.get(this).setLastSystemUiStateFlags( + mDeviceState.getSystemUiStateFlags()); mOverviewComponentObserver.onSystemUiStateChanged(); } } @@ -434,11 +454,10 @@ public class TouchInteractionService extends Service implements if (FeatureFlags.ENABLE_QUICK_CAPTURE_GESTURE.get()) { // Put the Compose gesture as higher priority than the Assistant or base gestures - base = new QuickCaptureTouchConsumer(this, base, - mInputMonitorCompat, mOverviewComponentObserver.getActivityControlHelper()); + base = new QuickCaptureInputConsumer(this, base, mInputMonitorCompat, + activityControl); } - if (mDeviceState.isScreenPinningActive()) { // Note: we only allow accessibility to wrap this, and it replaces the previous // base input consumer (which should be NO_OP anyway since topTaskLocked == true). diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/QuickCaptureTouchConsumer.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/QuickCaptureInputConsumer.java similarity index 96% rename from quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/QuickCaptureTouchConsumer.java rename to quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/QuickCaptureInputConsumer.java index 3101bb8263..ad9405f478 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/QuickCaptureTouchConsumer.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/QuickCaptureInputConsumer.java @@ -40,13 +40,13 @@ import com.android.quickstep.views.RecentsView; import com.android.systemui.shared.system.InputMonitorCompat; /** - * Touch consumer for handling events to launch quick capture from launcher + * Input consumer for handling events to launch quick capture from launcher * @param Draggable activity subclass used by RecentsView */ -public class QuickCaptureTouchConsumer +public class QuickCaptureInputConsumer extends DelegateInputConsumer { - private static final String TAG = "QuickCaptureTouchConsumer"; + private static final String TAG = "QuickCaptureInputConsumer"; private static final String QUICK_CAPTURE_PACKAGE = "com.google.auxe.compose"; private static final String QUICK_CAPTURE_PACKAGE_DEV = "com.google.auxe.compose.debug"; @@ -72,7 +72,7 @@ public class QuickCaptureTouchConsumer private RecentsView mRecentsView; - public QuickCaptureTouchConsumer(Context context, InputConsumer delegate, + public QuickCaptureInputConsumer(Context context, InputConsumer delegate, InputMonitorCompat inputMonitor, ActivityControlHelper activityControlHelper) { super(delegate, inputMonitor); mContext = context; diff --git a/quickstep/src/com/android/launcher3/uioverrides/BackButtonAlphaHandler.java b/quickstep/src/com/android/launcher3/uioverrides/BackButtonAlphaHandler.java index 693ae60f22..aa0dfc3d3b 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/BackButtonAlphaHandler.java +++ b/quickstep/src/com/android/launcher3/uioverrides/BackButtonAlphaHandler.java @@ -24,18 +24,18 @@ import com.android.launcher3.Launcher; import com.android.launcher3.LauncherState; import com.android.launcher3.LauncherStateManager; import com.android.launcher3.anim.AnimatorSetBuilder; -import com.android.quickstep.OverviewInteractionState; +import com.android.launcher3.util.UiThreadHelper; +import com.android.quickstep.SysUINavigationMode; +import com.android.quickstep.SystemUiProxy; public class BackButtonAlphaHandler implements LauncherStateManager.StateHandler { private static final String TAG = "BackButtonAlphaHandler"; private final Launcher mLauncher; - private final OverviewInteractionState mOverviewInteractionState; public BackButtonAlphaHandler(Launcher launcher) { mLauncher = launcher; - mOverviewInteractionState = OverviewInteractionState.INSTANCE.get(mLauncher); } @Override @@ -49,14 +49,23 @@ public class BackButtonAlphaHandler implements LauncherStateManager.StateHandler if (!config.playNonAtomicComponent()) { return; } - float fromAlpha = mOverviewInteractionState.getBackButtonAlpha(); + + if (!SysUINavigationMode.getMode(mLauncher).hasGestures) { + // If the nav mode is not gestural, then force back button alpha to be 1 + UiThreadHelper.setBackButtonAlphaAsync(mLauncher, UiFactory.SET_BACK_BUTTON_ALPHA, 1f, + true /* animate */); + return; + } + + float fromAlpha = SystemUiProxy.INSTANCE.get(mLauncher).getLastBackButtonAlpha(); float toAlpha = toState.hideBackButton ? 0 : 1; if (Float.compare(fromAlpha, toAlpha) != 0) { ValueAnimator anim = ValueAnimator.ofFloat(fromAlpha, toAlpha); anim.setDuration(config.duration); anim.addUpdateListener(valueAnimator -> { final float alpha = (float) valueAnimator.getAnimatedValue(); - mOverviewInteractionState.setBackButtonAlpha(alpha, false); + UiThreadHelper.setBackButtonAlphaAsync(mLauncher, UiFactory.SET_BACK_BUTTON_ALPHA, + alpha, false /* animate */); }); anim.addListener(new AnimatorListenerAdapter() { @Override diff --git a/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java b/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java index b0b5dcf751..17c681b26f 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java +++ b/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java @@ -51,11 +51,12 @@ import com.android.launcher3.QuickstepAppTransitionManagerImpl; import com.android.launcher3.Utilities; import com.android.launcher3.proxy.ProxyActivityStarter; import com.android.launcher3.proxy.StartActivityParams; -import com.android.quickstep.OverviewInteractionState; +import com.android.launcher3.util.UiThreadHelper; import com.android.quickstep.RecentsModel; import com.android.quickstep.SysUINavigationMode; import com.android.quickstep.SysUINavigationMode.Mode; import com.android.quickstep.SysUINavigationMode.NavigationModeChangeListener; +import com.android.quickstep.SystemUiProxy; import com.android.quickstep.util.RemoteFadeOutAnimationListener; import com.android.systemui.shared.system.ActivityCompat; @@ -65,6 +66,15 @@ import java.util.zip.Deflater; public class UiFactory extends RecentsUiFactory { + /** + * 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(Float.intBitsToFloat(arg1), + arg2 != 0); + }; + public static Runnable enableLiveUIChanges(Launcher launcher) { NavigationModeChangeListener listener = m -> { launcher.getDragLayer().recreateControllers(); @@ -88,7 +98,9 @@ public class UiFactory extends RecentsUiFactory { * Sets the back button visibility based on the current state/window focus. */ public static void onLauncherStateOrFocusChanged(Launcher launcher) { - boolean shouldBackButtonBeHidden = launcher != null + Mode mode = SysUINavigationMode.getMode(launcher); + boolean shouldBackButtonBeHidden = mode.hasGestures + && launcher != null && launcher.getStateManager().getState().hideBackButton && launcher.hasWindowFocus(); if (shouldBackButtonBeHidden) { @@ -96,8 +108,8 @@ public class UiFactory extends RecentsUiFactory { shouldBackButtonBeHidden = AbstractFloatingView.getTopOpenViewWithType(launcher, TYPE_ALL & ~TYPE_HIDE_BACK_BUTTON) == null; } - OverviewInteractionState.INSTANCE.get(launcher) - .setBackButtonAlpha(shouldBackButtonBeHidden ? 0 : 1, true /* animate */); + UiThreadHelper.setBackButtonAlphaAsync(launcher, UiFactory.SET_BACK_BUTTON_ALPHA, + shouldBackButtonBeHidden ? 0f : 1f, true /* animate */); if (launcher != null && launcher.getDragLayer() != null) { launcher.getRootView().setDisallowBackGesture(shouldBackButtonBeHidden); } diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/PortraitStatesTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/PortraitStatesTouchController.java index 9813295561..ef6a5e23d6 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/PortraitStatesTouchController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/PortraitStatesTouchController.java @@ -47,8 +47,8 @@ import com.android.launcher3.touch.SwipeDetector; import com.android.launcher3.uioverrides.states.OverviewState; import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch; import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType; -import com.android.quickstep.OverviewInteractionState; import com.android.quickstep.RecentsModel; +import com.android.quickstep.SystemUiProxy; import com.android.quickstep.TouchInteractionService; import com.android.quickstep.util.LayoutUtils; @@ -137,8 +137,7 @@ public class PortraitStatesTouchController extends AbstractStateChangeTouchContr } else if (fromState == OVERVIEW) { return isDragTowardPositive ? ALL_APPS : NORMAL; } else if (fromState == NORMAL && isDragTowardPositive) { - int stateFlags = OverviewInteractionState.INSTANCE.get(mLauncher) - .getSystemUiStateFlags(); + int stateFlags = SystemUiProxy.INSTANCE.get(mLauncher).getLastSystemUiStateFlags(); return mAllowDragToOverview && TouchInteractionService.isConnected() && (stateFlags & SYSUI_STATE_OVERVIEW_DISABLED) == 0 ? OVERVIEW : ALL_APPS; diff --git a/quickstep/src/com/android/quickstep/OverviewInteractionState.java b/quickstep/src/com/android/quickstep/OverviewInteractionState.java deleted file mode 100644 index 6b68b1952a..0000000000 --- a/quickstep/src/com/android/quickstep/OverviewInteractionState.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (C) 2018 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.android.quickstep; - -import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR; - -import android.content.Context; -import android.os.Handler; -import android.os.Message; - -import androidx.annotation.WorkerThread; - -import com.android.launcher3.Utilities; -import com.android.launcher3.allapps.DiscoveryBounce; -import com.android.launcher3.util.MainThreadInitializedObject; - -/** - * Sets alpha for the back button - */ -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<>(OverviewInteractionState::new); - - private static final int MSG_SET_BACK_BUTTON_ALPHA = 201; - - private final Context mContext; - private final Handler mUiHandler; - private final Handler mBgHandler; - - // These are updated on the background thread - private float mBackButtonAlpha = 1; - - private int mSystemUiStateFlags; - - private OverviewInteractionState(Context context) { - mContext = context; - - // Data posted to the uihandler will be sent to the bghandler. Data is sent to uihandler - // because of its high send frequency and data may be very different than the previous value - // For example, send back alpha on uihandler to avoid flickering when setting its visibility - mUiHandler = new Handler(this::handleUiMessage); - mBgHandler = new Handler(UI_HELPER_EXECUTOR.getLooper(), this::handleBgMessage); - - onNavigationModeChanged(SysUINavigationMode.INSTANCE.get(context) - .addModeChangeListener(this::onNavigationModeChanged)); - } - - public float getBackButtonAlpha() { - return mBackButtonAlpha; - } - - public void setBackButtonAlpha(float alpha, boolean animate) { - if (!modeSupportsGestures()) { - alpha = 1; - } - mUiHandler.removeMessages(MSG_SET_BACK_BUTTON_ALPHA); - mUiHandler.obtainMessage(MSG_SET_BACK_BUTTON_ALPHA, animate ? 1 : 0, 0, alpha) - .sendToTarget(); - } - - // TODO(141886704): See if we can remove this - public void setSystemUiStateFlags(int stateFlags) { - mSystemUiStateFlags = stateFlags; - } - - public int getSystemUiStateFlags() { - return mSystemUiStateFlags; - } - - private boolean handleUiMessage(Message msg) { - if (msg.what == MSG_SET_BACK_BUTTON_ALPHA) { - mBackButtonAlpha = (float) msg.obj; - } - mBgHandler.obtainMessage(msg.what, msg.arg1, msg.arg2, msg.obj).sendToTarget(); - return true; - } - - private boolean handleBgMessage(Message msg) { - switch (msg.what) { - case MSG_SET_BACK_BUTTON_ALPHA: - applyBackButtonAlpha((float) msg.obj, msg.arg1 == 1); - return true; - } - return true; - } - - @WorkerThread - private void applyBackButtonAlpha(float alpha, boolean animate) { - SystemUiProxy.INSTANCE.get(mContext).setBackButtonAlpha(alpha, animate); - } - - 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; - } -} diff --git a/quickstep/src/com/android/quickstep/SysUINavigationMode.java b/quickstep/src/com/android/quickstep/SysUINavigationMode.java index b67c6f8c8d..5902672d5c 100644 --- a/quickstep/src/com/android/quickstep/SysUINavigationMode.java +++ b/quickstep/src/com/android/quickstep/SysUINavigationMode.java @@ -57,7 +57,7 @@ public class SysUINavigationMode { private static final String TAG = "SysUINavigationMode"; - private final String ACTION_OVERLAY_CHANGED = "android.intent.action.OVERLAY_CHANGED"; + private static final String ACTION_OVERLAY_CHANGED = "android.intent.action.OVERLAY_CHANGED"; private static final String NAV_BAR_INTERACTION_MODE_RES_NAME = "config_navBarInteractionMode"; diff --git a/quickstep/src/com/android/quickstep/SystemUiProxy.java b/quickstep/src/com/android/quickstep/SystemUiProxy.java index f37e679ef7..5539b3e393 100644 --- a/quickstep/src/com/android/quickstep/SystemUiProxy.java +++ b/quickstep/src/com/android/quickstep/SystemUiProxy.java @@ -46,6 +46,11 @@ public class SystemUiProxy implements ISystemUiProxy { // Used to dedupe calls to SystemUI private int mLastShelfHeight; private boolean mLastShelfVisible; + private float mLastBackButtonAlpha; + private boolean mLastBackButtonAnimate; + + // TODO(141886704): Find a way to remove this + private int mLastSystemUiStateFlags; public SystemUiProxy(Context context) { // Do nothing @@ -63,6 +68,16 @@ public class SystemUiProxy implements ISystemUiProxy { linkToDeath(); } + // TODO(141886704): Find a way to remove this + public void setLastSystemUiStateFlags(int stateFlags) { + mLastSystemUiStateFlags = stateFlags; + } + + // TODO(141886704): Find a way to remove this + public int getLastSystemUiStateFlags() { + return mLastSystemUiStateFlags; + } + public boolean isActive() { return mSystemUiProxy != null; } @@ -134,7 +149,11 @@ public class SystemUiProxy implements ISystemUiProxy { @Override public void setBackButtonAlpha(float alpha, boolean animate) { - if (mSystemUiProxy != null) { + 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) { @@ -143,6 +162,10 @@ public class SystemUiProxy implements ISystemUiProxy { } } + public float getLastBackButtonAlpha() { + return mLastBackButtonAlpha; + } + @Override public void setNavBarButtonAlpha(float alpha, boolean animate) { if (mSystemUiProxy != null) { diff --git a/src/com/android/launcher3/util/UiThreadHelper.java b/src/com/android/launcher3/util/UiThreadHelper.java index fb1dc0d840..a133f01d4e 100644 --- a/src/com/android/launcher3/util/UiThreadHelper.java +++ b/src/com/android/launcher3/util/UiThreadHelper.java @@ -23,6 +23,7 @@ import android.os.Handler; import android.os.IBinder; import android.os.Message; import android.view.inputmethod.InputMethodManager; +import com.android.launcher3.uioverrides.UiFactory; /** * Utility class for offloading some class from UI thread @@ -52,10 +53,13 @@ public class UiThreadHelper { .sendToTarget(); } - public static void runAsyncCommand(Context context, AsyncCommand command, boolean arg1, - float arg2) { - Message.obtain(getHandler(context), MSG_RUN_COMMAND, arg1 ? 1 : 0, - Float.floatToIntBits(arg2), command).sendToTarget(); + public static void setBackButtonAlphaAsync(Context context, AsyncCommand command, float alpha, + boolean animate) { + runAsyncCommand(context, command, Float.floatToIntBits(alpha), animate ? 1 : 0); + } + + public static void runAsyncCommand(Context context, AsyncCommand command, int arg1, int arg2) { + Message.obtain(getHandler(context), MSG_RUN_COMMAND, arg1, arg2, command).sendToTarget(); } private static class UiCallbacks implements Handler.Callback { @@ -78,8 +82,7 @@ public class UiThreadHelper { ((Activity) message.obj).setRequestedOrientation(message.arg1); return true; case MSG_RUN_COMMAND: - ((AsyncCommand) message.obj).execute(mContext, message.arg1 == 1, - Float.intBitsToFloat(message.arg2)); + ((AsyncCommand) message.obj).execute(mContext, message.arg1, message.arg2); return true; } return false; @@ -87,6 +90,6 @@ public class UiThreadHelper { } public interface AsyncCommand { - void execute(Context proxy, boolean state, float value); + void execute(Context proxy, int arg1, int arg2); } }