Converting widget panel into a floating view

> The widget panel is only inflated when needed
> Using the swipe up/down interaction for widgets tray
> Removing additional view wrappers from all-apps
> Widget tray is preserved across activity recreation
> Launcher no longer has WIDGET state, the actual code around
  the states will be removed in a follow-up cl

Bug: 67678570
Bug: 67585158
Change-Id: Ia29a7c33ec81e6c53cc24e2906b7022b6f41755b
diff --git a/res/layout-land/launcher.xml b/res/layout-land/launcher.xml
index ac440fc..0c7999e 100644
--- a/res/layout-land/launcher.xml
+++ b/res/layout-land/launcher.xml
@@ -60,12 +60,6 @@
             android:id="@+id/overview_panel"
             android:visibility="gone" />
 
-        <include layout="@layout/widgets_view"
-            android:id="@+id/widgets_view"
-            android:layout_width="match_parent"
-            android:layout_height="match_parent"
-            android:visibility="invisible" />
-
         <include layout="@layout/all_apps"
             android:id="@+id/apps_view"
             android:layout_width="match_parent"
diff --git a/res/layout-port/launcher.xml b/res/layout-port/launcher.xml
index c41a6e3..f58a87e 100644
--- a/res/layout-port/launcher.xml
+++ b/res/layout-port/launcher.xml
@@ -66,12 +66,6 @@
             android:id="@+id/drop_target_bar"
             layout="@layout/drop_target_bar_horz" />
 
-        <include layout="@layout/widgets_view"
-            android:id="@+id/widgets_view"
-            android:layout_width="match_parent"
-            android:layout_height="match_parent"
-            android:visibility="invisible" />
-
         <include layout="@layout/all_apps"
             android:id="@+id/apps_view"
             android:layout_width="match_parent"
diff --git a/res/layout-sw720dp/launcher.xml b/res/layout-sw720dp/launcher.xml
index 03e42bc..660d0ed 100644
--- a/res/layout-sw720dp/launcher.xml
+++ b/res/layout-sw720dp/launcher.xml
@@ -65,12 +65,6 @@
         <include layout="@layout/page_indicator"
                  android:id="@+id/page_indicator" />
 
-        <include layout="@layout/widgets_view"
-            android:id="@+id/widgets_view"
-            android:layout_width="match_parent"
-            android:layout_height="match_parent"
-            android:visibility="invisible" />
-
         <include layout="@layout/all_apps"
             android:id="@+id/apps_view"
             android:layout_width="match_parent"
diff --git a/res/layout/all_apps.xml b/res/layout/all_apps.xml
index 39df2b1..6f837ae 100644
--- a/res/layout/all_apps.xml
+++ b/res/layout/all_apps.xml
@@ -18,60 +18,39 @@
      will bake the left/right padding into that view's background itself. -->
 <com.android.launcher3.allapps.AllAppsContainerView
     xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:launcher="http://schemas.android.com/apk/res-auto"
     android:id="@+id/apps_view"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    android:orientation="vertical"
-    launcher:revealBackground="@drawable/round_rect_primary">
+    android:clipChildren="true"
+    android:clipToPadding="false"
+    android:focusable="true"
+    android:focusableInTouchMode="true"
+    android:saveEnabled="false" >
 
-    <View
-        android:id="@+id/reveal_view"
+    <!-- DO NOT CHANGE THE ID -->
+    <com.android.launcher3.allapps.AllAppsRecyclerView
+        android:id="@+id/apps_list_view"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
-        android:layout_gravity="center"
-        android:focusable="false"
-        android:visibility="invisible" />
-
-
-    <com.android.launcher3.allapps.AllAppsRecyclerViewContainerView
-        android:id="@+id/main_content"
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:layout_gravity="center"
-        android:focusable="true"
+        android:layout_below="@id/search_container_all_apps"
+        android:layout_gravity="center_horizontal|top"
         android:clipToPadding="false"
-        android:clipChildren="true"
-        android:focusableInTouchMode="true"
-        android:saveEnabled="false"
-        android:visibility="gone">
+        android:descendantFocusability="afterDescendants"
+        android:focusable="true"
+        android:overScrollMode="never" />
 
-        <!-- DO NOT CHANGE THE ID -->
-        <com.android.launcher3.allapps.AllAppsRecyclerView
-            android:id="@+id/apps_list_view"
-            android:layout_below="@id/search_container_all_apps"
-            android:layout_width="match_parent"
-            android:layout_height="match_parent"
-            android:layout_gravity="center_horizontal|top"
-            android:clipToPadding="false"
-            android:overScrollMode="never"
-            android:descendantFocusability="afterDescendants"
-            android:focusable="true" />
+    <!-- Note: we are reusing/repurposing a system attribute for search layout, because of a
+     platform bug, which prevents using custom attributes in <include> tag -->
+    <include
+        android:id="@id/search_container_all_apps"
+        layout="?android:attr/keyboardLayout" />
 
-        <!-- Note: we are reusing/repurposing a system attribute for search layout, because of a
-         platform bug, which prevents using custom attributes in <include> tag -->
-        <include
-            layout="?android:attr/keyboardLayout"
-            android:id="@id/search_container_all_apps" />
+    <include layout="@layout/all_apps_fast_scroller" />
 
-        <include layout="@layout/all_apps_fast_scroller" />
-
-    </com.android.launcher3.allapps.AllAppsRecyclerViewContainerView>
     <View
         android:id="@+id/nav_bar_bg"
