|
4 | 4 | import android.app.AlertDialog; |
5 | 5 | import android.content.Context; |
6 | 6 | import android.content.DialogInterface; |
7 | | -import android.graphics.Color; |
| 7 | +import android.content.res.TypedArray; |
8 | 8 | import android.view.LayoutInflater; |
9 | 9 | import android.view.View; |
10 | 10 | import android.widget.Button; |
@@ -51,7 +51,7 @@ public static void showMessage(Context context, String titleText, String message |
51 | 51 | final DialogInterface.OnClickListener onNegativeButton, |
52 | 52 | final DialogInterface.OnDismissListener onDismiss) { |
53 | 53 |
|
54 | | - AlertDialog.Builder builder = new AlertDialog.Builder(context, androidx.appcompat.R.style.Theme_AppCompat_Light_Dialog); |
| 54 | + AlertDialog.Builder builder = new AlertDialog.Builder(context, androidx.appcompat.R.style.Theme_AppCompat_DayNight_Dialog); |
55 | 55 |
|
56 | 56 | LayoutInflater inflater = (LayoutInflater) context.getSystemService( Context.LAYOUT_INFLATER_SERVICE ); |
57 | 57 | View view = inflater.inflate(R.layout.dialog_show_message, null); |
@@ -81,12 +81,17 @@ public static void showMessage(Context context, String titleText, String message |
81 | 81 |
|
82 | 82 | dialog.setOnShowListener(dialogInterface -> { |
83 | 83 | Logger.logError("dialog"); |
| 84 | + int[] attrs = new int[] { android.R.attr.textColorPrimary }; |
| 85 | + TypedArray ta = context.obtainStyledAttributes(attrs); |
| 86 | + int textColor = ta.getColor(0, 0xFF000000); |
| 87 | + ta.recycle(); |
| 88 | + |
84 | 89 | Button button = dialog.getButton(AlertDialog.BUTTON_POSITIVE); |
85 | 90 | if (button != null) |
86 | | - button.setTextColor(Color.BLACK); |
| 91 | + button.setTextColor(textColor); |
87 | 92 | button = dialog.getButton(AlertDialog.BUTTON_NEGATIVE); |
88 | 93 | if (button != null) |
89 | | - button.setTextColor(Color.BLACK); |
| 94 | + button.setTextColor(textColor); |
90 | 95 | }); |
91 | 96 |
|
92 | 97 | dialog.show(); |
|
0 commit comments