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
This commit is contained in:
Svetoslav Ganov
2013-10-07 22:17:30 -07:00
parent be5ba9a255
commit 69b91e0ecb
3 changed files with 14 additions and 1 deletions

View File

@@ -37,7 +37,8 @@
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
android:orientation="vertical"
android:duplicateParentState="true">
<TextView
android:id="@+id/title"

View File

@@ -555,6 +555,7 @@ public class PrintJobConfigActivity extends Activity {
// TODO: We need some UI for announcing an error.
mControllerState = CONTROLLER_STATE_FAILED;
Log.e(LOG_TAG, "Received invalid pages from the app");
mEditor.cancel();
PrintJobConfigActivity.this.finish();
}
}
@@ -1152,6 +1153,9 @@ public class PrintJobConfigActivity extends Activity {
if (!mFavoritePrinterSelected && mDestinationSpinnerAdapter.getCount() > 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

View File

@@ -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<List<PrinterInfo>> onCreateLoader(int id, Bundle args) {
if (id == LOADER_ID_PRINTERS_LOADER) {