Addressing comments for the print preview feature.
Change-Id: Ib72140a912e22f859258d970e0d1c4ef06e807d5
This commit is contained in:
committed by
Svetoslav Ganov
parent
398b6c26c3
commit
15cbc8a032
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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">
|
||||
|
||||
<Spinner
|
||||
@@ -50,7 +50,7 @@
|
||||
android:paddingStart="16dip"
|
||||
android:paddingEnd="16dip"
|
||||
android:orientation="horizontal"
|
||||
android:elevation="8dip"
|
||||
android:elevation="@dimen/preview_controls_elevation"
|
||||
android:background="?android:attr/colorForegroundInverse">
|
||||
|
||||
<TextView
|
||||
@@ -103,274 +103,13 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="16dip"
|
||||
android:elevation="8dip"
|
||||
android:elevation="@dimen/preview_controls_elevation"
|
||||
android:background="@drawable/print_button">
|
||||
</ImageButton>
|
||||
|
||||
<!-- Controls -->
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/dynamic_content"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:elevation="8dip"
|
||||
android:background="?android:attr/colorForegroundInverse">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/draggable_content"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.android.printspooler.widget.PrintOptionsLayout
|
||||
android:id="@+id/options_container"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
printspooler:columnCount="@integer/print_option_column_count">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dip"
|
||||
android:layout_marginEnd="16dip"
|
||||
android:orientation="vertical">
|
||||
|
||||
<!-- Copies -->
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dip"
|
||||
android:layout_marginStart="12dip"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:labelFor="@+id/copies_edittext"
|
||||
android:text="@string/label_copies">
|
||||
</TextView>
|
||||
|
||||
<view
|
||||
class="com.android.printspooler.widget.FirstFocusableEditText"
|
||||
android:id="@+id/copies_edittext"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
style="?android:attr/editTextStyle"
|
||||
android:inputType="numberDecimal">
|
||||
</view>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dip"
|
||||
android:layout_marginEnd="16dip"
|
||||
android:orientation="vertical">
|
||||
|
||||
<!-- Paper size -->
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dip"
|
||||
android:layout_marginStart="12dip"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:labelFor="@+id/paper_size_spinner"
|
||||
android:text="@string/label_paper_size">
|
||||
</TextView>
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/paper_size_spinner"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/PrintOptionSpinnerStyle">
|
||||
</Spinner>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dip"
|
||||
android:layout_marginEnd="16dip"
|
||||
android:orientation="vertical">
|
||||
|
||||
<!-- Color -->
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dip"
|
||||
android:layout_marginStart="12dip"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:labelFor="@+id/color_spinner"
|
||||
android:text="@string/label_color">
|
||||
</TextView>
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/color_spinner"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/PrintOptionSpinnerStyle">
|
||||
</Spinner>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dip"
|
||||
android:layout_marginEnd="16dip"
|
||||
android:orientation="vertical">
|
||||
|
||||
<!-- Orientation -->
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dip"
|
||||
android:layout_marginStart="12dip"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:labelFor="@+id/orientation_spinner"
|
||||
android:text="@string/label_orientation">
|
||||
</TextView>
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/orientation_spinner"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/PrintOptionSpinnerStyle">
|
||||
</Spinner>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dip"
|
||||
android:layout_marginEnd="16dip"
|
||||
android:orientation="vertical">
|
||||
|
||||
<!-- Range options -->
|
||||
|
||||
<TextView
|
||||
android:id="@+id/range_options_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dip"
|
||||
android:layout_marginStart="12dip"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:labelFor="@+id/range_options_spinner"
|
||||
android:text="@string/page_count_unknown">
|
||||
</TextView>
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/range_options_spinner"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/PrintOptionSpinnerStyle">
|
||||
</Spinner>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dip"
|
||||
android:layout_marginEnd="16dip"
|
||||
android:orientation="vertical">
|
||||
|
||||
<!-- Pages -->
|
||||
|
||||
<TextView
|
||||
android:id="@+id/page_range_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dip"
|
||||
android:layout_marginStart="12dip"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:text="@string/pages_range_example"
|
||||
android:labelFor="@+id/page_range_edittext"
|
||||
android:textAllCaps="false"
|
||||
android:visibility="visible">
|
||||
</TextView>
|
||||
|
||||
<view
|
||||
class="com.android.printspooler.widget.FirstFocusableEditText"
|
||||
android:id="@+id/page_range_edittext"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|fill_horizontal"
|
||||
style="@style/PrintOptionEditTextStyle"
|
||||
android:visibility="visible"
|
||||
android:inputType="textNoSuggestions">
|
||||
</view>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</com.android.printspooler.widget.PrintOptionsLayout>
|
||||
|
||||
<!-- More options -->
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/more_options_container"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="28dip"
|
||||
android:paddingEnd="28dip"
|
||||
android:orientation="vertical"
|
||||
android:visibility="visible">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="1dip"
|
||||
android:layout_gravity="fill_horizontal"
|
||||
android:background="?android:attr/colorControlNormal"
|
||||
android:contentDescription="@null">
|
||||
</ImageView>
|
||||
|
||||
<Button
|
||||
android:id="@+id/more_options_button"
|
||||
style="?android:attr/borderlessButtonStyle"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="fill_horizontal"
|
||||
android:text="@string/more_options_button"
|
||||
android:gravity="start|center_vertical"
|
||||
android:textAllCaps="false">
|
||||
</Button>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="1dip"
|
||||
android:layout_gravity="fill_horizontal"
|
||||
android:background="?android:attr/colorControlNormal"
|
||||
android:contentDescription="@null">
|
||||
</ImageView>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<!-- Expand/collapse handle -->
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/expand_collapse_handle"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/expand_collapse_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dip"
|
||||
android:layout_marginBottom="8dip"
|
||||
android:layout_gravity="center"
|
||||
android:background="@drawable/ic_expand_more">
|
||||
</ImageView>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</LinearLayout>
|
||||
<include layout="@layout/print_activity_controls"/>
|
||||
|
||||
<!-- Content -->
|
||||
|
||||
|
||||
281
packages/PrintSpooler/res/layout/print_activity_controls.xml
Normal file
281
packages/PrintSpooler/res/layout/print_activity_controls.xml
Normal file
@@ -0,0 +1,281 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2014 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:printspooler="http://schemas.android.com/apk/res/com.android.printspooler"
|
||||
android:id="@+id/dynamic_content"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:elevation="@dimen/preview_controls_elevation"
|
||||
android:background="?android:attr/colorForegroundInverse">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/draggable_content"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.android.printspooler.widget.PrintOptionsLayout
|
||||
android:id="@+id/options_container"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
printspooler:columnCount="@integer/print_option_column_count">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dip"
|
||||
android:layout_marginEnd="16dip"
|
||||
android:orientation="vertical">
|
||||
|
||||
<!-- Copies -->
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dip"
|
||||
android:layout_marginStart="12dip"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:labelFor="@+id/copies_edittext"
|
||||
android:text="@string/label_copies">
|
||||
</TextView>
|
||||
|
||||
<view
|
||||
class="com.android.printspooler.widget.FirstFocusableEditText"
|
||||
android:id="@+id/copies_edittext"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
style="?android:attr/editTextStyle"
|
||||
android:inputType="numberDecimal">
|
||||
</view>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dip"
|
||||
android:layout_marginEnd="16dip"
|
||||
android:orientation="vertical">
|
||||
|
||||
<!-- Paper size -->
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dip"
|
||||
android:layout_marginStart="12dip"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:labelFor="@+id/paper_size_spinner"
|
||||
android:text="@string/label_paper_size">
|
||||
</TextView>
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/paper_size_spinner"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/PrintOptionSpinnerStyle">
|
||||
</Spinner>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dip"
|
||||
android:layout_marginEnd="16dip"
|
||||
android:orientation="vertical">
|
||||
|
||||
<!-- Color -->
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dip"
|
||||
android:layout_marginStart="12dip"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:labelFor="@+id/color_spinner"
|
||||
android:text="@string/label_color">
|
||||
</TextView>
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/color_spinner"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/PrintOptionSpinnerStyle">
|
||||
</Spinner>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dip"
|
||||
android:layout_marginEnd="16dip"
|
||||
android:orientation="vertical">
|
||||
|
||||
<!-- Orientation -->
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dip"
|
||||
android:layout_marginStart="12dip"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:labelFor="@+id/orientation_spinner"
|
||||
android:text="@string/label_orientation">
|
||||
</TextView>
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/orientation_spinner"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/PrintOptionSpinnerStyle">
|
||||
</Spinner>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dip"
|
||||
android:layout_marginEnd="16dip"
|
||||
android:orientation="vertical">
|
||||
|
||||
<!-- Range options -->
|
||||
|
||||
<TextView
|
||||
android:id="@+id/range_options_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dip"
|
||||
android:layout_marginStart="12dip"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:labelFor="@+id/range_options_spinner"
|
||||
android:text="@string/page_count_unknown">
|
||||
</TextView>
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/range_options_spinner"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/PrintOptionSpinnerStyle">
|
||||
</Spinner>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dip"
|
||||
android:layout_marginEnd="16dip"
|
||||
android:orientation="vertical">
|
||||
|
||||
<!-- Pages -->
|
||||
|
||||
<TextView
|
||||
android:id="@+id/page_range_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dip"
|
||||
android:layout_marginStart="12dip"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:text="@string/pages_range_example"
|
||||
android:labelFor="@+id/page_range_edittext"
|
||||
android:textAllCaps="false"
|
||||
android:visibility="visible">
|
||||
</TextView>
|
||||
|
||||
<view
|
||||
class="com.android.printspooler.widget.FirstFocusableEditText"
|
||||
android:id="@+id/page_range_edittext"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|fill_horizontal"
|
||||
style="@style/PrintOptionEditTextStyle"
|
||||
android:visibility="visible"
|
||||
android:inputType="textNoSuggestions">
|
||||
</view>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</com.android.printspooler.widget.PrintOptionsLayout>
|
||||
|
||||
<!-- More options -->
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/more_options_container"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="28dip"
|
||||
android:paddingEnd="28dip"
|
||||
android:orientation="vertical"
|
||||
android:visibility="visible">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="1dip"
|
||||
android:layout_gravity="fill_horizontal"
|
||||
android:background="?android:attr/colorControlNormal"
|
||||
android:contentDescription="@null">
|
||||
</ImageView>
|
||||
|
||||
<Button
|
||||
android:id="@+id/more_options_button"
|
||||
style="?android:attr/borderlessButtonStyle"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="fill_horizontal"
|
||||
android:text="@string/more_options_button"
|
||||
android:gravity="start|center_vertical"
|
||||
android:textAllCaps="false">
|
||||
</Button>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="1dip"
|
||||
android:layout_gravity="fill_horizontal"
|
||||
android:background="?android:attr/colorControlNormal"
|
||||
android:contentDescription="@null">
|
||||
</ImageView>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<!-- Expand/collapse handle -->
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/expand_collapse_handle"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/expand_collapse_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dip"
|
||||
android:layout_marginBottom="8dip"
|
||||
android:layout_gravity="center"
|
||||
android:background="@drawable/ic_expand_more">
|
||||
</ImageView>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
@@ -38,4 +38,6 @@
|
||||
|
||||
<dimen name="preview_list_padding">24dip</dimen>
|
||||
|
||||
<dimen name="preview_controls_elevation">8dip</dimen>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -68,54 +68,42 @@ public final class PageAdapter extends Adapter {
|
||||
private final CloseGuard mCloseGuard = CloseGuard.get();
|
||||
|
||||
private final SparseArray<Void> mBoundPagesInAdapter = new SparseArray<>();
|
||||
|
||||
private final SparseArray<Void> 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 {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -43,7 +43,6 @@ public class PageContentView extends View
|
||||
private PageContentProvider mProvider;
|
||||
|
||||
private MediaSize mMediaSize;
|
||||
|
||||
private Margins mMinMargins;
|
||||
|
||||
private boolean mContentRequested;
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user