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

Commit a97415b0 authored by Philip P. Moltmann's avatar Philip P. Moltmann Committed by Android (Google) Code Review
Browse files

Merge "Make sure to update the selected pages when needed in the right order." into nyc-dev

parents c84bbd57 c309d715
Loading
Loading
Loading
Loading
+20 −14
Original line number Diff line number Diff line
@@ -1169,6 +1169,18 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat
        doFinish();
    }

    /**
     * Update the selected pages from the text field.
     */
    private void updateSelectedPagesFromTextField() {
        PageRange[] selectedPages = computeSelectedPages();
        if (!Arrays.equals(mSelectedPages, selectedPages)) {
            mSelectedPages = selectedPages;
            // Update preview.
            updatePrintPreviewController(false);
        }
    }

    private void confirmPrint() {
        setState(STATE_PRINT_CONFIRMED);

@@ -1178,14 +1190,10 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat
        addCurrentPrinterToHistory();
        setUserPrinted();

        PageRange[] selectedPages = computeSelectedPages();
        if (!Arrays.equals(mSelectedPages, selectedPages)) {
            mSelectedPages = selectedPages;
            // Update preview.
            updatePrintPreviewController(false);
        }

        // updateSelectedPagesFromTextField migth update the preview, hence apply the preview first
        updateSelectedPagesFromPreview();
        updateSelectedPagesFromTextField();

        mPrintPreviewController.closeOptions();

        if (canUpdateDocument()) {
@@ -1485,6 +1493,10 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat
                    cancelPrint();
                }
            } else if (view == mMoreOptionsButton) {
                // The selected pages is only applied once the user leaves the text field. A click
                // on this button, does not count as leaving.
                updateSelectedPagesFromTextField();

                if (mCurrentPrinter != null) {
                    startAdvancedPrintOptionsActivity(mCurrentPrinter);
                }
@@ -2774,13 +2786,7 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat
            }

            if (view == mPageRangeEditText && !hasFocus) {
                PageRange[] selectedPages = computeSelectedPages();
                if (selectedPages != null && !Arrays.equals(mSelectedPages, selectedPages)) {
                    mSelectedPages = selectedPages;

                    // Update preview.
                    updatePrintPreviewController(false);
                }
                updateSelectedPagesFromTextField();
            }
        }
    }