added alertdialog theme
Signed-off-by: nuclearfog <hatespirit666@gmail.com>
This commit is contained in:
parent
12e20c8cc7
commit
c88c065348
|
@ -1,12 +1,17 @@
|
||||||
package org.nuclearfog.twidda.dialog;
|
package org.nuclearfog.twidda.dialog;
|
||||||
|
|
||||||
|
import static android.util.TypedValue.COMPLEX_UNIT_SP;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.DialogInterface.OnClickListener;
|
import android.content.DialogInterface.OnClickListener;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
|
||||||
import org.nuclearfog.twidda.R;
|
import org.nuclearfog.twidda.R;
|
||||||
|
import org.nuclearfog.twidda.database.GlobalSettings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* this dialog is to confirm for user action
|
* this dialog is to confirm for user action
|
||||||
|
@ -49,7 +54,7 @@ public class ConfirmDialog extends AlertDialog implements OnClickListener {
|
||||||
* @param listener listener for the confirmation button
|
* @param listener listener for the confirmation button
|
||||||
*/
|
*/
|
||||||
public ConfirmDialog(Context context, DialogType type, OnConfirmListener listener) {
|
public ConfirmDialog(Context context, DialogType type, OnConfirmListener listener) {
|
||||||
super(context, R.style.ConfirmDialog);
|
super(context);
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
build();
|
build();
|
||||||
|
@ -63,6 +68,13 @@ public class ConfirmDialog extends AlertDialog implements OnClickListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void show() {
|
||||||
|
super.show();
|
||||||
|
setTheme();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* creates an alert dialog
|
* creates an alert dialog
|
||||||
*/
|
*/
|
||||||
|
@ -157,6 +169,38 @@ public class ConfirmDialog extends AlertDialog implements OnClickListener {
|
||||||
setButton(BUTTON_POSITIVE, posButton, this);
|
setButton(BUTTON_POSITIVE, posButton, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private void setTheme() {
|
||||||
|
GlobalSettings settings = GlobalSettings.getInstance(getContext());
|
||||||
|
TextView message = findViewById(android.R.id.message);
|
||||||
|
TextView title = findViewById(android.R.id.title);
|
||||||
|
Button button1 = findViewById(android.R.id.button1);
|
||||||
|
Button button2 = findViewById(android.R.id.button2);
|
||||||
|
|
||||||
|
if (getWindow() != null) {
|
||||||
|
getWindow().getDecorView().setBackgroundColor(settings.getBackgroundColor());
|
||||||
|
}
|
||||||
|
if (message != null) {
|
||||||
|
message.setTypeface(settings.getTypeFace());
|
||||||
|
message.setTextColor(settings.getFontColor());
|
||||||
|
message.setTextSize(COMPLEX_UNIT_SP, 20);
|
||||||
|
}
|
||||||
|
if (title != null) {
|
||||||
|
title.setTypeface(settings.getTypeFace());
|
||||||
|
title.setTextColor(settings.getFontColor());
|
||||||
|
}
|
||||||
|
if (button1 != null) {
|
||||||
|
button1.setTypeface(settings.getTypeFace());
|
||||||
|
button1.setTextColor(settings.getFontColor());
|
||||||
|
}
|
||||||
|
if (button2 != null) {
|
||||||
|
button2.setTypeface(settings.getTypeFace());
|
||||||
|
button2.setTextColor(settings.getFontColor());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Alert dialog listener
|
* Alert dialog listener
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -18,15 +18,6 @@
|
||||||
<item name="android:backgroundDimEnabled">true</item>
|
<item name="android:backgroundDimEnabled">true</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="ConfirmDialog" parent="Theme.AppCompat.Dialog.Alert">
|
|
||||||
<item name="android:colorBackground">@color/bright_transparent</item>
|
|
||||||
<item name="android:textColor">@android:color/holo_red_dark</item>
|
|
||||||
<item name="android:textColorPrimary">@android:color/black</item>
|
|
||||||
<item name="buttonBarPositiveButtonStyle">@style/PositiveButton</item>
|
|
||||||
<item name="buttonBarNegativeButtonStyle">@style/NegativeButton</item>
|
|
||||||
<item name="android:backgroundDimEnabled">true</item>
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<style name="AppInfoDialog" parent="Theme.AppCompat.Dialog.Alert">
|
<style name="AppInfoDialog" parent="Theme.AppCompat.Dialog.Alert">
|
||||||
<item name="android:background">@android:color/white</item>
|
<item name="android:background">@android:color/white</item>
|
||||||
<item name="android:textColor">@android:color/black</item>
|
<item name="android:textColor">@android:color/black</item>
|
||||||
|
@ -86,12 +77,4 @@
|
||||||
<item name="cardElevation">2dp</item>
|
<item name="cardElevation">2dp</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="NegativeButton" parent="Widget.AppCompat.ButtonBar.AlertDialog">
|
|
||||||
<item name="android:textColor">@color/negative_button</item>
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<style name="PositiveButton" parent="Widget.AppCompat.ButtonBar.AlertDialog">
|
|
||||||
<item name="android:textColor">@color/positive_button</item>
|
|
||||||
</style>
|
|
||||||
|
|
||||||
</resources>
|
</resources>
|
Loading…
Reference in New Issue