Merge "key event focus logic should support large tablets" into ub-launcher3-burnaby
diff --git a/res/drawable/apps_list_bg.xml b/res/drawable/apps_list_bg.xml
index 61f1c08..64177c1 100644
--- a/res/drawable/apps_list_bg.xml
+++ b/res/drawable/apps_list_bg.xml
@@ -14,8 +14,7 @@
      See the License for the specific language governing permissions and
      limitations under the License.
 -->
-<shape xmlns:android="http://schemas.android.com/apk/res/android"
-       android:shape="rectangle">
-    <solid android:color="#ffffff" />
-    <corners android:radius="3dp" />
-</shape>
\ No newline at end of file
+<inset xmlns:android="http://schemas.android.com/apk/res/android"
+       android:drawable="@drawable/apps_list_bg_inset"
+       android:insetLeft="@dimen/apps_container_inset"
+       android:insetRight="@dimen/apps_container_inset" />
\ No newline at end of file
diff --git a/res/drawable/apps_list_bg_inset.xml b/res/drawable/apps_list_bg_inset.xml
new file mode 100644
index 0000000..5ea7895
--- /dev/null
+++ b/res/drawable/apps_list_bg_inset.xml
@@ -0,0 +1,23 @@
+<?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.
+-->
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+       android:shape="rectangle">
+    <solid android:color="#ffffff" />
+    <corners
+        android:bottomLeftRadius="3dp"
+        android:bottomRightRadius="3dp" />
+</shape>
\ No newline at end of file
diff --git a/res/drawable/apps_list_fastscroll_bg.xml b/res/drawable/apps_list_fastscroll_bg.xml
index 4ec1848..780d3b0 100644
--- a/res/drawable/apps_list_fastscroll_bg.xml
+++ b/res/drawable/apps_list_fastscroll_bg.xml
@@ -18,7 +18,10 @@
        android:shape="rectangle">
     <solid android:color="@color/apps_view_scrollbar_thumb_color" />
     <size
-        android:width="48dp"
-        android:height="48dp" />
-    <corners android:radius="4dp" />
+        android:width="64dp"
+        android:height="64dp" />
+    <corners
+        android:topLeftRadius="64dp"
+        android:topRightRadius="64dp"
+        android:bottomLeftRadius="64dp" />
 </shape>
\ No newline at end of file
diff --git a/res/drawable/apps_list_scrollbar_thumb.xml b/res/drawable/apps_list_scrollbar_thumb.xml
index ddd65b2..59383a5 100644
--- a/res/drawable/apps_list_scrollbar_thumb.xml
+++ b/res/drawable/apps_list_scrollbar_thumb.xml
@@ -17,5 +17,5 @@
 <shape xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="rectangle">
     <solid android:color="@color/apps_view_scrollbar_thumb_color" />
-    <size android:width="4dp"/>
+    <size android:width="@dimen/apps_view_fast_scroll_bar_size" />
 </shape>
\ No newline at end of file
diff --git a/res/drawable/apps_reveal_bg.xml b/res/drawable/apps_reveal_bg.xml
new file mode 100644
index 0000000..47c608f
--- /dev/null
+++ b/res/drawable/apps_reveal_bg.xml
@@ -0,0 +1,20 @@
+<?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.
+-->
+<inset xmlns:android="http://schemas.android.com/apk/res/android"
+       android:drawable="@drawable/apps_reveal_bg_inset"
+       android:insetLeft="@dimen/apps_container_inset"
+       android:insetRight="@dimen/apps_container_inset" />
\ No newline at end of file
diff --git a/res/drawable/apps_reveal_bg_inset.xml b/res/drawable/apps_reveal_bg_inset.xml
new file mode 100644
index 0000000..61f1c08
--- /dev/null
+++ b/res/drawable/apps_reveal_bg_inset.xml
@@ -0,0 +1,21 @@
+<?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.
+-->
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+       android:shape="rectangle">
+    <solid android:color="#ffffff" />
+    <corners android:radius="3dp" />
+</shape>
\ No newline at end of file
diff --git a/res/layout-sw600dp/apps_view.xml b/res/layout-sw600dp/apps_view.xml
index 0628ca6..6f22460 100644
--- a/res/layout-sw600dp/apps_view.xml
+++ b/res/layout-sw600dp/apps_view.xml
@@ -18,7 +18,6 @@
     android:id="@+id/apps_view"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    android:padding="8dp"
     android:background="#22000000"
     android:descendantFocusability="afterDescendants">
     <include