-        android:background="?attr/allAppsNavBarScrimColor"
         android:layout_width="match_parent"
         android:layout_height="0dp"
-        android:layout_gravity="bottom"
-        android:focusable="false"  />
+        android:layout_alignParentBottom="true"
+        android:background="?attr/allAppsNavBarScrimColor" />
 </com.android.launcher3.allapps.AllAppsContainerView>
\ No newline at end of file
diff --git a/res/layout/widgets_full_sheet.xml b/res/layout/widgets_full_sheet.xml
new file mode 100644
index 0000000..1535299
--- /dev/null
+++ b/res/layout/widgets_full_sheet.xml
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2017 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.
+-->
+<com.android.launcher3.widget.WidgetsFullSheet
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="vertical"
+    android:theme="?attr/widgetsTheme" >
+
+    <com.android.launcher3.graphics.GradientView
+        android:id="@+id/gradient_bg"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent" />
+
+    <FrameLayout
+        android:id="@+id/container"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:background="?android:attr/colorPrimary"
+        android:elevation="4dp">
+
+        <com.android.launcher3.widget.WidgetsRecyclerView
+            android:id="@+id/widgets_list_view"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:clipToPadding="false"
+            />
+
+        <!-- Fast scroller popup -->
+        <TextView
+            android:id="@+id/fast_scroller_popup"
+            style="@style/FastScrollerPopup"
+            android:layout_gravity="top|end"
+            android:layout_marginEnd="@dimen/fastscroll_popup_margin" />
+
+        <com.android.launcher3.views.RecyclerViewFastScroller
+            android:id="@+id/fast_scroller"
+            android:layout_width="@dimen/fastscroll_width"
+            android:layout_height="match_parent"
+            android:layout_gravity="end"
+            android:layout_marginEnd="@dimen/fastscroll_end_margin" />
+
+        <View
+            android:id="@+id/nav_bar_bg"
+            android:layout_width="match_parent"
+            android:layout_height="0dp"
+            android:layout_gravity="bottom"
+            android:background="?attr/allAppsNavBarScrimColor"
+            android:focusable="false"  />
+    </FrameLayout>
+</com.android.launcher3.widget.WidgetsFullSheet>
\ No newline at end of file
diff --git a/res/layout/widgets_view.xml b/res/layout/widgets_view.xml
deleted file mode 100644
index 4f3c7c8..0000000
--- a/res/layout/widgets_view.xml
+++ /dev/null
@@ -1,73 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2015 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.
--->
-<!-- The top and bottom paddings are defined in this container, but since we want
-     the list view to span the full width (for touch interception purposes), we
-     will bake the left/right padding into that view's background itself. -->
-<com.android.launcher3.widget.WidgetsContainerView
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:launcher="http://schemas.android.com/apk/res-auto"
-    android:id="@+id/widgets_view"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:descendantFocusability="afterDescendants"
-    android:theme="?attr/widgetsTheme"
-    launcher:revealBackground="@drawable/round_rect_primary">
-
-    <View
-        android:id="@+id/reveal_view"
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:layout_gravity="center"
-        android:elevation="2dp"
-        android:focusable="false"
-        android:visibility="invisible" />
-
-    <FrameLayout
-        android:id="@+id/main_content"
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:layout_gravity="center"
-        android:elevation="15dp"
-        android:visibility="gone">
-
-        <com.android.launcher3.widget.WidgetsRecyclerView
-            android:id="@+id/widgets_list_view"
-            android:layout_width="match_parent"
-            android:layout_height="match_parent" />
-
-        <!-- Fast scroller popup -->
-        <TextView
-            android:id="@+id/fast_scroller_popup"
-            style="@style/FastScrollerPopup"
-            android:layout_gravity="top|end"
-            android:layout_marginEnd="@dimen/fastscroll_popup_margin" />
-
-        <ProgressBar
-            android:id="@+id/loader"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_gravity="center" />
-
-        <com.android.launcher3.views.RecyclerViewFastScroller
-            android:id="@+id/fast_scroller"
-            android:layout_width="@dimen/fastscroll_width"
-            android:layout_height="match_parent"
-            android:layout_gravity="end"
-            android:layout_marginEnd="@dimen/fastscroll_end_margin" />
-
-    </FrameLayout>
-
-</com.android.launcher3.widget.WidgetsContainerView>
\ No newline at end of file
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index e87397b..ad5f0b8 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -63,13 +63,6 @@
         <attr name="pageIndicator" format="reference" />
     </declare-styleable>
 
-    <!-- BaseContainerView specific attributes. These attributes are used to customize
-         AllApps view and WidgetsView in xml. -->
-    <declare-styleable name="BaseContainerView">
-        <!-- Drawable to use for the reveal animation -->
-        <attr name="revealBackground" format="reference" />
-    </declare-styleable>
-
     <!-- XML attributes used by default_workspace.xml -->
     <declare-styleable name="Favorite">
         <attr name="className" format="string" />
diff --git a/res/values/config.xml b/res/values/config.xml
index f8faf98..27d4655 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -57,10 +57,8 @@
 
     <!-- Fade/zoom in/out duration & scale in a Launcher overlay transition.
          Note: This should be less than the config_overlayTransitionTime as they happen together. -->
-    <integer name="config_overlayRevealTime">220</integer>
     <integer name="config_overlaySlideRevealTime">320</integer>
     <integer name="config_overlayTransitionTime">300</integer>
-    <integer name="config_overlayItemsAlphaStagger">60</integer>
 
     <!-- This constant stores the ratio of the all apps button drawable which
          is used for internal (baked-in) padding -->