Update alert dialogs in ApiDemos for Material theme

BUG: 17415772
Change-Id: Ifc1de793458f678a3c40b734d5ab08b2eb382f7a
This commit is contained in:
Alan Viverette
2014-09-07 17:45:26 -07:00
parent 53f6e127b0
commit b4ced6163b
4 changed files with 58 additions and 41 deletions

View File

@@ -38,6 +38,9 @@
<Button android:id="@+id/progress_button"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:text="@string/alert_dialog_progress_button"/>
<Button android:id="@+id/progress_spinner_button"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:text="@string/alert_dialog_progress_spinner_button"/>
<Button android:id="@+id/radio_button"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:text="@string/alert_dialog_single_choice"/>

View File

@@ -17,14 +17,14 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="24dp"
android:paddingEnd="24dp"
android:orientation="vertical">
<TextView
android:id="@+id/username_view"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:text="@string/alert_dialog_username"
android:gravity="left"
android:textAppearance="?android:attr/textAppearanceMedium" />
@@ -33,8 +33,6 @@
android:id="@+id/username_edit"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:scrollHorizontally="true"
android:autoText="false"
android:capitalize="none"
@@ -45,8 +43,6 @@
android:id="@+id/password_view"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:text="@string/alert_dialog_password"
android:gravity="left"
android:textAppearance="?android:attr/textAppearanceMedium" />
@@ -55,8 +51,6 @@
android:id="@+id/password_edit"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:scrollHorizontally="true"
android:autoText="false"
android:capitalize="none"

View File

@@ -530,7 +530,8 @@
<string name="alert_dialog_single_choice">Single choice list</string>
<string name="alert_dialog_multi_choice">Repeat alarm</string>
<string name="alert_dialog_multi_choice_cursor">Send Call to VoiceMail</string>
<string name="alert_dialog_progress_button">Progress dialog</string>
<string name="alert_dialog_progress_button">Progress bar dialog</string>
<string name="alert_dialog_progress_spinner_button">Progress spinner dialog</string>
<string name="alert_dialog_text_entry">Text Entry dialog</string>
<string name="alert_dialog_username">Name:</string>
<string name="alert_dialog_password">Password:</string>

View File

