Merge "Close system windows when toggling overview" into tm-dev
diff --git a/fill_screens.py b/fill_screens.py
deleted file mode 100755
index a887792..0000000
--- a/fill_screens.py
+++ /dev/null
@@ -1,90 +0,0 @@
-#!/usr/bin/env python2.5
-
-import cgi
-import os
-import shutil
-import sys
-import sqlite3
-
-SCREENS = 5
-COLUMNS = 4
-ROWS = 4
-CELL_SIZE = 110
-
-DIR = "db_files"
-AUTO_FILE = "launcher.db"
-
-APPLICATION_COMPONENTS = [
-  "com.android.calculator2/com.android.calculator2.Calculator",
-  "com.android.providers.downloads.ui/com.android.providers.downloads.ui.DownloadList",
-  "com.android.settings/com.android.settings.Settings",
-  "com.android.mms/com.android.mms.ui.ConversationList",
-  "com.android.contacts/com.android.contacts.activities.PeopleActivity",
-  "com.android.dialer/com.android.dialer.DialtactsActivity"
-]
-
-def usage():
-  print "usage: fill_screens.py -- fills up the launcher db"
-
-
-def make_dir():
-  shutil.rmtree(DIR, True)
-  os.makedirs(DIR)
-
-def pull_file(fn):
-  print "pull_file: " + fn
-  rv = os.system("adb pull"
-    + " /data/data/com.android.launcher/databases/launcher.db"
-    + " " + fn);
-  if rv != 0:
-    print "adb pull failed"
-    sys.exit(1)
-
-def push_file(fn):
-  print "push_file: " + fn
-  rv = os.system("adb push"
-    + " " + fn
-    + " /data/data/com.android.launcher/databases/launcher.db")
-  if rv != 0:
-    print "adb push failed"
-    sys.exit(1)
-
-def process_file(fn):
-  print "process_file: " + fn
-  conn = sqlite3.connect(fn)
-  c = conn.cursor()
-  c.execute("DELETE FROM favorites")
-
-  intentFormat = "#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=%s;end"
-
-  id = 0;
-  for s in range(SCREENS):
-    for x in range(ROWS):
-      for y in range(COLUMNS):
-        id += 1
-        insert = "INSERT into favorites (_id, title, intent, container, screen, cellX, cellY, spanX, spanY, itemType, appWidgetId, iconType) VALUES (%d, '%s', '%s', %d, %d, %d, %d, %d, %d, %d, %d, %d)"
-        insert = insert % (id, "title", "", -100, s, x, y, 1, 1, 2, -1, 0)
-        c.execute(insert)
-        folder_id = id
-
-        for z in range(15):
-          id += 1
-          intent = intentFormat % (APPLICATION_COMPONENTS[id % len(APPLICATION_COMPONENTS)])
-          insert = "INSERT into favorites (_id, title, intent, container, screen, cellX, cellY, spanX, spanY, itemType, appWidgetId, iconType) VALUES (%d, '%s', '%s', %d, %d, %d, %d, %d, %d, %d, %d, %d)"
-          insert = insert % (id, "title", intent, folder_id, 0, 0, 0, 1, 1, 0, -1, 0)
-          c.execute(insert)
-
-  conn.commit()
-  c.close()
-
-def main(argv):
-  if len(argv) == 1:
-    make_dir()
-    pull_file(AUTO_FILE)
-    process_file(AUTO_FILE)
-    push_file(AUTO_FILE)
-  else:
-    usage()
-
-if __name__=="__main__":
-  main(sys.argv)
diff --git a/quickstep/res/values-ru/strings.xml b/quickstep/res/values-ru/strings.xml
index 8deb58e..6b36b5a 100644
--- a/quickstep/res/values-ru/strings.xml
+++ b/quickstep/res/values-ru/strings.xml
@@ -76,8 +76,7 @@
     <string name="allset_title" msgid="5021126669778966707">"Готово!"</string>
     <string name="allset_hint" msgid="2384632994739392447">"Чтобы перейти на главный экран, проведите вверх."</string>
     <string name="allset_description" msgid="6350320429953234580">"Теперь вы можете использовать телефон."</string>
