Add a dialog with only positive button to ThemesPlayGroundApp
Bug: 124232382
Test: Manual
Change-Id: I572c25fe10fc2f116a937419337d3592cf7b6e81
(cherry picked from commit fb21d3116a5b2489bf2055def17cceec58a337f2)
diff --git a/tests/ThemePlayground/res/layout/dialog_samples.xml b/tests/ThemePlayground/res/layout/dialog_samples.xml
index e8c398b..47d679f 100644
--- a/tests/ThemePlayground/res/layout/dialog_samples.xml
+++ b/tests/ThemePlayground/res/layout/dialog_samples.xml
@@ -38,20 +38,30 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Show Dialog"
- app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintBottom_toTopOf="@+id/showDialogOnlyPositiveBT"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
- app:layout_constraintTop_toTopOf="parent" />
+ app:layout_constraintTop_toBottomOf="@+id/setBackground" />
+
+ <Button
+ android:id="@+id/showDialogOnlyPositiveBT"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Show Dialog with only positive button"
+ app:layout_constraintBottom_toTopOf="@+id/showDialogWithCheckboxBT"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@+id/showDialogBT" />
<Button
android:id="@+id/showDialogWithCheckboxBT"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Show Dialog With Checkbox"
- app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintBottom_toTopOf="@+id/showToast"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toTopOf="@+id/showDialogBT" />
+ app:layout_constraintTop_toBottomOf="@+id/showDialogOnlyPositiveBT" />
<Button
android:id="@+id/showToast"
@@ -61,7 +71,7 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toTopOf="@+id/showDialogWithCheckboxBT" />
+ app:layout_constraintTop_toBottomOf="@+id/showDialogWithCheckboxBT" />
<include layout="@layout/menu_button"/>
diff --git a/tests/ThemePlayground/src/com/android/car/themeplayground/DialogSamples.java b/tests/ThemePlayground/src/com/android/car/themeplayground/DialogSamples.java
index ca07a71..0b311ef 100644
--- a/tests/ThemePlayground/src/com/android/car/themeplayground/DialogSamples.java
+++ b/tests/ThemePlayground/src/com/android/car/themeplayground/DialogSamples.java
@@ -36,9 +36,11 @@
setContentView(R.layout.dialog_samples);
Button mShowDialogBT = findViewById(R.id.showDialogBT);
+ Button mShowDialogOnlyPositiveBT = findViewById(R.id.showDialogOnlyPositiveBT);
Button mShowDialogWithCheckboxBT = findViewById(R.id.showDialogWithCheckboxBT);
setupBackgroundColorControls(R.id.dialogLayout);
mShowDialogBT.setOnClickListener(v -> openDialog(false));
+ mShowDialogOnlyPositiveBT.setOnClickListener(v -> openDialogWithOnlyPositiveButton());
mShowDialogWithCheckboxBT.setOnClickListener(v -> openDialog(true));
Button mShowToast = findViewById(R.id.showToast);
mShowToast.setOnClickListener(v -> showToast());
@@ -72,6 +74,16 @@
builder.show();
}
+ private void openDialogWithOnlyPositiveButton() {
+ AlertDialog.Builder builder = new AlertDialog.Builder(
+ new ContextThemeWrapper(this, R.style.Theme_Testing_Dialog_Alert));
+ builder.setTitle("Standard Alert Dialog")
+ .setMessage("With a message to show.");
+ builder.setPositiveButton("OK", (dialoginterface, i) -> {
+ });
+ builder.show();
+ }
+
private void showToast() {
Toast.makeText(this, "Toast message looks like this",
Toast.LENGTH_LONG).show();