Update the print job dialog and added notification assets.

1. Update the transition between the print job edit dialog and the
   generating print job dialog. Now the former shrinks into the
   latter.

2. Added most of the notification assets.

Change-Id: I84f35df5cb4f71b86a103c16ab87fd4d108b055b
diff --git a/packages/PrintSpooler/AndroidManifest.xml b/packages/PrintSpooler/AndroidManifest.xml
index 72d064a..74fd7a8 100644
--- a/packages/PrintSpooler/AndroidManifest.xml
+++ b/packages/PrintSpooler/AndroidManifest.xml
@@ -46,8 +46,8 @@
 
         <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
diff --git a/packages/PrintSpooler/res/drawable-hdpi/stat_notify_cancelling.png b/packages/PrintSpooler/res/drawable-hdpi/stat_notify_cancelling.png
new file mode 100644
index 0000000..2757db0
--- /dev/null
+++ b/packages/PrintSpooler/res/drawable-hdpi/stat_notify_cancelling.png
Binary files differ
diff --git a/packages/PrintSpooler/res/drawable-hdpi/stat_notify_error.png b/packages/PrintSpooler/res/drawable-hdpi/stat_notify_error.png
new file mode 100644
index 0000000..7846a78
--- /dev/null
+++ b/packages/PrintSpooler/res/drawable-hdpi/stat_notify_error.png
Binary files differ
diff --git a/packages/PrintSpooler/res/drawable-hdpi/stat_notify_print.png b/packages/PrintSpooler/res/drawable-hdpi/stat_notify_print.png
new file mode 100644
index 0000000..aaff3dd
--- /dev/null
+++ b/packages/PrintSpooler/res/drawable-hdpi/stat_notify_print.png
Binary files differ
diff --git a/packages/PrintSpooler/res/drawable-mdpi/stat_notify_cancelling.png b/packages/PrintSpooler/res/drawable-mdpi/stat_notify_cancelling.png
new file mode 100644
index 0000000..c1b380a
--- /dev/null
+++ b/packages/PrintSpooler/res/drawable-mdpi/stat_notify_cancelling.png
Binary files differ
diff --git a/packages/PrintSpooler/res/drawable-mdpi/stat_notify_error.png b/packages/PrintSpooler/res/drawable-mdpi/stat_notify_error.png
new file mode 100644
index 0000000..44109eb
--- /dev/null
+++ b/packages/PrintSpooler/res/drawable-mdpi/stat_notify_error.png
Binary files differ
diff --git a/packages/PrintSpooler/res/drawable-mdpi/stat_notify_print.png b/packages/PrintSpooler/res/drawable-mdpi/stat_notify_print.png
new file mode 100644
index 0000000..a3954b5
--- /dev/null
+++ b/packages/PrintSpooler/res/drawable-mdpi/stat_notify_print.png
Binary files differ
diff --git a/packages/PrintSpooler/res/drawable-xhdpi/stat_notify_cancelling.png b/packages/PrintSpooler/res/drawable-xhdpi/stat_notify_cancelling.png
new file mode 100644
index 0000000..fedc00e
--- /dev/null
+++ b/packages/PrintSpooler/res/drawable-xhdpi/stat_notify_cancelling.png
Binary files differ
diff --git a/packages/PrintSpooler/res/drawable-xhdpi/stat_notify_error.png b/packages/PrintSpooler/res/drawable-xhdpi/stat_notify_error.png
new file mode 100644
index 0000000..c3faa42
--- /dev/null
+++ b/packages/PrintSpooler/res/drawable-xhdpi/stat_notify_error.png
Binary files differ
diff --git a/packages/PrintSpooler/res/drawable-xhdpi/stat_notify_print.png b/packages/PrintSpooler/res/drawable-xhdpi/stat_notify_print.png
new file mode 100644
index 0000000..6b55a14
--- /dev/null
+++ b/packages/PrintSpooler/res/drawable-xhdpi/stat_notify_print.png
Binary files differ
diff --git a/packages/PrintSpooler/res/layout/generating_print_job_dialog.xml b/packages/PrintSpooler/res/layout/print_job_config_activity_container.xml
similarity index 65%
rename from packages/PrintSpooler/res/layout/generating_print_job_dialog.xml
rename to packages/PrintSpooler/res/layout/print_job_config_activity_container.xml
index 360f8434..e36b8b5 100644
--- a/packages/PrintSpooler/res/layout/generating_print_job_dialog.xml
+++ b/packages/PrintSpooler/res/layout/print_job_config_activity_container.xml
@@ -14,11 +14,15 @@
      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>