-    <!-- no translation found for allset_description_tablet (7332070270570039247) -->
-    <skip />
+    <string name="allset_description_tablet" msgid="7332070270570039247">"Теперь вы можете использовать планшет."</string>
     <string name="allset_navigation_settings" msgid="4713404605961476027"><annotation id="link">"Системные настройки навигации"</annotation></string>
     <string name="action_share" msgid="2648470652637092375">"Поделиться"</string>
     <string name="action_screenshot" msgid="8171125848358142917">"Скриншот"</string>
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
index 0f3a6ee..5479664 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
@@ -22,6 +22,7 @@
 import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL;
 
 import static com.android.launcher3.AbstractFloatingView.TYPE_ALL;
+import static com.android.launcher3.AbstractFloatingView.TYPE_REBIND_SAFE;
 import static com.android.launcher3.ResourceUtils.getBoolByName;
 import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_FOLDER_OPEN;
 import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED;
@@ -227,6 +228,11 @@
     public void updateDeviceProfile(DeviceProfile dp) {
         mDeviceProfile = dp;
         updateIconSize(getResources());
+
+        AbstractFloatingView.closeAllOpenViewsExcept(this, false, TYPE_REBIND_SAFE);
+        // Reapply fullscreen to take potential new screen size into account.
+        setTaskbarWindowFullscreen(mIsFullscreen);
+
         dispatchDeviceProfileChanged();
     }
 
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java
index 0b537e2..8291475 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java
@@ -28,6 +28,7 @@
 import androidx.annotation.LayoutRes;
 import androidx.annotation.NonNull;
 import androidx.annotation.Nullable;
+import androidx.core.graphics.ColorUtils;
 
 import com.android.launcher3.BubbleTextView;
 import com.android.launcher3.Insettable;
@@ -35,6 +36,7 @@
 import com.android.launcher3.Utilities;
 import com.android.launcher3.config.FeatureFlags;
 import com.android.launcher3.folder.FolderIcon;
+import com.android.launcher3.icons.ThemedIconDrawable;
 import com.android.launcher3.model.data.FolderInfo;
 import com.android.launcher3.model.data.ItemInfo;
 import com.android.launcher3.model.data.WorkspaceItemInfo;
@@ -43,14 +45,17 @@
 import com.android.launcher3.util.LauncherBindableItemsContainer;
 import com.android.launcher3.views.ActivityContext;
 import com.android.launcher3.views.AllAppsButton;
