Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a76233ae authored by Svetoslav's avatar Svetoslav
Browse files

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
parent 773f54de
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -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();
+14 −24
Original line number Diff line number Diff line
@@ -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,
            return new MediaSize(mId, mPackageName, mLabel,
                    Math.min(mWidthMils, mHeightMils),
                        Math.max(mWidthMils, mHeightMils));
            } else {
                return new MediaSize(mId, mLabel,
                        Math.min(mWidthMils, mHeightMils),
                        Math.max(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;
            }
+7 −8
Original line number Diff line number Diff line
@@ -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);