diff --git a/res/layout/apps_list_view.xml b/res/layout/apps_list_view.xml
index dfb2fc4..59c0410 100644
--- a/res/layout/apps_list_view.xml
+++ b/res/layout/apps_list_view.xml
@@ -20,12 +20,13 @@
     android:layout_height="match_parent"
     android:orientation="vertical"
     android:elevation="15dp"
-    android:background="@drawable/apps_list_bg"
     android:visibility="gone">
     <EditText
         android:id="@+id/app_search_box"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
+        android:layout_marginLeft="@dimen/apps_container_inset"
+        android:layout_marginRight="@dimen/apps_container_inset"
         android:padding="16dp"
         android:hint="@string/apps_view_search_bar_hint"
         android:maxLines="1"
@@ -46,8 +47,10 @@
         android:paddingTop="12dp"
         android:paddingBottom="12dp"
         android:clipToPadding="false"
+        android:fadeScrollbars="false"
         android:scrollbars="vertical"
         android:scrollbarThumbVertical="@drawable/apps_list_scrollbar_thumb"
         android:focusable="true"
-        android:descendantFocusability="afterDescendants" />
+        android:descendantFocusability="afterDescendants"
+        android:background="@drawable/apps_list_bg" />
 </LinearLayout>
\ No newline at end of file
diff --git a/res/layout/apps_reveal_view.xml b/res/layout/apps_reveal_view.xml
index 19e462b..bc93359 100644
--- a/res/layout/apps_reveal_view.xml
+++ b/res/layout/apps_reveal_view.xml
@@ -21,5 +21,5 @@
     android:layout_gravity="center"
     android:elevation="15dp"
     android:visibility="invisible"
-    android:background="@drawable/apps_list_bg"
+    android:background="@drawable/apps_reveal_bg"
     android:focusable="false" />
\ No newline at end of file
diff --git a/res/layout/apps_view.xml b/res/layout/apps_view.xml
index 00f3cca..86d67e1 100644
--- a/res/layout/apps_view.xml
+++ b/res/layout/apps_view.xml
@@ -13,16 +13,26 @@
      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.AppsContainerView
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/apps_view"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    android:padding="8dp"
+    android:paddingTop="@dimen/apps_container_inset"
+    android:paddingBottom="@dimen/apps_container_inset"
     android:background="@drawable/apps_customize_bg"
     android:descendantFocusability="afterDescendants">
     <include
-        layout="@layout/apps_reveal_view" />
+        layout="@layout/apps_reveal_view"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:layout_gravity="center" />
     <include
-        layout="@layout/apps_list_view" />
+        layout="@layout/apps_list_view"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:layout_gravity="center" />
 </com.android.launcher3.AppsContainerView>
\ No newline at end of file
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 9b4c560..b9b9a24 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -48,12 +48,14 @@
 
 <!-- Apps view -->
     <dimen name="apps_container_width">0dp</dimen>
+    <dimen name="apps_container_inset">8dp</dimen>
     <dimen name="apps_grid_view_start_margin">52dp</dimen>
     <dimen name="apps_view_row_height">64dp</dimen>
     <dimen name="apps_view_section_text_size">24sp</dimen>
-    <dimen name="apps_view_fast_scroll_gutter_size">48dp</dimen>
+    <dimen name="apps_view_fast_scroll_bar_size">6dp</dimen>
+    <dimen name="apps_view_fast_scroll_gutter_size">40dp</dimen>
     <dimen name="apps_view_fast_scroll_popup_size">64dp</dimen>
-    <dimen name="apps_view_fast_scroll_text_size">48dp</dimen>
+    <dimen name="apps_view_fast_scroll_text_size">40dp</dimen>
 
 <!-- AllApps/Customize/AppsCustomize -->
     <!-- The height of the tab bar - if this changes, we should update the
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 408109d..a1e4601 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -311,34 +311,34 @@
     </string>
 
 <!-- Strings for accessibility actions -->
