Merge "Make RefreshRateTracker to be injected by Dagger (11/n)" into main
diff --git a/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java b/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java
index 0b850bd..042bc9a 100644
--- a/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java
@@ -154,6 +154,12 @@
         }
     }
 
+    @Override
+    protected boolean isTaskbarTouchable() {
+        return !(mTaskbarLauncherStateController.isAnimatingToLauncher()
+                && mTaskbarLauncherStateController.isTaskbarAlignedWithHotseat());
+    }
+
     public void setShouldDelayLauncherStateAnim(boolean shouldDelayLauncherStateAnim) {
         mTaskbarLauncherStateController.setShouldDelayLauncherStateAnim(
                 shouldDelayLauncherStateAnim);
@@ -447,16 +453,6 @@
     }
 
     @Override
-    public boolean isHotseatVisibleForTaskBarAlignment() {
-        return mTaskbarLauncherStateController.isHotseatVisibleForTaskbarAlignment();
-    }
-
-    @Override
-    public boolean isAnimatingToLauncher() {
-        return mTaskbarLauncherStateController.isAnimatingToLauncher();
-    }
-
-    @Override
     protected boolean isInOverviewUi() {
         return mTaskbarLauncherStateController.isInOverviewUi();
     }
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarInsetsController.kt b/quickstep/src/com/android/launcher3/taskbar/TaskbarInsetsController.kt
index 55722a9..058dd07 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarInsetsController.kt
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarInsetsController.kt
@@ -47,7 +47,6 @@
 import com.android.internal.policy.GestureNavigationSettingsObserver
 import com.android.launcher3.DeviceProfile
 import com.android.launcher3.R
-import com.android.launcher3.Utilities
 import com.android.launcher3.anim.AlphaUpdateListener
 import com.android.launcher3.config.FeatureFlags.ENABLE_TASKBAR_NAVBAR_UNIFICATION
 import com.android.launcher3.config.FeatureFlags.enableTaskbarNoRecreate
@@ -134,6 +133,9 @@
         }
 
         val bubbleControllers = controllers.bubbleControllers.getOrNull()
+        val taskbarTouchableHeight = taskbarStashController.touchableHeight
+        val bubblesTouchableHeight =
+            bubbleControllers?.bubbleStashController?.getTouchableHeight() ?: 0
         // reset touch bounds
         defaultTouchableRegion.setEmpty()
         if (bubbleControllers != null) {
@@ -145,41 +147,16 @@
                 defaultTouchableRegion.addBoundsToRegion(bubbleBarViewController.bubbleBarBounds)
             }
         }
-        val uiController = controllers.uiController
         if (
-            !uiController.isHotseatVisibleForTaskBarAlignment ||
+            taskbarStashController.isInApp ||
+                taskbarStashController.isInOverview ||
                 DisplayController.showLockedTaskbarOnHome(context)
         ) {
-            // adding the taskbar touch region
-            var left = 0
-            var right = context.deviceProfile.widthPx
-            val touchableHeight: Int
-            if (uiController.isAnimatingToLauncher) {
-                val dp = controllers.taskbarActivityContext.deviceProfile
-                touchableHeight = windowLayoutParams.height
-                if (dp.isQsbInline) {
-                    // if Qsb is inline need to exclude search icon from touch region
-                    val isRtl = Utilities.isRtl(context.resources)
-                    val navBarOffset =
-                        bubbleControllers?.bubbleBarViewController?.let {
-                            val isBubblesOnLeft = it.bubbleBarLocation.isOnLeft(isRtl)
-                            dp.getHotseatTranslationXForNavBar(context, isBubblesOnLeft)
-                        } ?: 0
-                    val hotseatPadding: Rect = dp.getHotseatLayoutPadding(context)
-                    val borderSpacing: Int = dp.hotseatBorderSpace
-                    if (isRtl) {
-                        right = dp.widthPx - hotseatPadding.right + borderSpacing + navBarOffset
-                    } else {
-                        left = hotseatPadding.left - borderSpacing + navBarOffset
-                    }
-                }
-            } else {
-                // if not animating to launcher use the taskbar touchanle height
-                touchableHeight = taskbarStashController.touchableHeight
-            }
+            // only add the taskbar touch region if not on home
             val bottom = windowLayoutParams.height
-            val top = bottom - touchableHeight
-            defaultTouchableRegion.addBoundsToRegion(Rect(left, top, right, bottom))
+            val top = bottom - taskbarTouchableHeight
+            val right = context.deviceProfile.widthPx
+            defaultTouchableRegion.addBoundsToRegion(Rect(/* left= */ 0, top, right, bottom))
         }
 
         // Pre-calculate insets for different providers across different rotations for this gravity
@@ -391,6 +368,10 @@
             // Let touches pass through us.
             insetsInfo.setTouchableInsets(TOUCHABLE_INSETS_REGION)
             debugTouchableRegion.lastSetTouchableReason = "Stashed over IME"
