diff options
| author | Svet Ganov <svetoslavganov@google.com> | 2014-06-14 22:29:00 -0700 |
|---|---|---|
| committer | Svetoslav Ganov <svetoslavganov@google.com> | 2014-07-09 18:43:38 +0000 |
| commit | 525a66b2bb5abf844aff2109bdc9ed819566bece (patch) | |
| tree | f1823f5ce8a6d26f538094bc6f99f23724e64d2f /core | |
| parent | d8da5c8ff5535fffce0c11d017d64efbda05def6 (diff) | |
| download | frameworks_base-525a66b2bb5abf844aff2109bdc9ed819566bece.zip frameworks_base-525a66b2bb5abf844aff2109bdc9ed819566bece.tar.gz frameworks_base-525a66b2bb5abf844aff2109bdc9ed819566bece.tar.bz2 | |
Adding print preview.
This change adds the pring preview part of the new print UX. The
UI has two parts, the top section is the print options and the
bottom section print preview with a list of pages. The user can
interact only with one of them. When print options are expanded
they cover the preview content and a scrim is laid out on top of
the preview. Tapping the scrim collapses the print options. When
the user types in page ranges and closes the options to look at
the preview, the latter is updated to show only these pages. In
the list of pages the user can further prune pages by deselecting
them.
Change-Id: I0b23d2c598afe2a34400ccfa43e4e935af83c72f
Diffstat (limited to 'core')
| -rw-r--r-- | core/java/android/print/PageRange.java | 24 | ||||
| -rw-r--r-- | core/java/android/print/PrintAttributes.java | 34 | ||||
| -rw-r--r-- | core/java/android/print/PrintManager.java | 2 | ||||
| -rw-r--r-- | core/jni/android/graphics/pdf/PdfRenderer.cpp | 11 |
4 files changed, 51 insertions, 20 deletions
diff --git a/core/java/android/print/PageRange.java b/core/java/android/print/PageRange.java index d6320f0..8c229c5 100644 --- a/core/java/android/print/PageRange.java +++ b/core/java/android/print/PageRange.java @@ -78,6 +78,30 @@ public final class PageRange implements Parcelable { return mEnd; } + /** + * Gets whether a page range contains a a given page. + * + * @param pageIndex The page index. + * @return True if the page is within this range. + * + * @hide + */ + public boolean contains(int pageIndex) { + return pageIndex >= mStart && pageIndex <= mEnd; + } + + /** + * Get the size of this range which is the number of + * pages it contains. + * + * @return The size of the range. + * + * @hide + */ + public int getSize() { + return mEnd - mStart + 1; + } + @Override public int describeContents() { return 0; diff --git a/core/java/android/print/PrintAttributes.java b/core/java/android/print/PrintAttributes.java index 2810d55..30f0c6a 100644 --- a/core/java/android/print/PrintAttributes.java +++ b/core/java/android/print/PrintAttributes.java @@ -105,6 +105,13 @@ public final class PrintAttributes implements Parcelable { /** * Gets the minimal margins. If the content does not fit * these margins it will be clipped. + * <p> + * <strong>These margins are physically imposed by the printer and they + * are <em>not</em> rotated, i.e. they are the same for both portrait and + * landscape. For example, a printer may not be able to print in a stripe + * on both left and right sides of the page. + * </strong> + * </p> * * @return The margins or <code>null</code> if not set. */ @@ -115,6 +122,13 @@ public final class PrintAttributes implements Parcelable { /** * Sets the minimal margins. If the content does not fit * these margins it will be clipped. + * <p> + * <strong>These margins are physically imposed by the printer and they + * are <em>not</em> rotated, i.e. they are the same for both portrait and + * landscape. For example, a printer may not be able to print in a stripe + * on both left and right sides of the page. + * </strong> + * </p> * * @param The margins. * @@ -193,14 +207,8 @@ public final class PrintAttributes implements Parcelable { oldResolution.getHorizontalDpi()); attributes.setResolution(newResolution); - // Rotate the physical margins. - Margins oldMinMargins = getMinMargins(); - Margins newMinMargins = new Margins( - oldMinMargins.getBottomMils(), - oldMinMargins.getLeftMils(), - oldMinMargins.getTopMils(), - oldMinMargins.getRightMils()); - attributes.setMinMargins(newMinMargins); + // Do not rotate the physical margins. + attributes.setMinMargins(getMinMargins()); attributes.setColorMode(getColorMode()); @@ -236,14 +244,8 @@ public final class PrintAttributes implements Parcelable { oldResolution.getHorizontalDpi()); attributes.setResolution(newResolution); - // Rotate the physical margins. - Margins oldMinMargins = getMinMargins(); - Margins newMargins = new Margins( - oldMinMargins.getTopMils(), - oldMinMargins.getRightMils(), - oldMinMargins.getBottomMils(), - oldMinMargins.getLeftMils()); - attributes.setMinMargins(newMargins); + // Do not rotate the physical margins. + attributes.setMinMargins(getMinMargins()); attributes.setColorMode(getColorMode()); diff --git a/core/java/android/print/PrintManager.java b/core/java/android/print/PrintManager.java index 9361286..7ec838e 100644 --- a/core/java/android/print/PrintManager.java +++ b/core/java/android/print/PrintManager.java @@ -105,7 +105,7 @@ public final class PrintManager { private static final String LOG_TAG = "PrintManager"; - private static final boolean DEBUG = false; + private static final boolean DEBUG = true; private static final int MSG_NOTIFY_PRINT_JOB_STATE_CHANGED = 1; diff --git a/core/jni/android/graphics/pdf/PdfRenderer.cpp b/core/jni/android/graphics/pdf/PdfRenderer.cpp index 15de24a..303ddea 100644 --- a/core/jni/android/graphics/pdf/PdfRenderer.cpp +++ b/core/jni/android/graphics/pdf/PdfRenderer.cpp @@ -204,9 +204,13 @@ static void renderPageBitmap(FPDF_BITMAP bitmap, FPDF_PAGE page, int destLeft, i // PDF's coordinate system origin is left-bottom while // in graphics it is the top-left, so remap the origin. matrix.Set(1, 0, 0, -1, 0, pPage->GetPageHeight()); - matrix.Scale(transform->getScaleX(), transform->getScaleY()); - matrix.Rotate(transform->getSkewX(), transform->getSkewY()); - matrix.Translate(transform->getTranslateX(), transform->getTranslateY()); + + SkScalar transformValues[6]; + transform->asAffine(transformValues); + + matrix.Concat(transformValues[SkMatrix::kAScaleX], transformValues[SkMatrix::kASkewY], + transformValues[SkMatrix::kASkewX], transformValues[SkMatrix::kAScaleY], + transformValues[SkMatrix::kATransX], transformValues[SkMatrix::kATransY]); } pageContext->AppendObjectList(pPage, &matrix); @@ -251,6 +255,7 @@ static void nativeRenderPage(JNIEnv* env, jclass thiz, jlong documentPtr, jlong renderPageBitmap(bitmap, page, destLeft, destTop, destRight, destBottom, skMatrix, renderFlags); + skBitmap->notifyPixelsChanged(); skBitmap->unlockPixels(); } |
