Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Styling FacebookActivity to avoid terrible progress bar

I just implemented logging in through Facebook using their SDK in conjunction with ParseFacebookUtilsV4.

In my manifest I had to declare a FacebookActivity that gets launched when I try to sign in, and that works great.

<activity android:name="com.facebook.FacebookActivity"
    android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
    android:theme="@android:style/Theme.Translucent.NoTitleBar"
    android:label="@string/app_name" />

This snippet comes from official docs so I didn't choose anything. What I found really weird is its styling. On my emulator (API 22) it has a ProgressBar that seems to be coming from the '90s! Is there a way to style it? I have tried changing the android:theme attribute, but with no success.

enter image description here

I thought of extending com.facebook.FacebookActivity, but after digging through source code I found out it inflates a com.facebook.LoginFragment, which is then responsible of the progress bar actually. Any ideas?

like image 391
natario Avatar asked May 11 '15 23:05

natario


2 Answers

You can now set theme in your AndroidManifest.xml

commit src link

Usage:

AndroidManifest.xml

    <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>
    <meta-data android:name="com.facebook.sdk.ApplicationName" android:value="@string/app_name"/>
    <meta-data android:name="com.facebook.sdk.WebDialogTheme" android:value="@style/Theme.AppCompat.Light.NoActionBar"/>

This is valid for facebook-android-sdk v4.8.0+

like image 196
eternal Avatar answered Oct 05 '22 20:10

eternal


First of all it's not progress bar, it's progress dialog. I don't know how make custom progress dialog with style.

So here is a solution changing default style(Theme_Translucent_NoTitleBar) with holo style(Theme.Holo.Light). For that we need to make changes in Facebook SDk.

1) Put below code in style.xml

<style name="NewDialogTheme" parent="@android:style/Theme.Holo.Light">
    <item name="android:windowBackground">@android:color/transparent</item>
    <item name="android:backgroundDimEnabled">false</item>
    <item name="android:background">@android:color/transparent</item>
</style>

2) And second thing that we need to change here in WebDialog.java inside com.facebook.widget package.

public static final int DEFAULT_THEME = R.style.NewDialogTheme;

Hope this helps you.

like image 24
Chitrang Avatar answered Oct 05 '22 18:10

Chitrang