summaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorSvetoslav <svetoslavganov@google.com>2013-09-16 19:03:39 -0700
committerSvetoslav <svetoslavganov@google.com>2013-09-16 19:13:25 -0700
commitc3484024e1117b518f06b39c406ba20f961d592e (patch)
treea7522008782fbd6ff30464c2cd49856a505d8942 /packages
parent3fb53d8238c0ccec275237cf4f4962f2a00eab7e (diff)
downloadframeworks_base-c3484024e1117b518f06b39c406ba20f961d592e.zip
frameworks_base-c3484024e1117b518f06b39c406ba20f961d592e.tar.gz
frameworks_base-c3484024e1117b518f06b39c406ba20f961d592e.tar.bz2
Print pooler crashes for some page ranges.
1. The print spooler fails to parse page ranges that end with a dash, e,g, "1-", which are however valid inputs since the user can continue typing to end up with a well-fromed range. 2. After a layout we are asking for the first selected page to be written emulating print preview, thus increasing the changes that apps will correctly implement the APIs. bug:10743632 Change-Id: Ia74172d4fa6bce6ad93a0bc53da1aaa3fe8bef42
Diffstat (limited to 'packages')
-rw-r--r--packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java23
1 files changed, 20 insertions, 3 deletions
diff --git a/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java b/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
index 14f60f1..f57bceb 100644
--- a/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
+++ b/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
@@ -413,12 +413,25 @@ public class PrintJobConfigActivity extends Activity {
// write anything and wait for the user to fix the range which will
// trigger an update.
mRequestedPages = mEditor.getRequestedPages();
- if (mRequestedPages == null) {
+ if (mRequestedPages == null || mRequestedPages.length == 0) {
mEditor.updateUi();
if (mEditor.isDone()) {
PrintJobConfigActivity.this.finish();
}
return;
+ } else {
+ // If print is not confirmed we just ask for the first of the
+ // selected pages to emulate a behavior that shows preview
+ // increasing the chances that apps will implement the APIs
+ // correctly.
+ if (!mEditor.isPrintConfirmed()) {
+ if (ALL_PAGES_ARRAY.equals(mRequestedPages)) {
+ mRequestedPages = new PageRange[] {new PageRange(0, 0)};
+ } else {
+ final int firstPage = mRequestedPages[0].getStart();
+ mRequestedPages = new PageRange[] {new PageRange(firstPage, firstPage)};
+ }
+ }
}
// If the info and the layout did not change and we already have
@@ -1460,8 +1473,12 @@ public class PrintJobConfigActivity extends Activity {
if (dashIndex > 0) {
fromIndex = Integer.parseInt(range.substring(0, dashIndex)) - 1;
- toIndex = Integer.parseInt(range.substring(
- dashIndex + 1, range.length())) - 1;
+ // It is possible that the dash is at the end since the input
+ // verification can has to allow the user to keep entering if
+ // this would lead to a valid input. So we handle this.
+ toIndex = (dashIndex < range.length() - 1)
+ ? Integer.parseInt(range.substring(dashIndex + 1,
+ range.length())) - 1 : fromIndex;
} else {
fromIndex = toIndex = Integer.parseInt(range) - 1;
}