diff --git a/packages/PrintSpooler/res/layout/print_job_config_activity.xml b/packages/PrintSpooler/res/layout/print_job_config_activity_content_editing.xml
similarity index 94%
rename from packages/PrintSpooler/res/layout/print_job_config_activity.xml
rename to packages/PrintSpooler/res/layout/print_job_config_activity_content_editing.xml
index 1a8b0f1..77ef5a2 100644
--- a/packages/PrintSpooler/res/layout/print_job_config_activity.xml
+++ b/packages/PrintSpooler/res/layout/print_job_config_activity_content_editing.xml
@@ -15,12 +15,15 @@
 -->
 
 <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">
@@ -262,17 +265,6 @@
                 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>
diff --git a/packages/PrintSpooler/res/layout/print_job_config_activity_content_generating.xml b/packages/PrintSpooler/res/layout/print_job_config_activity_content_generating.xml
new file mode 100644
index 0000000..6352afc
--- /dev/null
+++ b/packages/PrintSpooler/res/layout/print_job_config_activity_content_generating.xml
@@ -0,0 +1,52 @@
+<?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>
diff --git a/packages/PrintSpooler/res/layout/generating_print_job_dialog.xml b/packages/PrintSpooler/res/values/colors.xml
similarity index 61%
copy from packages/PrintSpooler/res/layout/generating_print_job_dialog.xml
copy to packages/PrintSpooler/res/values/colors.xml
index 360f8434..3d8ba223 100644
--- a/packages/PrintSpooler/res/layout/generating_print_job_dialog.xml
+++ b/packages/PrintSpooler/res/values/colors.xml
@@ -5,7 +5,7 @@
      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
+          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,
@@ -14,11 +14,6 @@
      limitations under the License.
 -->
 
-<ProgressBar xmlns:android="http://schemas.android.com/apk/res/android"
-    android:id="@+id/progress"
-    android:layout_width="fill_parent"
-    android:layout_height="wrap_content"
-    android:layout_margin="16dip"
-    android:layout_gravity="center_horizontal"
-    style="?android:attr/progressBarStyleLarge">
-</ProgressBar>
+<resources>
+    <color name="print_job_config_activity_content_background">#FFF2F2F2</color>
+</resources>
\ No newline at end of file
diff --git a/packages/PrintSpooler/res/values/strings.xml b/packages/PrintSpooler/res/values/strings.xml
index fbddf43..8391509 100644
--- a/packages/PrintSpooler/res/values/strings.xml
+++ b/packages/PrintSpooler/res/values/strings.xml
@@ -22,6 +22,9 @@
     <!-- 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>
 
diff --git a/packages/PrintSpooler/res/values/themes.xml b/packages/PrintSpooler/res/values/themes.xml
new file mode 100644
index 0000000..ab16c65
--- /dev/null
+++ b/packages/PrintSpooler/res/values/themes.xml
@@ -0,0 +1,27 @@
+<?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>
diff --git a/packages/PrintSpooler/src/com/android/printspooler/NotificationController.java b/packages/PrintSpooler/src/com/android/printspooler/NotificationController.java
index 8b49c0e..130320b 100644
--- a/packages/PrintSpooler/src/com/android/printspooler/NotificationController.java
+++ b/packages/PrintSpooler/src/com/android/printspooler/NotificationController.java
@@ -81,12 +81,10 @@
 
     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())
@@ -97,12 +95,10 @@
 
     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),
@@ -161,8 +157,7 @@
             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))
diff --git a/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java b/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
index 00a76b8..824815f 100644
--- a/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
+++ b/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
@@ -17,11 +17,8 @@
 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;
@@ -57,6 +54,7 @@
 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;
@@ -147,7 +145,7 @@
     @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);
 
@@ -234,10 +232,14 @@
     }
 
     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;
@@ -249,31 +251,6 @@
         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();
 
@@ -915,6 +892,67 @@
             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) {