Extend DialogActivity API demo to show off new window re-measuring.

Change-Id: Ia04dbf95131d5cffbdd3ae0c22758da7f6d28a1b
diff --git a/samples/ApiDemos/AndroidManifest.xml b/samples/ApiDemos/AndroidManifest.xml
index b425eaa..81dea15 100644
--- a/samples/ApiDemos/AndroidManifest.xml
+++ b/samples/ApiDemos/AndroidManifest.xml
@@ -75,7 +75,7 @@
 
         <activity android:name=".app.DialogActivity"
                 android:label="@string/activity_dialog"
-                android:theme="@android:style/Theme.Dialog">
+                android:theme="@android:style/Theme.Holo.Dialog">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.SAMPLE_CODE" />
diff --git a/samples/ApiDemos/res/layout/dialog_activity.xml b/samples/ApiDemos/res/layout/dialog_activity.xml
index 2b27d9a..b3a5689 100644
--- a/samples/ApiDemos/res/layout/dialog_activity.xml
+++ b/samples/ApiDemos/res/layout/dialog_activity.xml
@@ -17,8 +17,28 @@
 <!-- Demonstrates an activity with a dialog theme.
      See corresponding Java code com.android.sdk.app.DialogActivity.java. -->
 
-<!-- This screen consists of a single text field that displays some text. -->
-<TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/text"
-    android:layout_width="match_parent" android:layout_height="match_parent"
-    android:gravity="center_vertical|center_horizontal"
-    android:text="@string/dialog_activity_text"/>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+        android:layout_width="match_parent" android:layout_height="match_parent"
+        android:orientation="vertical"
+        android:padding="4dip" android:gravity="center_horizontal">
+    <TextView android:id="@+id/text"
+        android:layout_width="wrap_content" android:layout_height="wrap_content"
+        android:gravity="center_vertical|center_horizontal"
+        android:text="@string/dialog_activity_text"/>
+    <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content"
+            android:orientation="horizontal" android:paddingTop="4dip">
+        <Button android:id="@+id/add"
+            android:layout_width="wrap_content" android:layout_height="wrap_content"
+            android:text="@string/dialog_activity_add">
+            <requestFocus />
+        </Button>
+        <Button android:id="@+id/remove"
+            android:layout_width="wrap_content" android:layout_height="wrap_content"
+            android:text="@string/dialog_activity_remove">
+        </Button>
+    </LinearLayout>
+    <LinearLayout android:id="@+id/inner_content"
+            android:layout_width="wrap_content" android:layout_height="wrap_content"
+            android:orientation="horizontal" android:paddingTop="4dip">
+    </LinearLayout>
+</LinearLayout>
diff --git a/samples/ApiDemos/res/layout/foreground_service_controller.xml b/samples/ApiDemos/res/layout/foreground_service_controller.xml
index 20ce103..076d4a3 100644
--- a/samples/ApiDemos/res/layout/foreground_service_controller.xml
+++ b/samples/ApiDemos/res/layout/foreground_service_controller.xml
@@ -17,9 +17,10 @@
 <!-- Demonstrates starting and stopping a local service.
      See corresponding Java code com.android.sdk.app.LocalSerice.java. -->
 
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:padding="4dip"
-    android:gravity="center_horizontal"
-    android:layout_width="match_parent" android:layout_height="match_parent">
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+        android:orientation="vertical" android:padding="4dip"
+        android:gravity="center_horizontal"
+        android:layout_width="match_parent" android:layout_height="match_parent">
 
     <TextView
         android:layout_width="match_parent" android:layout_height="wrap_content"
diff --git a/samples/ApiDemos/res/values/strings.xml b/samples/ApiDemos/res/values/strings.xml
index 4eb54c2..998caec 100644
--- a/samples/ApiDemos/res/values/strings.xml
+++ b/samples/ApiDemos/res/values/strings.xml
@@ -31,7 +31,10 @@
     <string name="activity_dialog">App/Activity/Dialog</string>
     <string name="dialog_activity_text">Example of how you can use the
             Theme.Dialog theme to make an activity that looks like a
-            dialog.</string>
+            dialog.  It also has lots of text to show how text wrapping (and
+            corresponding window size adjustment) can happen in a dialog.</string>
+    <string name="dialog_activity_add">Add content</string>
+    <string name="dialog_activity_remove">Remove content</string>
     <string name="activity_custom_dialog">App/Activity/Custom Dialog</string>
     <string name="custom_dialog_activity_text">Example of how you can use a
             custom Theme.Dialog theme to make an activity that looks like a
@@ -372,7 +375,7 @@
     <!--  app/dialog examples strings  -->
     <!-- ============================== -->
 
-    <string name="activity_alert_dialog">App/Dialog</string>
+    <string name="activity_alert_dialog">App/Alert Dialogs</string>
     <string name="alert_dialog_two_buttons">OK Cancel dialog with a message</string>
     <string name="alert_dialog_two_buttons2">OK Cancel dialog with a long message</string>
     <string name="alert_dialog_two_buttons2ultra">OK Cancel dialog with ultra long message</string>
diff --git a/samples/ApiDemos/src/com/example/android/apis/app/DialogActivity.java b/samples/ApiDemos/src/com/example/android/apis/app/DialogActivity.java
index 7441b75..0a6b724 100644
--- a/samples/ApiDemos/src/com/example/android/apis/app/DialogActivity.java
+++ b/samples/ApiDemos/src/com/example/android/apis/app/DialogActivity.java
@@ -19,10 +19,17 @@
 // Need the following import to get access to the app resources, since this
 // class is in a sub-package.
 import android.app.Activity;
+import android.content.Intent;
 import android.os.Bundle;
+import android.view.View;
 import android.view.Window;
+import android.view.View.OnClickListener;
+import android.widget.Button;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
 
 import com.example.android.apis.R;
+import com.example.android.apis.app.ForegroundService.Controller;
 
 /**
  * <h3>Dialog Activity</h3>
@@ -50,5 +57,30 @@
         
         getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, 
                 android.R.drawable.ic_dialog_alert);
+
+        Button button = (Button)findViewById(R.id.add);
+        button.setOnClickListener(mAddContentListener);
+        button = (Button)findViewById(R.id.remove);
+        button.setOnClickListener(mRemoveContentListener);
     }
+
+    private OnClickListener mAddContentListener = new OnClickListener() {
+        public void onClick(View v) {
+            LinearLayout layout = (LinearLayout)findViewById(R.id.inner_content);
+            ImageView iv = new ImageView(DialogActivity.this);
+            iv.setImageDrawable(getResources().getDrawable(R.drawable.icon48x48_1));
+            iv.setPadding(4, 4, 4, 4);
+            layout.addView(iv);
+        }
+    };
+
+    private OnClickListener mRemoveContentListener = new OnClickListener() {
+        public void onClick(View v) {
+            LinearLayout layout = (LinearLayout)findViewById(R.id.inner_content);
+            int num = layout.getChildCount();
+            if (num > 0) {
+                layout.removeViewAt(num-1);
+            }
+        }
+    };
 }