diff options
| author | Svetoslav <svetoslavganov@google.com> | 2013-10-16 16:37:48 -0700 |
|---|---|---|
| committer | Android Git Automerger <android-git-automerger@android.com> | 2013-10-16 16:37:48 -0700 |
| commit | 13bc41a52d19dc32a5a0a9b23d27a26978439010 (patch) | |
| tree | 34ed9391dccc91e1e26f60d19e2ad4ecbb271447 /core/java | |
| parent | 7ca960b7c7d9c942d12636cc18191f704c9cd3a6 (diff) | |
| parent | 265a099c105ec600e52011862c2e49b748a860d0 (diff) | |
am 265a099c: Merge "Add APIs for an advanced print options activity." into klp-dev
* commit '265a099c105ec600e52011862c2e49b748a860d0':
Add APIs for an advanced print options activity.
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/print/PrintJobInfo.java | 77 | ||||
| -rw-r--r-- | core/java/android/printservice/PrintJob.java | 36 | ||||
| -rw-r--r-- | core/java/android/printservice/PrintService.java | 23 |
3 files changed, 134 insertions, 2 deletions
diff --git a/core/java/android/print/PrintJobInfo.java b/core/java/android/print/PrintJobInfo.java index 9f935c8311b1..c6f0a6848f91 100644 --- a/core/java/android/print/PrintJobInfo.java +++ b/core/java/android/print/PrintJobInfo.java @@ -439,7 +439,7 @@ public final class PrintJobInfo implements Parcelable { /** * Sets the included pages. * - * @return The included pages. + * @param pageRanges The included pages. * * @hide */ @@ -601,6 +601,81 @@ public final class PrintJobInfo implements Parcelable { } } + /** + * Builder for creating a {@link PrintJobInfo}. + */ + public static final class Builder { + private final PrintJobInfo mPrototype; + + /** + * Constructor. + * + * @param prototype Prototype to use as a starting point. + * Can be null. + */ + public Builder(PrintJobInfo prototype) { + mPrototype = (prototype != null) + ? new PrintJobInfo(prototype) + : new PrintJobInfo(); + } + + /** + * Sets the number of copies. + * + * @param copies The number of copies. + */ + public void setCopies(int copies) { + mPrototype.mCopies = copies; + } + + /** + * Sets the print job attributes. + * + * @param attributes The attributes. + */ + public void setAttributes(PrintAttributes attributes) { + mPrototype.mAttributes = attributes; + } + + /** + * Sets the included pages. + * + * @param pages The included pages. + */ + public void setPages(PageRange[] pages) { + mPrototype.mPageRanges = pages; + } + + /** + * Puts an advanced (printer specific) option. + * + * @param key The option key. + * @param value The option value. + */ + public void putAdvancedOption(String key, String value) { + + } + + /** + * Puts an advanced (printer specific) option. + * + * @param key The option key. + * @param value The option value. + */ + public void putAdvancedOption(String key, int value) { + + } + + /** + * Creates a new {@link PrintJobInfo} instance. + * + * @return The new instance. + */ + public PrintJobInfo build() { + return mPrototype; + } + } + public static final Parcelable.Creator<PrintJobInfo> CREATOR = new Creator<PrintJobInfo>() { @Override diff --git a/core/java/android/printservice/PrintJob.java b/core/java/android/printservice/PrintJob.java index d1dbedf9ef63..fdeb3730b90e 100644 --- a/core/java/android/printservice/PrintJob.java +++ b/core/java/android/printservice/PrintJob.java @@ -304,7 +304,7 @@ public final class PrintJob { /** * Gets the print job tag. * - * @return tag The tag or null. + * @return The tag or null. * * @see #setTag(String) */ @@ -313,6 +313,40 @@ public final class PrintJob { return getInfo().getTag(); } + /** + * Gets the value of an advanced (printer specific) print option. + * + * @param key The option key. + * @return The option value. + */ + public String getAdvancedStringOption(String key) { + PrintService.throwIfNotCalledOnMainThread(); + return null; + } + + /** + * Gets whether this job has a given advanced (printer specific) print + * option. + * + * @param key The option key. + * @return Whether the option is present. + */ + public boolean hasAdvancedOption(String key) { + PrintService.throwIfNotCalledOnMainThread(); + return false; + } + + /** + * Gets the value of an advanced (printer specific) print option. + * + * @param key The option key. + * @return The option value. + */ + public int getAdvancedIntOption(String key) { + PrintService.throwIfNotCalledOnMainThread(); + return 0; + } + @Override public boolean equals(Object obj) { if (this == obj) { diff --git a/core/java/android/printservice/PrintService.java b/core/java/android/printservice/PrintService.java index e73a53bee819..0fc5f7f035a6 100644 --- a/core/java/android/printservice/PrintService.java +++ b/core/java/android/printservice/PrintService.java @@ -16,6 +16,7 @@ package android.printservice; +import android.R; import android.app.Service; import android.content.ComponentName; import android.content.Context; @@ -189,6 +190,28 @@ public abstract class PrintService extends Service { */ public static final String SERVICE_META_DATA = "android.printservice"; + /** + * If you declared an optional activity with advanced print options via the + * {@link R.attr#advancedPrintOptionsActivity advancedPrintOptionsActivity} + * attribute, this extra is used to pass in the currently constructed {@link + * PrintJobInfo} to your activity allowing you to modify it. After you are + * done, you must return the modified {@link PrintJobInfo} via the same extra. + * <p> + * You cannot modify the passed in {@link PrintJobInfo} directly, rather you + * should build another one using the {@link PrintJobInfo.Builder} class. You + * can specify any standard properties and add advanced, printer specific, + * ones via {@link PrintJobInfo.Builder#putAdvancedOption(String, String) + * PrintJobInfo.Builder#putAdvancedOption(String, String)} and {@link + * PrintJobInfo.Builder#putAdvancedOption(String, int) + * PrintJobInfo.Builder#putAdvancedOption(String, int)}. The advanced options + * are not interpreted by the system, they will not be visible to applications, + * and can only be accessed by your print service via {@link + * PrintJob#getAdvancedStringOption(String) PrintJob.getAdvancedStringOption(String)} + * and {@link PrintJob#getAdvancedIntOption(String) PrintJob.getAdvancedIntOption(String)}. + * </p> + */ + public static final String EXTRA_PRINT_JOB_INFO = "android.intent.extra.print.PRINT_JOB_INFO"; + private Handler mHandler; private IPrintServiceClient mClient; |