@@ -69,9 +69,11 @@ public class AlertDialogSamples extends Activity {
private static final int DIALOG_YES_NO_HOLO_LIGHT_MESSAGE = 11;
private static final int DIALOG_YES_NO_DEFAULT_LIGHT_MESSAGE = 12;
private static final int DIALOG_YES_NO_DEFAULT_DARK_MESSAGE = 13;
private static final int DIALOG_PROGRESS_SPINNER = 14;
private static final int MAX_PROGRESS = 100;
private ProgressDialog mProgressSpinnerDialog;
private ProgressDialog mProgressDialog;
private int mProgress;
private Handler mProgressHandler;
@@ -81,7 +83,6 @@ public class AlertDialogSamples extends Activity {
switch (id) {
case DIALOG_YES_NO_MESSAGE:
return new AlertDialog.Builder(AlertDialogSamples.this)
.setIconAttribute(android.R.attr.alertDialogIcon)
.setTitle(R.string.alert_dialog_two_buttons_title)
.setPositiveButton(R.string.alert_dialog_ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
@@ -124,7 +125,6 @@ public class AlertDialogSamples extends Activity {
.create();
case DIALOG_YES_NO_DEFAULT_LIGHT_MESSAGE:
return new AlertDialog.Builder(AlertDialogSamples.this, AlertDialog.THEME_DEVICE_DEFAULT_LIGHT)
.setIconAttribute(android.R.attr.alertDialogIcon)
.setTitle(R.string.alert_dialog_two_buttons_title)
.setPositiveButton(R.string.alert_dialog_ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
@@ -137,7 +137,6 @@ public class AlertDialogSamples extends Activity {
.create();
case DIALOG_YES_NO_DEFAULT_DARK_MESSAGE:
return new AlertDialog.Builder(AlertDialogSamples.this, AlertDialog.THEME_DEVICE_DEFAULT_DARK)
.setIconAttribute(android.R.attr.alertDialogIcon)
.setTitle(R.string.alert_dialog_two_buttons_title)
.setPositiveButton(R.string.alert_dialog_ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
@@ -150,7 +149,6 @@ public class AlertDialogSamples extends Activity {
.create();
case DIALOG_YES_NO_LONG_MESSAGE:
return new AlertDialog.Builder(AlertDialogSamples.this)
.setIconAttribute(android.R.attr.alertDialogIcon)
.setTitle(R.string.alert_dialog_two_buttons_msg)
.setMessage(R.string.alert_dialog_two_buttons2_msg)
.setPositiveButton(R.string.alert_dialog_ok, new DialogInterface.OnClickListener() {
@@ -174,7 +172,6 @@ public class AlertDialogSamples extends Activity {
.create();
case DIALOG_YES_NO_ULTRA_LONG_MESSAGE:
return new AlertDialog.Builder(AlertDialogSamples.this)
.setIconAttribute(android.R.attr.alertDialogIcon)
.setTitle(R.string.alert_dialog_two_buttons_msg)
.setMessage(R.string.alert_dialog_two_buttons2ultra_msg)
.setPositiveButton(R.string.alert_dialog_ok, new DialogInterface.OnClickListener() {
@@ -212,7 +209,6 @@ public class AlertDialogSamples extends Activity {
.create();
case DIALOG_PROGRESS:
mProgressDialog = new ProgressDialog(AlertDialogSamples.this);
mProgressDialog.setIconAttribute(android.R.attr.alertDialogIcon);
mProgressDialog.setTitle(R.string.select_dialog);
mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
mProgressDialog.setMax(MAX_PROGRESS);
@@ -231,9 +227,27 @@ public class AlertDialogSamples extends Activity {
}
});
return mProgressDialog;
case DIALOG_PROGRESS_SPINNER:
mProgressSpinnerDialog = new ProgressDialog(AlertDialogSamples.this);
mProgressSpinnerDialog.setTitle(R.string.select_dialog);
mProgressSpinnerDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
mProgressSpinnerDialog.setButton(DialogInterface.BUTTON_POSITIVE,
getText(R.string.alert_dialog_hide), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
/* User clicked Yes so do some stuff */
}
});
mProgressSpinnerDialog.setButton(DialogInterface.BUTTON_NEGATIVE,
getText(R.string.alert_dialog_cancel), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
/* User clicked No so do some stuff */
}
});
return mProgressSpinnerDialog;
case DIALOG_SINGLE_CHOICE:
return new AlertDialog.Builder(AlertDialogSamples.this)
.setIconAttribute(android.R.attr.alertDialogIcon)
.setTitle(R.string.alert_dialog_single_choice)
.setSingleChoiceItems(R.array.select_dialog_items2, 0, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
@@ -256,7 +270,6 @@ public class AlertDialogSamples extends Activity {
.create();
case DIALOG_MULTIPLE_CHOICE:
return new AlertDialog.Builder(AlertDialogSamples.this)
.setIcon(R.drawable.ic_popup_reminder)
.setTitle(R.string.alert_dialog_multi_choice)
.setMultiChoiceItems(R.array.select_dialog_items3,
new boolean[]{false, true, false, true, false, false, false},
@@ -291,7 +304,6 @@ public class AlertDialogSamples extends Activity {
Cursor cursor = managedQuery(ContactsContract.Contacts.CONTENT_URI,
projection, null, null, null);
return new AlertDialog.Builder(AlertDialogSamples.this)
.setIcon(R.drawable.ic_popup_reminder)
.setTitle(R.string.alert_dialog_multi_choice_cursor)
.setMultiChoiceItems(cursor,
ContactsContract.Contacts.SEND_TO_VOICEMAIL,
@@ -310,7 +322,6 @@ public class AlertDialogSamples extends Activity {
LayoutInflater factory = LayoutInflater.from(this);
final View textEntryView = factory.inflate(R.layout.alert_dialog_text_entry, null);
return new AlertDialog.Builder(AlertDialogSamples.this)
.setIconAttribute(android.R.attr.alertDialogIcon)
.setTitle(R.string.alert_dialog_text_entry)
.setView(textEntryView)
.setPositiveButton(R.string.alert_dialog_ok, new DialogInterface.OnClickListener() {
@@ -386,6 +397,14 @@ public class AlertDialogSamples extends Activity {
}
});
/* Display a custom progress bar */
Button progressSpinnerButton = (Button) findViewById(R.id.progress_spinner_button);
progressButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
showDialog(DIALOG_PROGRESS_SPINNER);
}
});
/* Display a radio button group */
Button radioButton = (Button) findViewById(R.id.radio_button);
radioButton.setOnClickListener(new OnClickListener() {