Merge "Crash in print spooler if save to PDF selected early." into lmp-dev
diff --git a/packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java b/packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java
index 72916ea..84ada6f 100644
--- a/packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java
+++ b/packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java
@@ -566,6 +566,9 @@
     }
 
     private void startCreateDocumentActivity() {
+        if (!isResumed()) {
+            return;
+        }
         PrintDocumentInfo info = mPrintedDocument.getDocumentInfo().info;
         if (info == null) {
             return;
@@ -1372,7 +1375,8 @@
             mPrintButton.setImageResource(R.drawable.ic_menu_savetopdf);
             mPrintButton.setContentDescription(getString(R.string.savetopdf_button));
         }
-        if ((mRangeOptionsSpinner.getSelectedItemPosition() == 1
+        if (!mPrintedDocument.getDocumentInfo().laidout
+                ||(mRangeOptionsSpinner.getSelectedItemPosition() == 1
                 && (TextUtils.isEmpty(mPageRangeEditText.getText()) || hasErrors()))
                 || (mRangeOptionsSpinner.getSelectedItemPosition() == 0
                 && (mPrintedDocument.getDocumentInfo() == null || hasErrors()))) {