blob: 6a265a814f72b77fc41bca0d86f171c3e3584ac5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
package it.niedermann.nextcloud.deck.ui.branding;
import android.content.Context;
import android.content.DialogInterface;
import android.widget.Button;
import androidx.annotation.CallSuper;
import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import org.jetbrains.annotations.NotNull;
import it.niedermann.nextcloud.deck.Application;
public class BrandedAlertDialogBuilder extends AlertDialog.Builder implements Branded {
protected AlertDialog dialog;
public BrandedAlertDialogBuilder(Context context) {
super(context);
}
@NotNull
@Override
public AlertDialog create() {
this.dialog = super.create();
@NonNull Context context = getContext();
@ColorInt final int mainColor = Application.readBrandMainColor(context);
applyBrand(mainColor);
dialog.setOnShowListener(dialog -> applyBrand(mainColor));
return dialog;
}
@CallSuper
@Override
public void applyBrand(int mainColor) {
final Button[] buttons = new Button[3];
buttons[0] = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
buttons[1] = dialog.getButton(DialogInterface.BUTTON_NEGATIVE);
buttons[2] = dialog.getButton(DialogInterface.BUTTON_NEUTRAL);
for (Button button : buttons) {
if (button != null) {
button.setTextColor(BrandedActivity.getSecondaryForegroundColorDependingOnTheme(button.getContext(), mainColor));
}
}
}
}
|