From 013b816ac7d723a0116c039e6266d93d13851fe1 Mon Sep 17 00:00:00 2001 From: Svetoslav Date: Wed, 18 Sep 2013 12:31:23 -0700 Subject: [PATCH] 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 --- api/current.txt | 4 +- core/java/android/print/PrintAttributes.java | 2 +- .../res/color/item_text_color.xml | 20 ++ .../print_job_config_activity_container.xml | 4 +- ...nt_job_config_activity_content_editing.xml | 324 +++++++++--------- .../res/layout/spinner_dropdown_item.xml | 8 +- .../PrintSpooler/res/values/constants.xml | 2 + packages/PrintSpooler/res/values/styles.xml | 8 - .../printspooler/PrintDialogFrame.java | 44 +++ 9 files changed, 231 insertions(+), 185 deletions(-) create mode 100644 packages/PrintSpooler/res/color/item_text_color.xml create mode 100644 packages/PrintSpooler/src/com/android/printspooler/PrintDialogFrame.java diff --git a/api/current.txt b/api/current.txt index 3c211654674fe..4fed1bb980a55 100644 --- a/api/current.txt +++ b/api/current.txt @@ -19178,7 +19178,7 @@ package android.print { 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 @@ package android.widget { 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 efe6b159d474b..e61fe89653e21 100644 --- a/core/java/android/print/PrintAttributes.java +++ b/core/java/android/print/PrintAttributes.java @@ -391,7 +391,7 @@ public final class PrintAttributes implements Parcelable { 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 0000000000000..f580fbd75577a --- /dev/null +++ b/packages/PrintSpooler/res/color/item_text_color.xml @@ -0,0 +1,20 @@ + + + + + + + \ 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 78170947915c7..98b5cfe164fa1 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. --> - - + 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 abf3c03256a27..83019b9ef79a3 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 @@ --> - + android:orientation="vertical"> @@ -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"> - - - - + android:orientation="horizontal" + android:baselineAligned="false"> - - + - + - - + + - - + + - + - - + + - - + + - + - - + + - - + + - + - - + - - + - + + - - + + - - + - + + + + + + + + + + + + + + + + + + + @@ -229,18 +217,14 @@ - + - diff --git a/packages/PrintSpooler/res/layout/spinner_dropdown_item.xml b/packages/PrintSpooler/res/layout/spinner_dropdown_item.xml index 48189bd021e48..f00da0dee060d 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. --> - + android:textColor="@color/item_text_color" + android:duplicateParentState="true"> + android:textColor="@color/item_text_color" + android:duplicateParentState="true"> diff --git a/packages/PrintSpooler/res/values/constants.xml b/packages/PrintSpooler/res/values/constants.xml index 96cdeb191dfad..e5a9d5d2768c5 100644 --- a/packages/PrintSpooler/res/values/constants.xml +++ b/packages/PrintSpooler/res/values/constants.xml @@ -24,4 +24,6 @@ @integer/page_option_value_page_range + 400dip + \ No newline at end of file diff --git a/packages/PrintSpooler/res/values/styles.xml b/packages/PrintSpooler/res/values/styles.xml index fe11c93a12fc4..f6db6befd9282 100644 --- a/packages/PrintSpooler/res/values/styles.xml +++ b/packages/PrintSpooler/res/values/styles.xml @@ -26,22 +26,14 @@ - - 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 0000000000000..6dd8aa0a6597c --- /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); + } +}