Refactoring all apps search to support external search bar.

- Adding support for an external search bar that can be used
  to search a container view.  This adds a new interface
  AllAppsSearchController which manages the external search
  bar.  Each controller will have its own search implementation
  which means that we no longer need a common AppSearchManager
  interface.
- Removing elevation controller as we no longer have a builtin
  search bar in all apps
- Refactoring container view insets so that they behave
  the same in all containers.
- Refactoring apps view to ensure that we only update the number
  of columns with the available width
- Cleaning up LauncherCallbacks interface

Bug: 20127840
Bug: 21494973

Change-Id: I710b8e18196961d77d8a29f0c345531d480936fe
diff --git a/res/layout/all_apps.xml b/res/layout/all_apps.xml
index b907c34..1bf54ee 100644
--- a/res/layout/all_apps.xml
+++ b/res/layout/all_apps.xml
@@ -21,15 +21,37 @@
     android:id="@+id/apps_view"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    android:descendantFocusability="afterDescendants">
-    <include
-        layout="@layout/all_apps_reveal"
+    android:orientation="vertical">
+
+    <!-- Both android:focusable and android:focusableInTouchMode are needed for
+         the view to get focus change events. -->
+    <FrameLayout
+        android:id="@+id/search_box_container"
         android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:layout_gravity="center" />
-    <include
-        layout="@layout/all_apps_container"
+        android:layout_height="wrap_content"
+        android:focusable="true"
+        android:focusableInTouchMode="true"
+        android:visibility="gone" />
+
+    <FrameLayout
+        android:id="@+id/content"
         android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:layout_gravity="center" />
+        android:layout_height="0dp"
+        android:layout_weight="1">
+        <FrameLayout
+            android:id="@+id/all_apps_reveal"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:layout_gravity="center"
+            android:focusable="false"
+            android:elevation="2dp"
+            android:visibility="invisible" />
+        <include
+            layout="@layout/all_apps_container"
+            android:id="@+id/all_apps_container"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:layout_gravity="center"
+            android:visibility="gone" />
+    </FrameLayout>
 </com.android.launcher3.allapps.AllAppsContainerView>
\ No newline at end of file
diff --git a/res/layout/all_apps_container.xml b/res/layout/all_apps_container.xml
index fc77cd3..5801a0e 100644
--- a/res/layout/all_apps_container.xml
+++ b/res/layout/all_apps_container.xml
@@ -14,95 +14,35 @@
      See the License for the specific language governing permissions and
      limitations under the License.
 -->
+<!-- Both android:focusable and android:focusableInTouchMode are needed for
+     the view to get focus change events. -->
 <com.android.launcher3.allapps.AllAppsRecyclerViewContainerView
     xmlns:android="http://schemas.android.com/apk/res/android"
-    android:id="@+id/apps_list"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:elevation="15dp"
-    android:focusableInTouchMode="true"
-    android:visibility="gone" >
+    android:focusable="true"
+    android:focusableInTouchMode="true">
 
     <com.android.launcher3.allapps.AllAppsRecyclerView
-        android:id="@+id/apps_list_view"
+        android:id="@+id/collection"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:layout_gravity="center_horizontal|top"
-        android:layout_marginTop="@dimen/all_apps_search_bar_height"
         android:clipToPadding="false"
-        android:descendantFocusability="afterDescendants"
-        android:focusable="true" />
+        android:focusable="true"
+        android:descendantFocusability="afterDescendants" />
 
     <LinearLayout
         android:id="@+id/prediction_bar"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:layout_marginTop="@dimen/all_apps_search_bar_height"
-        android:paddingBottom="@dimen/all_apps_prediction_bar_bottom_padding"
+        android:paddingTop="@dimen/all_apps_prediction_bar_top_bottom_padding"
+        android:paddingBottom="@dimen/all_apps_prediction_bar_top_bottom_padding"
         android:orientation="horizontal"
-        android:descendantFocusability="afterDescendants"
         android:focusable="true"
+        android:descendantFocusability="afterDescendants"
         android:visibility="invisible" >
     </LinearLayout>
 
-    <!-- We always want the search bar on top, so it goes last. -->
-
-    <FrameLayout
-        android:id="@+id/header"
-        android:layout_width="match_parent"
-        android:layout_height="@dimen/all_apps_search_bar_height"
-        android:background="@drawable/all_apps_search_bg" >
-
-        <LinearLayout
-            android:id="@+id/app_search_container"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:orientation="horizontal"
-            android:visibility="invisible" >
-
-            <ImageView
-                android:id="@+id/dismiss_search_button"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_gravity="start|center_vertical"
-                android:layout_marginLeft="4dp"
-                android:layout_marginStart="4dp"
-                android:contentDescription="@string/all_apps_button_label"
-                android:paddingBottom="13dp"
-                android:paddingTop="13dp"
-                android:src="@drawable/ic_arrow_back_grey" />
-
-            <com.android.launcher3.allapps.AllAppsSearchEditView
-                android:id="@+id/apps_search_box"
-                android:layout_width="match_parent"
-                android:layout_height="match_parent"
-                android:background="@android:color/transparent"
-                android:focusableInTouchMode="true"
-                android:gravity="fill_horizontal"
-                android:hint="@string/all_apps_search_bar_hint"
-                android:imeOptions="actionDone|flagNoExtractUi"
-                android:maxLines="1"
-                android:paddingBottom="16dp"
-                android:paddingLeft="8dp"
-                android:paddingTop="16dp"
-                android:scrollHorizontally="true"
-                android:singleLine="true"
-                android:textColor="#4c4c4c"
-                android:textColorHint="#9c9c9c"
-                android:textSize="16sp" />
-        </LinearLayout>
-
-        <ImageView
-            android:id="@+id/search_button"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_gravity="end|center_vertical"
-            android:layout_marginEnd="6dp"
-            android:layout_marginRight="6dp"
-            android:contentDescription="@string/all_apps_search_bar_hint"
-            android:paddingBottom="13dp"
-            android:paddingTop="13dp"
-            android:src="@drawable/ic_search_grey" />
-    </FrameLayout>
-
 </com.android.launcher3.allapps.AllAppsRecyclerViewContainerView>
