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

Commit c309d715 authored by Philip P. Moltmann's avatar Philip P. Moltmann
Browse files

Make sure to update the selected pages when needed in the right order.

Fixes: 27945066
Change-Id: I9c83a5283d6bf093a35ad835532d3c8690b4b989
parent 3dafea31
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);
                }
@@ -2773,13 +2785,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();
            }
        }
    }