From 29fef9a26683cebf8c60202348be20f2827e0a82 Mon Sep 17 00:00:00 2001 From: JG-Cody Date: Sun, 2 Jul 2023 19:40:15 +0200 Subject: [PATCH] dialog and error messages redesigned --- .../cringe_authenticator/MainActivity.java | 1 + .../cringe_authenticator/util/DialogUtil.java | 11 +++--- app/src/main/res/drawable/dialog_themed.xml | 36 +++++++++++++++++++ 3 files changed, 43 insertions(+), 5 deletions(-) create mode 100644 app/src/main/res/drawable/dialog_themed.xml diff --git a/app/src/main/java/com/cringe_studios/cringe_authenticator/MainActivity.java b/app/src/main/java/com/cringe_studios/cringe_authenticator/MainActivity.java index 180f68e..c41c1b4 100644 --- a/app/src/main/java/com/cringe_studios/cringe_authenticator/MainActivity.java +++ b/app/src/main/java/com/cringe_studios/cringe_authenticator/MainActivity.java @@ -200,6 +200,7 @@ public class MainActivity extends AppCompatActivity { .setNegativeButton(R.string.cancel, (view, which) -> {}) .create(); + dialog.getWindow().setBackgroundDrawableResource(R.drawable.dialog_themed); // TODO: dialog style binding.codeTypes.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, options)); binding.codeTypes.setOnItemClickListener((AdapterView parent, View view, int position, long id) -> { switch(position) { diff --git a/app/src/main/java/com/cringe_studios/cringe_authenticator/util/DialogUtil.java b/app/src/main/java/com/cringe_studios/cringe_authenticator/util/DialogUtil.java index eb4c3c3..5a3f9d7 100644 --- a/app/src/main/java/com/cringe_studios/cringe_authenticator/util/DialogUtil.java +++ b/app/src/main/java/com/cringe_studios/cringe_authenticator/util/DialogUtil.java @@ -32,7 +32,7 @@ public class DialogUtil { .setNegativeButton(R.string.cancel, (btnView, which) -> {}) .create(); - //dialog.getWindow().setBackgroundDrawableResource(R.drawable.button_themed); TODO: dialog style + dialog.getWindow().setBackgroundDrawableResource(R.drawable.dialog_themed); // TODO: dialog style dialog.setOnShowListener(d -> { Button okButton = dialog.getButton(AlertDialog.BUTTON_POSITIVE); @@ -45,11 +45,13 @@ public class DialogUtil { } public static void showErrorDialog(Context context, String errorMessage) { - new AlertDialog.Builder(context) + AlertDialog dialog = new AlertDialog.Builder(context) .setTitle(R.string.failed_title) .setMessage(errorMessage) - .setPositiveButton(R.string.ok, (dialog, which) -> {}) - .show(); + .setPositiveButton(R.string.ok, (d, which) -> {}) + .create(); + dialog.getWindow().setBackgroundDrawableResource(R.drawable.dialog_themed); // TODO: dialog style + dialog.show(); } public static void showTOTPDialog(LayoutInflater inflater, OTPData initialData, Consumer callback, Runnable back, boolean view) { @@ -171,5 +173,4 @@ public class DialogUtil { case TOTP: showTOTPDialog(inflater, initialData, callback, back, false); break; } } - } diff --git a/app/src/main/res/drawable/dialog_themed.xml b/app/src/main/res/drawable/dialog_themed.xml new file mode 100644 index 0000000..94f7983 --- /dev/null +++ b/app/src/main/res/drawable/dialog_themed.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file