-    <!-- Accessibility action to add an app to workspace. [CHAR_LIMIT=30] -->
+    <!-- Accessibility action to add an app to workspace. [CHAR_LIMIT=30] [DO NOT TRANSLATE] -->
     <string name="action_add_to_workspace">Add To Workspace</string>
 
-    <!-- Accessibility confirmation for item added to workspace -->
+    <!-- Accessibility confirmation for item added to workspace [DO NOT TRANSLATE] -->
     <string name="item_added_to_workspace">Item added to workspace</string>
 
-    <!-- Accessibility confirmation for item removed-->
+    <!-- Accessibility confirmation for item removed [DO NOT TRANSLATE] -->
     <string name="item_removed_from_workspace">Item removed from workspace</string>
 
-    <!-- Accessibility action to move an item on the workspace. [CHAR_LIMIT=30] -->
+    <!-- Accessibility action to move an item on the workspace. [CHAR_LIMIT=30] [DO NOT TRANSLATE] -->
     <string name="action_move">Move Item</string>
 
-    <!-- Accessibility description to move item to empty cell. -->
+    <!-- Accessibility description to move item to empty cell. [DO NOT TRANSLATE] -->
     <string name="move_to_empty_cell">Move to empty cell <xliff:g id="number" example="1">%1$s</xliff:g>, <xliff:g id="number" example="1">%2$s</xliff:g></string>
 
-    <!-- Accessibility confirmation for item move -->
+    <!-- Accessibility confirmation for item move [DO NOT TRANSLATE]-->
     <string name="item_moved">Item moved</string>
 
-    <!-- Accessibility description to move item into an existing folder. -->
+    <!-- Accessibility description to move item into an existing folder. [DO NOT TRANSLATE]-->
     <string name="add_to_folder">Add to folder: <xliff:g id="name" example="Games">%1$s</xliff:g></string>
 
-    <!-- Accessibility confirmation for item added to folder-->
+    <!-- Accessibility confirmation for item added to folder [DO NOT TRANSLATE] -->
     <string name="added_to_folder">Item added to folder</string>
 
-    <!-- Accessibility description to create folder with another item. -->
+    <!-- Accessibility description to create folder with another item. [DO NOT TRANSLATE] -->
     <string name="create_folder_with">Create folder with: <xliff:g id="name" example="Game">%1$s</xliff:g></string>
 
-    <!-- Accessibility confirmation for folder created -->
+    <!-- Accessibility confirmation for folder created [DO NOT TRANSLATE] -->
     <string name="folder_created">Folder created</string>
 
 </resources>
diff --git a/src/com/android/launcher3/AppsContainerRecyclerView.java b/src/com/android/launcher3/AppsContainerRecyclerView.java
index 2280e99..c5a508c 100644
--- a/src/com/android/launcher3/AppsContainerRecyclerView.java
+++ b/src/com/android/launcher3/AppsContainerRecyclerView.java
@@ -37,6 +37,8 @@
 public class AppsContainerRecyclerView extends RecyclerView
         implements RecyclerView.OnItemTouchListener {
 
+    private static final float FAST_SCROLL_OVERLAY_Y_OFFSET_FACTOR = 1.5f;
+
     private AlphabeticalAppsList mApps;
     private int mNumAppsPerRow;
 
@@ -130,7 +132,7 @@
             } else {
                 x = getWidth() - getPaddingRight() - getScrollBarSize() - bgBounds.width();
             }
-            int y = mLastY - bgBounds.height() / 2;
+            int y = mLastY - (int) (FAST_SCROLL_OVERLAY_Y_OFFSET_FACTOR * bgBounds.height());
             y = Math.max(getPaddingTop(), Math.min(y, getHeight() - getPaddingBottom() -
                     bgBounds.height()));
             canvas.translate(x, y);
diff --git a/src/com/android/launcher3/AppsContainerView.java b/src/com/android/launcher3/AppsContainerView.java
index 64b27ba..ce092bf 100644
--- a/src/com/android/launcher3/AppsContainerView.java
+++ b/src/com/android/launcher3/AppsContainerView.java
@@ -39,9 +39,9 @@
 /**
  * The all apps list view container.
  */
