1. Refreshed the print UI based on UX redlines.
2. Implemented tap outside cancel for the print job config activity
which is full-screen but pretends to be a dialog.
Change-Id: I5afc7cd40c696109d70af31536898cfcad91b2ab
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
- android:background="@color/print_job_config_activity_content_background">
+ android:background="@color/container_background">
<include
layout="@layout/print_job_config_activity_content_editing">
android:id="@+id/content_editing"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:orientation="vertical"
- android:divider="?android:attr/dividerHorizontal"
- android:showDividers="middle">
+ android:orientation="vertical">
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
- android:scrollbars="vertical">
+ android:scrollbars="vertical"
+ android:background="@color/editable_background">
<GridLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:layout_marginStart="24dip"
+ android:layout_marginTop="32dip"
+ android:layout_marginEnd="24dip"
+ android:layout_marginBottom="24dip"
android:orientation="vertical"
android:columnCount="2">
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="fill_horizontal"
- android:layout_marginLeft="32dip"
- android:layout_marginTop="32dip"
- android:layout_marginRight="32dip"
- android:layout_marginBottom="12dip"
android:layout_row="0"
android:layout_column="0"
android:layout_columnSpan="2"
- android:minHeight="?android:attr/listPreferredItemHeight">
+ android:minHeight="?android:attr/listPreferredItemHeightSmall">
</Spinner>
<!-- Copies -->
android:id="@+id/copies_edittext"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
- android:layout_marginLeft="32dip"
- android:layout_marginRight="12dip"
- android:layout_marginBottom="12dip"
+ android:layout_marginEnd="6dip"
android:layout_row="2"
android:layout_column="0"
android:layout_gravity="bottom"
android:inputType="numberDecimal"
android:selectAllOnFocus="true"
android:minWidth="150dip"
- android:minHeight="?android:attr/listPreferredItemHeight">
+ android:minHeight="?android:attr/listPreferredItemHeightSmall">
</view>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_marginLeft="32dip"
android:layout_marginTop="12dip"
- android:layout_marginRight="12dip"
+ android:layout_marginStart="12dip"
+ android:layout_marginEnd="6dip"
android:layout_row="1"
android:layout_column="0"
- android:layout_gravity="left|bottom"
+ android:layout_gravity="start|bottom"
+ android:labelFor="@id/copies_edittext"
android:text="@string/label_copies"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textStyle="bold"
- android:labelFor="@id/copies_edittext">
+ android:textAppearance="@style/PrintOptionTitleTextAppearance">
</TextView>
<!-- Paper size -->
android:id="@+id/paper_size_spinner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
- android:layout_marginLeft="12dip"
- android:layout_marginRight="32dip"
- android:layout_marginBottom="12dip"
+ android:layout_marginStart="6dip"
android:layout_row="2"
android:layout_column="1"
- android:minWidth="150dip"
- android:minHeight="?android:attr/listPreferredItemHeight">
+ style="@style/PrintOptionSpinnerStyle">
</Spinner>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_marginLeft="12dip"
- android:layout_marginRight="32dip"
android:layout_marginTop="12dip"
+ android:layout_marginStart="18dip"
android:layout_row="1"
android:layout_column="1"
+ android:labelFor="@id/paper_size_spinner"
android:text="@string/label_paper_size"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textStyle="bold"
- android:labelFor="@id/paper_size_spinner">
+ android:textAppearance="@style/PrintOptionTitleTextAppearance">
</TextView>
<!-- Color -->
android:id="@+id/color_spinner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
- android:layout_marginLeft="32dip"
- android:layout_marginRight="12dip"
- android:layout_marginBottom="12dip"
+ android:layout_marginEnd="6dip"
android:layout_row="4"
android:layout_column="0"
- android:minWidth="150dip"
- android:minHeight="?android:attr/listPreferredItemHeight">
+ style="@style/PrintOptionSpinnerStyle">
</Spinner>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_marginLeft="32dip"
android:layout_marginTop="12dip"
- android:layout_marginRight="12dip"
+ android:layout_marginStart="12dip"
+ android:layout_marginEnd="6dip"
android:layout_row="3"
android:layout_column="0"
+ android:labelFor="@id/color_spinner"
android:text="@string/label_color"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textStyle="bold"
- android:labelFor="@id/color_spinner">
+ android:textAppearance="@style/PrintOptionTitleTextAppearance">
</TextView>
<!-- Orientation -->
android:id="@+id/orientation_spinner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
- android:layout_marginLeft="12dip"
- android:layout_marginRight="32dip"
- android:layout_marginBottom="12dip"
+ android:layout_marginStart="6dip"
android:layout_row="4"
android:layout_column="1"
- android:minWidth="150dip"
- android:minHeight="?android:attr/listPreferredItemHeight">
+ style="@style/PrintOptionSpinnerStyle">
</Spinner>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_marginLeft="12dip"
android:layout_marginTop="12dip"
- android:layout_marginRight="32dip"
+ android:layout_marginStart="18dip"
android:layout_row="3"
android:layout_column="1"
+ android:labelFor="@id/orientation_spinner"
android:text="@string/label_orientation"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textStyle="bold"
- android:labelFor="@id/orientation_spinner">
+ android:textAppearance="@style/PrintOptionTitleTextAppearance">
</TextView>
<!-- Pages -->
android:id="@+id/range_options_spinner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
- android:layout_marginLeft="32dip"
- android:layout_marginRight="12dip"
+ android:layout_marginEnd="6dip"
android:layout_row="6"
android:layout_column="0"
- android:minWidth="150dip"
- android:minHeight="?android:attr/listPreferredItemHeight">
+ style="@style/PrintOptionSpinnerStyle">
</Spinner>
<view
android:id="@+id/page_range_edittext"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
- android:layout_marginLeft="12dip"
- android:layout_marginRight="32dip"
+ android:layout_marginTop="12dip"
+ android:layout_marginStart="6dip"
android:layout_row="6"
android:layout_column="1"
android:layout_gravity="bottom"
android:hint="@string/pages_range_example"
android:inputType="textNoSuggestions"
android:visibility="gone"
- android:minHeight="?android:attr/listPreferredItemHeight">
+ android:minHeight="?android:attr/listPreferredItemHeightSmall">
</view>
<TextView
android:id="@+id/page_range_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_marginLeft="32dip"
android:layout_marginTop="12dip"
- android:layout_marginRight="12dip"
+ android:layout_marginStart="12dip"
android:layout_row="5"
android:layout_column="0"
+ android:labelFor="@id/range_options_spinner"
android:text="@string/label_pages"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textStyle="bold"
- android:labelFor="@id/range_options_spinner">
+ android:textAppearance="@style/PrintOptionTitleTextAppearance">
</TextView>
- <!-- Print pereview -->
-
- <ImageView
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="fill_horizontal"
- android:layout_marginLeft="32dip"
- android:layout_marginTop="32dip"
- android:layout_marginRight="32dip"
- android:layout_row="7"
- android:layout_column="0"
- android:layout_columnSpan="2"
- android:background="?android:attr/listDivider"
- android:contentDescription="@null">
- </ImageView>
-
- <Button
- android:id="@+id/print_preview_button"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="fill_horizontal"
- android:layout_marginLeft="32dip"
- android:layout_marginRight="32dip"
- android:layout_row="8"
- android:layout_column="0"
- android:layout_columnSpan="2"
- android:text="@string/print_preview"
- android:gravity="left|center_vertical"
- android:background="?android:attr/selectableItemBackground"
- android:minHeight="?android:attr/listPreferredItemHeight">
- </Button>
-
- <ImageView
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="fill_horizontal"
- android:layout_marginLeft="32dip"
- android:layout_marginRight="32dip"
- android:layout_marginBottom="32dip"
- android:layout_row="9"
- android:layout_column="0"
- android:layout_columnSpan="2"
- android:background="?android:attr/listDivider"
- android:contentDescription="@null">
- </ImageView>
-
</GridLayout>
</ScrollView>
+ <View
+ android:layout_width="fill_parent"
+ android:layout_height="1dip"
+ android:background="@color/separator">
+ </View>
+
<Button
android:id="@+id/print_button"
+ style="?android:attr/buttonBarButtonStyle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="fill_horizontal"
android:text="@string/print_button"
- style="?android:attr/buttonBarButtonStyle">
+ android:textSize="16sp"
+ android:textColor="@color/important_text">
</Button>
</LinearLayout>
android:id="@+id/content_generating"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:orientation="vertical"
- android:divider="?android:attr/dividerHorizontal"
- android:showDividers="middle">
+ android:orientation="vertical">
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- style="?android:attr/buttonBarButtonStyle"
- android:singleLine="true"
- android:ellipsize="end"
- android:textAlignment="viewStart"
- android:text="@string/generating_print_job" >
- </TextView>
-
- <ProgressBar
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_margin="32dip"
- android:layout_gravity="center_horizontal"
- style="?android:attr/progressBarStyleLarge">
- </ProgressBar>
+ <LinearLayout
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:background="@color/editable_background"
+ android:orientation="vertical">
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="16dip"
+ android:layout_marginEnd="16dip"
+ android:layout_gravity="center"
+ style="?android:attr/buttonBarButtonStyle"
+ android:singleLine="true"
+ android:ellipsize="end"
+ android:text="@string/generating_print_job"
+ android:textColor="@color/important_text"
+ android:textSize="16sp">
+ </TextView>
+
+ <ProgressBar
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="32dip"
+ android:layout_marginEnd="32dip"
+ android:layout_marginTop="16dip"
+ android:layout_marginBottom="32dip"
+ android:layout_gravity="center_horizontal"
+ style="?android:attr/progressBarStyleLarge">
+ </ProgressBar>
+
+ <View
+ android:layout_width="fill_parent"
+ android:layout_height="1dip"
+ android:background="@color/separator">
+ </View>
+
+ </LinearLayout>
<Button
android:id="@+id/cancel_button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="fill_horizontal"
- android:text="@string/cancel_button"
- style="?android:attr/buttonBarButtonStyle">
+ style="?android:attr/buttonBarButtonStyle"
+ android:text="@string/cancel"
+ android:textSize="16sp"
+ android:textColor="@color/important_text">
</Button>
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:paddingLeft="8dip"
- android:paddingRight="8dip"
+ android:paddingStart="8dip"
+ android:paddingEnd="8dip"
android:minHeight="?android:attr/listPreferredItemHeightSmall"
android:orientation="vertical"
- android:gravity="center_vertical">
+ android:gravity="left|center_vertical">
<TextView
android:id="@+id/title"
android:textAppearance="?android:attr/textAppearanceMedium"
android:singleLine="true"
android:ellipsize="end"
- android:textIsSelectable="false">
+ android:textIsSelectable="false"
+ android:gravity="top|left"
+ android:textColor="@color/important_text">
</TextView>
<TextView
android:singleLine="true"
android:ellipsize="end"
android:textIsSelectable="false"
- android:visibility="gone">
+ android:visibility="gone"
+ android:textColor="@color/important_text">
</TextView>
-->
<resources>
- <color name="print_job_config_activity_content_background">#FFF2F2F2</color>
+
+ <color name="container_background">#FFFFFF</color>
+ <color name="important_text">#333333</color>
+ <color name="print_option_title">#888888</color>
+ <color name="separator">#CCCCCC</color>
+ <color name="editable_background">#F2F2F2</color>
+
</resources>
\ No newline at end of file
<string name="app_label">Print Spooler</string>
<!-- Label of the print dialog's print button. [CHAR LIMIT=16] -->
- <string name="print_button">PRINT</string>
-
- <!-- Label of the print dialog's cancel button. [CHAR LIMIT=16] -->
- <string name="cancel_button">CANCEL</string>
+ <string name="print_button">Print</string>
<!-- Label of the destination widget. [CHAR LIMIT=20] -->
<string name="label_destination">DESTIINATION</string>
--- /dev/null
+<?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.
+-->
+
+<resources>
+
+ <style name="PrintOptionTitleTextAppearance">
+ <item name="android:textStyle">normal</item>
+ <item name="android:textSize">14sp</item>
+ <item name="android:textAllCaps">true</item>
+ <item name="android:textColor">@color/print_option_title</item>
+ </style>
+
+ <style name="PrintOptionSpinnerStyle">
+ <item name="android:paddingTop">0dip</item>
+ <item name="android:paddingBottom">0dip</item>
+ <item name="android:minWidth">150dip</item>
+ <item name="android:minHeight">?android:attr/listPreferredItemHeightSmall</item>
+ </style>
+
+</resources>
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
-import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.view.View;
import android.view.View.MeasureSpec;
import android.view.View.OnClickListener;
+import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;
-import android.widget.Toast;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
private static final int EDITOR_STATE_INITIALIZED = 1;
private static final int EDITOR_STATE_CONFIRMED_PRINT = 2;
- private static final int EDITOR_STATE_CONFIRMED_PREVIEW = 3;
+// private static final int EDITOR_STATE_CONFIRMED_PREVIEW = 3;
private static final int EDITOR_STATE_CANCELLED = 4;
private static final int MIN_COPIES = 1;
public boolean onTouchEvent(MotionEvent event) {
if (!mEditor.isPrintConfirmed() && !mEditor.isPreviewConfirmed()
- && getWindow().shouldCloseOnTouch(this, event)) {
+ && mEditor.shouldCloseOnTouch(event)) {
if (!mController.isWorking()) {
PrintJobConfigActivity.this.finish();
}
private final SimpleStringSplitter mStringCommaSplitter =
new SimpleStringSplitter(',');
- private final Button mPrintPreviewButton;
+ private final View mContentContainer;
private final Button mPrintButton;
private boolean mIgnoreNextRangeChange;
public Editor() {
+ // Content container
+ mContentContainer = findViewById(R.id.content_container);
+
// Copies
mCopiesEditText = (EditText) findViewById(R.id.copies_edittext);
mCopiesEditText.setText(String.valueOf(MIN_COPIES));
mRangeOptionsSpinner.setSelection(0);
}
- // Preview button
- mPrintPreviewButton = (Button) findViewById(R.id.print_preview_button);
- mPrintPreviewButton.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- mEditor.confirmPreview();
- // TODO: Implement me
- Toast.makeText(PrintJobConfigActivity.this,
- "Stop poking me! Not implemented yet :)",
- Toast.LENGTH_LONG).show();
- }
- });
-
// Print button
mPrintButton = (Button) findViewById(R.id.print_button);
mPrintButton.setOnClickListener(new OnClickListener() {
updateUi();
}
+ public boolean shouldCloseOnTouch(MotionEvent event) {
+ if (event.getAction() != MotionEvent.ACTION_DOWN) {
+ return false;
+ }
+
+ final int[] locationInWindow = new int[2];
+ mContentContainer.getLocationInWindow(locationInWindow);
+
+ final int windowTouchSlop = ViewConfiguration.get(PrintJobConfigActivity.this)
+ .getScaledWindowTouchSlop();
+ final int eventX = (int) event.getX();
+ final int eventY = (int) event.getY();
+ final int lenientWindowLeft = locationInWindow[0] - windowTouchSlop;
+ final int lenientWindowRight = lenientWindowLeft + mContentContainer.getWidth()
+ + windowTouchSlop;
+ final int lenientWindowTop = locationInWindow[1] - windowTouchSlop;
+ final int lenientWindowBottom = lenientWindowTop + mContentContainer.getHeight()
+ + windowTouchSlop;
+
+ if (eventX < lenientWindowLeft || eventX > lenientWindowRight
+ || eventY < lenientWindowTop || eventY > lenientWindowBottom) {
+ return true;
+ }
+ return false;
+ }
+
public boolean isShwoingGeneratingPrintJobUi() {
return (findViewById(R.id.content_generating) != null);
}
});
// First animation - fade out the old content.
- contentEditing.animate().alpha(0.0f).withEndAction(new Runnable() {
+ contentEditing.animate().alpha(0.0f).withLayer().withEndAction(new Runnable() {
@Override
public void run() {
contentEditing.setVisibility(View.INVISIBLE);
/ (float) contentContainer.getHeight();
// Second animation - resize the container.
- contentContainer.animate().scaleY(scaleY).withEndAction(
+ contentContainer.animate().scaleY(scaleY).withLayer().withEndAction(
new Runnable() {
@Override
public void run() {
contentContainer.addView(contentGenerating);
// Third animation - show the new content.
- contentGenerating.animate().alpha(1.0f);
+ contentGenerating.animate().withLayer().alpha(1.0f);
}
});
}
return mEditorState == EDITOR_STATE_CONFIRMED_PRINT;
}
- public void confirmPreview() {
- mEditorState = EDITOR_STATE_CONFIRMED_PREVIEW;
- }
+// public void confirmPreview() {
+// mEditorState = EDITOR_STATE_CONFIRMED_PREVIEW;
+// }
public PageRange[] getRequestedPages() {
if (hasErrors()) {
mOrientationSpinner.setEnabled(false);
mRangeOptionsSpinner.setEnabled(false);
mRangeEditText.setEnabled(false);
- mPrintPreviewButton.setEnabled(false);
+ // TODO: Remove entirely or implement print preview.
+// mPrintPreviewButton.setEnabled(false);
mPrintButton.setEnabled(false);
return;
}
mRangeEditText.setEnabled(false);
mRangeEditText.setVisibility(View.INVISIBLE);
- // Print preview
- mPrintPreviewButton.setEnabled(false);
- mPrintPreviewButton.setText(getString(R.string.print_preview));
+// // Print preview
+// mPrintPreviewButton.setEnabled(false);
+// mPrintPreviewButton.setText(getString(R.string.print_preview));
// Print
mPrintButton.setEnabled(false);
&& (TextUtils.isEmpty(mRangeEditText.getText()) || hasErrors()))
|| (mRangeOptionsSpinner.getSelectedItemPosition() == 0
&& (!mController.hasPerformedLayout() || hasErrors()))) {
- mPrintPreviewButton.setEnabled(false);
+// mPrintPreviewButton.setEnabled(false);
mPrintButton.setEnabled(false);
} else {
- mPrintPreviewButton.setEnabled(true);
- if (hasPdfViewer()) {
- mPrintPreviewButton.setText(getString(R.string.print_preview));
- } else {
- mPrintPreviewButton.setText(getString(R.string.install_for_print_preview));
- }
+// mPrintPreviewButton.setEnabled(true);
+// if (hasPdfViewer()) {
+// mPrintPreviewButton.setText(getString(R.string.print_preview));
+// } else {
+// mPrintPreviewButton.setText(getString(R.string.install_for_print_preview));
+// }
mPrintButton.setEnabled(true);
}
|| mCopiesEditText.getError() != null;
}
- private boolean hasPdfViewer() {
- Intent intent = new Intent(Intent.ACTION_VIEW);
- intent.setType("application/pdf");
- return !getPackageManager().queryIntentActivities(intent,
- PackageManager.MATCH_DEFAULT_ONLY).isEmpty();
- }
+// private boolean hasPdfViewer() {
+// Intent intent = new Intent(Intent.ACTION_VIEW);
+// intent.setType("application/pdf");
+// return !getPackageManager().queryIntentActivities(intent,
+// PackageManager.MATCH_DEFAULT_ONLY).isEmpty();
+// }
private final class SpinnerItem<T> {
final T value;