Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 69b91e0e authored by Svetoslav Ganov's avatar Svetoslav Ganov
Browse files

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
parent be5ba9a2
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -37,7 +37,8 @@
    <LinearLayout
    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical">
        android:orientation="vertical"
        android:duplicateParentState="true">


        <TextView
        <TextView
            android:id="@+id/title"
            android:id="@+id/title"
+4 −0
Original line number Original line Diff line number Diff line
@@ -555,6 +555,7 @@ public class PrintJobConfigActivity extends Activity {
                // TODO: We need some UI for announcing an error.
                // TODO: We need some UI for announcing an error.
                mControllerState = CONTROLLER_STATE_FAILED;
                mControllerState = CONTROLLER_STATE_FAILED;
                Log.e(LOG_TAG, "Received invalid pages from the app");
                Log.e(LOG_TAG, "Received invalid pages from the app");
                mEditor.cancel();
                PrintJobConfigActivity.this.finish();
                PrintJobConfigActivity.this.finish();
            }
            }
        }
        }
@@ -1152,6 +1153,9 @@ public class PrintJobConfigActivity extends Activity {
                    if (!mFavoritePrinterSelected && mDestinationSpinnerAdapter.getCount() > 2) {
                    if (!mFavoritePrinterSelected && mDestinationSpinnerAdapter.getCount() > 2) {
                        mFavoritePrinterSelected = true;
                        mFavoritePrinterSelected = true;
                        mDestinationSpinner.setSelection(0);
                        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
                    // If there is a next printer to select and we succeed selecting
+8 −0
Original line number Original line Diff line number Diff line
@@ -435,6 +435,8 @@ public final class SelectPrinterFragment extends ListFragment {
                        R.layout.printer_dropdown_item, parent, false);
                        R.layout.printer_dropdown_item, parent, false);
            }
            }


            convertView.setEnabled(isEnabled(position));

            CharSequence title = null;
            CharSequence title = null;
            CharSequence subtitle = null;
            CharSequence subtitle = null;
            Drawable icon = null;
            Drawable icon = null;
@@ -475,6 +477,12 @@ public final class SelectPrinterFragment extends ListFragment {
            return convertView;
            return convertView;
        }
        }


        @Override
        public boolean isEnabled(int position) {
            PrinterInfo printer =  (PrinterInfo) getItem(position);
            return printer.getStatus() != PrinterInfo.STATUS_UNAVAILABLE;
        }

        @Override
        @Override
        public Loader<List<PrinterInfo>> onCreateLoader(int id, Bundle args) {
        public Loader<List<PrinterInfo>> onCreateLoader(int id, Bundle args) {
            if (id == LOADER_ID_PRINTERS_LOADER) {
            if (id == LOADER_ID_PRINTERS_LOADER) {