Fix some minor print UX bugs.
1. The last row of print options was not visible on a phone.
2. The preview page size on a phone in landscape unusably small.
3. Updated the Save to PDF icon.
bug:16966145
Change-Id: I25ce1572758c62f34344683af2452fb045bb857e
diff --git a/packages/PrintSpooler/res/drawable/ic_savetopdf.xml b/packages/PrintSpooler/res/drawable/ic_savetopdf.xml
new file mode 100644
index 0000000..60ed33a
--- /dev/null
+++ b/packages/PrintSpooler/res/drawable/ic_savetopdf.xml
@@ -0,0 +1,19 @@
+<?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.
+-->
+
+<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
+ android:src="@drawable/ic_menu_savetopdf"
+ android:tint="@color/promoted_action_background_color" />
diff --git a/packages/PrintSpooler/res/layout/preview_page.xml b/packages/PrintSpooler/res/layout/preview_page.xml
index 509a1d2..76dd76b 100644
--- a/packages/PrintSpooler/res/layout/preview_page.xml
+++ b/packages/PrintSpooler/res/layout/preview_page.xml
@@ -31,7 +31,7 @@
<RelativeLayout
android:id="@+id/page_footer"
android:layout_width="fill_parent"
- android:layout_height="32dip"
+ android:layout_height="@dimen/preview_page_footer_height"
android:background="@*android:color/material_grey_500"
android:orientation="horizontal">
diff --git a/packages/PrintSpooler/res/layout/print_activity.xml b/packages/PrintSpooler/res/layout/print_activity.xml
index 3905646..ee5d42a 100644
--- a/packages/PrintSpooler/res/layout/print_activity.xml
+++ b/packages/PrintSpooler/res/layout/print_activity.xml
@@ -27,7 +27,6 @@
android:id="@+id/static_content"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
- android:padding="16dip"
android:elevation="@dimen/preview_controls_elevation"
android:background="?android:attr/colorPrimary">
@@ -35,6 +34,7 @@
android:id="@+id/destination_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:layout_marginTop="4dip"
android:dropDownWidth="wrap_content"
android:minHeight="?android:attr/listPreferredItemHeightSmall">
</Spinner>
@@ -56,7 +56,6 @@
<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_count_summary"
@@ -67,7 +66,6 @@
android:id="@+id/copies_count_summary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_marginTop="8dip"
android:layout_marginStart="16dip"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="?android:attr/textColorPrimary">
@@ -76,7 +74,6 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_marginTop="8dip"
android:layout_marginStart="32dip"
android:textAppearance="?android:attr/textAppearanceSmall"
android:labelFor="@+id/paper_size_summary"
@@ -87,7 +84,6 @@
android:id="@+id/paper_size_summary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_marginTop="8dip"
android:layout_marginStart="16dip"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="?android:attr/textColorPrimary">
diff --git a/packages/PrintSpooler/res/layout/print_activity_controls.xml b/packages/PrintSpooler/res/layout/print_activity_controls.xml
index ef6044a..31bda7e 100644
--- a/packages/PrintSpooler/res/layout/print_activity_controls.xml
+++ b/packages/PrintSpooler/res/layout/print_activity_controls.xml
@@ -267,8 +267,8 @@
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_marginTop="4dip"
+ android:layout_marginBottom="4dip"
android:layout_gravity="center"
android:background="@drawable/ic_expand_more">
</ImageView>
diff --git a/packages/PrintSpooler/res/values/constants.xml b/packages/PrintSpooler/res/values/constants.xml
index faad527..b95703b 100644
--- a/packages/PrintSpooler/res/values/constants.xml
+++ b/packages/PrintSpooler/res/values/constants.xml
@@ -45,4 +45,7 @@
<fraction name="page_selected_alpha">100%</fraction>
<fraction name="page_unselected_alpha">50%</fraction>
+ <dimen name="preview_page_footer_height">32dip</dimen>
+ <dimen name="preview_page_min_width">130dip</dimen>
+
</resources>
diff --git a/packages/PrintSpooler/src/com/android/printspooler/ui/PageAdapter.java b/packages/PrintSpooler/src/com/android/printspooler/ui/PageAdapter.java
index e976936..5bcdb9f 100644
--- a/packages/PrintSpooler/src/com/android/printspooler/ui/PageAdapter.java
+++ b/packages/PrintSpooler/src/com/android/printspooler/ui/PageAdapter.java
@@ -96,6 +96,7 @@
private float mUnselectedPageAlpha;
private int mPreviewPageMargin;
+ private int mPreviewPageMinWidth;
private int mPreviewListPadding;
private int mFooterHeight;
@@ -141,17 +142,17 @@
mPreviewPageMargin = mContext.getResources().getDimensionPixelSize(
R.dimen.preview_page_margin);
+ mPreviewPageMinWidth = mContext.getResources().getDimensionPixelSize(
+ R.dimen.preview_page_min_width);
+
mPreviewListPadding = mContext.getResources().getDimensionPixelSize(
R.dimen.preview_list_padding);
mColumnCount = mContext.getResources().getInteger(
R.integer.preview_page_per_row_count);
- TypedValue outValue = new TypedValue();
- mContext.getTheme().resolveAttribute(
- com.android.internal.R.attr.listPreferredItemHeightSmall, outValue, true);
- mFooterHeight = TypedValue.complexToDimensionPixelSize(outValue.data,
- mContext.getResources().getDisplayMetrics());
+ mFooterHeight = mContext.getResources().getDimensionPixelSize(
+ R.dimen.preview_page_footer_height);
mPreviewArea = previewArea;
@@ -428,8 +429,12 @@
// Compute max page height.
final int pageContentDesiredHeight = (int) (((float) pageContentDesiredWidth
/ pageAspectRatio) + 0.5f);
- final int pageContentMaxHeight = availableHeight - 2 * (mPreviewListPadding
- + mPreviewPageMargin) - mFooterHeight;
+
+ // If the page does not fit entirely in a vertial direction,
+ // we shirk it but not less than the minimal page width.
+ final int pageContentMinHeight = (int) (mPreviewPageMinWidth / pageAspectRatio + 0.5f);
+ final int pageContentMaxHeight = Math.max(pageContentMinHeight,
+ availableHeight - 2 * (mPreviewListPadding + mPreviewPageMargin) - mFooterHeight);
mPageContentHeight = Math.min(pageContentDesiredHeight, pageContentMaxHeight);
mPageContentWidth = (int) ((mPageContentHeight * pageAspectRatio) + 0.5f);
@@ -439,10 +444,17 @@
final int rowCount = mSelectedPageCount / columnCount
+ ((mSelectedPageCount % columnCount) > 0 ? 1 : 0);
- final int totalContentHeight = rowCount* (mPageContentHeight + mFooterHeight + 2
+ final int totalContentHeight = rowCount * (mPageContentHeight + mFooterHeight + 2
* mPreviewPageMargin);
- final int verticalPadding = Math.max(mPreviewListPadding,
- (availableHeight - totalContentHeight) / 2);
+
+ final int verticalPadding;
+ if (mPageContentHeight + mFooterHeight + mPreviewListPadding > availableHeight) {
+ verticalPadding = Math.max(mPreviewPageMargin,
+ (availableHeight - totalContentHeight) / 2);
+ } else {
+ verticalPadding = Math.max(mPreviewListPadding,
+ (availableHeight - totalContentHeight) / 2);
+ }
mPreviewArea.setPadding(horizontalPadding, verticalPadding,
horizontalPadding, verticalPadding);
diff --git a/packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java b/packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java
index a1b1aec..6b29e5f 100644
--- a/packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java
+++ b/packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java
@@ -1704,7 +1704,7 @@
if (position == 0 && getPdfPrinter() != null) {
PrinterHolder printerHolder = (PrinterHolder) getItem(position);
title = printerHolder.printer.getName();
- icon = getResources().getDrawable(com.android.internal.R.drawable.ic_menu_save);
+ icon = getResources().getDrawable(R.drawable.ic_savetopdf);
} else if (position == 1) {
title = getString(R.string.all_printers);
}
@@ -1712,7 +1712,7 @@
if (position == 1 && getPdfPrinter() != null) {
PrinterHolder printerHolder = (PrinterHolder) getItem(position);
title = printerHolder.printer.getName();
- icon = getResources().getDrawable(com.android.internal.R.drawable.ic_menu_save);
+ icon = getResources().getDrawable(R.drawable.ic_savetopdf);
} else if (position == getCount() - 1) {
title = getString(R.string.all_printers);
} else {
diff --git a/packages/PrintSpooler/src/com/android/printspooler/widget/PageContentView.java b/packages/PrintSpooler/src/com/android/printspooler/widget/PageContentView.java
index 4d2cb6c..8365373 100644
--- a/packages/PrintSpooler/src/com/android/printspooler/widget/PageContentView.java
+++ b/packages/PrintSpooler/src/com/android/printspooler/widget/PageContentView.java
@@ -94,7 +94,7 @@
mMinMargins = minMargins;
mContentRequested = false;
- // If there is not provider we want immediately to switch to
+ // If there is no provider we want immediately to switch to
// the empty state, so pages with no content appear blank.
if (mProvider == null && getBackground() != mEmptyState) {
setBackground(mEmptyState);
diff --git a/packages/PrintSpooler/src/com/android/printspooler/widget/PrintOptionsLayout.java b/packages/PrintSpooler/src/com/android/printspooler/widget/PrintOptionsLayout.java
index 01f4a04..71f4aa7 100644
--- a/packages/PrintSpooler/src/com/android/printspooler/widget/PrintOptionsLayout.java
+++ b/packages/PrintSpooler/src/com/android/printspooler/widget/PrintOptionsLayout.java
@@ -162,7 +162,7 @@
}
cellStart = getPaddingStart();
- cellTop += cellTop + rowHeight;
+ cellTop += rowHeight;
}
}