Extend the TimePickerDialog test to cover 12- and 24-hour clocks.

Used to test https://android-review.googlesource.com/54121.

Change-Id: Ibf8418f21a7c242aac27c7e05b4990149c8305b3
diff --git a/samples/ApiDemos/res/layout/date_widgets_example_1.xml b/samples/ApiDemos/res/layout/date_widgets_example_1.xml
index b9db6a0..9313cdf 100644
--- a/samples/ApiDemos/res/layout/date_widgets_example_1.xml
+++ b/samples/ApiDemos/res/layout/date_widgets_example_1.xml
@@ -32,9 +32,14 @@
             android:layout_height="wrap_content"
             android:text="@string/date_widgets_example_pickDate_text"/>
 
-    <Button android:id="@+id/pickTime"
+    <Button android:id="@+id/pickTime12"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            android:text="@string/date_widgets_example_pickTime_text"/>
+            android:text="@string/date_widgets_example_pickTime12_text"/>
+
+    <Button android:id="@+id/pickTime24"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:text="@string/date_widgets_example_pickTime24_text"/>
 
 </LinearLayout>
diff --git a/samples/ApiDemos/res/values/strings.xml b/samples/ApiDemos/res/values/strings.xml
index ee1241e..fef41f5 100644
--- a/samples/ApiDemos/res/values/strings.xml
+++ b/samples/ApiDemos/res/values/strings.xml
@@ -1312,7 +1312,8 @@
     <string name="text_switcher_1_next_text">Next</string>
 
     <string name="date_widgets_example_dateDisplay_text"></string>
-    <string name="date_widgets_example_pickTime_text">change the time</string>
+    <string name="date_widgets_example_pickTime12_text">change the time (12 hour)</string>
+    <string name="date_widgets_example_pickTime24_text">change the time (24 hour)</string>
     <string name="date_widgets_example_pickDate_text">change the date</string>
 
     <string name="buttons_1_normal">Normal</string>
diff --git a/samples/ApiDemos/src/com/example/android/apis/view/DateWidgets1.java b/samples/ApiDemos/src/com/example/android/apis/view/DateWidgets1.java
index f0b1d22..537bda8 100644
--- a/samples/ApiDemos/src/com/example/android/apis/view/DateWidgets1.java
+++ b/samples/ApiDemos/src/com/example/android/apis/view/DateWidgets1.java
@@ -51,8 +51,9 @@
     private int mHour;
     private int mMinute;
 
-    static final int TIME_DIALOG_ID = 0;
-    static final int DATE_DIALOG_ID = 1;
+    static final int TIME_12_DIALOG_ID = 0;
+    static final int TIME_24_DIALOG_ID = 1;
+    static final int DATE_DIALOG_ID = 2;
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
@@ -62,21 +63,9 @@
 
         mDateDisplay = (TextView) findViewById(R.id.dateDisplay);
 
-        Button pickDate = (Button) findViewById(R.id.pickDate);
-        pickDate.setOnClickListener(new View.OnClickListener() {
-
-            public void onClick(View v) {
-                showDialog(DATE_DIALOG_ID);
-            }
-        });
-
-        Button pickTime = (Button) findViewById(R.id.pickTime);
-        pickTime.setOnClickListener(new View.OnClickListener() {
-
-            public void onClick(View v) {
-                showDialog(TIME_DIALOG_ID);
-            }
-        });
+        setDialogOnClickListener(R.id.pickDate, DATE_DIALOG_ID);
+        setDialogOnClickListener(R.id.pickTime12, TIME_12_DIALOG_ID);
+        setDialogOnClickListener(R.id.pickTime24, TIME_24_DIALOG_ID);
 
         final Calendar c = Calendar.getInstance();
         mYear = c.get(Calendar.YEAR);
@@ -88,12 +77,22 @@
         updateDisplay();
     }
 
+    private void setDialogOnClickListener(int buttonId, final int dialogId) {
+        Button b = (Button) findViewById(buttonId);
+        b.setOnClickListener(new View.OnClickListener() {
+            public void onClick(View v) {
+                showDialog(dialogId);
+            }
+        });
+    }
+
     @Override
     protected Dialog onCreateDialog(int id) {
         switch (id) {
-            case TIME_DIALOG_ID:
+            case TIME_12_DIALOG_ID:
+            case TIME_24_DIALOG_ID:
                 return new TimePickerDialog(this,
-                        mTimeSetListener, mHour, mMinute, false);
+                        mTimeSetListener, mHour, mMinute, id == TIME_24_DIALOG_ID);
             case DATE_DIALOG_ID:
                 return new DatePickerDialog(this,
                             mDateSetListener,
@@ -105,7 +104,8 @@
     @Override
     protected void onPrepareDialog(int id, Dialog dialog) {
         switch (id) {
-            case TIME_DIALOG_ID:
+            case TIME_12_DIALOG_ID:
+            case TIME_24_DIALOG_ID:
                 ((TimePickerDialog) dialog).updateTime(mHour, mMinute);
                 break;
             case DATE_DIALOG_ID: