<activity
android:name=".PrintJobConfigActivity"
- android:exported="true"
- android:theme="@android:style/Theme.Holo.Light.Dialog.NoActionBar">
+ android:exported="false"
+ android:theme="@style/PrintJobConfigActivityTheme">
</activity>
<receiver
limitations under the License.
-->
-<ProgressBar xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/progress"
- android:layout_width="fill_parent"
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/content_container"
+ android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_margin="16dip"
- android:layout_gravity="center_horizontal"
- style="?android:attr/progressBarStyleLarge">
-</ProgressBar>
+ android:layout_gravity="center"
+ android:background="@color/print_job_config_activity_content_background">
+
+ <include
+ layout="@layout/print_job_config_activity_content_editing">
+ </include>
+
+</FrameLayout>
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
+ android:id="@+id/content_editing"
+ android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:orientation="vertical">
+ android:orientation="vertical"
+ android:divider="?android:attr/dividerHorizontal"
+ android:showDividers="middle">
<ScrollView
- android:layout_width="fill_parent"
+ android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:scrollbars="vertical">
android:contentDescription="@null">
</ImageView>
- <ImageView
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="fill_horizontal"
- android:layout_row="10"
- android:layout_column="0"
- android:layout_columnSpan="2"
- android:background="?android:attr/listDivider"
- android:contentDescription="@null">
- </ImageView>
-
</GridLayout>
</ScrollView>
--- /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.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ 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">
+
+ <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>
+
+ <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">
+ </Button>
+
+</LinearLayout>
--- /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>
+ <color name="print_job_config_activity_content_background">#FFF2F2F2</color>
+</resources>
\ No newline at end of file
<!-- 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>
+
<!-- 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="PrintJobConfigActivityTheme" parent="@android:style/Theme.Holo.Light.NoActionBar">
+ <item name="android:windowBackground">@android:color/transparent</item>
+ <item name="android:windowSoftInputMode">stateAlwaysHidden|adjustPan</item>
+ <item name="android:windowIsTranslucent">true</item>
+ <item name="android:backgroundDimEnabled">true</item>
+ <item name="android:colorBackgroundCacheHint">@android:color/transparent</item>
+ </style>
+
+</resources>
private void createPrintingNotificaiton(PrintJobInfo printJob) {
Notification.Builder builder = new Notification.Builder(mContext)
- // TODO: Use appropriate icon when assets are ready
- .setSmallIcon(android.R.drawable.ic_secure)
+ .setSmallIcon(R.drawable.stat_notify_print)
.setContentTitle(mContext.getString(R.string.printing_notification_title_template,
printJob.getLabel()))
- // TODO: Use appropriate icon when assets are ready
- .addAction(android.R.drawable.ic_secure, mContext.getString(R.string.cancel),
+ .addAction(R.drawable.stat_notify_cancelling, mContext.getString(R.string.cancel),
createCancelIntent(printJob))
.setContentText(printJob.getPrinterId().getPrinterName())
.setWhen(System.currentTimeMillis())
private void createFailedNotificaiton(PrintJobInfo printJob) {
Notification.Builder builder = new Notification.Builder(mContext)
- // TODO: Use appropriate icon when assets are ready
- .setSmallIcon(android.R.drawable.ic_secure)
+ .setSmallIcon(R.drawable.stat_notify_error)
.setContentTitle(mContext.getString(R.string.failed_notification_title_template,
printJob.getLabel()))
- // TODO: Use appropriate icon when assets are ready
- .addAction(android.R.drawable.ic_secure, mContext.getString(R.string.cancel),
+ .addAction(R.drawable.stat_notify_cancelling, mContext.getString(R.string.cancel),
createCancelIntent(printJob))
// TODO: Use appropriate icon when assets are ready
.addAction(android.R.drawable.ic_secure, mContext.getString(R.string.restart),
NotificationManager notificationManager = (NotificationManager)
context.getSystemService(Context.NOTIFICATION_SERVICE);
Notification.Builder builder = new Notification.Builder(context)
- // TODO: Use appropriate icon when assets are ready
- .setSmallIcon(android.R.drawable.ic_secure)
+ .setSmallIcon(R.drawable.stat_notify_cancelling)
.setContentTitle(context.getString(
R.string.cancelling_notification_title_template,
printJobLabel))
package com.android.printspooler;
import android.app.Activity;
-import android.app.AlertDialog;
import android.app.Dialog;
-import android.app.DialogFragment;
import android.content.Context;
-import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
+import android.view.View.MeasureSpec;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.WindowManager;
@Override
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
- setContentView(R.layout.print_job_config_activity);
+ setContentView(R.layout.print_job_config_activity_container);
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
}
public boolean onKeyUp(int keyCode, KeyEvent event) {
- if (keyCode == KeyEvent.KEYCODE_BACK && event.isTracking()
- && !event.isCanceled()) {
- if (!mController.isWorking()) {
- PrintJobConfigActivity.this.finish();
+ if (keyCode == KeyEvent.KEYCODE_BACK) {
+ if (mEditor.isShwoingGeneratingPrintJobUi()) {
+ return true;
+ }
+ if (event.isTracking() && !event.isCanceled()) {
+ if (!mController.isWorking()) {
+ PrintJobConfigActivity.this.finish();
+ }
}
mEditor.cancel();
return true;
return !mOldPrintAttributes.equals(mCurrPrintAttributes);
}
- private void showGeneratingPrintJobUi() {
- getWindow().getDecorView().setVisibility(View.GONE);
-
- DialogFragment fragment = new DialogFragment() {
- @Override
- public Dialog onCreateDialog(Bundle savedInstanceState) {
- return new AlertDialog.Builder(PrintJobConfigActivity.this)
- .setTitle(getString(R.string.generating_print_job))
- .setView(PrintJobConfigActivity.this.getLayoutInflater().inflate(
- R.layout.generating_print_job_dialog, null))
- .setCancelable(false)
- .setPositiveButton(getString(R.string.cancel),
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- mEditor.cancel();
- PrintJobConfigActivity.this.finish();
- }
- })
- .create();
- }
- };
- fragment.show(getFragmentManager(), getString(R.string.generating_print_job));
- }
-
private class PrintController {
private final AtomicInteger mRequestCounter = new AtomicInteger();
updateUi();
}
+ public boolean isShwoingGeneratingPrintJobUi() {
+ return (findViewById(R.id.content_generating) != null);
+ }
+
+ private void showGeneratingPrintJobUi() {
+ // Find everything we will shuffle around.
+ final ViewGroup contentContainer = (ViewGroup) findViewById(R.id.content_container);
+ final View contentEditing = contentContainer.findViewById(R.id.content_editing);
+ final View contentGenerating = getLayoutInflater().inflate(
+ R.layout.print_job_config_activity_content_generating,
+ contentContainer, false);
+
+ // Wire the cancel action.
+ Button cancelButton = (Button) contentGenerating.findViewById(R.id.cancel_button);
+ cancelButton.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (!mController.isWorking()) {
+ PrintJobConfigActivity.this.finish();
+ }
+ mEditor.cancel();
+ }
+ });
+
+ // First animation - fade out the old content.
+ contentEditing.animate().alpha(0.0f).withEndAction(new Runnable() {
+ @Override
+ public void run() {
+ contentEditing.setVisibility(View.INVISIBLE);
+
+ // Prepare the new content with correct size and alpha.
+ contentGenerating.setMinimumWidth(contentContainer.getWidth());
+ contentGenerating.setAlpha(0.0f);
+
+ // Compute how to much shrink the container to fit around the new content.
+ final int widthSpec = MeasureSpec.makeMeasureSpec(
+ contentContainer.getWidth(), MeasureSpec.AT_MOST);
+ final int heightSpec = MeasureSpec.makeMeasureSpec(
+ contentContainer.getHeight(), MeasureSpec.AT_MOST);
+ contentGenerating.measure(widthSpec, heightSpec);
+ final float scaleY = (float) contentGenerating.getMeasuredHeight()
+ / (float) contentContainer.getHeight();
+
+ // Second animation - resize the container.
+ contentContainer.animate().scaleY(scaleY).withEndAction(
+ new Runnable() {
+ @Override
+ public void run() {
+ // Swap the old and the new content.
+ contentContainer.removeAllViews();
+ contentContainer.setScaleY(1.0f);
+ contentContainer.addView(contentGenerating);
+
+ // Third animation - show the new content.
+ contentGenerating.animate().alpha(1.0f);
+ }
+ });
+ }
+ });
+ }
+
public void initialize() {
mEditorState = EDITOR_STATE_INITIALIZED;
if (mDestinationSpinner.getSelectedItemPosition() != AdapterView.INVALID_POSITION) {