summaryrefslogtreecommitdiffstats
path: root/packages/PrintSpooler
diff options
context:
space:
mode:
authorSvetoslav <svetoslavganov@google.com>2014-07-15 22:59:49 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-07-15 20:33:11 +0000
commit67eb5bbd5374fe96209cf7b68543cb48ee959b96 (patch)
treef8ba551e05607a083615ea58d2c04af9ae850adc /packages/PrintSpooler
parentb024aaa9b90e117bc72e83923c688bb62468ecea (diff)
parent73764e347d387657b3e2f8027d135de612cf454f (diff)
downloadframeworks_base-67eb5bbd5374fe96209cf7b68543cb48ee959b96.zip
frameworks_base-67eb5bbd5374fe96209cf7b68543cb48ee959b96.tar.gz
frameworks_base-67eb5bbd5374fe96209cf7b68543cb48ee959b96.tar.bz2
Merge "Update the page count in the print UI to meet new UX." into lmp-dev
Diffstat (limited to 'packages/PrintSpooler')
-rw-r--r--packages/PrintSpooler/res/layout/print_activity_controls.xml3
-rw-r--r--packages/PrintSpooler/res/values/strings.xml19
-rw-r--r--packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java46
3 files changed, 38 insertions, 30 deletions
diff --git a/packages/PrintSpooler/res/layout/print_activity_controls.xml b/packages/PrintSpooler/res/layout/print_activity_controls.xml
index 05a04ce..ef6044a 100644
--- a/packages/PrintSpooler/res/layout/print_activity_controls.xml
+++ b/packages/PrintSpooler/res/layout/print_activity_controls.xml
@@ -159,14 +159,13 @@
<!-- 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">
+ android:text="@string/label_pages">
</TextView>
<Spinner
diff --git a/packages/PrintSpooler/res/values/strings.xml b/packages/PrintSpooler/res/values/strings.xml
index dd90bec..5b7fda3 100644
--- a/packages/PrintSpooler/res/values/strings.xml
+++ b/packages/PrintSpooler/res/values/strings.xml
@@ -44,7 +44,13 @@
<string name="label_orientation">Orientation</string>
<!-- Label of the page selection widget. [CHAR LIMIT=20] -->
- <string name="label_pages">Pages (<xliff:g id="page_count" example="5">%1$s</xliff:g>)</string>
+ <string name="label_pages">Pages</string>
+
+ <!-- Template for the all pages option in the page selection widget. [CHAR LIMIT=20] -->
+ <string name="template_all_pages">All <xliff:g id="page_count" example="100">%1$s</xliff:g></string>
+
+ <!-- Template for the page range option in the page selection widget. [CHAR LIMIT=20] -->
+ <string name="template_page_range">Range of <xliff:g id="page_count" example="100">%1$s</xliff:g></string>
<!-- Page range exmple used as a hint of how to specify such. [CHAR LIMIT=20] -->
<string name="pages_range_example">e.g. 1&#8212;5,8,11&#8212;13</string>
@@ -58,9 +64,6 @@
<!-- Title of the message that the printing application crashed. [CHAR LIMIT=50] -->
<string name="printing_app_crashed">Printing app crashed</string>
- <!-- Title if the number of pages in a printed document is unknown. [CHAR LIMIT=20] -->
- <string name="page_count_unknown">Pages</string>
-
<!-- Title for the temporary dialog show while an app is generating a print job. [CHAR LIMIT=30] -->
<string name="generating_print_job">Generating print job</string>
@@ -174,14 +177,6 @@
<item>Landscape</item>
</string-array>
- <!-- Page options labels. -->
- <string-array name="page_options_labels">
- <!-- Page range option label: Print all pages [CHAR LIMIT=30] -->
- <item>All</item>
- <!-- Page range option label: Print a page range [CHAR LIMIT=30] -->
- <item>Range</item>
- </string-array>
-
<!-- Permissions -->
<!-- Title of an application permission, listed so the user can choose whether they want
diff --git a/packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java b/packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java
index 5e646ff..a01e45c 100644
--- a/packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java
+++ b/packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java
@@ -157,7 +157,6 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat
private EditText mCopiesEditText;
- private TextView mPageRangeOptionsTitle;
private TextView mPageRangeTitle;
private EditText mPageRangeEditText;
@@ -196,6 +195,8 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat
private String mCallingPackageName;
+ private int mCurrentPageCount;
+
private int mState;
private int mUiState = UI_STATE_PREVIEW;
@@ -996,19 +997,10 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat
// Range options
ArrayAdapter<SpinnerItem<Integer>> rangeOptionsSpinnerAdapter =
new ArrayAdapter<>(this, R.layout.spinner_dropdown_item, R.id.title);
- final int[] rangeOptionsValues = getResources().getIntArray(
- R.array.page_options_values);
- String[] rangeOptionsLabels = getResources().getStringArray(
- R.array.page_options_labels);
- final int rangeOptionsCount = rangeOptionsLabels.length;
- for (int i = 0; i < rangeOptionsCount; i++) {
- rangeOptionsSpinnerAdapter.add(new SpinnerItem<>(
- rangeOptionsValues[i], rangeOptionsLabels[i]));
- }
- mPageRangeOptionsTitle = (TextView) findViewById(R.id.range_options_title);
mRangeOptionsSpinner = (Spinner) findViewById(R.id.range_options_spinner);
mRangeOptionsSpinner.setAdapter(rangeOptionsSpinnerAdapter);
mRangeOptionsSpinner.setOnItemSelectedListener(itemSelectedListener);
+ updatePageRangeOptions(PrintDocumentInfo.PAGE_COUNT_UNKNOWN);
// Page range
mPageRangeTitle = (TextView) findViewById(R.id.page_range_title);
@@ -1265,22 +1257,23 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat
mPageRangeTitle.setVisibility(View.INVISIBLE);
}
}
- String title = (pageCount != PrintDocumentInfo.PAGE_COUNT_UNKNOWN)
- ? getString(R.string.label_pages, String.valueOf(pageCount))
- : getString(R.string.page_count_unknown);
- mPageRangeOptionsTitle.setText(title);
} else {
if (mRangeOptionsSpinner.getSelectedItemPosition() != 0) {
mRangeOptionsSpinner.setSelection(0);
mPageRangeEditText.setText("");
}
mRangeOptionsSpinner.setEnabled(false);
- mPageRangeOptionsTitle.setText(getString(R.string.page_count_unknown));
mPageRangeEditText.setEnabled(false);
mPageRangeEditText.setVisibility(View.INVISIBLE);
mPageRangeTitle.setVisibility(View.INVISIBLE);
}
+ final int newPageCount = getAdjustedPageCount(info);
+ if (newPageCount != mCurrentPageCount) {
+ mCurrentPageCount = newPageCount;
+ updatePageRangeOptions(newPageCount);
+ }
+
// Advanced print options
ComponentName serviceName = mCurrentPrinter.getId().getServiceName();
if (!TextUtils.isEmpty(PrintOptionUtils.getAdvancedOptionsActivityName(
@@ -1320,6 +1313,27 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat
}
}
+ private void updatePageRangeOptions(int pageCount) {
+ ArrayAdapter<SpinnerItem<Integer>> rangeOptionsSpinnerAdapter =
+ (ArrayAdapter) mRangeOptionsSpinner.getAdapter();
+ rangeOptionsSpinnerAdapter.clear();
+
+ final int[] rangeOptionsValues = getResources().getIntArray(
+ R.array.page_options_values);
+
+ String pageCountLabel = (pageCount > 0) ? String.valueOf(pageCount) : "";
+ String[] rangeOptionsLabels = new String[] {
+ getString(R.string.template_all_pages, pageCountLabel),
+ getString(R.string.template_page_range, pageCountLabel)
+ };
+
+ final int rangeOptionsCount = rangeOptionsLabels.length;
+ for (int i = 0; i < rangeOptionsCount; i++) {
+ rangeOptionsSpinnerAdapter.add(new SpinnerItem<>(
+ rangeOptionsValues[i], rangeOptionsLabels[i]));
+ }
+ }
+
private PageRange[] computeSelectedPages() {
if (hasErrors()) {
return null;