\ No newline at end of file
diff --git a/res/layout/all_apps_reveal.xml b/res/layout/all_apps_reveal.xml
deleted file mode 100644
index 5f46656..0000000
--- a/res/layout/all_apps_reveal.xml
+++ /dev/null
@@ -1,24 +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.
--->
-<FrameLayout
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    android:id="@+id/apps_view_transition_overlay"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:layout_gravity="center"
-    android:elevation="2dp"
-    android:visibility="invisible"
-    android:focusable="false" />
\ No newline at end of file
diff --git a/res/layout/all_apps_search_bar.xml b/res/layout/all_apps_search_bar.xml
new file mode 100644
index 0000000..9f4e322
--- /dev/null
+++ b/res/layout/all_apps_search_bar.xml
@@ -0,0 +1,72 @@
+<?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.
+-->
+<FrameLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:background="@drawable/all_apps_search_bg" >
+
+    <LinearLayout
+        android:id="@+id/search_container"
+        android:layout_width="match_parent"
+        android:layout_height="@dimen/all_apps_search_bar_height"
+        android:layout_gravity="start|center_vertical"
+        android:orientation="horizontal"
+        android:visibility="invisible" >
+
+        <ImageView
+            android:id="@+id/dismiss_search_button"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginLeft="4dp"
+            android:layout_marginStart="4dp"
+            android:contentDescription="@string/all_apps_button_label"
+            android:paddingBottom="13dp"
+            android:paddingTop="13dp"
+            android:src="@drawable/ic_arrow_back_grey" />
+
+        <com.android.launcher3.allapps.AllAppsSearchEditView
+            android:id="@+id/search_box"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:background="@android:color/transparent"
+            android:focusableInTouchMode="true"
+            android:gravity="fill_horizontal|center_vertical"
+            android:hint="@string/all_apps_search_bar_hint"
+            android:inputType="text|textNoSuggestions|textCapWords"
+            android:imeOptions="actionDone|flagNoExtractUi"
+            android:maxLines="1"
+            android:paddingLeft="8dp"
+            android:scrollHorizontally="true"
+            android:singleLine="true"
+            android:textColor="#4c4c4c"
+            android:textColorHint="#9c9c9c"
+            android:textSize="16sp" />
+    </LinearLayout>
+
+    <ImageView
+        android:id="@+id/search_button"
+        android:layout_width="wrap_content"
+        android:layout_height="@dimen/all_apps_search_bar_height"
+        android:layout_gravity="end|center_vertical"
+        android:layout_marginEnd="6dp"
+        android:layout_marginRight="6dp"
+        android:contentDescription="@string/all_apps_search_bar_hint"
+        android:paddingBottom="13dp"
+        android:paddingTop="13dp"
+        android:src="@drawable/ic_search_grey" />
+</FrameLayout>
\ No newline at end of file
diff --git a/res/layout/widgets_view.xml b/res/layout/widgets_view.xml
index a1a62b3..c27e79b 100644
--- a/res/layout/widgets_view.xml
+++ b/res/layout/widgets_view.xml
@@ -21,25 +21,29 @@
     android:id="@+id/widgets_view"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    android:paddingTop="@dimen/widget_container_inset"
-    android:paddingBottom="@dimen/widget_container_inset"
+    android:orientation="vertical"
     android:descendantFocusability="afterDescendants">
 
     <FrameLayout
-        android:id="@+id/widgets_reveal_view"
+        android:id="@+id/content"
         android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:layout_gravity="center"
-        android:elevation="2dp"
-        android:focusable="false"
-        android:visibility="invisible" />
+        android:layout_height="match_parent">
+        <FrameLayout
+            android:id="@+id/widgets_reveal_view"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:layout_gravity="center"
+            android:focusable="false"
+            android:elevation="2dp"
+            android:visibility="invisible" />
 
         <com.android.launcher3.widget.WidgetsRecyclerView
             android:id="@+id/widgets_list_view"
             android:layout_width="match_parent"
             android:layout_height="match_parent"
-            android:background="@drawable/quantum_panel_dark"
+            android:layout_gravity="center"
             android:elevation="15dp"
             android:visibility="gone" />
+    </FrameLayout>
 
 </com.android.launcher3.widget.WidgetsContainerView>
\ No newline at end of file