BirjuVachhani/locus-android

Changing the style of dialogs and disabling them.

OmarELRayes opened this issue · 5 comments

Is it possible to customize the styling of the dialogs ?
I have a problem with the settings resolution dialog, the buttons are displayed in red.

also is it possible to disable the settings resolution dialog ? because it's unnecessary as Google already shows one so it would be awesome if you provide an option to either show it or not

You should be able to change color using theming. Let me know how this works out.
As for the disable option, I'll take a look.

what values should I override ?

It depends on what theme you override for your application. Try something like that in your theme.xml:

    <style name="Theme.MyApp" parent="Theme.MaterialComponents.DayNight">
        <item name="alertDialogTheme">@style/MyDialogTheme</item>
        <item name="android:dialogTheme">?alertDialogTheme</item>
        <item name="dialogTheme">?alertDialogTheme</item>
    </style>

    <style name="MyDialogTheme" parent="ThemeOverlay.MaterialComponents.Dialog.Alert">
        <item name="android:windowBackground">@drawable/dialog_background</item>
        <item name="android:popupBackground">@drawable/dialog_background</item>
        <item name="popupMenuBackground">@drawable/dialog_background</item>
        <item name="windowFixedWidthMajor">90%</item>
        <item name="windowFixedWidthMinor">90%</item>
        <item name="buttonBarNegativeButtonStyle">@style/Widget.MyApp.NegativeButton</item>
        <item name="buttonBarPositiveButtonStyle">@style/Widget.MyApp.PositiveButton</item>
    </style>

    <style name="Widget.MyApp.NegativeButton" parent="Widget.MaterialComponents.Button.TextButton.Dialog">
        <item name="materialThemeOverlay">@style/ThemeOverlay.MyApp.NegativeButton</item>
        <item name="android:textColor">@color/some_color</item>
    </style>

    <style name="Widget.MyApp.PositiveButton" parent="Widget.MaterialComponents.Button.TextButton.Dialog">
        <item name="materialThemeOverlay">@style/ThemeOverlay.MyApp.PositiveButton</item>
    </style>

    <style name="ThemeOverlay.MyApp.NegativeButton" parent="">
        <item name="colorPrimary">@color/some_color</item>
        <item name="colorOnSurface">@color/some_color</item>
        <item name="android:textColor">@color/some_color</item>
    </style>

    <style name="ThemeOverlay.MyApp.PositiveButton" parent="">
        <item name="colorPrimary">@color/some_color</item>
        <item name="colorOnSurface">@color/some_color</item>
        <item name="android:textColor">@color/some_color</item>
    </style>

@OmarELRayes

You should be able to disable it like this:

Locus.configure {
    shouldResolveRequest = false
}

Feel free to reopen if this doesn't work.

@OmarELRayes As for the styling, I think @BurgerZ's answer is correct and should help you figure it out.