Merge "Support entering PiP from live tile" into sc-dev
diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/TaskViewTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/TaskViewTouchController.java
index c2e5cda..70b3870 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/TaskViewTouchController.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/TaskViewTouchController.java
@@ -167,6 +167,7 @@
                                 mAllowGoingDown = true;
                                 directionsToDetectScroll = DIRECTION_BOTH;
                             } else {
+                                mAllowGoingDown = false;
                                 directionsToDetectScroll = upDirection;
                             }
                         }
diff --git a/quickstep/src/com/android/quickstep/inputconsumers/OverviewInputConsumer.java b/quickstep/src/com/android/quickstep/inputconsumers/OverviewInputConsumer.java
index fa9e0ec..4af6338 100644
--- a/quickstep/src/com/android/quickstep/inputconsumers/OverviewInputConsumer.java
+++ b/quickstep/src/com/android/quickstep/inputconsumers/OverviewInputConsumer.java
@@ -18,6 +18,8 @@
 import static com.android.quickstep.util.NavigationModeFeatureFlag.LIVE_TILE;
 import static com.android.systemui.shared.system.ActivityManagerWrapper.CLOSE_SYSTEM_WINDOWS_REASON_RECENTS;
 
+import android.media.AudioManager;
+import android.media.session.MediaSessionManager;
 import android.view.KeyEvent;
 import android.view.MotionEvent;
 
@@ -101,6 +103,17 @@
     @Override
     public void onKeyEvent(KeyEvent ev) {
         if (LIVE_TILE.get()) {
+            switch (ev.getKeyCode()) {
+                case KeyEvent.KEYCODE_VOLUME_DOWN:
+                case KeyEvent.KEYCODE_VOLUME_UP:
+                case KeyEvent.KEYCODE_VOLUME_MUTE:
+                    MediaSessionManager mgr = mActivity.getSystemService(MediaSessionManager.class);
+                    mgr.dispatchVolumeKeyEventAsSystemService(ev,
+                            AudioManager.USE_DEFAULT_STREAM_TYPE);
+                    break;
+                default:
+                    break;
+            }
             mActivity.dispatchKeyEvent(ev);
         }
     }
diff --git a/res/color/all_apps_tab_text.xml b/res/color/all_apps_tab_text.xml
index f0c6310..0c9acf9 100644
--- a/res/color/all_apps_tab_text.xml
+++ b/res/color/all_apps_tab_text.xml
@@ -14,6 +14,6 @@
      limitations under the License.
 -->
 <selector xmlns:android="http://schemas.android.com/apk/res/android">
-    <item android:color="?android:attr/colorAccent" android:state_selected="true"/>
+    <item android:color="@android:color/white" android:state_selected="true"/>
     <item android:color="?android:attr/textColorTertiary"/>
 </selector>
\ No newline at end of file
diff --git a/res/drawable/all_apps_tabs_background.xml b/res/drawable/all_apps_tabs_background.xml
new file mode 100644
index 0000000..ca2beec
--- /dev/null
+++ b/res/drawable/all_apps_tabs_background.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?><!--
+     Copyright (C) 2021 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.
+-->
+<shape android:shape="rectangle"
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:androidprv="http://schemas.android.com/apk/prv/res/android">
+    <solid android:color="?androidprv:attr/colorSurfaceVariant" />
+    <corners android:radius="@dimen/all_apps_header_pill_corner_radius" />
+</shape>
\ No newline at end of file
diff --git a/res/layout/all_apps_personal_work_tabs.xml b/res/layout/all_apps_personal_work_tabs.xml
index 5fb5bcb..cefd0ab 100644
--- a/res/layout/all_apps_personal_work_tabs.xml
+++ b/res/layout/all_apps_personal_work_tabs.xml
@@ -19,7 +19,8 @@
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/tabs"
     android:layout_width="match_parent"
