diff options
| author | 2013-09-05 09:38:02 -0700 | |
|---|---|---|
| committer | 2013-09-05 09:50:28 -0700 | |
| commit | a76233ae845da4bc9e3bcd89821701a747215e7b (patch) | |
| tree | d74d079330fe51f0a80658943ce642ec0d2fb465 | |
| parent | 773f54de3de9bce7b6f915aa47ed686b161d77aa (diff) | |
Hiding some unneeded APIs,
1. Hide the MediaSize and Resolution constructors that take
package and resource Id.
2. Fix a bug and docs in creating portrait and landscape media
size.
Change-Id: If59992e355391de6ad6d14d4f7b3be8c8b6cc0e0
| -rw-r--r-- | api/current.txt | 2 | ||||
| -rw-r--r-- | core/java/android/print/PrintAttributes.java | 38 | ||||
| -rw-r--r-- | packages/PrintSpooler/src/com/android/printspooler/PrintSpoolerService.java | 15 |
3 files changed, 21 insertions, 34 deletions
diff --git a/api/current.txt b/api/current.txt index 3887630fd8d6..6060f05eb6c5 100644 --- a/api/current.txt +++ b/api/current.txt @@ -19068,7 +19068,6 @@ package android.print { } public static final class PrintAttributes.MediaSize { - ctor public PrintAttributes.MediaSize(java.lang.String, java.lang.String, int, int, int); ctor public PrintAttributes.MediaSize(java.lang.String, java.lang.String, int, int); method public android.print.PrintAttributes.MediaSize asLandscape(); method public android.print.PrintAttributes.MediaSize asPortrait(); @@ -19119,7 +19118,6 @@ package android.print { } public static final class PrintAttributes.Resolution { - ctor public PrintAttributes.Resolution(java.lang.String, java.lang.String, int, int, int); ctor public PrintAttributes.Resolution(java.lang.String, java.lang.String, int, int); method public int getHorizontalDpi(); method public java.lang.String getId(); diff --git a/core/java/android/print/PrintAttributes.java b/core/java/android/print/PrintAttributes.java index f975ebd42baa..f4cc7677a6a2 100644 --- a/core/java/android/print/PrintAttributes.java +++ b/core/java/android/print/PrintAttributes.java @@ -412,6 +412,8 @@ public final class PrintAttributes implements Parcelable { * @throws IllegalArgumentException If the label is empty. * @throws IllegalArgumentException If the widthMils is less than or equal to zero. * @throws IllegalArgumentException If the heightMils is less than or equal to zero. + * + * @hide */ public MediaSize(String id, String packageName, int labelResId, int widthMils, int heightMils) { @@ -441,8 +443,7 @@ public final class PrintAttributes implements Parcelable { } /** - * Creates a new instance. You should use this constructor as a fallback - * in cases when you do not have a localized string for the label. + * Creates a new instance. * * @param id The unique media size id. * @param label The <strong>internationalized</strong> human readable label. @@ -550,32 +551,28 @@ public final class PrintAttributes implements Parcelable { /** * Returns a new media size in a portrait orientation - * which is the height is the lesser dimension. + * which is the height is the greater dimension. * * @return New instance in landscape orientation. */ public MediaSize asPortrait() { - if (!TextUtils.isEmpty(mPackageName) && mLabelResId > 0) { - return new MediaSize(mId, mPackageName, mLabelResId, - Math.min(mWidthMils, mHeightMils), - Math.max(mWidthMils, mHeightMils)); - } else { - return new MediaSize(mId, mLabel, - Math.min(mWidthMils, mHeightMils), - Math.max(mWidthMils, mHeightMils)); - } + return new MediaSize(mId, mPackageName, mLabel, + Math.min(mWidthMils, mHeightMils), + Math.max(mWidthMils, mHeightMils), + mLabelResId); } /** * Returns a new media size in a landscape orientation - * which is the height is the greater dimension. + * which is the height is the lesser dimension. * * @return New instance in landscape orientation. */ public MediaSize asLandscape() { return new MediaSize(mId, mLabel, Math.max(mWidthMils, mHeightMils), - Math.min(mWidthMils, mHeightMils)); + Math.min(mWidthMils, mHeightMils), + mLabelResId); } void writeToParcel(Parcel parcel) { @@ -601,7 +598,6 @@ public final class PrintAttributes implements Parcelable { public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + ((mId == null) ? 0 : mId.hashCode()); result = prime * result + mWidthMils; result = prime * result + mHeightMils; return result; @@ -619,9 +615,6 @@ public final class PrintAttributes implements Parcelable { return false; } MediaSize other = (MediaSize) obj; - if (!TextUtils.equals(mId, other.mId)) { - return false; - } if (mWidthMils != other.mWidthMils) { return false; } @@ -677,6 +670,8 @@ public final class PrintAttributes implements Parcelable { * @throws IllegalArgumentException If the label is empty. * @throws IllegalArgumentException If the horizontalDpi is less than or equal to zero. * @throws IllegalArgumentException If the verticalDpi is less than or equal to zero. + * + * @hide */ public Resolution(String id, String packageName, int labelResId, int horizontalDpi, int verticalDpi) { @@ -706,8 +701,7 @@ public final class PrintAttributes implements Parcelable { } /** - * Creates a new instance. You should use this constructor as a fallback - * in cases when you do not have a localized string for the label. + * Creates a new instance. * * @param id The unique resolution id. * @param label The <strong>internationalized</strong> human readable label. @@ -825,7 +819,6 @@ public final class PrintAttributes implements Parcelable { public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + ((mId == null) ? 0 : mId.hashCode()); result = prime * result + mHorizontalDpi; result = prime * result + mVerticalDpi; return result; @@ -843,9 +836,6 @@ public final class PrintAttributes implements Parcelable { return false; } Resolution other = (Resolution) obj; - if (!TextUtils.equals(mId, other.mId)) { - return false; - } if (mHorizontalDpi != other.mHorizontalDpi) { return false; } diff --git a/packages/PrintSpooler/src/com/android/printspooler/PrintSpoolerService.java b/packages/PrintSpooler/src/com/android/printspooler/PrintSpoolerService.java index 00c9a685778c..7266af8adf57 100644 --- a/packages/PrintSpooler/src/com/android/printspooler/PrintSpoolerService.java +++ b/packages/PrintSpooler/src/com/android/printspooler/PrintSpoolerService.java @@ -41,6 +41,7 @@ import android.print.PrintJobInfo; import android.print.PrintManager; import android.print.PrinterId; import android.print.PrinterInfo; +import android.text.TextUtils; import android.util.AtomicFile; import android.util.Log; import android.util.Slog; @@ -814,10 +815,9 @@ public final class PrintSpoolerService extends Service { mediaSize.getWidthMils())); serializer.attribute(null, ATTR_HEIGHT_MILS, String.valueOf( mediaSize.getHeightMils())); - // Store only the platform localized versions of the label - // since the resource ids for a print service are not stable - // across application versions. - if ("android".equals(mediaSize.mPackageName) + // We prefer to store only the package name and + // resource id and fallback to the label. + if (!TextUtils.isEmpty(mediaSize.mPackageName) && mediaSize.mLabelResId > 0) { serializer.attribute(null, ATTR_PACKAGE_NAME, mediaSize.mPackageName); @@ -838,10 +838,9 @@ public final class PrintSpoolerService extends Service { resolution.getHorizontalDpi())); serializer.attribute(null, ATTR_VERTICAL_DPI, String.valueOf( resolution.getVerticalDpi())); - // Store only the platform localized versions of the label - // since the resource ids for a print service are not stable - // across application versions. - if ("android".equals(resolution.mPackageName) + // We prefer to store only the package name and + // resource id and fallback to the label. + if (!TextUtils.isEmpty(mediaSize.mPackageName) && resolution.mLabelResId > 0) { serializer.attribute(null, ATTR_PACKAGE_NAME, resolution.mPackageName); |