AlertDialog theme compatibility, possible user error

Showing 1-5 of 5 messages
AlertDialog theme compatibility, possible user error tommytomatoe 6/13/12 10:32 PM
Hey there Jake and co.

First, thank you very much for this awesome library. With ABS I've been able to give my apps the awesome features of the actionbar and other features without issues on gingerbread as well as ics devices.

This issue might not be an issue at all. I remember reading a comment by you that the Theme.Sherlock.Dialog was not meant for dialogs, but I cannot find that comment with Google search.

Here is a code snippet of how I am building the alert dialog:

*******************************************
AlertDialog.Builder builder;
        try {
            builder =  new AlertDialog.Builder(getActivity(), R.style.Theme.Sherlock.Dialog);
        } catch (NoSuchMethodError e) {
            Log.e(TAG, "Older SDK, using old Builder");
            builder =  new AlertDialog.Builder(getActivity());
        }

********************************************

I am using the optional constructor for AlertDialog.Builder to call a theme of the dialog because the theme of the app itself uses Theme.Sherlock.Light.DarkActionbar as a parent, which causes the AlertDialog to be light, but I prefer the darker dialog box. Using that code, I get this wonky background: http://imgur.com/doBg8

I know that it is an error from me using the Theme.Sherlock.Dialog style. I came up with two different methods to resolve this:

1. Use the constant "AlertDialog.THEME_HOLO_DARK" instead of "R.style.Theme.Sherlock.Dialog". This actually works pretty nicely, but I would like to know how to do it using Sherlock themes.

2. Create a theme that uses Theme.Sherlock.Dialog as a parent and setting the attribute "abdroid:windowBackground" to a transparent resource. This also works ok but it makes the dialog box smaller than it should be, because it actually puts the dialog box inside of another dialog box, like if I used Theme.Sherlock.Dialog. Example from my themes.xml:

    <style name="Theme.Classic.Dialog" parent="Theme.Sherlock.Dialog">
        <item name="android:windowBackground">@drawable/bg_clear</item>
    </style>

If I haven't lost you, do you have any thoughts on a different approach? Is there an official style/theme I could use that comes with the Sherlock library?

Thank you again for your great contribution.

Tommy
Re: AlertDialog theme compatibility, possible user error Jake Wharton 6/13/12 10:35 PM
There is not, and you are correct that the theme is not for dialogs. It is for theming activities to look like dialogs.

Making an AlertDialog look like it does on ICS is much more involved than a theme can accomplish which makes it fall out of scope for ActionBarSherlock. Despite backporting the action bar which looks Holo, ABS is not meant to be a Holo backport by any means. The use of this theme is merely to put both ICS and pre-ICS on the same level visually so that customizations across the platforms will always look the same.

There is an attempt to backport the AlertDialog in the HoloEverywhere library (which I hesitate to recommend) but it too falls a bit short in achieving a full backport of the look. You may be better off just rolling a custom dialog yourself and making it look Holo-ish.

---
Jake Wharton
http://about.me/jakewharton
Re: AlertDialog theme compatibility, possible user error tommytomatoe 6/13/12 10:48 PM
Oh wow you are fast.

Thanks for the quick and thorough response. I was afraid of that, but not a major issue. Further down the road I might create a custom dialog layout when most of the app is written. For now I am happy using the AlertDialog.THEME_HOLO_DIALOG for ICS devices and just the stock AlertDialog on older devices.

An offtopic question. If you want I can create a new topic. Have you thought about, or have already implemented, an indeterminant horizontal progressbar above the ActionBar? To be clear I don't mean the circle but the loading bar that Google uses in the Play store before an app downloads and other areas. I am using these methods in an Asynctask to display the download progress, but it would be nice to have the indeterminant loading bar while the app tries to connect.

           @Override
        protected void onPreExecute() {
            super.onPreExecute();
            updateMenu(mMenuDownload);
            setSupportProgressBarVisibility(true);
            setSupportProgressBarIndeterminateVisibility(false);
           
        }

       //snip snip

       protected void onProgressUpdate(String... progress) {
            Log.d(TAG,progress[0]);
            setSupportProgress(100 * Integer.parseInt(progress[0]));
            btnCheckUpdate.setText("Dowloaded " + progress[0] + "/100");
       }

Thank you again for your time.


On Thursday, June 14, 2012 1:35:46 AM UTC-4, Jake Wharton wrote:
There is not, and you are correct that the theme is not for dialogs. It is for theming activities to look like dialogs.

Making an AlertDialog look like it does on ICS is much more involved than a theme can accomplish which makes it fall out of scope for ActionBarSherlock. Despite backporting the action bar which looks Holo, ABS is not meant to be a Holo backport by any means. The use of this theme is merely to put both ICS and pre-ICS on the same level visually so that customizations across the platforms will always look the same.

There is an attempt to backport the AlertDialog in the HoloEverywhere library (which I hesitate to recommend) but it too falls a bit short in achieving a full backport of the look. You may be better off just rolling a custom dialog yourself and making it look Holo-ish.

---
Jake Wharton
http://about.me/jakewharton


On Wed, Jun 13, 2012 at 10:32 PM, tommytomatoe  wrote:
Hey there Jake and co.

First, thank you very much for this awesome library. With ABS I've been able to give my apps the awesome features of the actionbar and other features without issues on gingerbread as well as ics devices.

This issue might not be an issue at all. I remember reading a comment by you that the Theme.Sherlock.Dialog was not meant for dialogs, but I cannot find that comment with Google search.

Here is a code snippet of how I am building the alert dialog:

*******************************************
AlertDialog.Builder builder;
        try {
            builder =  new AlertDialog.Builder(getActivity(), R.style.Theme.Sherlock.Dialog);
        } catch (NoSuchMethodError e) {
            Log.e(TAG, "Older SDK, using old Builder");
            builder =  new AlertDialog.Builder(getActivity());
        }

********************************************

I am using the optional constructor for AlertDialog.Builder to call a theme of the dialog because the theme of the app itself uses Theme.Sherlock.Light.DarkActionbar as a parent, which causes the AlertDialog to be light, but I prefer the darker dialog box. Using that code, I get this wonky background: http://imgur.com/doBg8

I know that it is an error from me using the Theme.Sherlock.Dialog style. I came up with two different methods to resolve this:

1. Use the constant "AlertDialog.THEME_HOLO_DARK" instead of "R.style.Theme.Sherlock.Dialog". This actually works pretty nicely, but I would like to know how to do it using Sherlock themes.

2. Create a theme that uses Theme.Sherlock.Dialog as a parent and setting the attribute "abdroid:windowBackground" to a transparent resource. This also works ok but it makes the dialog box smaller than it should be, because it actually puts the dialog box inside of another dialog box, like if I used Theme.Sherlock.Dialog. Example from my themes.xml:

    <style name="Theme.Classic.Dialog" parent="Theme.Sherlock.Dialog">
        <item name="android:windowBackground">@drawable/bg_clear</item>
    </style>

If I haven't lost you, do you have any thoughts on a different approach? Is there an official style/theme I could use that comes with the Sherlock library?

Thank you again for your great contribution.

Tommy

Re: AlertDialog theme compatibility, possible user error Jake Wharton 6/13/12 10:50 PM
Re: AlertDialog theme compatibility, possible user error gowtham....@photoninfotech.net 2/19/13 9:38 PM
hi Jake,
           I have a doubt
           1) Is it possible to override the sherlock themes for alert dialogs and progress bar to display the it in device theme i.e) Halo