+import com.android.launcher3.views.DoubleShadowBubbleTextView;
 
 /**
  * Hosts the Taskbar content such as Hotseat and Recent Apps. Drawn on top of other apps.
  */
 public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconParent, Insettable {
 
-    private final int[] mTempOutLocation = new int[2];
+    private static final float TASKBAR_BACKGROUND_LUMINANCE = 0.30f;
+    public int mThemeIconsBackground;
 
+    private final int[] mTempOutLocation = new int[2];
     private final Rect mIconLayoutBounds = new Rect();
     private final int mIconTouchSize;
     private final int mItemMarginLeftRight;
@@ -103,6 +108,8 @@
         // Needed to draw folder leave-behind when opening one.
         setWillNotDraw(false);
 
+        mThemeIconsBackground = calculateThemeIconsBackground();
+
         if (FeatureFlags.ENABLE_ALL_APPS_IN_TASKBAR.get()) {
             mAllAppsButton = new AllAppsButton(context);
             mAllAppsButton.setLayoutParams(
@@ -111,6 +118,21 @@
         }
     }
 
+    private int getColorWithGivenLuminance(int color, float luminance) {
+        float[] colorHSL = new float[3];
+        ColorUtils.colorToHSL(color, colorHSL);
+        colorHSL[2] = luminance;
+        return ColorUtils.HSLToColor(colorHSL);
+    }
+
+    private int calculateThemeIconsBackground() {
+        int color = ThemedIconDrawable.getColors(mContext)[0];
+        if (Utilities.isDarkTheme(mContext)) {
+            return getColorWithGivenLuminance(color, TASKBAR_BACKGROUND_LUMINANCE);
+        }
+        return color;
+    }
+
     protected void init(TaskbarViewController.TaskbarViewCallbacks callbacks) {
         mControllerCallbacks = callbacks;
         mIconClickListener = mControllerCallbacks.getIconOnClickListener();
@@ -219,6 +241,24 @@
             int index = Utilities.isRtl(getResources()) ? 0 : getChildCount();
             addView(mAllAppsButton, index);
         }
+
+        mThemeIconsBackground = calculateThemeIconsBackground();
+        setThemedIconsBackgroundColor(mThemeIconsBackground);
+    }
+
+    /**
+     * Traverse all the child views and change the background of themeIcons
+     **/
+    public void setThemedIconsBackgroundColor(int color) {
+        for (View icon : getIconViews()) {
+            if (icon instanceof DoubleShadowBubbleTextView) {
+                DoubleShadowBubbleTextView textView = ((DoubleShadowBubbleTextView) icon);
+                if (textView.getIcon() != null
+                        && textView.getIcon() instanceof ThemedIconDrawable) {
+                    ((ThemedIconDrawable) textView.getIcon()).changeBackgroundColor(color);
+                }
+            }
+        }
     }
 
     /**
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java
index a89061b..f5c382d 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java
@@ -27,6 +27,7 @@
 import android.view.MotionEvent;
 import android.view.View;
 
+import androidx.core.graphics.ColorUtils;
 import androidx.core.view.OneShotPreDrawListener;
 
 import com.android.launcher3.BubbleTextView;
@@ -37,6 +38,7 @@
 import com.android.launcher3.anim.PendingAnimation;
 import com.android.launcher3.config.FeatureFlags;
 import com.android.launcher3.folder.FolderIcon;
+import com.android.launcher3.icons.ThemedIconDrawable;
 import com.android.launcher3.model.data.ItemInfo;
 import com.android.launcher3.util.ItemInfoMatcher;
 import com.android.launcher3.util.LauncherBindableItemsContainer;
@@ -71,6 +73,9 @@
             this::updateTranslationY);
     private AnimatedFloat mTaskbarNavButtonTranslationY;
 
+    private final AnimatedFloat mThemeIconsBackground = new AnimatedFloat(
+            this::updateIconsBackground);
+
     private final TaskbarModelCallbacks mModelCallbacks;
 
     // Initialized in init.
@@ -81,6 +86,8 @@
     private AnimatorPlaybackController mIconAlignControllerLazy = null;
     private Runnable mOnControllerPreCreateCallback = NO_OP;
 
+    private int mThemeIconsColor;
+
     public TaskbarViewController(TaskbarActivityContext activity, TaskbarView taskbarView) {
         mActivity = activity;
         mTaskbarView = taskbarView;
@@ -93,6 +100,7 @@
         mControllers = controllers;
         mTaskbarView.init(new TaskbarViewCallbacks());
         mTaskbarView.getLayoutParams().height = mActivity.getDeviceProfile().taskbarSize;
+        mThemeIconsColor = ThemedIconDrawable.getColors(mTaskbarView.getContext())[0];
 
         mTaskbarIconScaleForStash.updateValue(1f);
 
@@ -182,6 +190,15 @@
                 + mTaskbarIconTranslationYForStash.value);
     }
 
+    private void updateIconsBackground() {
+        mTaskbarView.setThemedIconsBackgroundColor(
+                ColorUtils.blendARGB(
+                        mThemeIconsColor,
+                        mTaskbarView.mThemeIconsBackground,
+                        mThemeIconsBackground.value
+                ));
+    }
+
     /**
      * Sets the taskbar icon alignment relative to Launcher hotseat icons
      * @param alignmentRatio [0, 1]
@@ -217,6 +234,10 @@
         setter.setFloat(mTaskbarIconTranslationYForHome, VALUE, -offsetY, LINEAR);
         setter.setFloat(mTaskbarNavButtonTranslationY, VALUE, -offsetY, LINEAR);
 
+        if (Utilities.isDarkTheme(mTaskbarView.getContext())) {
+            setter.addFloat(mThemeIconsBackground, VALUE, 0f, 1f, LINEAR);
+        }
+
         int collapsedHeight = mActivity.getDefaultTaskbarWindowHeight();
         int expandedHeight = Math.max(collapsedHeight,
                 mActivity.getDeviceProfile().taskbarSize + offsetY);
diff --git a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsContext.java b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsContext.java
index 50dfff0..1cdbdb2 100644
--- a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsContext.java
+++ b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsContext.java
@@ -19,6 +19,7 @@
 import static android.view.KeyEvent.KEYCODE_BACK;
 import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
 
+import static com.android.launcher3.AbstractFloatingView.TYPE_REBIND_SAFE;
 import static com.android.systemui.shared.system.ViewTreeObserverWrapper.InsetsInfo.TOUCHABLE_INSETS_REGION;
 
 import android.content.Context;
@@ -143,6 +144,9 @@
     @Override
     public void updateDeviceProfile(DeviceProfile dp) {
         mDeviceProfile = dp;
+
+        AbstractFloatingView.closeAllOpenViewsExcept(this, false, TYPE_REBIND_SAFE);
+
         dispatchDeviceProfileChanged();
     }
 
diff --git a/quickstep/src/com/android/quickstep/RotationTouchHelper.java b/quickstep/src/com/android/quickstep/RotationTouchHelper.java
index dad5071..f952e0d 100644
--- a/quickstep/src/com/android/quickstep/RotationTouchHelper.java
+++ b/quickstep/src/com/android/quickstep/RotationTouchHelper.java
@@ -22,6 +22,7 @@
 import static com.android.launcher3.util.DisplayController.CHANGE_ALL;
 import static com.android.launcher3.util.DisplayController.CHANGE_NAVIGATION_MODE;
 import static com.android.launcher3.util.DisplayController.CHANGE_ROTATION;
+import static com.android.launcher3.util.DisplayController.CHANGE_SUPPORTED_BOUNDS;
 import static com.android.launcher3.util.DisplayController.NavigationMode.THREE_BUTTONS;
 import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR;
 
@@ -250,7 +251,8 @@
     }
 
     private void onDisplayInfoChangedInternal(Info info, int flags, boolean forceRegister) {
-        if ((flags & (CHANGE_ROTATION | CHANGE_ACTIVE_SCREEN | CHANGE_NAVIGATION_MODE)) != 0) {
+        if ((flags & (CHANGE_ROTATION | CHANGE_ACTIVE_SCREEN | CHANGE_NAVIGATION_MODE
+                | CHANGE_SUPPORTED_BOUNDS)) != 0) {
             mDisplayRotation = info.rotation;
 
             if (mMode.hasGestures) {
diff --git a/quickstep/tests/src/com/android/quickstep/FallbackRecentsTest.java b/quickstep/tests/src/com/android/quickstep/FallbackRecentsTest.java
index 4529217..9b38853 100644
--- a/quickstep/tests/src/com/android/quickstep/FallbackRecentsTest.java
+++ b/quickstep/tests/src/com/android/quickstep/FallbackRecentsTest.java
@@ -57,6 +57,7 @@
 import com.android.launcher3.testcomponent.TestCommandReceiver;
 import com.android.launcher3.util.Wait;
 import com.android.launcher3.util.rule.FailureWatcher;
+import com.android.launcher3.util.rule.ScreenRecordRule.ScreenRecord;
 import com.android.quickstep.views.RecentsView;
 
 import org.junit.After;
@@ -160,6 +161,7 @@
     // b/143488140
     //@NavigationModeSwitch
     @Test
+    @ScreenRecord // b/223278795
     public void goToOverviewFromHome() {
         mDevice.pressHome();
         assertTrue("Fallback Launcher not visible", mDevice.wait(Until.hasObject(By.pkg(
diff --git a/res/color-v31/overview_scrim_dark.xml b/res/color-v31/overview_scrim_dark.xml
index 2ab8ecd..487b9f8 100644
--- a/res/color-v31/overview_scrim_dark.xml
+++ b/res/color-v31/overview_scrim_dark.xml
@@ -14,5 +14,5 @@
      limitations under the License.
 -->
 <selector xmlns:android="http://schemas.android.com/apk/res/android">
-  <item android:color="@android:color/system_neutral1_500" android:lStar="35" />
+  <item android:color="@android:color/system_neutral1_500" android:lStar="15" />
 </selector>
diff --git a/src/com/android/launcher3/AbstractFloatingView.java b/src/com/android/launcher3/AbstractFloatingView.java
index e75348c..ceb38d0 100644
--- a/src/com/android/launcher3/AbstractFloatingView.java
+++ b/src/com/android/launcher3/AbstractFloatingView.java
@@ -103,7 +103,7 @@
     public static final int TYPE_REBIND_SAFE = TYPE_WIDGETS_FULL_SHEET
             | TYPE_WIDGETS_BOTTOM_SHEET | TYPE_ON_BOARD_POPUP | TYPE_DISCOVERY_BOUNCE
             | TYPE_ALL_APPS_EDU | TYPE_ICON_SURFACE | TYPE_WIDGETS_EDUCATION_DIALOG
-            | TYPE_TASKBAR_EDUCATION_DIALOG;
+            | TYPE_TASKBAR_EDUCATION_DIALOG | TYPE_TASKBAR_ALL_APPS;
 
     // Usually we show the back button when a floating view is open. Instead, hide for these types.
     public static final int TYPE_HIDE_BACK_BUTTON = TYPE_ON_BOARD_POPUP | TYPE_DISCOVERY_BOUNCE
diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java
index 3bc0f6d..74ec7ee 100644
--- a/src/com/android/launcher3/BubbleTextView.java
+++ b/src/com/android/launcher3/BubbleTextView.java
@@ -55,7 +55,6 @@
 import com.android.launcher3.dot.DotInfo;
 import com.android.launcher3.dragndrop.DraggableView;
 import com.android.launcher3.folder.FolderIcon;
-import com.android.launcher3.graphics.IconPalette;
 import com.android.launcher3.graphics.IconShape;
 import com.android.launcher3.graphics.PreloadIconDrawable;
 import com.android.launcher3.icons.DotRenderer;
@@ -378,8 +377,7 @@
             flags |= FLAG_NO_BADGE;
         }
         FastBitmapDrawable iconDrawable = info.newIcon(getContext(), flags);
-        mDotParams.color = IconPalette.getMutedColor(iconDrawable.getIconColor(), 0.54f);
-
+        mDotParams.color = iconDrawable.getIconColor();
         setIcon(iconDrawable);
         applyLabel(info);
     }
diff --git a/src/com/android/launcher3/graphics/IconPalette.java b/src/com/android/launcher3/graphics/IconPalette.java
index 3d4a100..778b32a 100644
--- a/src/com/android/launcher3/graphics/IconPalette.java
+++ b/src/com/android/launcher3/graphics/IconPalette.java
@@ -16,18 +16,16 @@
 
 package com.android.launcher3.graphics;
 
-import static com.android.launcher3.icons.GraphicsUtils.setColorAlphaBound;
-
 import android.app.Notification;
 import android.content.Context;
 import android.graphics.Color;
 import android.util.Log;
 
+import androidx.core.graphics.ColorUtils;
+
 import com.android.launcher3.R;
 import com.android.launcher3.util.Themes;
 
-import androidx.core.graphics.ColorUtils;
-
 /**
  * Contains colors based on the dominant color of an icon.
  */
@@ -147,9 +145,4 @@
         }
         return ColorUtils.LABToColor(low, a, b);
     }
-
-    public static int getMutedColor(int color, float whiteScrimAlpha) {
-        int whiteScrim = setColorAlphaBound(Color.WHITE, (int) (255 * whiteScrimAlpha));
-        return ColorUtils.compositeColors(whiteScrim, color);
-    }
 }
diff --git a/src/com/android/launcher3/settings/NotificationDotsPreference.java b/src/com/android/launcher3/settings/NotificationDotsPreference.java
index 0ee2744..f2a052d 100644
--- a/src/com/android/launcher3/settings/NotificationDotsPreference.java
+++ b/src/com/android/launcher3/settings/NotificationDotsPreference.java
@@ -89,7 +89,8 @@
         // Update intent
         Bundle extras = new Bundle();
         extras.putString(EXTRA_FRAGMENT_ARG_KEY, "notification_badging");
-        setIntent(new Intent("android.settings.NOTIFICATION_SETTINGS")
+
+        setIntent(new Intent("android.settings.SETTINGS_EMBED_DEEP_LINK_ACTIVITY")
                 .putExtra(EXTRA_SHOW_FRAGMENT_ARGS, extras));
     }