Loading packages/PrintSpooler/src/com/android/printspooler/model/RemotePrintDocument.java +5 −1 Original line number Original line Diff line number Diff line Loading @@ -113,12 +113,14 @@ public final class RemotePrintDocument { } } // Notify we are done. // Notify we are done. mState = STATE_UPDATED; mState = STATE_UPDATED; mDocumentInfo.updated = true; notifyUpdateCompleted(); notifyUpdateCompleted(); } } } } } else { } else { // We always notify after a write. // We always notify after a write. mState = STATE_UPDATED; mState = STATE_UPDATED; mDocumentInfo.updated = true; notifyUpdateCompleted(); notifyUpdateCompleted(); } } runPendingCommand(); runPendingCommand(); Loading Loading @@ -229,6 +231,7 @@ public final class RemotePrintDocument { mDocumentInfo, oldAttributes, attributes, preview, mCommandResultCallback); mDocumentInfo, oldAttributes, attributes, preview, mCommandResultCallback); scheduleCommand(command); scheduleCommand(command); mDocumentInfo.updated = false; mState = STATE_UPDATING; mState = STATE_UPDATING; // If no layout in progress and we don't have all pages - schedule a write. // If no layout in progress and we don't have all pages - schedule a write. } else if ((!(mCurrentCommand instanceof LayoutCommand) } else if ((!(mCurrentCommand instanceof LayoutCommand) Loading @@ -249,6 +252,7 @@ public final class RemotePrintDocument { mDocumentInfo.fileProvider, mCommandResultCallback); mDocumentInfo.fileProvider, mCommandResultCallback); scheduleCommand(command); scheduleCommand(command); mDocumentInfo.updated = false; mState = STATE_UPDATING; mState = STATE_UPDATING; } else { } else { willUpdate = false; willUpdate = false; Loading Loading @@ -396,7 +400,7 @@ public final class RemotePrintDocument { private void notifyUpdateFailed(CharSequence error) { private void notifyUpdateFailed(CharSequence error) { if (DEBUG) { if (DEBUG) { Log.i(LOG_TAG, "[CALLING] onUpdateCompleted()"); Log.i(LOG_TAG, "[CALLING] notifyUpdateFailed()"); } } mUpdateCallbacks.onUpdateFailed(error); mUpdateCallbacks.onUpdateFailed(error); } } Loading packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java +6 −17 Original line number Original line Diff line number Diff line Loading @@ -491,8 +491,6 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat setState(STATE_UPDATE_FAILED); setState(STATE_UPDATE_FAILED); updateOptionsUi(); mPrintedDocument.kill(message); mPrintedDocument.kill(message); } } Loading @@ -502,7 +500,6 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat && canUpdateDocument() && updateDocument(true)) { && canUpdateDocument() && updateDocument(true)) { ensurePreviewUiShown(); ensurePreviewUiShown(); setState(STATE_CONFIGURING); setState(STATE_CONFIGURING); updateOptionsUi(); } } } } Loading Loading @@ -579,7 +576,6 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat updatePrintPreviewController(document.changed); updatePrintPreviewController(document.changed); setState(STATE_CONFIGURING); setState(STATE_CONFIGURING); updateOptionsUi(); } break; } break; } } } } Loading @@ -600,8 +596,6 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat } } setState(STATE_UPDATE_FAILED); setState(STATE_UPDATE_FAILED); updateOptionsUi(); } } @Override @Override Loading Loading @@ -734,7 +728,6 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat updateOptionsUi(); updateOptionsUi(); } else { } else { setState(STATE_CREATE_FILE_FAILED); setState(STATE_CREATE_FILE_FAILED); updateOptionsUi(); // Calling finish here does not invoke lifecycle callbacks but we // Calling finish here does not invoke lifecycle callbacks but we // update the print job in onPause if finishing, hence post a message. // update the print job in onPause if finishing, hence post a message. mDestinationSpinner.post(new Runnable() { mDestinationSpinner.post(new Runnable() { Loading Loading @@ -958,12 +951,14 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat Log.i(LOG_TAG, "[state]" + state); Log.i(LOG_TAG, "[state]" + state); } } mState = state; mState = state; updateOptionsUi(); } } } else { } else { if (DEBUG) { if (DEBUG) { Log.i(LOG_TAG, "[state]" + state); Log.i(LOG_TAG, "[state]" + state); } } mState = state; mState = state; updateOptionsUi(); } } } } Loading Loading @@ -1230,6 +1225,7 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat final boolean willUpdate = mPrintedDocument.update(mPrintJob.getAttributes(), final boolean willUpdate = mPrintedDocument.update(mPrintJob.getAttributes(), pages, preview); pages, preview); updateOptionsUi(); if (willUpdate && !mPrintedDocument.hasLaidOutPages()) { if (willUpdate && !mPrintedDocument.hasLaidOutPages()) { // When the update is done we update the print preview. // When the update is done we update the print preview. Loading @@ -1254,7 +1250,6 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat private void cancelPrint() { private void cancelPrint() { setState(STATE_PRINT_CANCELED); setState(STATE_PRINT_CANCELED); updateOptionsUi(); mPrintedDocument.cancel(true); mPrintedDocument.cancel(true); doFinish(); doFinish(); } } Loading @@ -1274,7 +1269,6 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat private void confirmPrint() { private void confirmPrint() { setState(STATE_PRINT_CONFIRMED); setState(STATE_PRINT_CONFIRMED); updateOptionsUi(); addCurrentPrinterToHistory(); addCurrentPrinterToHistory(); setUserPrinted(); setUserPrinted(); Loading Loading @@ -1629,6 +1623,8 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat // Always update the summary. // Always update the summary. updateSummary(); updateSummary(); mDestinationSpinner.setEnabled(!isFinalState(mState)); if (mState == STATE_PRINT_CONFIRMED if (mState == STATE_PRINT_CONFIRMED || mState == STATE_PRINT_COMPLETED || mState == STATE_PRINT_COMPLETED || mState == STATE_PRINT_CANCELED || mState == STATE_PRINT_CANCELED Loading @@ -1636,9 +1632,6 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat || mState == STATE_CREATE_FILE_FAILED || mState == STATE_CREATE_FILE_FAILED || mState == STATE_PRINTER_UNAVAILABLE || mState == STATE_PRINTER_UNAVAILABLE || mState == STATE_UPDATE_SLOW) { || mState == STATE_UPDATE_SLOW) { if (mState != STATE_PRINTER_UNAVAILABLE) { mDestinationSpinner.setEnabled(false); } disableOptionsUi(isFinalState(mState)); disableOptionsUi(isFinalState(mState)); return; return; } } Loading Loading @@ -1927,7 +1920,7 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat mPrintButton.setImageResource(R.drawable.ic_menu_savetopdf); mPrintButton.setImageResource(R.drawable.ic_menu_savetopdf); mPrintButton.setContentDescription(getString(R.string.savetopdf_button)); mPrintButton.setContentDescription(getString(R.string.savetopdf_button)); } } if (!mPrintedDocument.getDocumentInfo().laidout if (!mPrintedDocument.getDocumentInfo().updated ||(mRangeOptionsSpinner.getSelectedItemPosition() == 1 ||(mRangeOptionsSpinner.getSelectedItemPosition() == 1 && (TextUtils.isEmpty(mPageRangeEditText.getText()) || hasErrors())) && (TextUtils.isEmpty(mPageRangeEditText.getText()) || hasErrors())) || (mRangeOptionsSpinner.getSelectedItemPosition() == 0 || (mRangeOptionsSpinner.getSelectedItemPosition() == 0 Loading Loading @@ -2048,7 +2041,6 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat updateDocument(false); updateDocument(false); } } ensurePreviewUiShown(); ensurePreviewUiShown(); updateOptionsUi(); } } } } Loading @@ -2058,7 +2050,6 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat mPrintedDocument.cancel(false); mPrintedDocument.cancel(false); ensureErrorUiShown(getString(R.string.print_error_printer_unavailable), ensureErrorUiShown(getString(R.string.print_error_printer_unavailable), PrintErrorFragment.ACTION_NONE); PrintErrorFragment.ACTION_NONE); updateOptionsUi(); } } } } Loading Loading @@ -3038,7 +3029,6 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat if (mState == STATE_UPDATE_SLOW) { if (mState == STATE_UPDATE_SLOW) { setState(STATE_UPDATE_SLOW); setState(STATE_UPDATE_SLOW); ensureProgressUiShown(); ensureProgressUiShown(); updateOptionsUi(); return; return; } else if (mPosted) { } else if (mPosted) { Loading Loading @@ -3080,7 +3070,6 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat mPreviousState = mState; mPreviousState = mState; setState(STATE_UPDATE_SLOW); setState(STATE_UPDATE_SLOW); ensureProgressUiShown(); ensureProgressUiShown(); updateOptionsUi(); } } } } Loading Loading
packages/PrintSpooler/src/com/android/printspooler/model/RemotePrintDocument.java +5 −1 Original line number Original line Diff line number Diff line Loading @@ -113,12 +113,14 @@ public final class RemotePrintDocument { } } // Notify we are done. // Notify we are done. mState = STATE_UPDATED; mState = STATE_UPDATED; mDocumentInfo.updated = true; notifyUpdateCompleted(); notifyUpdateCompleted(); } } } } } else { } else { // We always notify after a write. // We always notify after a write. mState = STATE_UPDATED; mState = STATE_UPDATED; mDocumentInfo.updated = true; notifyUpdateCompleted(); notifyUpdateCompleted(); } } runPendingCommand(); runPendingCommand(); Loading Loading @@ -229,6 +231,7 @@ public final class RemotePrintDocument { mDocumentInfo, oldAttributes, attributes, preview, mCommandResultCallback); mDocumentInfo, oldAttributes, attributes, preview, mCommandResultCallback); scheduleCommand(command); scheduleCommand(command); mDocumentInfo.updated = false; mState = STATE_UPDATING; mState = STATE_UPDATING; // If no layout in progress and we don't have all pages - schedule a write. // If no layout in progress and we don't have all pages - schedule a write. } else if ((!(mCurrentCommand instanceof LayoutCommand) } else if ((!(mCurrentCommand instanceof LayoutCommand) Loading @@ -249,6 +252,7 @@ public final class RemotePrintDocument { mDocumentInfo.fileProvider, mCommandResultCallback); mDocumentInfo.fileProvider, mCommandResultCallback); scheduleCommand(command); scheduleCommand(command); mDocumentInfo.updated = false; mState = STATE_UPDATING; mState = STATE_UPDATING; } else { } else { willUpdate = false; willUpdate = false; Loading Loading @@ -396,7 +400,7 @@ public final class RemotePrintDocument { private void notifyUpdateFailed(CharSequence error) { private void notifyUpdateFailed(CharSequence error) { if (DEBUG) { if (DEBUG) { Log.i(LOG_TAG, "[CALLING] onUpdateCompleted()"); Log.i(LOG_TAG, "[CALLING] notifyUpdateFailed()"); } } mUpdateCallbacks.onUpdateFailed(error); mUpdateCallbacks.onUpdateFailed(error); } } Loading
packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java +6 −17 Original line number Original line Diff line number Diff line Loading @@ -491,8 +491,6 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat setState(STATE_UPDATE_FAILED); setState(STATE_UPDATE_FAILED); updateOptionsUi(); mPrintedDocument.kill(message); mPrintedDocument.kill(message); } } Loading @@ -502,7 +500,6 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat && canUpdateDocument() && updateDocument(true)) { && canUpdateDocument() && updateDocument(true)) { ensurePreviewUiShown(); ensurePreviewUiShown(); setState(STATE_CONFIGURING); setState(STATE_CONFIGURING); updateOptionsUi(); } } } } Loading Loading @@ -579,7 +576,6 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat updatePrintPreviewController(document.changed); updatePrintPreviewController(document.changed); setState(STATE_CONFIGURING); setState(STATE_CONFIGURING); updateOptionsUi(); } break; } break; } } } } Loading @@ -600,8 +596,6 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat } } setState(STATE_UPDATE_FAILED); setState(STATE_UPDATE_FAILED); updateOptionsUi(); } } @Override @Override Loading Loading @@ -734,7 +728,6 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat updateOptionsUi(); updateOptionsUi(); } else { } else { setState(STATE_CREATE_FILE_FAILED); setState(STATE_CREATE_FILE_FAILED); updateOptionsUi(); // Calling finish here does not invoke lifecycle callbacks but we // Calling finish here does not invoke lifecycle callbacks but we // update the print job in onPause if finishing, hence post a message. // update the print job in onPause if finishing, hence post a message. mDestinationSpinner.post(new Runnable() { mDestinationSpinner.post(new Runnable() { Loading Loading @@ -958,12 +951,14 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat Log.i(LOG_TAG, "[state]" + state); Log.i(LOG_TAG, "[state]" + state); } } mState = state; mState = state; updateOptionsUi(); } } } else { } else { if (DEBUG) { if (DEBUG) { Log.i(LOG_TAG, "[state]" + state); Log.i(LOG_TAG, "[state]" + state); } } mState = state; mState = state; updateOptionsUi(); } } } } Loading Loading @@ -1230,6 +1225,7 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat final boolean willUpdate = mPrintedDocument.update(mPrintJob.getAttributes(), final boolean willUpdate = mPrintedDocument.update(mPrintJob.getAttributes(), pages, preview); pages, preview); updateOptionsUi(); if (willUpdate && !mPrintedDocument.hasLaidOutPages()) { if (willUpdate && !mPrintedDocument.hasLaidOutPages()) { // When the update is done we update the print preview. // When the update is done we update the print preview. Loading @@ -1254,7 +1250,6 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat private void cancelPrint() { private void cancelPrint() { setState(STATE_PRINT_CANCELED); setState(STATE_PRINT_CANCELED); updateOptionsUi(); mPrintedDocument.cancel(true); mPrintedDocument.cancel(true); doFinish(); doFinish(); } } Loading @@ -1274,7 +1269,6 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat private void confirmPrint() { private void confirmPrint() { setState(STATE_PRINT_CONFIRMED); setState(STATE_PRINT_CONFIRMED); updateOptionsUi(); addCurrentPrinterToHistory(); addCurrentPrinterToHistory(); setUserPrinted(); setUserPrinted(); Loading Loading @@ -1629,6 +1623,8 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat // Always update the summary. // Always update the summary. updateSummary(); updateSummary(); mDestinationSpinner.setEnabled(!isFinalState(mState)); if (mState == STATE_PRINT_CONFIRMED if (mState == STATE_PRINT_CONFIRMED || mState == STATE_PRINT_COMPLETED || mState == STATE_PRINT_COMPLETED || mState == STATE_PRINT_CANCELED || mState == STATE_PRINT_CANCELED Loading @@ -1636,9 +1632,6 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat || mState == STATE_CREATE_FILE_FAILED || mState == STATE_CREATE_FILE_FAILED || mState == STATE_PRINTER_UNAVAILABLE || mState == STATE_PRINTER_UNAVAILABLE || mState == STATE_UPDATE_SLOW) { || mState == STATE_UPDATE_SLOW) { if (mState != STATE_PRINTER_UNAVAILABLE) { mDestinationSpinner.setEnabled(false); } disableOptionsUi(isFinalState(mState)); disableOptionsUi(isFinalState(mState)); return; return; } } Loading Loading @@ -1927,7 +1920,7 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat mPrintButton.setImageResource(R.drawable.ic_menu_savetopdf); mPrintButton.setImageResource(R.drawable.ic_menu_savetopdf); mPrintButton.setContentDescription(getString(R.string.savetopdf_button)); mPrintButton.setContentDescription(getString(R.string.savetopdf_button)); } } if (!mPrintedDocument.getDocumentInfo().laidout if (!mPrintedDocument.getDocumentInfo().updated ||(mRangeOptionsSpinner.getSelectedItemPosition() == 1 ||(mRangeOptionsSpinner.getSelectedItemPosition() == 1 && (TextUtils.isEmpty(mPageRangeEditText.getText()) || hasErrors())) && (TextUtils.isEmpty(mPageRangeEditText.getText()) || hasErrors())) || (mRangeOptionsSpinner.getSelectedItemPosition() == 0 || (mRangeOptionsSpinner.getSelectedItemPosition() == 0 Loading Loading @@ -2048,7 +2041,6 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat updateDocument(false); updateDocument(false); } } ensurePreviewUiShown(); ensurePreviewUiShown(); updateOptionsUi(); } } } } Loading @@ -2058,7 +2050,6 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat mPrintedDocument.cancel(false); mPrintedDocument.cancel(false); ensureErrorUiShown(getString(R.string.print_error_printer_unavailable), ensureErrorUiShown(getString(R.string.print_error_printer_unavailable), PrintErrorFragment.ACTION_NONE); PrintErrorFragment.ACTION_NONE); updateOptionsUi(); } } } } Loading Loading @@ -3038,7 +3029,6 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat if (mState == STATE_UPDATE_SLOW) { if (mState == STATE_UPDATE_SLOW) { setState(STATE_UPDATE_SLOW); setState(STATE_UPDATE_SLOW); ensureProgressUiShown(); ensureProgressUiShown(); updateOptionsUi(); return; return; } else if (mPosted) { } else if (mPosted) { Loading Loading @@ -3080,7 +3070,6 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat mPreviousState = mState; mPreviousState = mState; setState(STATE_UPDATE_SLOW); setState(STATE_UPDATE_SLOW); ensureProgressUiShown(); ensureProgressUiShown(); updateOptionsUi(); } } } } Loading