-public class AppsContainerView extends FrameLayout implements DragSource, View.OnTouchListener,
-        View.OnLongClickListener, Insettable, TextWatcher, TextView.OnEditorActionListener,
-        LauncherTransitionable {
+public class AppsContainerView extends FrameLayout implements DragSource, Insettable, TextWatcher,
+        TextView.OnEditorActionListener, LauncherTransitionable, View.OnTouchListener,
+        View.OnLongClickListener {
 
     private static final boolean ALLOW_SINGLE_APP_LAUNCH = true;
 
@@ -188,10 +188,10 @@
     }
 
     @Override
-    public boolean onTouch(View v, MotionEvent event) {
-        if (event.getAction() == MotionEvent.ACTION_DOWN ||
-                event.getAction() == MotionEvent.ACTION_MOVE) {
-            mLastTouchDownPos.set((int) event.getX(), (int) event.getY());
+    public boolean onTouch(View v, MotionEvent ev) {
+        if (ev.getAction() == MotionEvent.ACTION_DOWN ||
+                ev.getAction() == MotionEvent.ACTION_MOVE) {
+            mLastTouchDownPos.set((int) ev.getX(), (int) ev.getY());
         }
         return false;
     }
@@ -333,7 +333,6 @@
             List<AppInfo> appsWithoutSections = mApps.getAppsWithoutSectionBreaks();
             List<AppInfo> apps = mApps.getApps();
             if (appsWithoutSections.size() == 1) {
-                mSearchBar.clearFocus();
                 mAppsListView.getChildAt(apps.indexOf(appsWithoutSections.get(0))).performClick();
                 InputMethodManager imm = (InputMethodManager)
                         getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
diff --git a/src/com/android/launcher3/AppsGridAdapter.java b/src/com/android/launcher3/AppsGridAdapter.java
index 028cd8f..6a4495e 100644
--- a/src/com/android/launcher3/AppsGridAdapter.java
+++ b/src/com/android/launcher3/AppsGridAdapter.java
@@ -84,12 +84,13 @@
                             mSectionTextPaint.getTextBounds(section, 0, section.length(),
                                     mTmpBounds);
                             if (mIsRtl) {
-                                c.drawText(section, parent.getWidth() - mStartMargin +
-                                                (mStartMargin - mTmpBounds.width()) / 2,
+                                int left = parent.getWidth() - mPaddingStart - mStartMargin;
+                                c.drawText(section, left + (mStartMargin - mTmpBounds.width()) / 2,
                                         child.getTop() + (2 * child.getPaddingTop()) +
                                                 mTmpBounds.height(), mSectionTextPaint);
                             } else {
-                                c.drawText(section, (mStartMargin - mTmpBounds.width()) / 2,
+                                int left = mPaddingStart;
+                                c.drawText(section, left + (mStartMargin - mTmpBounds.width()) / 2,
                                     child.getTop() + (2 * child.getPaddingTop()) +
                                             mTmpBounds.height(), mSectionTextPaint);
                             }
@@ -118,6 +119,7 @@
     private String mEmptySearchText;
 
     // Section drawing
+    private int mPaddingStart;
     private int mStartMargin;
     private Paint mSectionTextPaint;
     private Rect mTmpBounds = new Rect();
@@ -136,6 +138,7 @@
         mIconClickListener = iconClickListener;
         mIconLongClickListener = iconLongClickListener;
         mStartMargin = res.getDimensionPixelSize(R.dimen.apps_grid_view_start_margin);
+        mPaddingStart = res.getDimensionPixelSize(R.dimen.apps_container_inset);
         mSectionTextPaint = new Paint();
         mSectionTextPaint.setTextSize(res.getDimensionPixelSize(
                 R.dimen.apps_view_section_text_size));
diff --git a/tests/res/values/string.xml b/tests/res/values/string.xml
new file mode 100644
index 0000000..3c1ec5c
--- /dev/null
+++ b/tests/res/values/string.xml
@@ -0,0 +1,21 @@
+<!-- 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.
+-->
+
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+
+    <!-- Dummy string for tests. [DO NOT TRANSLATE] -->
+    <string name="dummy" >Dummy string for tests.</string>
+
+</resources>