diff --git a/core/java/android/print/PageRange.java b/core/java/android/print/PageRange.java index 8c229c505014f..8bc157a9fcada 100644 --- a/core/java/android/print/PageRange.java +++ b/core/java/android/print/PageRange.java @@ -87,7 +87,7 @@ public final class PageRange implements Parcelable { * @hide */ public boolean contains(int pageIndex) { - return pageIndex >= mStart && pageIndex <= mEnd; + return (pageIndex >= mStart) && (pageIndex <= mEnd); } /** diff --git a/core/java/android/print/PrintManager.java b/core/java/android/print/PrintManager.java index 7ec838e736688..936128655128f 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 = true; + private static final boolean DEBUG = false; private static final int MSG_NOTIFY_PRINT_JOB_STATE_CHANGED = 1; diff --git a/packages/PrintSpooler/res/layout/print_activity.xml b/packages/PrintSpooler/res/layout/print_activity.xml index 01cf9c1efd41d..325d317874e0b 100644 --- a/packages/PrintSpooler/res/layout/print_activity.xml +++ b/packages/PrintSpooler/res/layout/print_activity.xml @@ -28,7 +28,7 @@ android:layout_width="fill_parent" android:layout_height="wrap_content" android:padding="16dip" - android:elevation="8dip" + android:elevation="@dimen/preview_controls_elevation" android:background="?android:attr/colorForegroundInverse"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/packages/PrintSpooler/res/layout/print_activity_controls.xml b/packages/PrintSpooler/res/layout/print_activity_controls.xml new file mode 100644 index 0000000000000..2da07145aa79b --- /dev/null +++ b/packages/PrintSpooler/res/layout/print_activity_controls.xml @@ -0,0 +1,281 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packages/PrintSpooler/res/values/constants.xml b/packages/PrintSpooler/res/values/constants.xml index a19cd65b3e400..2b801c9c8198c 100644 --- a/packages/PrintSpooler/res/values/constants.xml +++ b/packages/PrintSpooler/res/values/constants.xml @@ -38,4 +38,6 @@ 24dip + 8dip + diff --git a/packages/PrintSpooler/src/com/android/printspooler/model/PageContentRepository.java b/packages/PrintSpooler/src/com/android/printspooler/model/PageContentRepository.java index 63b4d96f8e129..4da2ba5e36719 100644 --- a/packages/PrintSpooler/src/com/android/printspooler/model/PageContentRepository.java +++ b/packages/PrintSpooler/src/com/android/printspooler/model/PageContentRepository.java @@ -44,7 +44,7 @@ import java.util.Map; public final class PageContentRepository { private static final String LOG_TAG = "PageContentRepository"; - private static final boolean DEBUG = true; + private static final boolean DEBUG = false; private static final int INVALID_PAGE_INDEX = -1; diff --git a/packages/PrintSpooler/src/com/android/printspooler/ui/PageAdapter.java b/packages/PrintSpooler/src/com/android/printspooler/ui/PageAdapter.java index 09ce4e15d7c24..1b83c431f8fb5 100644 --- a/packages/PrintSpooler/src/com/android/printspooler/ui/PageAdapter.java +++ b/packages/PrintSpooler/src/com/android/printspooler/ui/PageAdapter.java @@ -68,54 +68,42 @@ public final class PageAdapter extends Adapter { private final CloseGuard mCloseGuard = CloseGuard.get(); private final SparseArray mBoundPagesInAdapter = new SparseArray<>(); - private final SparseArray mConfirmedPagesInDocument = new SparseArray<>(); private final PageClickListener mPageClickListener = new PageClickListener(); + private final Context mContext; private final LayoutInflater mLayoutInflater; - private final Context mContext; - private final ContentUpdateRequestCallback mContentUpdateRequestCallback; - private final PageContentRepository mPageContentRepository; - private final PreviewArea mPreviewArea; - private int mDocumentPageCount = PrintDocumentInfo.PAGE_COUNT_UNKNOWN; - - private int mSelectedPageCount; - // Which document pages to be written. private PageRange[] mRequestedPages; - // Pages written in the current file. private PageRange[] mWrittenPages; - // Pages the user selected in the UI. private PageRange[] mSelectedPages; - private float mSelectedPageElevation; + private int mDocumentPageCount = PrintDocumentInfo.PAGE_COUNT_UNKNOWN; + private int mSelectedPageCount; + private float mSelectedPageElevation; private float mUnselectedPageElevation; private int mPreviewPageMargin; - private int mPreviewListPadding; - private int mFooterHeight; private int mColumnCount; private MediaSize mMediaSize; - private Margins mMinMargins; private int mState; private int mPageContentWidth; - private int mPageContentHeight; public interface ContentUpdateRequestCallback { diff --git a/packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java b/packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java index 735922145775a..5ec2111e72f46 100644 --- a/packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java +++ b/packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java @@ -268,7 +268,6 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat mPrintPreviewController = new PrintPreviewController(PrintActivity.this, fileProvider); - mPrintedDocument = new RemotePrintDocument(PrintActivity.this, IPrintDocumentAdapter.Stub.asInterface(documentAdapter), fileProvider, new RemotePrintDocument.DocumentObserver() { @@ -277,23 +276,17 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat finish(); } }, PrintActivity.this); - mProgressMessageController = new ProgressMessageController( PrintActivity.this); - mMediaSizeComparator = new MediaSizeComparator(PrintActivity.this); - mDestinationSpinnerAdapter = new DestinationAdapter(); bindUi(); - updateOptionsUi(); // Now show the updated UI to avoid flicker. mOptionsContent.setVisibility(View.VISIBLE); - mSelectedPages = computeSelectedPages(); - mPrintedDocument.start(); ensurePreviewUiShown(); @@ -345,7 +338,8 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat public boolean onKeyUp(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && event.isTracking() && !event.isCanceled()) { - if (mPrintPreviewController != null&&mPrintPreviewController.isOptionsOpened() && !hasErrors()) { + if (mPrintPreviewController != null&&mPrintPreviewController.isOptionsOpened() + && !hasErrors()) { mPrintPreviewController.closeOptions(); } else { cancelPrint(); @@ -364,8 +358,7 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat @Override public void onActionPerformed() { - if (mState == STATE_UPDATE_FAILED - && canUpdateDocument()) { + if (mState == STATE_UPDATE_FAILED && canUpdateDocument()) { updateDocument(true, true); ensurePreviewUiShown(); setState(STATE_CONFIGURING); @@ -648,7 +641,8 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat final int mediaSizeCount = mMediaSizeSpinnerAdapter.getCount(); MediaSize newMediaSizePortrait = newAttributes.getMediaSize().asPortrait(); for (int i = 0; i < mediaSizeCount; i++) { - MediaSize supportedSizePortrait = mMediaSizeSpinnerAdapter.getItem(i).value.asPortrait(); + MediaSize supportedSizePortrait = mMediaSizeSpinnerAdapter.getItem(i) + .value.asPortrait(); if (supportedSizePortrait.equals(newMediaSizePortrait)) { currAttributes.setMediaSize(newMediaSize); mMediaSizeSpinner.setSelection(i); diff --git a/packages/PrintSpooler/src/com/android/printspooler/ui/PrintPreviewController.java b/packages/PrintSpooler/src/com/android/printspooler/ui/PrintPreviewController.java index 910818bfc23b0..ce47b3e1bd978 100644 --- a/packages/PrintSpooler/src/com/android/printspooler/ui/PrintPreviewController.java +++ b/packages/PrintSpooler/src/com/android/printspooler/ui/PrintPreviewController.java @@ -45,22 +45,17 @@ import java.util.List; class PrintPreviewController implements MutexFileProvider.OnReleaseRequestCallback, PageAdapter.PreviewArea, EmbeddedContentContainer.OnSizeChangeListener { - private PrintActivity mActivity; + private final PrintActivity mActivity; private final MutexFileProvider mFileProvider; - private final MyHandler mHandler; private final PageAdapter mPageAdapter; - private final StaggeredGridLayoutManager mLayoutManger; - private PrintOptionsLayout mPrintOptionsLayout; - + private final PrintOptionsLayout mPrintOptionsLayout; private final RecyclerView mRecyclerView; - private final PrintContentView mContentView; - private final EmbeddedContentContainer mEmbeddedContentContainer; private final PreloadController mPreloadController; @@ -79,6 +74,7 @@ class PrintPreviewController implements MutexFileProvider.OnReleaseRequestCallba R.integer.preview_page_per_row_count); mLayoutManger = new StaggeredGridLayoutManager(columnCount, OrientationHelper.VERTICAL); + mRecyclerView = (RecyclerView) activity.findViewById(R.id.preview_content); mRecyclerView.setLayoutManager(mLayoutManger); mRecyclerView.setAdapter(mPageAdapter); diff --git a/packages/PrintSpooler/src/com/android/printspooler/widget/PageContentView.java b/packages/PrintSpooler/src/com/android/printspooler/widget/PageContentView.java index bb63fb8e5b2c8..4d2cb6ce8e295 100644 --- a/packages/PrintSpooler/src/com/android/printspooler/widget/PageContentView.java +++ b/packages/PrintSpooler/src/com/android/printspooler/widget/PageContentView.java @@ -43,7 +43,6 @@ public class PageContentView extends View private PageContentProvider mProvider; private MediaSize mMediaSize; - private Margins mMinMargins; private boolean mContentRequested; diff --git a/packages/PrintSpooler/src/com/android/printspooler/widget/PrintContentView.java b/packages/PrintSpooler/src/com/android/printspooler/widget/PrintContentView.java index b4a78e6d4a9bd..afdbb2a4ce036 100644 --- a/packages/PrintSpooler/src/com/android/printspooler/widget/PrintContentView.java +++ b/packages/PrintSpooler/src/com/android/printspooler/widget/PrintContentView.java @@ -37,6 +37,11 @@ import com.android.printspooler.R; public final class PrintContentView extends ViewGroup implements View.OnClickListener { private static final int FIRST_POINTER_ID = 0; + private static final int ALPHA_MASK = 0xff000000; + private static final int ALPHA_SHIFT = 24; + + private static final int COLOR_MASK = 0xffffff; + private final ViewDragHelper mDragger; private final int mScrimColor; @@ -187,9 +192,9 @@ public final class PrintContentView extends ViewGroup implements View.OnClickLis } private int computeScrimColor() { - final int baseAlpha = (mScrimColor & 0xff000000) >>> 24; + final int baseAlpha = (mScrimColor & ALPHA_MASK) >>> ALPHA_SHIFT; final int adjustedAlpha = (int) (baseAlpha * (1 - mDragProgress)); - return adjustedAlpha << 24 | (mScrimColor & 0xffffff); + return adjustedAlpha << ALPHA_SHIFT | (mScrimColor & COLOR_MASK); } private int getOpenedOptionsY() {