diff options
| author | Svetoslav Ganov <svetoslavganov@google.com> | 2013-09-30 09:04:50 -0700 |
|---|---|---|
| committer | Svetoslav <svetoslavganov@google.com> | 2013-10-04 11:45:15 -0700 |
| commit | 7be27acac922b5ea66ec6b464ded6f057bd6f1e5 (patch) | |
| tree | cfc3d44f5fbe42a88de0f540c8c2a0b07a94b37f /core/java/android/print/PrintAttributes.java | |
| parent | 5c126892ec53772d784fcf9cef9165acf1d92ce3 (diff) | |
| download | frameworks_base-7be27acac922b5ea66ec6b464ded6f057bd6f1e5.zip frameworks_base-7be27acac922b5ea66ec6b464ded6f057bd6f1e5.tar.gz frameworks_base-7be27acac922b5ea66ec6b464ded6f057bd6f1e5.tar.bz2 | |
Print attributes hint not honored.
1. Initially we have a single printer, the fake PDF printer, and
wait for printers to be discovered. This printer was handling
only a couple of media sizes. Hence, if the app provides a
media size hint and the PDF printer does not support it, we
were essentially ignoring the suggested media size since it
was not supported by the selected printer and we fell back to
the default paper size for that printer. The fake PDF printer
should support all predefined media sizes.
2. The list of available paper sizes was shown in the order they
are added ignoring the current locale. It is much better user
experience if the media sizes used in the current locale are
shown at the top and all others after that. Also the media
sizes for the current locale should be alphabetically ordered
so the user can quickly find the desired one.
3. The orientation was reset on media size or printer change.
bug:10564537
Change-Id: Iaa0d42242730ce69cea3effd4d0f4bc087068804
Diffstat (limited to 'core/java/android/print/PrintAttributes.java')
| -rw-r--r-- | core/java/android/print/PrintAttributes.java | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/core/java/android/print/PrintAttributes.java b/core/java/android/print/PrintAttributes.java index 959380d..ec979b3 100644 --- a/core/java/android/print/PrintAttributes.java +++ b/core/java/android/print/PrintAttributes.java @@ -22,10 +22,13 @@ import android.content.res.Resources.NotFoundException; import android.os.Parcel; import android.os.Parcelable; import android.text.TextUtils; +import android.util.ArrayMap; import android.util.Log; import com.android.internal.R; +import java.util.Map; + /** * This class represents the attributes of a print job. */ @@ -267,6 +270,9 @@ public final class PrintAttributes implements Parcelable { public static final class MediaSize { private static final String LOG_TAG = "MediaSize"; + private static final Map<String, MediaSize> sIdToMediaSizeMap = + new ArrayMap<String, MediaSize>(); + /** * Unknown media size in portrait mode. * <p> @@ -494,8 +500,8 @@ public final class PrintAttributes implements Parcelable { R.string.mediasize_chinese_prc_10, 12756, 18032); /** Chinese PRC 16k media size: 146mm x 215mm (5.749" x 8.465") */ - public static final MediaSize PRC_16k = - new MediaSize("PRC_16k", "android", + public static final MediaSize PRC_16K = + new MediaSize("PRC_16K", "android", R.string.mediasize_chinese_prc_16k, 5749, 8465); /** Chinese Pa Kai media size: 267mm x 389mm (10.512" x 15.315") */ public static final MediaSize OM_PA_KAI = @@ -651,6 +657,9 @@ public final class PrintAttributes implements Parcelable { mWidthMils = widthMils; mHeightMils = heightMils; mLabel = null; + + // Build this mapping only for predefined media sizes. + sIdToMediaSizeMap.put(mId, this); } /** @@ -854,6 +863,18 @@ public final class PrintAttributes implements Parcelable { builder.append("}"); return builder.toString(); } + + /** + * Gets a standard media size given its id. + * + * @param id The media size id. + * @return The media size for the given id or null. + * + * @hide + */ + public static MediaSize getStandardMediaSizeById(String id) { + return sIdToMediaSizeMap.get(id); + } } /** |
