Merge "Update the page count in the print UI to meet new UX." into lmp-dev
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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—5,8,11—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
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user