Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0d1daa50 authored by Svetoslav Ganov's avatar Svetoslav Ganov
Browse files

Updating the print dialog and its interactinos with the printing app.

1. Added support for reporting the old print attributes during layout.
   Now we keep track of the old print attributes, so the app can
   compute the delta and decide whether re-layout work is needed.

2. Fixed PrintDocumentAdapter callback interleavings. Layout callbacks
   were intermixing with write ones - a mess. Now we make an attempt
   to cancel layout and write if they respond to cancellation, otherwise
   we wait but do not interleave them.

3. Refactored the PrintJobConfigActivity for easier maintenance and
   to have a single update UI method that does the minimal amount
   of work.

Change-Id: I31ada1a0550882e6185018e6f17f923aed165d15
parent 88d19913
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -383,6 +383,22 @@ public final class PrintAttributes implements Parcelable {
        mCopies = 0;
    }

    /**
     * @hide
     */
    public void copyFrom(PrintAttributes other) {
        mMediaSize = other.mMediaSize;
        mResolution = other.mResolution;
        mMargins = other.mMargins;
        mInputTray = other.mInputTray;
        mOutputTray = other.mOutputTray;
        mDuplexMode = other.mDuplexMode;
        mColorMode = other.mColorMode;
        mFittingMode = other.mFittingMode;
        mOrientation = other.mOrientation;
        mCopies = other.mCopies;
    }

    /**
     * This class specifies a supported media size.
     */
+254 −187
Original line number Diff line number Diff line
@@ -14,20 +14,15 @@
     limitations under the License.
-->

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@*android:color/bright_foreground_disabled_holo_light">
    android:orientation="vertical"
    android:scrollbars="vertical">

    <GridLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
            android:layout_margin="32dip"
        android:orientation="vertical"
        android:columnCount="2">

@@ -37,11 +32,13 @@
            android:id="@+id/destination_spinner"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="fill_horizontal"
            android:layout_marginLeft="32dip"
            android:layout_marginRight="32dip"
            android:layout_marginBottom="12dip"
            android:layout_row="0"
            android:layout_column="0"
            android:layout_columnSpan="2"
                android:minWidth="324dip"
            android:minHeight="?android:attr/listPreferredItemHeightSmall">
        </Spinner>

@@ -52,6 +49,7 @@
            android:id="@+id/copies_edittext"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="32dip"
            android:layout_marginRight="12dip"
            android:layout_marginBottom="12dip"
            android:layout_row="2"
@@ -65,6 +63,7 @@
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="32dip"
            android:layout_marginTop="12dip"
            android:layout_marginRight="12dip"
            android:layout_row="1"
@@ -83,6 +82,7 @@
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="12dip"
            android:layout_marginRight="32dip"
            android:layout_marginBottom="12dip"
            android:layout_row="2"
            android:layout_column="1"
@@ -93,6 +93,7 @@
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="12dip"
            android:layout_marginRight="32dip"
            android:layout_marginTop="12dip"
            android:layout_row="1"
            android:layout_column="1"
@@ -108,6 +109,7 @@
            android:id="@+id/color_spinner"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="32dip"
            android:layout_marginRight="12dip"
            android:layout_marginBottom="12dip"
            android:layout_row="4"
@@ -118,6 +120,7 @@
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="32dip"
            android:layout_marginTop="12dip"
            android:layout_marginRight="12dip"
            android:layout_row="3"
@@ -135,6 +138,7 @@
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="12dip"
            android:layout_marginRight="32dip"
            android:layout_marginBottom="12dip"
            android:layout_row="4"
            android:layout_column="1"
@@ -146,6 +150,7 @@
            android:layout_height="wrap_content"
            android:layout_marginLeft="12dip"
            android:layout_marginTop="12dip"
            android:layout_marginRight="32dip"
            android:layout_row="3"
            android:layout_column="1"
            android:text="@string/label_orientation"
