drpout / boilr

Price alarms for Bitcoin, cryptocurrencies, cryptoassets, futures and options.
http://boilr.mobi
GNU General Public License v3.0
128 stars 67 forks source link

AlertDialog with pinstripe background #78

Open dllud opened 9 years ago

dllud commented 9 years ago

We would like to use the pinstripe as background for all AlertDialogs in the app. However, Android does not provide an easy way to change the background of Holo themed AlertDialogs and it will never do, read Android Issue 155470: Make core Holo AlertDialog themes public

Our only option is to build an AlertDialog theme and an AlertDialog style from scratch, make them look like Holo and change just the background. Though, making them look like Holo is a dirty job. All Holo drawables are private too (e.g. dialog_full_holo_dark used in AlertDialog.Holo style, check themes_holo.xml and styles_holo.xml). We would have to copy them and all their dependencies to Boilr's resources: a mess.

On the process of discovering this I got to:

    <style name="Theme.Boilr.Dark" parent="@android:style/Theme.Holo">
        <item name="android:alertDialogStyle">@style/BoilrDialogStyle</item>
        <item name="android:alertDialogTheme">@style/BoilrAlertDialogTheme</item>
    </style>

    <style name="BoilrAlertDialogTitle">
        <item name="android:maxLines">1</item>
        <item name="android:scrollHorizontally">true</item>
        <item name="android:textAppearance">@android:style/TextAppearance.Holo.DialogWindowTitle</item>
    </style>

    <style name="BoilrAlertDialogTheme">
        <item name="android:windowBackground">@android:color/transparent</item>
        <item name="android:windowTitleStyle">@style/BoilrAlertDialogTitle</item>
        <item name="android:windowContentOverlay">@null</item>
        <item name="android:windowMinWidthMajor">@android:dimen/dialog_min_width_major</item>
        <item name="android:windowMinWidthMinor">@android:dimen/dialog_min_width_minor</item>
        <item name="android:windowIsFloating">true</item>
        <item name="android:textAppearanceMedium">@android:style/TextAppearance.Holo.Medium</item>
        <item name="android:buttonBarStyle">@android:style/Holo.ButtonBar.AlertDialog</item>
        <item name="android:buttonBarButtonStyle">?android:attr/borderlessButtonStyle</item>
    </style>

    <style name="BoilrDialogStyle">
        <item name="android:fullDark">@drawable/backrepeat_dark</item>
        <item name="android:topDark">@drawable/backrepeat_dark</item>
        <item name="android:centerDark">@drawable/backrepeat_dark</item>
        <item name="android:bottomDark">@drawable/backrepeat_dark</item>
        <item name="android:fullBright">@drawable/backrepeat_dark</item>
        <item name="android:topBright">@drawable/backrepeat_dark</item>
        <item name="android:centerBright">@drawable/backrepeat_dark</item>
        <item name="android:bottomBright">@drawable/backrepeat_dark</item>
        <item name="android:bottomMedium">@drawable/backrepeat_dark</item>
        <item name="android:centerMedium">@drawable/backrepeat_dark</item>
    </style>

Which gives this ugly result to the left. Better leave it using the Holo theme (on the right): alertdialog-pinstripe alertdialog-holo

We can fix this once we move to a Material based theme, where AlertDialog themes are public.

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

algazarra commented 9 years ago

Better leave it using the Holo theme (on the right)

yes!