From 69b91e0ecb8cef95c030f5076779e07d363a45f2 Mon Sep 17 00:00:00 2001 From: Svetoslav Ganov Date: Mon, 7 Oct 2013 22:17:30 -0700 Subject: [PATCH] Show unavailable printers disabled and grayed out. 1. If a printer is not available it has to disabled and grayed out. 2. Cancle a print job if the app does not provide the requested pages. 3. Fix current printer selection flicker when the print dialog is showing up. Often the current printer is initially set to the user's favorite and then it is changed back to the PDF one. bug:10983508 Change-Id: I8d53eb992cf1c92675ec09f61b2ec272b962fa68 --- .../PrintSpooler/res/layout/printer_dropdown_item.xml | 3 ++- .../com/android/printspooler/PrintJobConfigActivity.java | 4 ++++ .../com/android/printspooler/SelectPrinterFragment.java | 8 ++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/PrintSpooler/res/layout/printer_dropdown_item.xml b/packages/PrintSpooler/res/layout/printer_dropdown_item.xml index 6439b49acc9d5..2749aa668ddbd 100644 --- a/packages/PrintSpooler/res/layout/printer_dropdown_item.xml +++ b/packages/PrintSpooler/res/layout/printer_dropdown_item.xml @@ -37,7 +37,8 @@ + android:orientation="vertical" + android:duplicateParentState="true"> 2) { mFavoritePrinterSelected = true; mDestinationSpinner.setSelection(0); + // Workaround again the weird spinner behavior to notify for selection + // change on the next layout pass as the current printer is used below. + mCurrentPrinter = (PrinterInfo) mDestinationSpinnerAdapter.getItem(0); } // If there is a next printer to select and we succeed selecting diff --git a/packages/PrintSpooler/src/com/android/printspooler/SelectPrinterFragment.java b/packages/PrintSpooler/src/com/android/printspooler/SelectPrinterFragment.java index b8a9417a2faa7..20315caae650a 100644 --- a/packages/PrintSpooler/src/com/android/printspooler/SelectPrinterFragment.java +++ b/packages/PrintSpooler/src/com/android/printspooler/SelectPrinterFragment.java @@ -435,6 +435,8 @@ public final class SelectPrinterFragment extends ListFragment { R.layout.printer_dropdown_item, parent, false); } + convertView.setEnabled(isEnabled(position)); + CharSequence title = null; CharSequence subtitle = null; Drawable icon = null; @@ -475,6 +477,12 @@ public final class SelectPrinterFragment extends ListFragment { return convertView; } + @Override + public boolean isEnabled(int position) { + PrinterInfo printer = (PrinterInfo) getItem(position); + return printer.getStatus() != PrinterInfo.STATUS_UNAVAILABLE; + } + @Override public Loader> onCreateLoader(int id, Bundle args) { if (id == LOADER_ID_PRINTERS_LOADER) {