@@ -160,17 +165,20 @@
            android:id="@+id/range_options_spinner"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="32dip"
            android:layout_marginRight="12dip"
            android:layout_row="6"
            android:layout_column="0"
            android:minWidth="150dip">
        </Spinner>

            <EditText
        <view
            class="com.android.printspooler.PrintJobConfigActivity$CustomEditText"
            android:id="@+id/page_range_edittext"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="12dip"
            android:layout_marginRight="32dip"
            android:layout_row="6"
            android:layout_column="1"
            android:layout_gravity="bottom"
@@ -179,11 +187,12 @@
            android:hint="@string/pages_range_example"
            android:inputType="textNoSuggestions"
            android:visibility="gone">
            </EditText>
        </view>

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="32dip"
            android:layout_marginTop="12dip"
            android:layout_marginRight="12dip"
            android:layout_row="5"
@@ -194,17 +203,75 @@
            android:labelFor="@id/range_options_spinner">
        </TextView>

        </GridLayout>
        <!-- Print pereview  -->

    </ScrollView>
        <ImageView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="fill_horizontal"
            android:layout_marginLeft="32dip"
            android:layout_marginTop="32dip"
            android:layout_marginRight="32dip"
            android:layout_row="7"
            android:layout_column="0"
            android:layout_columnSpan="2"
            android:background="?android:attr/listDivider"
            android:contentDescription="@null">
        </ImageView>

        <Button
            android:id="@+id/print_preview_button"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="fill_horizontal"
            android:layout_marginLeft="32dip"
            android:layout_marginRight="32dip"
            android:layout_row="8"
            android:layout_column="0"
            android:layout_columnSpan="2"
            android:text="@string/print_preview"
            android:gravity="left|center_vertical"
            android:background="?android:attr/selectableItemBackground">
        </Button>

        <ImageView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="fill_horizontal"
            android:layout_marginLeft="32dip"
            android:layout_marginRight="32dip"
            android:layout_marginBottom="32dip"
            android:layout_row="9"
            android:layout_column="0"
            android:layout_columnSpan="2"
            android:background="?android:attr/listDivider"
            android:contentDescription="@null">
        </ImageView>

        <ImageView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="fill_horizontal"
            android:layout_row="10"
            android:layout_column="0"
            android:layout_columnSpan="2"
            android:background="?android:attr/listDivider"
            android:contentDescription="@null">
        </ImageView>

        <Button
            android:id="@+id/print_button"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="fill_horizontal"
            android:layout_row="11"
            android:layout_column="0"
            android:layout_columnSpan="2"
            android:padding="0dip"
            android:text="@string/print_button"
            android:background="?android:attr/selectableItemBackground">
        </Button>

</LinearLayout>
    </GridLayout>

</ScrollView>
+2 −2
Original line number Diff line number Diff line
@@ -16,8 +16,8 @@

<resources>

    <integer name="page_option_value_all">1</integer>
    <integer name="page_option_value_page_range">2</integer>
    <integer name="page_option_value_all">0</integer>
    <integer name="page_option_value_page_range">1</integer>

    <integer-array name="page_options_values" translatable="false">
        <item>@integer/page_option_value_all</item>
+8 −2
Original line number Diff line number Diff line
@@ -43,8 +43,14 @@
    <!-- Page range exmple used as a hint of how to specify such. [CHAR LIMIT=15] -->
    <string name="pages_range_example">e.g. 1&#8211;5, 8</string>

    <!-- Message to notify the user of entering invalid input. [CHAR LIMIT=25] -->
    <string name="invalid_input">Invalid input</string>
    <!-- Title for the pring preview button .[CHAR LIMIT=30] -->
    <string name="print_preview">Print preview</string>

    <!-- Title for the pring preview button if there is no PDF viewer isntalled. [CHAR LIMIT=50] -->
    <string name="install_for_print_preview">Install PDF viewer for preview</string>

    <!-- Title of the message that the printing application crashed. [CHAR LIMIT=50] -->
    <string name="printing_app_crashed">Printing app crashed</string>

    <!-- Color mode labels. -->
    <string-array name="color_mode_labels">
+692 −426

File changed.

Preview size limit exceeded, changes collapsed.

Loading