Update the print dialog.
1. The print dialog was resizable and as a result when printers
come and go its size changes which looks bad. The dialog is
now trying to be maximally large limited by a max size or the
screen - whichever is smaller. This required moving from
GridLayout to several LinearLayouts since the former does not
support distribution of empty space evently between the items
in a row. Also we want all items in a column of inputs to be
of equal size (the spinners specifically).
2. Added labeledBy attribute to associate a view with another one
that serves as its label for accessibility purposes. We have
lebelFor attribute but it is not useful in most layout files
since it has to refer the auto-generated id of a view which
usually appears later in the layout file, thus generating a
compilation error. This was needed for the accessibility support
of the print dialog.
bug:10631660
2. Disabling the spinners or the print button did not produce
visual feedback leading to user frustration.
bug:10741907
Change-Id: I0c12eddabc4035bc7becd1b86c1f1b8fdcf4289c
diff --git a/api/current.txt b/api/current.txt
index 3c21165..4fed1bb 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -19178,7 +19178,7 @@
field public static final android.print.PrintAttributes.MediaSize NA_LETTER;
field public static final android.print.PrintAttributes.MediaSize NA_MONARCH;
field public static final android.print.PrintAttributes.MediaSize NA_QUARTO;
- field public static final android.print.PrintAttributes.MediaSize NA_TBLOID;
+ field public static final android.print.PrintAttributes.MediaSize NA_TABLOID;
field public static final android.print.PrintAttributes.MediaSize OM_DAI_PA_KAI;
field public static final android.print.PrintAttributes.MediaSize OM_JUURO_KU_KAI;
field public static final android.print.PrintAttributes.MediaSize OM_PA_KAI;
@@ -31611,6 +31611,8 @@
ctor public NumberPicker(android.content.Context);
ctor public NumberPicker(android.content.Context, android.util.AttributeSet);
ctor public NumberPicker(android.content.Context, android.util.AttributeSet, int);
+ method public int computeVerticalScrollOffset();
+ method public int computeVerticalScrollRange();
method public java.lang.String[] getDisplayedValues();
method public int getMaxValue();
method public int getMinValue();
diff --git a/core/java/android/print/PrintAttributes.java b/core/java/android/print/PrintAttributes.java
index efe6b15..e61fe89 100644
--- a/core/java/android/print/PrintAttributes.java
+++ b/core/java/android/print/PrintAttributes.java
@@ -391,7 +391,7 @@
public static final MediaSize NA_LEDGER =
new MediaSize("NA_LEDGER", "android", R.string.mediaSize_na_ledger, 17000, 11000);
/** North America Tabloid media size: 11" x 17" (279mm × 432mm) */
- public static final MediaSize NA_TBLOID =
+ public static final MediaSize NA_TABLOID =
new MediaSize("NA_TABLOID", "android",
R.string.mediaSize_na_tabloid, 11000, 17000);
/** North America Index Card 3x5 media size: 3" x 5" (76mm x 127mm) */
diff --git a/packages/PrintSpooler/res/color/item_text_color.xml b/packages/PrintSpooler/res/color/item_text_color.xml
new file mode 100644
index 0000000..f580fbd
--- /dev/null
+++ b/packages/PrintSpooler/res/color/item_text_color.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2013 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.
+-->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:state_enabled="true" android:color="#333333" />
+ <item android:color="#888888"/>
+</selector>
\ No newline at end of file
diff --git a/packages/PrintSpooler/res/layout/print_job_config_activity_container.xml b/packages/PrintSpooler/res/layout/print_job_config_activity_container.xml
index 7817094..98b5cfe 100644
--- a/packages/PrintSpooler/res/layout/print_job_config_activity_container.xml
+++ b/packages/PrintSpooler/res/layout/print_job_config_activity_container.xml
@@ -14,10 +14,10 @@
limitations under the License.
-->
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<com.android.printspooler.PrintDialogFrame xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/content_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@color/container_background">
-</FrameLayout>
+</com.android.printspooler.PrintDialogFrame>
diff --git a/packages/PrintSpooler/res/layout/print_job_config_activity_content_editing.xml b/packages/PrintSpooler/res/layout/print_job_config_activity_content_editing.xml
index abf3c03..83019b9 100644
--- a/packages/PrintSpooler/res/layout/print_job_config_activity_content_editing.xml
+++ b/packages/PrintSpooler/res/layout/print_job_config_activity_content_editing.xml
@@ -15,17 +15,16 @@
-->
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="wrap_content"
+ android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:scrollbars="vertical"
android:background="@color/editable_background">
- <GridLayout
- android:layout_width="wrap_content"
+ <LinearLayout
+ android:layout_width="fill_parent"
android:layout_height="wrap_content"
- android:orientation="vertical"
- android:columnCount="2">
+ android:orientation="vertical">
<!-- Destination -->
@@ -37,190 +36,179 @@
android:layout_marginTop="24dip"
android:layout_marginStart="24dip"
android:layout_marginEnd="24dip"
- android:layout_row="0"
- android:layout_column="0"
- android:layout_columnSpan="2"
android:minHeight="?android:attr/listPreferredItemHeightSmall">
</Spinner>
- <!-- Copies -->
-
- <view
- class="com.android.printspooler.PrintJobConfigActivity$CustomEditText"
- android:id="@+id/copies_edittext"
+ <LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
- android:layout_marginStart="24dip"
- android:layout_marginEnd="6dip"
- android:layout_row="2"
- android:layout_column="0"
- android:layout_gravity="bottom|fill_horizontal"
- style="@style/PrintOptionEditTextStyle"
- android:inputType="numberDecimal">
- </view>
+ android:orientation="horizontal"
+ android:baselineAligned="false">
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginTop="12dip"
- android:layout_marginStart="36dip"
- android:layout_marginEnd="6dip"
- android:layout_row="1"
- android:layout_column="0"
- style="@style/PrintOptionTextViewStyle"
- android:labelFor="@id/copies_edittext"
- android:text="@string/label_copies">
- </TextView>
+ <LinearLayout
+ android:layout_width="0dip"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:orientation="vertical">
- <!-- Paper size -->
+ <!-- Copies -->
- <Spinner
- android:id="@+id/paper_size_spinner"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_marginStart="6dip"
- android:layout_marginEnd="24dip"
- android:layout_row="2"
- android:layout_column="1"
- android:layout_gravity="fill_horizontal"
- style="@style/PrintOptionSpinnerStyle">
- </Spinner>
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="12dip"
+ android:layout_marginStart="36dip"
+ android:layout_marginEnd="6dip"
+ android:textAppearance="@style/PrintOptionTitleTextAppearance"
+ android:labelFor="@+id/copies_edittext"
+ android:text="@string/label_copies">
+ </TextView>
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginTop="12dip"
- android:layout_marginStart="18dip"
- android:layout_marginEnd="24dip"
- android:layout_row="1"
- android:layout_column="1"
- style="@style/PrintOptionTextViewStyle"
- android:labelFor="@id/paper_size_spinner"
- android:text="@string/label_paper_size">
- </TextView>
+ <view
+ class="com.android.printspooler.PrintJobConfigActivity$CustomEditText"
+ android:id="@+id/copies_edittext"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="24dip"
+ android:layout_marginEnd="6dip"
+ style="@style/PrintOptionEditTextStyle"
+ android:inputType="numberDecimal">
+ </view>
- <!-- Color -->
+ <!-- Color -->
- <Spinner
- android:id="@+id/color_spinner"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_marginStart="24dip"
- android:layout_marginEnd="6dip"
- android:layout_row="4"
- android:layout_column="0"
- android:layout_gravity="fill_horizontal"
- style="@style/PrintOptionSpinnerStyle">
- </Spinner>
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="12dip"
+ android:layout_marginStart="36dip"
+ android:layout_marginEnd="6dip"
+ android:textAppearance="@style/PrintOptionTitleTextAppearance"
+ android:labelFor="@+id/color_spinner"
+ android:text="@string/label_color">
+ </TextView>
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginTop="12dip"
- android:layout_marginStart="36dip"
- android:layout_marginEnd="6dip"
- android:layout_row="3"
- android:layout_column="0"
- style="@style/PrintOptionTextViewStyle"
- 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"
+ android:layout_marginStart="24dip"
+ android:layout_marginEnd="6dip"
+ style="@style/PrintOptionSpinnerStyle">
+ </Spinner>
- <!-- Orientation -->
+ <!-- Range options -->
- <Spinner
- android:id="@+id/orientation_spinner"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_marginStart="6dip"
- android:layout_marginEnd="24dip"
- android:layout_row="4"
- android:layout_column="1"
- android:layout_gravity="fill_horizontal"
- style="@style/PrintOptionSpinnerStyle">
- </Spinner>
+ <TextView
+ android:id="@+id/range_options_title"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="12dip"
+ android:layout_marginStart="36dip"
+ android:textAppearance="@style/PrintOptionTitleTextAppearance"
+ android:labelFor="@+id/range_options_spinner"
+ android:text="@string/label_pages">
+ </TextView>
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginTop="12dip"
- android:layout_marginStart="18dip"
- android:layout_marginEnd="24dip"
- android:layout_row="3"
- android:layout_column="1"
- style="@style/PrintOptionTextViewStyle"
- android:labelFor="@id/orientation_spinner"
- android:text="@string/label_orientation">
- </TextView>
+ <Spinner
+ android:id="@+id/range_options_spinner"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="24dip"
+ android:layout_marginEnd="6dip"
+ style="@style/PrintOptionSpinnerStyle">
+ </Spinner>
- <!-- Range options -->
+ </LinearLayout>
- <Spinner
- android:id="@+id/range_options_spinner"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_marginStart="24dip"
- android:layout_marginEnd="6dip"
- android:layout_row="6"
- android:layout_column="0"
- android:layout_gravity="fill_horizontal"
- style="@style/PrintOptionSpinnerStyle">
- </Spinner>
+ <LinearLayout
+ android:layout_width="0dip"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:orientation="vertical">
- <TextView
- android:id="@+id/range_options_title"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginTop="12dip"
- android:layout_marginStart="36dip"
- android:layout_row="5"
- android:layout_column="0"
- style="@style/PrintOptionTextViewStyle"
- android:labelFor="@id/range_options_spinner"
- android:text="@string/label_pages">
- </TextView>
+ <!-- Paper size -->
- <!-- Pages -->
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="12dip"
+ android:layout_marginStart="18dip"
+ android:layout_marginEnd="24dip"
+ android:textAppearance="@style/PrintOptionTitleTextAppearance"
+ android:labelFor="@+id/paper_size_spinner"
+ android:text="@string/label_paper_size">
+ </TextView>
- <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_marginStart="6dip"
- android:layout_marginEnd="24dip"
- android:layout_row="6"
- android:layout_column="1"
- android:layout_gravity="bottom|fill_horizontal"
- style="@style/PrintOptionEditTextStyle"
- android:visibility="gone"
- android:inputType="textNoSuggestions">
- </view>
+ <Spinner
+ android:id="@+id/paper_size_spinner"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="6dip"
+ android:layout_marginEnd="24dip"
+ style="@style/PrintOptionSpinnerStyle">
+ </Spinner>
- <TextView
- android:id="@+id/page_range_title"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginTop="12dip"
- android:layout_marginStart="12dip"
- android:layout_marginEnd="24dip"
- android:layout_row="5"
- android:layout_column="1"
- style="@style/PrintOptionTextViewStyle"
- android:labelFor="@id/page_range_edittext"
- android:text="@string/pages_range_example"
- android:textAllCaps="false">
- </TextView>
+ <!-- Orientation -->
- <!-- Print button -->
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="12dip"
+ android:layout_marginStart="18dip"
+ android:layout_marginEnd="24dip"
+ android:textAppearance="@style/PrintOptionTitleTextAppearance"
+ 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"
+ android:layout_marginStart="6dip"
+ android:layout_marginEnd="24dip"
+ style="@style/PrintOptionSpinnerStyle">
+ </Spinner>
+
+ <!-- Pages -->
+
+ <TextView
+ android:id="@+id/page_range_title"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="12dip"
+ android:layout_marginStart="12dip"
+ android:layout_marginEnd="24dip"
+ android:textAppearance="@style/PrintOptionTitleTextAppearance"
+ android:text="@string/pages_range_example"
+ android:labelFor="@+id/page_range_edittext"
+ android:textAllCaps="false">
+ </TextView>
+
+ <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_marginStart="6dip"
+ android:layout_marginEnd="24dip"
+ android:layout_gravity="bottom|fill_horizontal"
+ style="@style/PrintOptionEditTextStyle"
+ android:visibility="gone"
+ android:inputType="textNoSuggestions">
+ </view>
+
+ </LinearLayout>
+
+ </LinearLayout>
+
+ <!-- Print button -->
<ImageView
- android:layout_width="wrap_content"
+ android:layout_width="fill_parent"
android:layout_height="1dip"
android:layout_marginTop="24dip"
- android:layout_row="7"
- android:layout_column="0"
- android:layout_columnSpan="2"
android:layout_gravity="fill_horizontal"
android:background="@color/separator"
android:contentDescription="@null">
@@ -229,18 +217,14 @@
<Button
android:id="@+id/print_button"
style="?android:attr/buttonBarButtonStyle"
- android:layout_width="wrap_content"
+ android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="fill_horizontal"
- android:layout_row="8"
- android:layout_column="0"
- android:layout_columnSpan="2"
android:text="@string/print_button"
android:textSize="16sp"
- android:textColor="@color/important_text">
+ android:textColor="@color/item_text_color">
</Button>
- </GridLayout>
+ </LinearLayout>
</ScrollView>
-
diff --git a/packages/PrintSpooler/res/layout/spinner_dropdown_item.xml b/packages/PrintSpooler/res/layout/spinner_dropdown_item.xml
index 48189bd..f00da0d 100644
--- a/packages/PrintSpooler/res/layout/spinner_dropdown_item.xml
+++ b/packages/PrintSpooler/res/layout/spinner_dropdown_item.xml
@@ -14,7 +14,7 @@
limitations under the License.
-->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingStart="8dip"
@@ -32,7 +32,8 @@
android:ellipsize="end"
android:textIsSelectable="false"
android:gravity="top|left"
- android:textColor="@color/important_text">
+ android:textColor="@color/item_text_color"
+ android:duplicateParentState="true">
</TextView>
<TextView
@@ -44,7 +45,8 @@
android:ellipsize="end"
android:textIsSelectable="false"
android:visibility="gone"
- android:textColor="@color/important_text">
+ android:textColor="@color/item_text_color"
+ android:duplicateParentState="true">
</TextView>
diff --git a/packages/PrintSpooler/res/values/constants.xml b/packages/PrintSpooler/res/values/constants.xml
index 96cdeb1..e5a9d5d 100644
--- a/packages/PrintSpooler/res/values/constants.xml
+++ b/packages/PrintSpooler/res/values/constants.xml
@@ -24,4 +24,6 @@
<item>@integer/page_option_value_page_range</item>
</integer-array>
+ <dimen name="print_dialog_frame_max_width_dip">400dip</dimen>
+
</resources>
\ No newline at end of file
diff --git a/packages/PrintSpooler/res/values/styles.xml b/packages/PrintSpooler/res/values/styles.xml
index fe11c93..f6db6be 100644
--- a/packages/PrintSpooler/res/values/styles.xml
+++ b/packages/PrintSpooler/res/values/styles.xml
@@ -26,22 +26,14 @@
<style name="PrintOptionSpinnerStyle">
<item name="android:paddingTop">0dip</item>
<item name="android:paddingBottom">0dip</item>
- <item name="android:minWidth">150dip</item>
- <item name="android:maxWidth">200dip</item>
<item name="android:minHeight">?android:attr/listPreferredItemHeightSmall</item>
</style>
<style name="PrintOptionEditTextStyle">
<item name="android:selectAllOnFocus">true</item>
<item name="android:minHeight">?android:attr/listPreferredItemHeightSmall</item>
- <item name="android:maxWidth">200dip</item>
<item name="android:singleLine">true</item>
<item name="android:ellipsize">end</item>
</style>
- <style name="PrintOptionTextViewStyle">
- <item name="android:textAppearance">@style/PrintOptionTitleTextAppearance</item>
- <item name="android:maxWidth">200dip</item>
- </style>
-
</resources>
diff --git a/packages/PrintSpooler/src/com/android/printspooler/PrintDialogFrame.java b/packages/PrintSpooler/src/com/android/printspooler/PrintDialogFrame.java
new file mode 100644
index 0000000..6dd8aa0a
--- /dev/null
+++ b/packages/PrintSpooler/src/com/android/printspooler/PrintDialogFrame.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2013 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.
+ */
+
+package com.android.printspooler;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.widget.FrameLayout;
+
+public class PrintDialogFrame extends FrameLayout {
+
+ public final int mMaxWidth;
+
+ public PrintDialogFrame(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ mMaxWidth = context.getResources().getDimensionPixelSize(
+ R.dimen.print_dialog_frame_max_width_dip);
+ }
+
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ final int widthMode = MeasureSpec.getMode(widthMeasureSpec);
+ if (widthMode == MeasureSpec.AT_MOST) {
+ final int receivedWidth = MeasureSpec.getSize(widthMeasureSpec);
+ final int computedWidth = Math.min(mMaxWidth, receivedWidth);
+ widthMeasureSpec = MeasureSpec.makeMeasureSpec(computedWidth,
+ MeasureSpec.EXACTLY);
+ }
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+ }
+}