-    android:layout_height="@dimen/all_apps_header_tab_height"
+    android:layout_height="@dimen/all_apps_header_pill_height"
+    android:background="@drawable/all_apps_tabs_background"
     android:layout_marginLeft="@dimen/all_apps_tabs_side_padding"
     android:layout_marginRight="@dimen/all_apps_tabs_side_padding"
     android:orientation="horizontal"
diff --git a/res/layout/all_apps_tabs.xml b/res/layout/all_apps_tabs.xml
index 2accd2d..de4a69d 100644
--- a/res/layout/all_apps_tabs.xml
+++ b/res/layout/all_apps_tabs.xml
@@ -22,7 +22,7 @@
     android:layout_height="match_parent"
     android:layout_below="@id/search_container_all_apps"
     android:layout_gravity="center_horizontal|top"
-    android:layout_marginTop="@dimen/all_apps_header_tab_height"
+    android:layout_marginTop="@dimen/all_apps_header_pill_height"
     android:clipChildren="true"
     android:clipToPadding="false"
     android:descendantFocusability="afterDescendants"
diff --git a/res/layout/secondary_launcher.xml b/res/layout/secondary_launcher.xml
index e3c60ec..94fcdb9 100644
--- a/res/layout/secondary_launcher.xml
+++ b/res/layout/secondary_launcher.xml
@@ -70,7 +70,7 @@
             <com.android.launcher3.workprofile.PersonalWorkSlidingTabStrip
                 android:id="@+id/tabs"
                 android:layout_width="match_parent"
-                android:layout_height="@dimen/all_apps_header_tab_height"
+                android:layout_height="@dimen/all_apps_header_pill_height"
                 android:layout_marginLeft="@dimen/all_apps_tabs_side_padding"
                 android:layout_marginRight="@dimen/all_apps_tabs_side_padding"
                 android:orientation="horizontal"
diff --git a/res/layout/widgets_bottom_sheet_content.xml b/res/layout/widgets_bottom_sheet_content.xml
index a9d523a..85c6488 100644
--- a/res/layout/widgets_bottom_sheet_content.xml
+++ b/res/layout/widgets_bottom_sheet_content.xml
@@ -15,10 +15,12 @@
 -->
 <merge xmlns:android="http://schemas.android.com/apk/res/android">
     <View
+        android:id="@+id/collapse_handle"
         android:layout_width="48dp"
         android:layout_height="2dp"
         android:layout_gravity="center_horizontal"
         android:layout_marginBottom="16dp"
+        android:visibility="gone"
         android:background="?android:attr/textColorSecondary"/>
     <TextView
         style="@style/TextHeadline"
diff --git a/res/layout/widgets_personal_work_tabs.xml b/res/layout/widgets_personal_work_tabs.xml
index 3d3ae6a..3402415 100644
--- a/res/layout/widgets_personal_work_tabs.xml
+++ b/res/layout/widgets_personal_work_tabs.xml
@@ -19,7 +19,7 @@
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/tabs"
     android:layout_width="match_parent"
-    android:layout_height="@dimen/all_apps_header_tab_height"
+    android:layout_height="@dimen/all_apps_header_pill_height"
     android:layout_marginLeft="@dimen/all_apps_tabs_side_padding"
     android:layout_marginRight="@dimen/all_apps_tabs_side_padding"
     android:orientation="horizontal"
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index a57ccde..fe0b11b 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -91,7 +91,8 @@
     <dimen name="all_apps_empty_search_bg_top_offset">144dp</dimen>
     <dimen name="all_apps_background_canvas_width">700dp</dimen>
     <dimen name="all_apps_background_canvas_height">475dp</dimen>
-    <dimen name="all_apps_header_tab_height">50dp</dimen>
+    <dimen name="all_apps_header_pill_height">50dp</dimen>
+    <dimen name="all_apps_header_pill_corner_radius">50dp</dimen>
     <dimen name="all_apps_tabs_indicator_height">2dp</dimen>
     <dimen name="all_apps_header_top_padding">36dp</dimen>
     <dimen name="all_apps_work_profile_tab_footer_top_padding">16dp</dimen>
