am b72ff5aa: Merge "Remove unneeded print APIs and update the min margins APIs." into klp-dev
* commit 'b72ff5aa4b8be587bcea82761aa08cd8c14b8b48': Remove unneeded print APIs and update the min margins APIs.
This commit is contained in:
@@ -19037,8 +19037,8 @@ package android.print {
|
||||
method public void clear();
|
||||
method public int describeContents();
|
||||
method public int getColorMode();
|
||||
method public android.print.PrintAttributes.Margins getMargins();
|
||||
method public android.print.PrintAttributes.MediaSize getMediaSize();
|
||||
method public android.print.PrintAttributes.Margins getMinMargins();
|
||||
method public android.print.PrintAttributes.Resolution getResolution();
|
||||
method public void writeToParcel(android.os.Parcel, int);
|
||||
field public static final int COLOR_MODE_COLOR = 2; // 0x2
|
||||
@@ -19048,10 +19048,10 @@ package android.print {
|
||||
|
||||
public static final class PrintAttributes.Builder {
|
||||
ctor public PrintAttributes.Builder();
|
||||
method public android.print.PrintAttributes create();
|
||||
method public android.print.PrintAttributes build();
|
||||
method public android.print.PrintAttributes.Builder setColorMode(int);
|
||||
method public android.print.PrintAttributes.Builder setMargins(android.print.PrintAttributes.Margins);
|
||||
method public android.print.PrintAttributes.Builder setMediaSize(android.print.PrintAttributes.MediaSize);
|
||||
method public android.print.PrintAttributes.Builder setMinMargins(android.print.PrintAttributes.Margins);
|
||||
method public android.print.PrintAttributes.Builder setResolution(android.print.PrintAttributes.Resolution);
|
||||
}
|
||||
|
||||
@@ -19118,7 +19118,7 @@ package android.print {
|
||||
ctor public PrintAttributes.Resolution(java.lang.String, java.lang.String, int, int);
|
||||
method public int getHorizontalDpi();
|
||||
method public java.lang.String getId();
|
||||
method public java.lang.String getLabel(android.content.pm.PackageManager);
|
||||
method public java.lang.String getLabel();
|
||||
method public int getVerticalDpi();
|
||||
}
|
||||
|
||||
@@ -19159,7 +19159,7 @@ package android.print {
|
||||
|
||||
public static final class PrintDocumentInfo.Builder {
|
||||
ctor public PrintDocumentInfo.Builder(java.lang.String);
|
||||
method public android.print.PrintDocumentInfo create();
|
||||
method public android.print.PrintDocumentInfo build();
|
||||
method public android.print.PrintDocumentInfo.Builder setContentType(int);
|
||||
method public android.print.PrintDocumentInfo.Builder setPageCount(int);
|
||||
}
|
||||
@@ -19206,7 +19206,7 @@ package android.print {
|
||||
public final class PrinterCapabilitiesInfo implements android.os.Parcelable {
|
||||
method public int describeContents();
|
||||
method public int getColorModes();
|
||||
method public void getDefaults(android.print.PrintAttributes);
|
||||
method public android.print.PrintAttributes getDefaults();
|
||||
method public java.util.List<android.print.PrintAttributes.MediaSize> getMediaSizes();
|
||||
method public android.print.PrintAttributes.Margins getMinMargins();
|
||||
method public java.util.List<android.print.PrintAttributes.Resolution> getResolutions();
|
||||
@@ -19218,9 +19218,9 @@ package android.print {
|
||||
ctor public PrinterCapabilitiesInfo.Builder(android.print.PrinterId);
|
||||
method public android.print.PrinterCapabilitiesInfo.Builder addMediaSize(android.print.PrintAttributes.MediaSize, boolean);
|
||||
method public android.print.PrinterCapabilitiesInfo.Builder addResolution(android.print.PrintAttributes.Resolution, boolean);
|
||||
method public android.print.PrinterCapabilitiesInfo create();
|
||||
method public android.print.PrinterCapabilitiesInfo build();
|
||||
method public android.print.PrinterCapabilitiesInfo.Builder setColorModes(int, int);
|
||||
method public android.print.PrinterCapabilitiesInfo.Builder setMinMargins(android.print.PrintAttributes.Margins, android.print.PrintAttributes.Margins);
|
||||
method public android.print.PrinterCapabilitiesInfo.Builder setMinMargins(android.print.PrintAttributes.Margins);
|
||||
}
|
||||
|
||||
public final class PrinterId implements android.os.Parcelable {
|
||||
@@ -19247,7 +19247,7 @@ package android.print {
|
||||
public static final class PrinterInfo.Builder {
|
||||
ctor public PrinterInfo.Builder(android.print.PrinterId, java.lang.String, int);
|
||||
ctor public PrinterInfo.Builder(android.print.PrinterInfo);
|
||||
method public android.print.PrinterInfo create();
|
||||
method public android.print.PrinterInfo build();
|
||||
method public android.print.PrinterInfo.Builder setCapabilities(android.print.PrinterCapabilitiesInfo);
|
||||
method public android.print.PrinterInfo.Builder setDescription(java.lang.String);
|
||||
method public android.print.PrinterInfo.Builder setName(java.lang.String);
|
||||
|
||||
@@ -41,7 +41,7 @@ public final class PrintAttributes implements Parcelable {
|
||||
|
||||
private MediaSize mMediaSize;
|
||||
private Resolution mResolution;
|
||||
private Margins mMargins;
|
||||
private Margins mMinMargins;
|
||||
|
||||
private int mColorMode;
|
||||
|
||||
@@ -52,7 +52,7 @@ public final class PrintAttributes implements Parcelable {
|
||||
private PrintAttributes(Parcel parcel) {
|
||||
mMediaSize = (parcel.readInt() == 1) ? MediaSize.createFromParcel(parcel) : null;
|
||||
mResolution = (parcel.readInt() == 1) ? Resolution.createFromParcel(parcel) : null;
|
||||
mMargins = (parcel.readInt() == 1) ? Margins.createFromParcel(parcel) : null;
|
||||
mMinMargins = (parcel.readInt() == 1) ? Margins.createFromParcel(parcel) : null;
|
||||
mColorMode = parcel.readInt();
|
||||
}
|
||||
|
||||
@@ -97,23 +97,25 @@ public final class PrintAttributes implements Parcelable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the margins.
|
||||
* Gets the minimal margins. If the content does not fit
|
||||
* these margins it will be clipped.
|
||||
*
|
||||
* @return The margins or <code>null</code> if not set.
|
||||
*/
|
||||
public Margins getMargins() {
|
||||
return mMargins;
|
||||
public Margins getMinMargins() {
|
||||
return mMinMargins;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the margins.
|
||||
* Sets the minimal margins. If the content does not fit
|
||||
* these margins it will be clipped.
|
||||
*
|
||||
* @param The margins.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public void setMargins(Margins margins) {
|
||||
mMargins = margins;
|
||||
public void setMinMargins(Margins margins) {
|
||||
mMinMargins = margins;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -157,9 +159,9 @@ public final class PrintAttributes implements Parcelable {
|
||||
} else {
|
||||
parcel.writeInt(0);
|
||||
}
|
||||
if (mMargins != null) {
|
||||
if (mMinMargins != null) {
|
||||
parcel.writeInt(1);
|
||||
mMargins.writeToParcel(parcel);
|
||||
mMinMargins.writeToParcel(parcel);
|
||||
} else {
|
||||
parcel.writeInt(0);
|
||||
}
|
||||
@@ -176,7 +178,7 @@ public final class PrintAttributes implements Parcelable {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + mColorMode;
|
||||
result = prime * result + ((mMargins == null) ? 0 : mMargins.hashCode());
|
||||
result = prime * result + ((mMinMargins == null) ? 0 : mMinMargins.hashCode());
|
||||
result = prime * result + ((mMediaSize == null) ? 0 : mMediaSize.hashCode());
|
||||
result = prime * result + ((mResolution == null) ? 0 : mResolution.hashCode());
|
||||
return result;
|
||||
@@ -197,11 +199,11 @@ public final class PrintAttributes implements Parcelable {
|
||||
if (mColorMode != other.mColorMode) {
|
||||
return false;
|
||||
}
|
||||
if (mMargins == null) {
|
||||
if (other.mMargins != null) {
|
||||
if (mMinMargins == null) {
|
||||
if (other.mMinMargins != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!mMargins.equals(other.mMargins)) {
|
||||
} else if (!mMinMargins.equals(other.mMinMargins)) {
|
||||
return false;
|
||||
}
|
||||
if (mMediaSize == null) {
|
||||
@@ -233,7 +235,7 @@ public final class PrintAttributes implements Parcelable {
|
||||
builder.append(", orientation: ").append("null");
|
||||
}
|
||||
builder.append(", resolution: ").append(mResolution);
|
||||
builder.append(", margins: ").append(mMargins);
|
||||
builder.append(", minMargins: ").append(mMinMargins);
|
||||
builder.append(", colorMode: ").append(colorModeToString(mColorMode));
|
||||
builder.append("}");
|
||||
return builder.toString();
|
||||
@@ -243,7 +245,7 @@ public final class PrintAttributes implements Parcelable {
|
||||
public void clear() {
|
||||
mMediaSize = null;
|
||||
mResolution = null;
|
||||
mMargins = null;
|
||||
mMinMargins = null;
|
||||
mColorMode = 0;
|
||||
}
|
||||
|
||||
@@ -253,7 +255,7 @@ public final class PrintAttributes implements Parcelable {
|
||||
public void copyFrom(PrintAttributes other) {
|
||||
mMediaSize = other.mMediaSize;
|
||||
mResolution = other.mResolution;
|
||||
mMargins = other.mMargins;
|
||||
mMinMargins = other.mMinMargins;
|
||||
mColorMode = other.mColorMode;
|
||||
}
|
||||
|
||||
@@ -649,63 +651,11 @@ public final class PrintAttributes implements Parcelable {
|
||||
* This class specifies a supported resolution in dpi (dots per inch).
|
||||
*/
|
||||
public static final class Resolution {
|
||||
private static final String LOG_TAG = "Resolution";
|
||||
|
||||
private final String mId;
|
||||
/**@hide */
|
||||
public final String mLabel;
|
||||
/**@hide */
|
||||
public final String mPackageName;
|
||||
/**@hide */
|
||||
public final int mLabelResId;
|
||||
private final String mLabel;
|
||||
private final int mHorizontalDpi;
|
||||
private final int mVerticalDpi;
|
||||
|
||||
/**
|
||||
* Creates a new instance. This is the preferred constructor since
|
||||
* it enables the resolution label to be shown in a localized fashion
|
||||
* on a locale change.
|
||||
*
|
||||
* @param id The unique resolution id.
|
||||
* @param packageName The name of the creating package.
|
||||
* @param labelResId The resource id of a human readable label.
|
||||
* @param horizontalDpi The horizontal resolution in dpi.
|
||||
* @param verticalDpi The vertical resolution in dpi.
|
||||
*
|
||||
* @throws IllegalArgumentException If the id is empty.
|
||||
* @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) {
|
||||
if (TextUtils.isEmpty(id)) {
|
||||
throw new IllegalArgumentException("id cannot be empty.");
|
||||
}
|
||||
if (TextUtils.isEmpty(packageName)) {
|
||||
throw new IllegalArgumentException("packageName cannot be empty.");
|
||||
}
|
||||
if (labelResId <= 0) {
|
||||
throw new IllegalArgumentException("labelResId must be greater than zero.");
|
||||
}
|
||||
if (horizontalDpi <= 0) {
|
||||
throw new IllegalArgumentException("horizontalDpi "
|
||||
+ "cannot be less than or equal to zero.");
|
||||
}
|
||||
if (verticalDpi <= 0) {
|
||||
throw new IllegalArgumentException("verticalDpi"
|
||||
+ " cannot be less than or equal to zero.");
|
||||
}
|
||||
mId = id;
|
||||
mPackageName = packageName;
|
||||
mLabelResId = labelResId;
|
||||
mHorizontalDpi = horizontalDpi;
|
||||
mVerticalDpi = verticalDpi;
|
||||
mLabel = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*
|
||||
@@ -738,19 +688,6 @@ public final class PrintAttributes implements Parcelable {
|
||||
mLabel = label;
|
||||
mHorizontalDpi = horizontalDpi;
|
||||
mVerticalDpi = verticalDpi;
|
||||
mPackageName = null;
|
||||
mLabelResId = 0;
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
public Resolution(String id, String label, String packageName,
|
||||
int horizontalDpi, int verticalDpi, int labelResId) {
|
||||
mId = id;
|
||||
mPackageName = packageName;
|
||||
mLabelResId = labelResId;
|
||||
mHorizontalDpi = horizontalDpi;
|
||||
mVerticalDpi = verticalDpi;
|
||||
mLabel = label;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -765,22 +702,9 @@ public final class PrintAttributes implements Parcelable {
|
||||
/**
|
||||
* Gets the resolution human readable label.
|
||||
*
|
||||
* @param packageManager The package manager for loading the label.
|
||||
* @return The human readable label.
|
||||
*/
|
||||
public String getLabel(PackageManager packageManager) {
|
||||
if (!TextUtils.isEmpty(mPackageName) && mLabelResId > 0) {
|
||||
try {
|
||||
return packageManager.getResourcesForApplication(
|
||||
mPackageName).getString(mLabelResId);
|
||||
} catch (NotFoundException nfe) {
|
||||
Log.w(LOG_TAG, "Could not load resouce" + mLabelResId
|
||||
+ " from package " + mPackageName);
|
||||
} catch (NameNotFoundException nnfee) {
|
||||
Log.w(LOG_TAG, "Could not load resouce" + mLabelResId
|
||||
+ " from package " + mPackageName);
|
||||
}
|
||||
}
|
||||
public String getLabel() {
|
||||
return mLabel;
|
||||
}
|
||||
|
||||
@@ -805,18 +729,14 @@ public final class PrintAttributes implements Parcelable {
|
||||
void writeToParcel(Parcel parcel) {
|
||||
parcel.writeString(mId);
|
||||
parcel.writeString(mLabel);
|
||||
parcel.writeString(mPackageName);
|
||||
parcel.writeInt(mHorizontalDpi);
|
||||
parcel.writeInt(mVerticalDpi);
|
||||
parcel.writeInt(mLabelResId);
|
||||
}
|
||||
|
||||
static Resolution createFromParcel(Parcel parcel) {
|
||||
return new Resolution(
|
||||
parcel.readString(),
|
||||
parcel.readString(),
|
||||
parcel.readString(),
|
||||
parcel.readInt(),
|
||||
parcel.readInt(),
|
||||
parcel.readInt());
|
||||
}
|
||||
@@ -857,10 +777,8 @@ public final class PrintAttributes implements Parcelable {
|
||||
builder.append("Resolution{");
|
||||
builder.append("id: ").append(mId);
|
||||
builder.append(", label: ").append(mLabel);
|
||||
builder.append(", packageName: ").append(mPackageName);
|
||||
builder.append(", horizontalDpi: ").append(mHorizontalDpi);
|
||||
builder.append(", verticalDpi: ").append(mVerticalDpi);
|
||||
builder.append(", labelResId: ").append(mLabelResId);
|
||||
builder.append("}");
|
||||
return builder.toString();
|
||||
}
|
||||
@@ -1042,13 +960,14 @@ public final class PrintAttributes implements Parcelable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the margins.
|
||||
* Sets the minimal margins. If the content does not fit
|
||||
* these margins it will be clipped.
|
||||
*
|
||||
* @param margins The margins.
|
||||
* @return This builder.
|
||||
*/
|
||||
public Builder setMargins(Margins margins) {
|
||||
mAttributes.setMargins(margins);
|
||||
public Builder setMinMargins(Margins margins) {
|
||||
mAttributes.setMinMargins(margins);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -1074,7 +993,7 @@ public final class PrintAttributes implements Parcelable {
|
||||
*
|
||||
* @return The new instance.
|
||||
*/
|
||||
public PrintAttributes create() {
|
||||
public PrintAttributes build() {
|
||||
return mAttributes;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -277,7 +277,7 @@ public final class PrintDocumentInfo implements Parcelable {
|
||||
*
|
||||
* @return The new instance.
|
||||
*/
|
||||
public PrintDocumentInfo create() {
|
||||
public PrintDocumentInfo build() {
|
||||
return new PrintDocumentInfo(mPrototype);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,6 @@ public final class PrinterCapabilitiesInfo implements Parcelable {
|
||||
private int mColorModes;
|
||||
|
||||
private final int[] mDefaults = new int[PROPERTY_COUNT];
|
||||
private Margins mDefaultMargins = DEFAULT_MARGINS;
|
||||
|
||||
/**
|
||||
* @hide
|
||||
@@ -71,6 +70,10 @@ public final class PrinterCapabilitiesInfo implements Parcelable {
|
||||
* @hide
|
||||
*/
|
||||
public void copyFrom(PrinterCapabilitiesInfo other) {
|
||||
if (this == other) {
|
||||
return;
|
||||
}
|
||||
|
||||
mMinMargins = other.mMinMargins;
|
||||
|
||||
if (other.mMediaSizes != null) {
|
||||
@@ -101,8 +104,6 @@ public final class PrinterCapabilitiesInfo implements Parcelable {
|
||||
for (int i = 0; i < defaultCount; i++) {
|
||||
mDefaults[i] = other.mDefaults[i];
|
||||
}
|
||||
|
||||
mDefaultMargins = other.mDefaultMargins;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -124,7 +125,8 @@ public final class PrinterCapabilitiesInfo implements Parcelable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the minimal supported margins.
|
||||
* Gets the minimal margins. These are the minimal margins
|
||||
* the printer physically supports.
|
||||
*
|
||||
* @return The minimal margins.
|
||||
*/
|
||||
@@ -147,27 +149,29 @@ public final class PrinterCapabilitiesInfo implements Parcelable {
|
||||
/**
|
||||
* Gets the default print attributes.
|
||||
*
|
||||
* @param outAttributes The attributes to populated.
|
||||
* @return The default attributes.
|
||||
*/
|
||||
public void getDefaults(PrintAttributes outAttributes) {
|
||||
outAttributes.clear();
|
||||
public PrintAttributes getDefaults() {
|
||||
PrintAttributes.Builder builder = new PrintAttributes.Builder();
|
||||
|
||||
outAttributes.setMargins(mDefaultMargins);
|
||||
builder.setMinMargins(mMinMargins);
|
||||
|
||||
final int mediaSizeIndex = mDefaults[PROPERTY_MEDIA_SIZE];
|
||||
if (mediaSizeIndex >= 0) {
|
||||
outAttributes.setMediaSize(mMediaSizes.get(mediaSizeIndex));
|
||||
builder.setMediaSize(mMediaSizes.get(mediaSizeIndex));
|
||||
}
|
||||
|
||||
final int resolutionIndex = mDefaults[PROPERTY_RESOLUTION];
|
||||
if (resolutionIndex >= 0) {
|
||||
outAttributes.setResolution(mResolutions.get(resolutionIndex));
|
||||
builder.setResolution(mResolutions.get(resolutionIndex));
|
||||
}
|
||||
|
||||
final int colorMode = mDefaults[PROPERTY_COLOR_MODE];
|
||||
if (colorMode > 0) {
|
||||
outAttributes.setColorMode(colorMode);
|
||||
builder.setColorMode(colorMode);
|
||||
}
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
private PrinterCapabilitiesInfo(Parcel parcel) {
|
||||
@@ -178,7 +182,6 @@ public final class PrinterCapabilitiesInfo implements Parcelable {
|
||||
mColorModes = parcel.readInt();
|
||||
|
||||
readDefaults(parcel);
|
||||
mDefaultMargins = readMargins(parcel);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -195,7 +198,6 @@ public final class PrinterCapabilitiesInfo implements Parcelable {
|
||||
parcel.writeInt(mColorModes);
|
||||
|
||||
writeDefaults(parcel);
|
||||
writeMargins(mDefaultMargins, parcel);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -207,7 +209,6 @@ public final class PrinterCapabilitiesInfo implements Parcelable {
|
||||
result = prime * result + ((mResolutions == null) ? 0 : mResolutions.hashCode());
|
||||
result = prime * result + mColorModes;
|
||||
result = prime * result + Arrays.hashCode(mDefaults);
|
||||
result = prime * result + ((mDefaultMargins == null) ? 0 : mDefaultMargins.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -250,13 +251,6 @@ public final class PrinterCapabilitiesInfo implements Parcelable {
|
||||
if (!Arrays.equals(mDefaults, other.mDefaults)) {
|
||||
return false;
|
||||
}
|
||||
if (mDefaultMargins == null) {
|
||||
if (other.mDefaultMargins != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!mDefaultMargins.equals(other.mDefaultMargins)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -279,7 +273,7 @@ public final class PrinterCapabilitiesInfo implements Parcelable {
|
||||
while (colorModes != 0) {
|
||||
final int colorMode = 1 << Integer.numberOfTrailingZeros(colorModes);
|
||||
colorModes &= ~colorMode;
|
||||
if (builder.length() > 0) {
|
||||
if (builder.length() > 1) {
|
||||
builder.append(", ");
|
||||
}
|
||||
builder.append(PrintAttributes.colorModeToString(colorMode));
|
||||
@@ -442,27 +436,25 @@ public final class PrinterCapabilitiesInfo implements Parcelable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the minimal margins.
|
||||
* Sets the minimal margins. These are the minimal margins
|
||||
* the printer physically supports.
|
||||
*
|
||||
* <p>
|
||||
* <strong>Required:</strong> No
|
||||
* <strong>Required:</strong> Yes
|
||||
* </p>
|
||||
*
|
||||
* @param margins The margins.
|
||||
* @param defaultMargins The default margins.
|
||||
* @return This builder.
|
||||
*
|
||||
* @throws IllegalArgumentException If margins are <code>null</code>.
|
||||
*
|
||||
* @see PrintAttributes.Margins
|
||||
*/
|
||||
public Builder setMinMargins(Margins margins, Margins defaultMargins) {
|
||||
if (margins.getLeftMils() > defaultMargins.getLeftMils()
|
||||
|| margins.getTopMils() > defaultMargins.getTopMils()
|
||||
|| margins.getRightMils() < defaultMargins.getRightMils()
|
||||
|| margins.getBottomMils() < defaultMargins.getBottomMils()) {
|
||||
throw new IllegalArgumentException("Default margins"
|
||||
+ " cannot be outside of the min margins.");
|
||||
public Builder setMinMargins(Margins margins) {
|
||||
if (margins == null) {
|
||||
throw new IllegalArgumentException("margins cannot be null");
|
||||
}
|
||||
mPrototype.mMinMargins = margins;
|
||||
mPrototype.mDefaultMargins = defaultMargins;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -507,7 +499,7 @@ public final class PrinterCapabilitiesInfo implements Parcelable {
|
||||
*
|
||||
* @throws IllegalStateException If a required attribute was not specified.
|
||||
*/
|
||||
public PrinterCapabilitiesInfo create() {
|
||||
public PrinterCapabilitiesInfo build() {
|
||||
if (mPrototype.mMediaSizes == null || mPrototype.mMediaSizes.isEmpty()) {
|
||||
throw new IllegalStateException("No media size specified.");
|
||||
}
|
||||
@@ -527,10 +519,7 @@ public final class PrinterCapabilitiesInfo implements Parcelable {
|
||||
throw new IllegalStateException("No default color mode specified.");
|
||||
}
|
||||
if (mPrototype.mMinMargins == null) {
|
||||
mPrototype.mMinMargins = new Margins(0, 0, 0, 0);
|
||||
}
|
||||
if (mPrototype.mDefaultMargins == null) {
|
||||
mPrototype.mDefaultMargins = mPrototype.mMinMargins;
|
||||
throw new IllegalArgumentException("margins cannot be null");
|
||||
}
|
||||
return new PrinterCapabilitiesInfo(mPrototype);
|
||||
}
|
||||
|
||||
@@ -56,6 +56,9 @@ public final class PrinterInfo implements Parcelable {
|
||||
* @hide
|
||||
*/
|
||||
public void copyFrom(PrinterInfo other) {
|
||||
if (this == other) {
|
||||
return;
|
||||
}
|
||||
mId = other.mId;
|
||||
mName = other.mName;
|
||||
mStatus = other.mStatus;
|
||||
@@ -293,7 +296,7 @@ public final class PrinterInfo implements Parcelable {
|
||||
*
|
||||
* @return A new {@link PrinterInfo}.
|
||||
*/
|
||||
public PrinterInfo create() {
|
||||
public PrinterInfo build() {
|
||||
return new PrinterInfo(mPrototype);
|
||||
}
|
||||
|
||||
|
||||
@@ -77,14 +77,14 @@ public final class PrintedPdfDocument {
|
||||
mPageSize.set(0, 0, pageWidth, pageHeight);
|
||||
|
||||
// Compute the content size from the attributes.
|
||||
Margins margins = attributes.getMargins();
|
||||
final int marginLeft = (int) (((float) margins.getLeftMils() /MILS_PER_INCH)
|
||||
Margins minMargins = attributes.getMinMargins();
|
||||
final int marginLeft = (int) (((float) minMargins.getLeftMils() /MILS_PER_INCH)
|
||||
* POINTS_IN_INCH);
|
||||
final int marginTop = (int) (((float) margins.getTopMils() / MILS_PER_INCH)
|
||||
final int marginTop = (int) (((float) minMargins.getTopMils() / MILS_PER_INCH)
|
||||
* POINTS_IN_INCH);
|
||||
final int marginRight = (int) (((float) margins.getRightMils() / MILS_PER_INCH)
|
||||
final int marginRight = (int) (((float) minMargins.getRightMils() / MILS_PER_INCH)
|
||||
* POINTS_IN_INCH);
|
||||
final int marginBottom = (int) (((float) margins.getBottomMils() / MILS_PER_INCH)
|
||||
final int marginBottom = (int) (((float) minMargins.getBottomMils() / MILS_PER_INCH)
|
||||
* POINTS_IN_INCH);
|
||||
mContentSize.set(mPageSize.left + marginLeft, mPageSize.top + marginTop,
|
||||
mPageSize.right - marginRight, mPageSize.bottom - marginBottom);
|
||||
|
||||
@@ -100,7 +100,7 @@ public class AccessibilityNodeInfoCache {
|
||||
}
|
||||
} break;
|
||||
}
|
||||
if (Build.IS_DEBUGGABLE && CHECK_INTEGRITY_IF_DEBUGGABLE_BUILD) {
|
||||
if (CHECK_INTEGRITY_IF_DEBUGGABLE_BUILD && Build.IS_DEBUGGABLE) {
|
||||
checkIntegrity();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -455,7 +455,7 @@ public class FusedPrintersProvider extends Loader<List<PrinterInfo>> {
|
||||
|
||||
PrinterInfo.Builder builder = new PrinterInfo.Builder(printerId, name, status);
|
||||
builder.setDescription(description);
|
||||
PrinterInfo printer = builder.create();
|
||||
PrinterInfo printer = builder.build();
|
||||
|
||||
outPrinters.add(printer);
|
||||
|
||||
|
||||
@@ -147,9 +147,8 @@ public class PrintJobConfigActivity extends Activity {
|
||||
|
||||
public static final PageRange[] ALL_PAGES_ARRAY = new PageRange[] {PageRange.ALL_PAGES};
|
||||
|
||||
private final PrintAttributes mOldPrintAttributes = new PrintAttributes.Builder().create();
|
||||
private final PrintAttributes mCurrPrintAttributes = new PrintAttributes.Builder().create();
|
||||
private final PrintAttributes mTempPrintAttributes = new PrintAttributes.Builder().create();
|
||||
private final PrintAttributes mOldPrintAttributes = new PrintAttributes.Builder().build();
|
||||
private final PrintAttributes mCurrPrintAttributes = new PrintAttributes.Builder().build();
|
||||
|
||||
private final DeathRecipient mDeathRecipient = new DeathRecipient() {
|
||||
@Override
|
||||
@@ -851,19 +850,19 @@ public class PrintJobConfigActivity extends Activity {
|
||||
Resolution oldResolution = mCurrPrintAttributes.getResolution();
|
||||
Resolution newResolution = new Resolution(
|
||||
oldResolution.getId(),
|
||||
oldResolution.getLabel(getPackageManager()),
|
||||
oldResolution.getLabel(),
|
||||
oldResolution.getVerticalDpi(),
|
||||
oldResolution.getHorizontalDpi());
|
||||
mCurrPrintAttributes.setResolution(newResolution);
|
||||
|
||||
// Rotate the physical margins.
|
||||
Margins oldMargins = mCurrPrintAttributes.getMargins();
|
||||
Margins newMargins = new Margins(
|
||||
oldMargins.getBottomMils(),
|
||||
oldMargins.getLeftMils(),
|
||||
oldMargins.getTopMils(),
|
||||
oldMargins.getRightMils());
|
||||
mCurrPrintAttributes.setMargins(newMargins);
|
||||
Margins oldMinMargins = mCurrPrintAttributes.getMinMargins();
|
||||
Margins newMinMargins = new Margins(
|
||||
oldMinMargins.getBottomMils(),
|
||||
oldMinMargins.getLeftMils(),
|
||||
oldMinMargins.getTopMils(),
|
||||
oldMinMargins.getRightMils());
|
||||
mCurrPrintAttributes.setMinMargins(newMinMargins);
|
||||
}
|
||||
} else {
|
||||
if (mediaSize.isPortrait()) {
|
||||
@@ -874,26 +873,25 @@ public class PrintJobConfigActivity extends Activity {
|
||||
Resolution oldResolution = mCurrPrintAttributes.getResolution();
|
||||
Resolution newResolution = new Resolution(
|
||||
oldResolution.getId(),
|
||||
oldResolution.getLabel(getPackageManager()),
|
||||
oldResolution.getLabel(),
|
||||
oldResolution.getVerticalDpi(),
|
||||
oldResolution.getHorizontalDpi());
|
||||
mCurrPrintAttributes.setResolution(newResolution);
|
||||
|
||||
// Rotate the physical margins.
|
||||
Margins oldMargins = mCurrPrintAttributes.getMargins();
|
||||
Margins oldMinMargins = mCurrPrintAttributes.getMinMargins();
|
||||
Margins newMargins = new Margins(
|
||||
oldMargins.getTopMils(),
|
||||
oldMargins.getRightMils(),
|
||||
oldMargins.getBottomMils(),
|
||||
oldMargins.getLeftMils());
|
||||
mCurrPrintAttributes.setMargins(newMargins);
|
||||
oldMinMargins.getTopMils(),
|
||||
oldMinMargins.getRightMils(),
|
||||
oldMinMargins.getBottomMils(),
|
||||
oldMinMargins.getLeftMils());
|
||||
mCurrPrintAttributes.setMinMargins(newMargins);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updatePrintAttributes(PrinterCapabilitiesInfo capabilities) {
|
||||
PrintAttributes defaults = mTempPrintAttributes;
|
||||
capabilities.getDefaults(defaults);
|
||||
PrintAttributes defaults = capabilities.getDefaults();
|
||||
|
||||
// Media size.
|
||||
MediaSize currMediaSize = mCurrPrintAttributes.getMediaSize();
|
||||
@@ -925,16 +923,16 @@ public class PrintJobConfigActivity extends Activity {
|
||||
}
|
||||
|
||||
// Margins.
|
||||
Margins margins = mCurrPrintAttributes.getMargins();
|
||||
Margins margins = mCurrPrintAttributes.getMinMargins();
|
||||
if (margins == null) {
|
||||
mCurrPrintAttributes.setMargins(defaults.getMargins());
|
||||
mCurrPrintAttributes.setMinMargins(defaults.getMinMargins());
|
||||
} else {
|
||||
Margins minMargins = capabilities.getMinMargins();
|
||||
if (margins.getLeftMils() < minMargins.getLeftMils()
|
||||
|| margins.getTopMils() < minMargins.getTopMils()
|
||||
|| margins.getRightMils() > minMargins.getRightMils()
|
||||
|| margins.getBottomMils() > minMargins.getBottomMils()) {
|
||||
mCurrPrintAttributes.setMargins(defaults.getMargins());
|
||||
mCurrPrintAttributes.setMinMargins(defaults.getMinMargins());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1633,8 +1631,7 @@ public class PrintJobConfigActivity extends Activity {
|
||||
|
||||
PrinterInfo printer = (PrinterInfo) mDestinationSpinner.getSelectedItem();
|
||||
PrinterCapabilitiesInfo capabilities = printer.getCapabilities();
|
||||
PrintAttributes defaultAttributes = mTempPrintAttributes;
|
||||
printer.getCapabilities().getDefaults(defaultAttributes);
|
||||
PrintAttributes defaultAttributes = printer.getCapabilities().getDefaults();
|
||||
|
||||
// Media size.
|
||||
List<MediaSize> mediaSizes = capabilities.getMediaSizes();
|
||||
@@ -2069,12 +2066,12 @@ public class PrintJobConfigActivity extends Activity {
|
||||
.setColorModes(PrintAttributes.COLOR_MODE_COLOR
|
||||
| PrintAttributes.COLOR_MODE_MONOCHROME,
|
||||
PrintAttributes.COLOR_MODE_COLOR)
|
||||
.create();
|
||||
.build();
|
||||
|
||||
return new PrinterInfo.Builder(printerId, getString(R.string.save_as_pdf),
|
||||
PrinterInfo.STATUS_IDLE)
|
||||
.setCapabilities(capabilities)
|
||||
.create();
|
||||
.build();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -839,11 +839,11 @@ public final class PrintSpoolerService extends Service {
|
||||
serializer.attribute(null, ATTR_VERTICAL_DPI, String.valueOf(
|
||||
resolution.getVerticalDpi()));
|
||||
serializer.attribute(null, ATTR_LABEL,
|
||||
resolution.getLabel(getPackageManager()));
|
||||
resolution.getLabel());
|
||||
serializer.endTag(null, TAG_RESOLUTION);
|
||||
}
|
||||
|
||||
Margins margins = attributes.getMargins();
|
||||
Margins margins = attributes.getMinMargins();
|
||||
if (margins != null) {
|
||||
serializer.startTag(null, TAG_MARGINS);
|
||||
serializer.attribute(null, ATTR_LEFT_MILS, String.valueOf(
|
||||
@@ -1056,14 +1056,14 @@ public final class PrintSpoolerService extends Service {
|
||||
final int bottomMils = Integer.parseInt(parser.getAttributeValue(null,
|
||||
ATTR_BOTTOM_MILS));
|
||||
Margins margins = new Margins(leftMils, topMils, rightMils, bottomMils);
|
||||
builder.setMargins(margins);
|
||||
builder.setMinMargins(margins);
|
||||
parser.next();
|
||||
skipEmptyTextTags(parser);
|
||||
expect(parser, XmlPullParser.END_TAG, TAG_MARGINS);
|
||||
parser.next();
|
||||
}
|
||||
|
||||
printJob.setAttributes(builder.create());
|
||||
printJob.setAttributes(builder.build());
|
||||
|
||||
skipEmptyTextTags(parser);
|
||||
expect(parser, XmlPullParser.END_TAG, TAG_ATTRIBUTES);
|
||||
@@ -1079,7 +1079,7 @@ public final class PrintSpoolerService extends Service {
|
||||
ATTR_CONTENT_TYPE));
|
||||
PrintDocumentInfo info = new PrintDocumentInfo.Builder(name)
|
||||
.setPageCount(pageCount)
|
||||
.setContentType(contentType).create();
|
||||
.setContentType(contentType).build();
|
||||
printJob.setDocumentInfo(info);
|
||||
parser.next();
|
||||
skipEmptyTextTags(parser);
|
||||
|
||||
@@ -433,7 +433,6 @@ final class UserState implements PrintSpoolerCallbacks, PrintServiceCallbacks {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private boolean readEnabledPrintServicesLocked() {
|
||||
Set<ComponentName> tempEnabledServiceNameSet = new HashSet<ComponentName>();
|
||||
readPrintServicesFromSettingLocked(Settings.Secure.ENABLED_PRINT_SERVICES,
|
||||
|
||||
Reference in New Issue
Block a user