Adding an empty state UI for the printer search activity in the spooler.

The user can select all printers from the print dropdown to get to
a search for printers activity where one can filter out the list
of a available printers. We did not have an empty state UI for the
case when the query yields no printers.

bug:11009053

Change-Id: I6b45517b8a7b319992019a1bf65858319a19a0de
diff --git a/core/res/res/drawable-hdpi/ic_grayedout_printer.png b/core/res/res/drawable-hdpi/ic_grayedout_printer.png
new file mode 100644
index 0000000..5e54970
--- /dev/null
+++ b/core/res/res/drawable-hdpi/ic_grayedout_printer.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/ic_grayedout_printer.png b/core/res/res/drawable-mdpi/ic_grayedout_printer.png
new file mode 100644
index 0000000..5e54970
--- /dev/null
+++ b/core/res/res/drawable-mdpi/ic_grayedout_printer.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/ic_grayedout_printer.png b/core/res/res/drawable-xhdpi/ic_grayedout_printer.png
new file mode 100644
index 0000000..5e54970
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/ic_grayedout_printer.png
Binary files differ
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 7608f99..9d3a985 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -1041,6 +1041,7 @@
   <java-symbol type="drawable" name="ic_text_dot" />
   <java-symbol type="drawable" name="ic_print" />
   <java-symbol type="drawable" name="ic_print_error" />
+  <java-symbol type="drawable" name="ic_grayedout_printer" />
   <java-symbol type="drawable" name="indicator_code_lock_drag_direction_green_up" />
   <java-symbol type="drawable" name="indicator_code_lock_drag_direction_red_up" />
   <java-symbol type="drawable" name="indicator_code_lock_point_area_default_holo" />
diff --git a/packages/PrintSpooler/res/layout/select_printer_activity.xml b/packages/PrintSpooler/res/layout/select_printer_activity.xml
index f4e1853..e86e9aa 100644
--- a/packages/PrintSpooler/res/layout/select_printer_activity.xml
+++ b/packages/PrintSpooler/res/layout/select_printer_activity.xml
@@ -14,10 +14,10 @@
      limitations under the License.
 -->
 
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:orientation="horizontal"
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:orientation="vertical"
     android:layout_width="fill_parent"
-    android:layout_height="wrap_content">
+    android:layout_height="fill_parent">
 
     <fragment
         android:name="com.android.printspooler.SelectPrinterFragment"
@@ -26,4 +26,39 @@
         android:layout_height="wrap_content">
     </fragment>
 
-</FrameLayout>
\ No newline at end of file
+    <FrameLayout
+        android:id="@+id/empty_print_state"
+        android:layout_width="fill_parent"
+        android:layout_height="fill_parent"
+        android:visibility="gone">
+
+        <LinearLayout
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_gravity="center"
+            android:gravity="center"
+            android:orientation="vertical">
+   
+            <ImageView
+                android:id="@+id/icon"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_marginBottom="12dip"
+                android:src="@*android:drawable/ic_grayedout_printer"
+                android:contentDescription="@string/print_no_printers_found">
+            </ImageView>
+
+            <TextView
+                android:id="@+id/message"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:textAppearance="?android:attr/textAppearanceLarge"
+                android:textColor="?android:attr/textColorSecondary"
+                android:text="@string/print_no_printers_found">
+            </TextView>
+
+        </LinearLayout>
+
+    </FrameLayout>
+
+</LinearLayout>
diff --git a/packages/PrintSpooler/res/values/strings.xml b/packages/PrintSpooler/res/values/strings.xml
index 5ee8d8c..41775a1 100644
--- a/packages/PrintSpooler/res/values/strings.xml
+++ b/packages/PrintSpooler/res/values/strings.xml
@@ -75,13 +75,16 @@
     <!-- Title for the select printer activity. [CHAR LIMIT=30] -->
     <string name="all_printers_label">All printers</string>
 
+    <!-- Title of the button to install a print service. [CHAR LIMIT=25] -->
+    <string name="add_print_service_label">Add service</string>
+
     <!-- Add printer dialog  -->
 
     <!-- Title for the alert dialog for selecting a print service. [CHAR LIMIT=50] -->
     <string name="choose_print_service">Choose print service</string>
 
-    <!-- Title for the button to search the play store for print services. [CHAR LIMIT=50] -->
-    <string name="search_play_store">Search in play store</string>
+    <!-- Title for the prompt shown as a placeholder if no printers are found while searching. [CHAR LIMIT=50] -->
+    <string name="print_no_printers_found">No printers found</string>
 
     <!-- Notifications -->
 
diff --git a/packages/PrintSpooler/src/com/android/printspooler/SelectPrinterFragment.java b/packages/PrintSpooler/src/com/android/printspooler/SelectPrinterFragment.java
index c397c40..c888e2c 100644
--- a/packages/PrintSpooler/src/com/android/printspooler/SelectPrinterFragment.java
+++ b/packages/PrintSpooler/src/com/android/printspooler/SelectPrinterFragment.java
@@ -92,6 +92,8 @@
     public void onActivityCreated(Bundle savedInstanceState) {
         super.onActivityCreated(savedInstanceState);
         setListAdapter(new DestinationAdapter());
+        View emptyView = getActivity().findViewById(R.id.empty_print_state);
+        getListView().setEmptyView(emptyView);
     }
 
     @Override
@@ -252,7 +254,7 @@
             Uri marketUri = Uri.parse(DEFAULT_MARKET_QUERY_STRING);
             final Intent marketIntent = new Intent(Intent.ACTION_VIEW, marketUri);
             if (getActivity().getPackageManager().resolveActivity(marketIntent, 0) != null) {
-                builder.setPositiveButton(R.string.search_play_store,
+                builder.setPositiveButton(R.string.add_print_service_label,
                     new DialogInterface.OnClickListener() {
                         public void onClick(DialogInterface dialog, int whichButton) {
                             try {