summaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorSvetoslav Ganov <svetoslavganov@google.com>2013-09-26 08:45:22 -0700
committerSvetoslav <svetoslavganov@google.com>2013-09-26 13:54:49 -0700
commit0ce3e8743c9127a688f007eed17a5ed18081d0fc (patch)
treea55dec1bc1db6bb8020919c943985e97fcc8bbec /packages
parent8c6c04197e58be6f3e46ba6a38f5d16e4fb091fa (diff)
downloadframeworks_base-0ce3e8743c9127a688f007eed17a5ed18081d0fc.zip
frameworks_base-0ce3e8743c9127a688f007eed17a5ed18081d0fc.tar.gz
frameworks_base-0ce3e8743c9127a688f007eed17a5ed18081d0fc.tar.bz2
Choosing default paper size for the "Save to PDF" fake printer
Change-Id: I1e2eb73fd1eb3b1e9812155b69b94cba261243c2
Diffstat (limited to 'packages')
-rw-r--r--packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java34
1 files changed, 32 insertions, 2 deletions
diff --git a/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java b/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
index d6cf76c..8d11a93 100644
--- a/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
+++ b/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
@@ -56,6 +56,7 @@ import android.text.Editable;
import android.text.TextUtils;
import android.text.TextUtils.SimpleStringSplitter;
import android.text.TextWatcher;
+import android.util.ArraySet;
import android.util.AttributeSet;
import android.util.Log;
import android.view.KeyEvent;
@@ -90,6 +91,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
+import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -147,6 +149,26 @@ public class PrintJobConfigActivity extends Activity {
"[\\s]*[0-9]*[\\s]*[\\-]?[\\s]*[0-9]*[\\s]*?(([,])"
+ "[\\s]*[0-9]*[\\s]*[\\-]?[\\s]*[0-9]*[\\s]*|[\\s]*)+");
+ // The list of countries where Letter is the default paper size. Culled from
+ // the OpenOffice wiki at http://wiki.openoffice.org/wiki/DefaultPaperSize.
+ private static final Set<String> sLetterDefaultCountries = new ArraySet<String>();
+ static {
+ sLetterDefaultCountries.add("US");
+ sLetterDefaultCountries.add("CA");
+ sLetterDefaultCountries.add("BZ");
+ sLetterDefaultCountries.add("CL");
+ sLetterDefaultCountries.add("CR");
+ sLetterDefaultCountries.add("GT");
+ sLetterDefaultCountries.add("NI");
+ sLetterDefaultCountries.add("PA");
+ sLetterDefaultCountries.add("PR");
+ sLetterDefaultCountries.add("SV");
+ sLetterDefaultCountries.add("VE");
+ sLetterDefaultCountries.add("MX");
+ sLetterDefaultCountries.add("CO");
+ sLetterDefaultCountries.add("PH");
+ }
+
public static final PageRange[] ALL_PAGES_ARRAY = new PageRange[] {PageRange.ALL_PAGES};
private final PrintAttributes mOldPrintAttributes = new PrintAttributes.Builder().build();
@@ -2136,12 +2158,20 @@ public class PrintJobConfigActivity extends Activity {
}
private PrinterInfo createFakePdfPrinter() {
+ final MediaSize defaultMediaSize;
+ String currentCountry = getResources().getConfiguration().locale.getCountry();
+ if (sLetterDefaultCountries.contains(currentCountry)) {
+ defaultMediaSize = MediaSize.NA_LETTER;
+ } else {
+ defaultMediaSize = MediaSize.ISO_A4;
+ }
+
PrinterId printerId = new PrinterId(getComponentName(), "PDF printer");
PrinterCapabilitiesInfo capabilities =
new PrinterCapabilitiesInfo.Builder(printerId)
- .addMediaSize(MediaSize.ISO_A4, true)
- .addMediaSize(MediaSize.NA_LETTER, false)
+ .addMediaSize(MediaSize.ISO_A4, MediaSize.ISO_A4 == defaultMediaSize)
+ .addMediaSize(MediaSize.NA_LETTER, MediaSize.NA_LETTER == defaultMediaSize)
.addResolution(new Resolution("PDF resolution", "PDF resolution",
300, 300), true)
.setColorModes(PrintAttributes.COLOR_MODE_COLOR