diff --git a/quickstep/res/drawable/taskbar_icon_click_feedback_roundrect.xml b/quickstep/res/drawable/taskbar_icon_click_feedback_roundrect.xml index d6160def0f..534f241ae9 100644 --- a/quickstep/res/drawable/taskbar_icon_click_feedback_roundrect.xml +++ b/quickstep/res/drawable/taskbar_icon_click_feedback_roundrect.xml @@ -16,7 +16,7 @@ --> + android:color="@color/taskbar_nav_icon_selection_ripple"> diff --git a/quickstep/res/layout/taskbar_nav_button.xml b/quickstep/res/layout/taskbar_nav_button.xml index 4ffb8d81dc..aea4885d15 100644 --- a/quickstep/res/layout/taskbar_nav_button.xml +++ b/quickstep/res/layout/taskbar_nav_button.xml @@ -15,7 +15,10 @@ --> \ No newline at end of file + android:scaleType="center" + android:tint="@color/taskbar_nav_icon_light_color" + tools:ignore="UseAppTint" /> \ No newline at end of file diff --git a/quickstep/res/values/colors.xml b/quickstep/res/values/colors.xml index f237d26aa6..671a617f01 100644 --- a/quickstep/res/values/colors.xml +++ b/quickstep/res/values/colors.xml @@ -25,14 +25,14 @@ @color/overview_scrim_dark - #E0E0E0 - + #E0E0E0 + #ffffff + + #99000000 #EBffffff #99000000 - #FFF - #99000000 - #FFFFFFFF diff --git a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java index 4b6dacd95e..0565f7e976 100644 --- a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java @@ -15,11 +15,8 @@ */ package com.android.launcher3.taskbar; -import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL; - import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_X; import static com.android.launcher3.taskbar.TaskbarNavButtonController.BUTTON_A11Y; -import static com.android.launcher3.taskbar.TaskbarNavButtonController.BUTTON_A11Y_LONG_CLICK; import static com.android.launcher3.taskbar.TaskbarNavButtonController.BUTTON_BACK; import static com.android.launcher3.taskbar.TaskbarNavButtonController.BUTTON_HOME; import static com.android.launcher3.taskbar.TaskbarNavButtonController.BUTTON_IME_SWITCH; @@ -36,11 +33,11 @@ import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_N import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_OVERVIEW_DISABLED; import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_QUICK_SETTINGS_EXPANDED; +import android.animation.ArgbEvaluator; import android.animation.ObjectAnimator; import android.annotation.DrawableRes; import android.annotation.IdRes; import android.annotation.LayoutRes; -import android.content.Context; import android.content.res.ColorStateList; import android.graphics.Rect; import android.graphics.Region; @@ -92,9 +89,8 @@ public class NavbarButtonsViewController { private static final int MASK_IME_SWITCHER_VISIBLE = FLAG_SWITCHER_SUPPORTED | FLAG_IME_VISIBLE; - private View.OnLongClickListener mA11yLongClickListener; private final ArrayList mPropertyHolders = new ArrayList<>(); - private final ArrayList mAllButtons = new ArrayList<>(); + private final ArrayList mAllButtons = new ArrayList<>(); private int mState; private final TaskbarActivityContext mContext; @@ -103,11 +99,17 @@ public class NavbarButtonsViewController { // Used for IME+A11Y buttons private final ViewGroup mEndContextualContainer; private final ViewGroup mStartContextualContainer; + private final int mLightIconColor; + private final int mDarkIconColor; private final AnimatedFloat mTaskbarNavButtonTranslationY = new AnimatedFloat( this::updateNavButtonTranslationY); private final AnimatedFloat mNavButtonTranslationYMultiplier = new AnimatedFloat( this::updateNavButtonTranslationY); + private final AnimatedFloat mTaskbarNavButtonDarkIntensity = new AnimatedFloat( + this::updateNavButtonDarkIntensity); + private final AnimatedFloat mNavButtonDarkIntensityMultiplier = new AnimatedFloat( + this::updateNavButtonDarkIntensity); private final RotationButtonListener mRotationButtonListener = new RotationButtonListener(); private final Rect mFloatingRotationButtonBounds = new Rect(); @@ -125,6 +127,9 @@ public class NavbarButtonsViewController { mNavButtonContainer = mNavButtonsView.findViewById(R.id.end_nav_buttons); mEndContextualContainer = mNavButtonsView.findViewById(R.id.end_contextual_buttons); mStartContextualContainer = mNavButtonsView.findViewById(R.id.start_contextual_buttons); + + mLightIconColor = context.getColor(R.color.taskbar_nav_icon_light_color); + mDarkIconColor = context.getColor(R.color.taskbar_nav_icon_dark_color); } /** @@ -135,11 +140,6 @@ public class NavbarButtonsViewController { mNavButtonsView.getLayoutParams().height = mContext.getDeviceProfile().taskbarSize; mNavButtonTranslationYMultiplier.value = 1; - mA11yLongClickListener = view -> { - mControllers.navButtonController.onButtonClick(BUTTON_A11Y_LONG_CLICK); - return true; - }; - mPropertyHolders.add(new StatePropertyHolder( mControllers.taskbarViewController.getTaskbarIconAlpha() .getProperty(ALPHA_INDEX_IME), @@ -278,7 +278,6 @@ public class NavbarButtonsViewController { mPropertyHolders.add(new StatePropertyHolder(mA11yButton, flags -> (flags & FLAG_A11Y_VISIBLE) != 0 && (flags & FLAG_ROTATION_BUTTON_VISIBLE) == 0)); - mA11yButton.setOnLongClickListener(mA11yLongClickListener); } private void parseSystemUiFlags(int sysUiStateFlags) { @@ -379,6 +378,16 @@ public class NavbarButtonsViewController { return mTaskbarNavButtonTranslationY; } + /** Use to set the dark intensity for the all nav+contextual buttons */ + public AnimatedFloat getTaskbarNavButtonDarkIntensity() { + return mTaskbarNavButtonDarkIntensity; + } + + /** Use to determine whether to use the dark intensity requested by the underlying app */ + public AnimatedFloat getNavButtonDarkIntensityMultiplier() { + return mNavButtonDarkIntensityMultiplier; + } + /** * Does not call {@link #applyState()}. Don't forget to! */ @@ -402,6 +411,16 @@ public class NavbarButtonsViewController { * mNavButtonTranslationYMultiplier.value); } + private void updateNavButtonDarkIntensity() { + float darkIntensity = mTaskbarNavButtonDarkIntensity.value + * mNavButtonDarkIntensityMultiplier.value; + int iconColor = (int) ArgbEvaluator.getInstance().evaluate(darkIntensity, mLightIconColor, + mDarkIconColor); + for (ImageView button : mAllButtons) { + button.setImageTintList(ColorStateList.valueOf(iconColor)); + } + } + private ImageView addButton(@DrawableRes int drawableId, @TaskbarButton int buttonType, ViewGroup parent, TaskbarNavButtonController navButtonController, @IdRes int id) { return addButton(drawableId, buttonType, parent, navButtonController, id, @@ -414,6 +433,8 @@ public class NavbarButtonsViewController { ImageView buttonView = addButton(parent, id, layoutId); buttonView.setImageResource(drawableId); buttonView.setOnClickListener(view -> navButtonController.onButtonClick(buttonType)); + buttonView.setOnLongClickListener(view -> + navButtonController.onButtonLongClick(buttonType)); return buttonView; } diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java index cc83431bf4..5354232e05 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java @@ -151,8 +151,8 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ buttonController, new NavbarButtonsViewController(this, navButtonsView), new RotationButtonController(this, - c.getColor(R.color.rotation_button_light_color), - c.getColor(R.color.rotation_button_dark_color), + c.getColor(R.color.taskbar_nav_icon_light_color), + c.getColor(R.color.taskbar_nav_icon_dark_color), R.drawable.ic_sysbar_rotate_button_ccw_start_0, R.drawable.ic_sysbar_rotate_button_ccw_start_90, R.drawable.ic_sysbar_rotate_button_cw_start_0, @@ -394,6 +394,11 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ mControllers.rotationButtonController.onBehaviorChanged(displayId, behavior); } + public void onNavButtonsDarkIntensityChanged(float darkIntensity) { + mControllers.navbarButtonsViewController.getTaskbarNavButtonDarkIntensity() + .updateValue(darkIntensity); + } + /** * Updates the TaskbarContainer to MATCH_PARENT vs original Taskbar size. */ diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarDragLayerController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarDragLayerController.java index 81039d4d58..248c40d978 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarDragLayerController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarDragLayerController.java @@ -52,6 +52,9 @@ public class TaskbarDragLayerController { // Initialized in init. private TaskbarControllers mControllers; + private AnimatedFloat mNavButtonDarkIntensityMultiplier; + + private float mLastSetBackgroundAlpha; public TaskbarDragLayerController(TaskbarActivityContext activity, TaskbarDragLayer taskbarDragLayer) { @@ -65,6 +68,9 @@ public class TaskbarDragLayerController { mControllers = controllers; mTaskbarDragLayer.init(new TaskbarDragLayerCallbacks()); + mNavButtonDarkIntensityMultiplier = mControllers.navbarButtonsViewController + .getNavButtonDarkIntensityMultiplier(); + mBgTaskbar.value = 1; mKeyguardBgTaskbar.value = 1; mNotificationShadeBgTaskbar.value = 1; @@ -114,13 +120,22 @@ public class TaskbarDragLayerController { final float bgNavbar = mBgNavbar.value; final float bgTaskbar = mBgTaskbar.value * mKeyguardBgTaskbar.value * mNotificationShadeBgTaskbar.value; - mTaskbarDragLayer.setTaskbarBackgroundAlpha( - mBgOverride.value * Math.max(bgNavbar, bgTaskbar) - ); + mLastSetBackgroundAlpha = mBgOverride.value * Math.max(bgNavbar, bgTaskbar); + mTaskbarDragLayer.setTaskbarBackgroundAlpha(mLastSetBackgroundAlpha); + + updateNavBarDarkIntensityMultiplier(); } private void updateBackgroundOffset() { mTaskbarDragLayer.setTaskbarBackgroundOffset(mBgOffset.value); + + updateNavBarDarkIntensityMultiplier(); + } + + private void updateNavBarDarkIntensityMultiplier() { + // Zero out the app-requested dark intensity when we're drawing our own background. + float effectiveBgAlpha = mLastSetBackgroundAlpha * (1 - mBgOffset.value); + mNavButtonDarkIntensityMultiplier.updateValue(1 - effectiveBgAlpha); } /** diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java index b2b078cb4f..6b7c597b45 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java @@ -42,7 +42,6 @@ import com.android.launcher3.DeviceProfile; import com.android.launcher3.LauncherAppState; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.statemanager.StatefulActivity; -import com.android.launcher3.testing.TestProtocol; import com.android.launcher3.util.DisplayController; import com.android.launcher3.util.DisplayController.Info; import com.android.launcher3.util.SettingsCache; @@ -269,6 +268,12 @@ public class TaskbarManager implements DisplayController.DisplayInfoChangeListen } } + public void onNavButtonsDarkIntensityChanged(float darkIntensity) { + if (mTaskbarActivityContext != null) { + mTaskbarActivityContext.onNavButtonsDarkIntensityChanged(darkIntensity); + } + } + /** * Called when the manager is no longer needed */ diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarNavButtonController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarNavButtonController.java index a8a0b59f87..ae23eda2a4 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarNavButtonController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarNavButtonController.java @@ -16,9 +16,11 @@ package com.android.launcher3.taskbar; -import static android.view.Display.DEFAULT_DISPLAY; -import android.view.inputmethod.InputMethodManager; +import static com.android.internal.app.AssistUtils.INVOCATION_TYPE_HOME_BUTTON_LONG_PRESS; +import static com.android.internal.app.AssistUtils.INVOCATION_TYPE_KEY; + +import android.os.Bundle; import androidx.annotation.IntDef; @@ -35,11 +37,9 @@ import java.lang.annotation.RetentionPolicy; * Controller for 3 button mode in the taskbar. * Handles all the functionality of the various buttons, making/routing the right calls into * launcher or sysui/system. - * - * TODO: Create callbacks to hook into UI layer since state will change for more context buttons/ - * assistant invocation. */ public class TaskbarNavButtonController { + @Retention(RetentionPolicy.SOURCE) @IntDef(value = { BUTTON_BACK, @@ -47,7 +47,6 @@ public class TaskbarNavButtonController { BUTTON_RECENTS, BUTTON_IME_SWITCH, BUTTON_A11Y, - BUTTON_A11Y_LONG_CLICK }) public @interface TaskbarButton {} @@ -57,7 +56,6 @@ public class TaskbarNavButtonController { static final int BUTTON_RECENTS = BUTTON_HOME << 1; static final int BUTTON_IME_SWITCH = BUTTON_RECENTS << 1; static final int BUTTON_A11Y = BUTTON_IME_SWITCH << 1; - static final int BUTTON_A11Y_LONG_CLICK = BUTTON_A11Y << 1; private final TouchInteractionService mService; @@ -82,9 +80,22 @@ public class TaskbarNavButtonController { case BUTTON_A11Y: notifyImeClick(false /* longClick */); break; - case BUTTON_A11Y_LONG_CLICK: + } + } + + public boolean onButtonLongClick(@TaskbarButton int buttonType) { + switch (buttonType) { + case BUTTON_HOME: + startAssistant(); + return true; + case BUTTON_A11Y: notifyImeClick(true /* longClick */); - break; + return true; + case BUTTON_BACK: + case BUTTON_IME_SWITCH: + case BUTTON_RECENTS: + default: + return false; } } @@ -113,4 +124,11 @@ public class TaskbarNavButtonController { systemUiProxy.notifyAccessibilityButtonClicked(mService.getDisplayId()); } } + + private void startAssistant() { + Bundle args = new Bundle(); + args.putInt(INVOCATION_TYPE_KEY, INVOCATION_TYPE_HOME_BUTTON_LONG_PRESS); + SystemUiProxy systemUiProxy = SystemUiProxy.INSTANCE.getNoCreate(); + systemUiProxy.startAssistant(args); + } } diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java index 377edbed5c..bda5a3044c 100644 --- a/quickstep/src/com/android/quickstep/TouchInteractionService.java +++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java @@ -289,6 +289,12 @@ public class TouchInteractionService extends Service .onSystemBarAttributesChanged(displayId, behavior)); } + @Override + public void onNavButtonsDarkIntensityChanged(float darkIntensity) { + executeForTaskbarManager(() -> mTaskbarManager + .onNavButtonsDarkIntensityChanged(darkIntensity)); + } + private void executeForTaskbarManager(final Runnable r) { MAIN_EXECUTOR.execute(() -> { if (mTaskbarManager == null) { diff --git a/quickstep/src/com/android/quickstep/ViewUtils.java b/quickstep/src/com/android/quickstep/ViewUtils.java index 184ab17ae2..e290be8e33 100644 --- a/quickstep/src/com/android/quickstep/ViewUtils.java +++ b/quickstep/src/com/android/quickstep/ViewUtils.java @@ -15,8 +15,10 @@ */ package com.android.quickstep; +import android.graphics.HardwareRenderer; import android.os.Handler; import android.view.View; +import android.view.ViewRootImpl; import com.android.launcher3.Utilities; import com.android.systemui.shared.system.ViewRootImplCompat; @@ -45,9 +47,9 @@ public class ViewUtils { return new FrameHandler(view, onFinishRunnable, canceled).schedule(); } - private static class FrameHandler implements LongConsumer { + private static class FrameHandler implements HardwareRenderer.FrameDrawingCallback { - final ViewRootImplCompat mViewRoot; + final ViewRootImpl mViewRoot; final Runnable mFinishCallback; final BooleanSupplier mCancelled; final Handler mHandler; @@ -55,14 +57,14 @@ public class ViewUtils { int mDeferFrameCount = 1; FrameHandler(View view, Runnable finishCallback, BooleanSupplier cancelled) { - mViewRoot = new ViewRootImplCompat(view); + mViewRoot = view.getViewRootImpl(); mFinishCallback = finishCallback; mCancelled = cancelled; mHandler = new Handler(); } @Override - public void accept(long l) { + public void onFrameDraw(long frame) { Utilities.postAsyncCallback(mHandler, this::onFrame); } @@ -83,7 +85,7 @@ public class ViewUtils { } private boolean schedule() { - if (mViewRoot.isValid()) { + if (mViewRoot.getView() != null) { mViewRoot.registerRtFrameCallback(this); mViewRoot.getView().invalidate(); return true; diff --git a/quickstep/src/com/android/quickstep/inputconsumers/AssistantInputConsumer.java b/quickstep/src/com/android/quickstep/inputconsumers/AssistantInputConsumer.java index 510820a1e5..162ace4965 100644 --- a/quickstep/src/com/android/quickstep/inputconsumers/AssistantInputConsumer.java +++ b/quickstep/src/com/android/quickstep/inputconsumers/AssistantInputConsumer.java @@ -24,6 +24,8 @@ import static android.view.MotionEvent.ACTION_POINTER_DOWN; import static android.view.MotionEvent.ACTION_POINTER_UP; import static android.view.MotionEvent.ACTION_UP; +import static com.android.internal.app.AssistUtils.INVOCATION_TYPE_GESTURE; +import static com.android.internal.app.AssistUtils.INVOCATION_TYPE_KEY; import static com.android.launcher3.Utilities.squaredHypot; import android.animation.Animator; @@ -64,8 +66,6 @@ public class AssistantInputConsumer extends DelegateInputConsumer { private static final String OPA_BUNDLE_TRIGGER = "triggered_by"; // From //java/com/google/android/apps/gsa/assistant/shared/proto/opa_trigger.proto. private static final int OPA_BUNDLE_TRIGGER_DIAG_SWIPE_GESTURE = 83; - private static final String INVOCATION_TYPE_KEY = "invocation_type"; - private static final int INVOCATION_TYPE_GESTURE = 1; private final PointF mDownPos = new PointF(); private final PointF mLastPos = new PointF(); diff --git a/quickstep/src/com/android/quickstep/util/SurfaceTransactionApplier.java b/quickstep/src/com/android/quickstep/util/SurfaceTransactionApplier.java index 3b4fd31fa5..3b1c150563 100644 --- a/quickstep/src/com/android/quickstep/util/SurfaceTransactionApplier.java +++ b/quickstep/src/com/android/quickstep/util/SurfaceTransactionApplier.java @@ -22,10 +22,10 @@ import android.os.Message; import android.view.SurfaceControl; import android.view.SurfaceControl.Transaction; import android.view.View; +import android.view.ViewRootImpl; import com.android.quickstep.RemoteAnimationTargets.ReleaseCheck; import com.android.systemui.shared.system.SyncRtSurfaceTransactionApplierCompat.SurfaceParams; -import com.android.systemui.shared.system.ViewRootImplCompat; import java.util.function.Consumer; @@ -41,7 +41,7 @@ public class SurfaceTransactionApplier extends ReleaseCheck { private static final int MSG_UPDATE_SEQUENCE_NUMBER = 0; private final SurfaceControl mBarrierSurfaceControl; - private final ViewRootImplCompat mTargetViewRootImpl; + private final ViewRootImpl mTargetViewRootImpl; private final Handler mApplyHandler; private int mLastSequenceNumber = 0; @@ -50,8 +50,8 @@ public class SurfaceTransactionApplier extends ReleaseCheck { * @param targetView The view in the surface that acts as synchronization anchor. */ public SurfaceTransactionApplier(View targetView) { - mTargetViewRootImpl = new ViewRootImplCompat(targetView); - mBarrierSurfaceControl = mTargetViewRootImpl.getRenderSurfaceControl(); + mTargetViewRootImpl = targetView.getViewRootImpl(); + mBarrierSurfaceControl = mTargetViewRootImpl.getSurfaceControl(); mApplyHandler = new Handler(this::onApplyMessage); } @@ -109,7 +109,7 @@ public class SurfaceTransactionApplier extends ReleaseCheck { if (targetView == null) { // No target view, no applier callback.accept(null); - } else if (new ViewRootImplCompat(targetView).isValid()) { + } else if (targetView.isAttachedToWindow()) { // Already attached, we're good to go callback.accept(new SurfaceTransactionApplier(targetView)); } else {