diff --git a/src/com/android/launcher3/widget/WidgetsBottomSheet.java b/src/com/android/launcher3/widget/WidgetsBottomSheet.java
index f18b63e..995ac47 100644
--- a/src/com/android/launcher3/widget/WidgetsBottomSheet.java
+++ b/src/com/android/launcher3/widget/WidgetsBottomSheet.java
@@ -118,6 +118,7 @@
             ViewGroup.LayoutParams layoutParams = widgetsTableScrollView.getLayoutParams();
             layoutParams.height = mMaxTableHeight;
             widgetsTableScrollView.setLayoutParams(layoutParams);
+            findViewById(R.id.collapse_handle).setVisibility(VISIBLE);
         }
     }
 
diff --git a/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java b/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java
index b1c5ffc..4d8c1ca 100644
--- a/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java
+++ b/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java
@@ -146,7 +146,7 @@
         mAdapters.put(AdapterHolder.SEARCH, new AdapterHolder(AdapterHolder.SEARCH));
         mTabsHeight = mHasWorkProfile
                 ? getContext().getResources()
-                        .getDimensionPixelSize(R.dimen.all_apps_header_tab_height)
+                        .getDimensionPixelSize(R.dimen.all_apps_header_pill_height)
                 : 0;
         mWidgetCellHorizontalPadding = 2 * getResources().getDimensionPixelOffset(
                 R.dimen.widget_cell_horizontal_padding);
diff --git a/src/com/android/launcher3/workprofile/PersonalWorkSlidingTabStrip.java b/src/com/android/launcher3/workprofile/PersonalWorkSlidingTabStrip.java
index 3a3028f..b5db8f4 100644
--- a/src/com/android/launcher3/workprofile/PersonalWorkSlidingTabStrip.java
+++ b/src/com/android/launcher3/workprofile/PersonalWorkSlidingTabStrip.java
@@ -39,6 +39,8 @@
     private final Paint mDividerPaint;
 
     private int mSelectedIndicatorHeight;
+    private final int mSelectedIndicatorRadius;
+
     private int mIndicatorLeft = -1;
     private int mIndicatorRight = -1;
     private float mScrollOffset;
@@ -54,7 +56,10 @@
         setWillNotDraw(false);
 
         mSelectedIndicatorHeight =
-                getResources().getDimensionPixelSize(R.dimen.all_apps_tabs_indicator_height);
+                getResources().getDimensionPixelSize(R.dimen.all_apps_header_pill_height);
+
+        mSelectedIndicatorRadius = getResources().getDimensionPixelSize(
+                R.dimen.all_apps_header_pill_corner_radius);
 
         mSelectedIndicatorPaint = new Paint();
         mSelectedIndicatorPaint.setColor(
@@ -118,9 +123,9 @@
         super.onDraw(canvas);
 
         float y = getHeight() - mDividerPaint.getStrokeWidth();
-        canvas.drawLine(getPaddingLeft(), y, getWidth() - getPaddingRight(), y, mDividerPaint);
-        canvas.drawRect(mIndicatorLeft, getHeight() - mSelectedIndicatorHeight,
-                mIndicatorRight, getHeight(), mSelectedIndicatorPaint);
+        canvas.drawRoundRect(mIndicatorLeft, getHeight() - mSelectedIndicatorHeight,
+                mIndicatorRight, getHeight(), mSelectedIndicatorRadius, mSelectedIndicatorRadius,
+                mSelectedIndicatorPaint);
     }
 
     @Override
@@ -144,7 +149,8 @@
     }
 
     @Override
-    public void setMarkersCount(int numMarkers) { }
+    public void setMarkersCount(int numMarkers) {
+    }
 
     @Override
     public boolean hasOverlappingRendering() {