New Corpus Selection dialog assets from mkoser.

Also improved behaviour of the same dialog when using trackball. Previously, could not move focus from the corpus GridView to the 'Add/Remove' button.

Bug: 2495099
Change-Id: I1f96f1c7d0c66f34006916589a5dc67e81d241f2
diff --git a/res/drawable-hdpi/corpus_edit_icon.png b/res/drawable-hdpi/corpus_edit_icon.png
new file mode 100644
index 0000000..a31a09b
--- /dev/null
+++ b/res/drawable-hdpi/corpus_edit_icon.png
Binary files differ
diff --git a/res/drawable-mdpi/corpus_edit_icon.png b/res/drawable-mdpi/corpus_edit_icon.png
new file mode 100644
index 0000000..6127be6
--- /dev/null
+++ b/res/drawable-mdpi/corpus_edit_icon.png
Binary files differ
diff --git a/res/drawable/corpus_edit_items_bg.xml b/res/drawable/corpus_edit_items_bg.xml
new file mode 100644
index 0000000..691b647
--- /dev/null
+++ b/res/drawable/corpus_edit_items_bg.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2010 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.
+-->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <item android:state_pressed="true"
+        android:drawable="@drawable/corpus_edit_items_bg_pressed" />
+
+    <item android:state_focused="true"
+        android:drawable="@drawable/corpus_edit_items_bg_focused" />
+
+</selector>
diff --git a/res/drawable/corpus_edit_items_bg_focused.9.png b/res/drawable/corpus_edit_items_bg_focused.9.png
new file mode 100644
index 0000000..45e4e9e
--- /dev/null
+++ b/res/drawable/corpus_edit_items_bg_focused.9.png
Binary files differ
diff --git a/res/drawable/corpus_edit_items_bg_pressed.9.png b/res/drawable/corpus_edit_items_bg_pressed.9.png
new file mode 100644
index 0000000..151b35f
--- /dev/null
+++ b/res/drawable/corpus_edit_items_bg_pressed.9.png
Binary files differ
diff --git a/res/layout/corpus_selection_dialog.xml b/res/layout/corpus_selection_dialog.xml
index 4739e06..35756a1 100644
--- a/res/layout/corpus_selection_dialog.xml
+++ b/res/layout/corpus_selection_dialog.xml
@@ -27,10 +27,10 @@
         android:layout_below="@+id/corpus_selector_arrow"
         android:layout_alignParentLeft="true"
         android:layout_alignParentRight="true"
-        android:paddingTop="20dip"
-        android:paddingBottom="20dip"
-        android:paddingLeft="8dip"
-        android:paddingRight="8dip"
+        android:paddingTop="22dip"
+        android:paddingBottom="24dip"
+        android:paddingLeft="4dip"
+        android:paddingRight="4dip"
         android:background="@drawable/corpus_selector_bg"
         android:orientation="vertical"
         >
@@ -40,9 +40,10 @@
             android:layout_height="wrap_content"
             android:layout_alignParentLeft="true"
             android:layout_alignBaseline="@+id/corpus_edit_items"
+            android:paddingLeft="16dip"
             android:singleLine="true"
             android:textColor="@android:color/primary_text_light"
-            android:textSize="16dip"
+            android:textSize="14dip"
             android:text="@string/corpus_selection_heading"
         />
 
@@ -52,15 +53,17 @@
             android:layout_height="wrap_content"
             android:layout_alignParentTop="true"
             android:layout_alignParentRight="true"
-            android:layout_marginRight="4dip"
+            android:paddingRight="16dip"
             android:gravity="center_vertical|left"
             android:singleLine="true"
             android:clickable="true"
             android:focusable="true"
             android:textColor="@android:color/primary_text_light"
-            android:textSize="16dip"
-            android:drawableLeft="@android:drawable/ic_menu_preferences"
+            android:textSize="14dip"
+            android:drawableLeft="@drawable/corpus_edit_icon"
+            android:drawablePadding="4dip"
             android:text="@string/corpus_selection_edit_items"
+            android:background="@drawable/corpus_edit_items_bg"
         />
 
         <GridView
@@ -72,7 +75,7 @@
             android:layout_alignParentRight="true"
             android:layout_marginTop="12dip"
             android:horizontalSpacing="2dip"
-            android:verticalSpacing="2dip"
+            android:verticalSpacing="4dip"
             android:numColumns="@integer/corpus_selection_dialog_columns"
             android:listSelector="@drawable/corpus_grid_item_bg"
             />
@@ -87,7 +90,7 @@
         android:layout_alignParentLeft="true"
         android:layout_marginTop="44dip"
         android:layout_marginBottom="-8.5dip"
-        android:layout_marginLeft="6.5dip"
+        android:layout_marginLeft="8.5dip"
         android:src="@drawable/corpus_selector_arrow_up"
         />
 
diff --git a/src/com/android/quicksearchbox/CorpusSelectionDialog.java b/src/com/android/quicksearchbox/CorpusSelectionDialog.java
index fcff3a9..db5964f 100644
--- a/src/com/android/quicksearchbox/CorpusSelectionDialog.java
+++ b/src/com/android/quicksearchbox/CorpusSelectionDialog.java
@@ -44,7 +44,7 @@
 
     private GridView mCorpusGrid;
 
-    private final int mGridColumns;
+    private TextView mEditItems;
 
     private OnCorpusSelectedListener mListener;
 
@@ -54,7 +54,6 @@
 
     public CorpusSelectionDialog(Context context) {
         super(context, R.style.Theme_SelectSearchSource);
-        mGridColumns = context.getResources().getInteger(R.integer.corpus_selection_dialog_columns);
     }
 
     /**
@@ -80,8 +79,8 @@
         // the list items unclickable.
         mCorpusGrid.setFocusable(true);
 
-        TextView editItems = (TextView) findViewById(R.id.corpus_edit_items);
-        editItems.setOnClickListener(new CorpusEditListener());
+        mEditItems = (TextView) findViewById(R.id.corpus_edit_items);
+        mEditItems.setOnClickListener(new CorpusEditListener());
 
         Window window = getWindow();
         WindowManager.LayoutParams lp = window.getAttributes();
@@ -133,8 +132,7 @@
         }
         // Dismiss dialog on up move when nothing, or an item on the top row, is selected.
         if (keyCode == KeyEvent.KEYCODE_DPAD_UP) {
-            int selectedRow = mCorpusGrid.getSelectedItemPosition() / mGridColumns;
-            if (selectedRow <= 0) {
+            if (mEditItems.isFocused()) {
                 cancel();
                 return true;
             }