+        } else if (!controllers.uiController.isTaskbarTouchable) {
+            // Let touches pass through us.
+            insetsInfo.setTouchableInsets(TOUCHABLE_INSETS_REGION)
+            debugTouchableRegion.lastSetTouchableReason = "Taskbar is not touchable"
         } else if (controllers.taskbarDragController.isSystemDragInProgress) {
             // Let touches pass through us.
             insetsInfo.setTouchableInsets(TOUCHABLE_INSETS_REGION)
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java
index 4bc7d3c..fa04739 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java
@@ -190,8 +190,6 @@
 
     private boolean mIsQsbInline;
 
-    private boolean mIsHotseatVisibleForTaskbarAlignment;
-
     private final DeviceProfile.OnDeviceProfileChangeListener mOnDeviceProfileChangeListener =
             new DeviceProfile.OnDeviceProfileChangeListener() {
                 @Override
@@ -733,7 +731,6 @@
             boolean committed) {
         boolean isInStashedState = mLauncherState.isTaskbarStashed(mLauncher);
         TaskbarStashController stashController = mControllers.taskbarStashController;
-        TaskbarInsetsController insetsController = mControllers.taskbarInsetsController;
         stashController.updateStateForFlag(FLAG_IN_STASHED_LAUNCHER_STATE, isInStashedState);
         Animator stashAnimator = stashController.createApplyStateAnimator(duration);
         if (stashAnimator != null) {
@@ -742,11 +739,7 @@
                 public void onAnimationEnd(Animator animation) {
                     if (isInStashedState && committed) {
                         // Reset hotseat alpha to default
-                        updateIconAlphaForHome(
-                                /* taskbarAlpha = */ 0,
-                                ALPHA_CHANNEL_TASKBAR_ALIGNMENT,
-                                /* updateTaskbarAlpha = */ false
-                        );
+                        mLauncher.getHotseat().setIconsAlpha(1, ALPHA_CHANNEL_TASKBAR_ALIGNMENT);
                     }
                 }
 
@@ -871,14 +864,6 @@
         if (mIsQsbInline) {
             mLauncher.getHotseat().setQsbAlpha(targetAlpha, alphaChannel);
         }
-        if (alphaChannel == ALPHA_CHANNEL_TASKBAR_ALIGNMENT) {
-            boolean isHotseatVisibleForTaskbarAlignment = isHotseatVisibleForTaskbarAlignment();
-            if (mIsHotseatVisibleForTaskbarAlignment != isHotseatVisibleForTaskbarAlignment) {
-                mIsHotseatVisibleForTaskbarAlignment = isHotseatVisibleForTaskbarAlignment;
-                mControllers.taskbarInsetsController
-                        .onTaskbarOrBubblebarWindowHeightOrInsetsChanged();
-            }
-        }
     }
 
     /** Updates launcher home screen appearance accordingly to the bubble bar location. */
@@ -939,13 +924,6 @@
         translationXAnimation.start();
     }
 
-    /** Returns true if hotseat icons visible for the taskbar alignment */
-    public boolean isHotseatVisibleForTaskbarAlignment() {
-        return mLauncher.getHotseat()
-                .getIconsAlpha(ALPHA_CHANNEL_TASKBAR_ALIGNMENT).getValue() == 1;
-    }
-
-
     private final class TaskBarRecentsAnimationListener implements
             RecentsAnimationCallbacks.RecentsAnimationListener {
         private final RecentsAnimationCallbacks mCallbacks;
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java
index db69e8f..7030088 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java
@@ -75,14 +75,8 @@
         mControllers = null;
     }
 
-    /** Returns true if transition animation to launcher home is being played. */
-    public boolean isAnimatingToLauncher() {
-        return false;
-    }
-
-    /** Returns true if hotseat icons visible for the taskbar alignment. */
-    public boolean isHotseatVisibleForTaskBarAlignment() {
-        return false;
+    protected boolean isTaskbarTouchable() {
+        return true;
     }
 
     /**
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java
index c0891a9..fcb583a 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java
@@ -185,6 +185,7 @@
                     resources.getDrawable(R.drawable.taskbar_overflow_icon));
             mTaskbarOverflowView.setPadding(mItemPadding, mItemPadding, mItemPadding, mItemPadding);
         }
+        // TODO: Disable touch events on QSB otherwise it can crash.
         mQsb = LayoutInflater.from(context).inflate(R.layout.search_container_hotseat, this, false);
 
         mMaxNumIcons = calculateMaxNumIcons();
diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java
index 5acff06..8dce723 100644
--- a/src/com/android/launcher3/BubbleTextView.java
+++ b/src/com/android/launcher3/BubbleTextView.java
@@ -187,7 +187,7 @@
     @ViewDebug.ExportedProperty(category = "launcher")
     private DotInfo mDotInfo;
     private DotRenderer mDotRenderer;
-    private Locale mCurrentLocale;
+    private String mCurrentLanguage;
     @ViewDebug.ExportedProperty(category = "launcher", deepExport = true)
     protected DotRenderer.DrawParams mDotParams;
     private Animator mDotScaleAnim;
@@ -298,7 +298,7 @@
 
         mDotParams = new DotRenderer.DrawParams();
 
-        mCurrentLocale = context.getResources().getConfiguration().locale;
+        mCurrentLanguage = context.getResources().getConfiguration().locale.getLanguage();
         setEllipsize(TruncateAt.END);
         setAccessibilityDelegate(mActivity.getAccessibilityDelegate());
         setTextAlpha(1f);
@@ -494,7 +494,7 @@
     }
 
     protected boolean isCurrentLanguageEnglish() {
-        return mCurrentLocale.equals(Locale.US);
+        return mCurrentLanguage.equals(Locale.ENGLISH.getLanguage());
     }
 
     @UiThread