merge in klp-release history after reset to klp-dev
diff --git a/v4/java/android/support/v4/print/PrintHelper.java b/v4/java/android/support/v4/print/PrintHelper.java
index 03c4428..0d3c5ba 100644
--- a/v4/java/android/support/v4/print/PrintHelper.java
+++ b/v4/java/android/support/v4/print/PrintHelper.java
@@ -31,10 +31,22 @@
* image will be scaled but leave white space
*/
public static final int SCALE_MODE_FIT = 1;
+
/**
* image will fill the paper and be cropped (default)
*/
public static final int SCALE_MODE_FILL = 2;
+
+ /**
+ * this is a black and white image
+ */
+ public static final int COLOR_MODE_MONOCHROME = 1;
+
+ /**
+ * this is a color image (default)
+ */
+ public static final int COLOR_MODE_COLOR = 2;
+
PrintHelperVersionImpl mImpl;
/**
@@ -59,6 +71,10 @@
public int getScaleMode();
+ public void setColorMode(int colorMode);
+
+ public int getColorMode();
+
public void printBitmap(String jobName, Bitmap bitmap);
public void printBitmap(String jobName, Uri imageFile)
@@ -69,7 +85,8 @@
* Implementation used when we do not support printing
*/
private static final class PrintHelperStubImpl implements PrintHelperVersionImpl {
- int mScaleMode;
+ int mScaleMode = SCALE_MODE_FILL;
+ int mColorMode = COLOR_MODE_COLOR;
@Override
public void setScaleMode(int scaleMode) {
@@ -77,6 +94,16 @@
}
@Override
+ public int getColorMode() {
+ return mColorMode;
+ }
+
+ @Override
+ public void setColorMode(int colorMode) {
+ mColorMode = colorMode;
+ }
+
+ @Override
public int getScaleMode() {
return mScaleMode;
}
@@ -111,6 +138,16 @@
}
@Override
+ public void setColorMode(int colorMode) {
+ printHelper.setColorMode(colorMode);
+ }
+
+ @Override
+ public int getColorMode() {
+ return printHelper.getColorMode();
+ }
+
+ @Override
public void printBitmap(String jobName, Bitmap bitmap) {
printHelper.printBitmap(jobName, bitmap);
}
@@ -159,6 +196,28 @@
}
/**
+ * Sets whether the image will be printed in color (default)
+ * {@link #COLOR_MODE_COLOR} or in back and white
+ * {@link #COLOR_MODE_MONOCHROME}.
+ *
+ * @param colorMode The color mode which is one of
+ * {@link #COLOR_MODE_COLOR} and {@link #COLOR_MODE_MONOCHROME}.
+ */
+ public void setColorMode(int colorMode) {
+ mImpl.setColorMode(colorMode);
+ }
+
+ /**
+ * Gets the color mode with which the image will be printed.
+ *
+ * @return The color mode which is one of {@link #COLOR_MODE_COLOR}
+ * and {@link #COLOR_MODE_MONOCHROME}.
+ */
+ public int getColorMode() {
+ return mImpl.getColorMode();
+ }
+
+ /**
* Prints a bitmap.
*
* @param jobName The print job name.
diff --git a/v4/kitkat/android/support/v4/print/PrintHelperKitkat.java b/v4/kitkat/android/support/v4/print/PrintHelperKitkat.java
index d5c7575..0786763 100644
--- a/v4/kitkat/android/support/v4/print/PrintHelperKitkat.java
+++ b/v4/kitkat/android/support/v4/print/PrintHelperKitkat.java
@@ -56,8 +56,20 @@
*/
public static final int SCALE_MODE_FILL = 2;
+ /**
+ * this is a black and white image
+ */
+ public static final int COLOR_MODE_MONOCHROME = 1;
+
+ /**
+ * this is a color image (default)
+ */
+ public static final int COLOR_MODE_COLOR = 2;
+
int mScaleMode = SCALE_MODE_FILL;
+ int mColorMode = COLOR_MODE_COLOR;
+
PrintHelperKitkat(Context context) {
mContext = context;
}
@@ -86,6 +98,28 @@
}
/**
+ * Sets whether the image will be printed in color (default)
+ * {@link #COLOR_MODE_COLOR} or in back and white
+ * {@link #COLOR_MODE_MONOCHROME}.
+ *
+ * @param colorMode The color mode which is one of
+ * {@link #COLOR_MODE_COLOR} and {@link #COLOR_MODE_MONOCHROME}.
+ */
+ public void setColorMode(int colorMode) {
+ mColorMode = colorMode;
+ }
+
+ /**
+ * Gets the color mode with which the image will be printed.
+ *
+ * @return The color mode which is one of {@link #COLOR_MODE_COLOR}
+ * and {@link #COLOR_MODE_MONOCHROME}.
+ */
+ public int getColorMode() {
+ return mColorMode;
+ }
+
+ /**
* Prints a bitmap.
*
* @param jobName The print job name.
@@ -101,7 +135,10 @@
if (bitmap.getWidth() > bitmap.getHeight()) {
mediaSize = PrintAttributes.MediaSize.UNKNOWN_LANDSCAPE;
}
- PrintAttributes attr = new PrintAttributes.Builder().setMediaSize(mediaSize).build();
+ PrintAttributes attr = new PrintAttributes.Builder()
+ .setMediaSize(mediaSize)
+ .setColorMode(mColorMode)
+ .build();
printManager.print(jobName,
new PrintDocumentAdapter() {