auth0 / Lock.Android

Android Library to authenticate using Auth0 and with a Native Look & Feel
https://auth0.com/lock
MIT License
143 stars 82 forks source link

How to change logo on LOCK activity ? #244

Closed sirvon closed 8 years ago

sirvon commented 8 years ago

How to change logo of silhouette to logo matching app?

lbalmaceda commented 8 years ago

Hello @sirvon! You can change the title Icon using styles. Let's say you created your own Theme that extends from Lock.Theme, then you just need to override the Auth0.Title.Icon value with the reference to your own resource file.

e.g.

<resources>
    <style name="MyTheme" parent="Lock.Theme">
        <item name="Auth0.Title.Icon">@drawable/my_company_logo.png</item>
    </style>
</resources>

Remember to specify in the Android Manifest that you want to use the new Theme.

Cheers!

altfuns commented 8 years ago

Hello @sirvon and @lbalmaceda,

Thank you @lbalmaceda, I was looking for this some time ago.

@lbalmaceda is nearly OK, but you also need a style that inherits from Lock.Theme.Title.Icon

where you can change icon with your apps logo.

Here is an example:

<style name="AppTheme.Lock.Theme" parent="Lock.Theme">
      <item name="Auth0.Title.Icon">@style/eXigo.Lock.Theme.Title.Icon</item>
</style>
<style name="AppTheme.Lock.Theme.Title.Icon" parent="Lock.Theme.Title.Icon">
       <item name="android:src">@drawable/ic_login_main</item>
 </style>

You can see the other fields you can customize here.

¡Pura Vida!

lbalmaceda commented 8 years ago

That's right! Thanks for the heads up @altfuns

sensitivusmk commented 7 years ago

Can't make it work with version 2.0. Tried with several variants over:

<style name="AppTheme.Lock.Theme" parent="Lock.Theme"> <item name="Auth0.Title.Logo">@style/AppTheme.Lock.Theme.Title.Logo</item> </style> <style name="AppTheme.Lock.Theme.Title.Logo" parent="Lock.Theme.Widget.Logo"> <item name="android:src">@drawable/fat_worm</item> </style>

I checked the source for Lock.Android. In com_auth0_lock_header.xml you'll find

tools:srcCompat="@drawable/com_auth0_lock_header_logo"

Wouldn't that permanently override the selected logo?

lbalmaceda commented 7 years ago

Hi @sensitivusmk. Thanks for reporting this, I've just fixed it in https://github.com/auth0/Lock.Android/pull/357 and will be merged in the next release. The tools namespace it's used only to preview stuff in the layout editor, it doesn't affect the final result. As the value is set from the Theme in runtime, you need to create your own theme using the same attribute names as defined in the Lock.Theme section. See this file to get the list of customizable attributes.

i.e. If you only need to change the logo, the custom theme will look something like this:

<resources>
    <style name="CustomLock" parent="Lock.Theme">
        <item name="Auth0.HeaderLogo">@drawable/fat_worm</item>
    </style>
</resources>

Cheers.

sayed19 commented 7 years ago

cannot make it work. customized the lock theme like this:

<style name="CustomLock" parent="Lock.Theme"> <item name="Auth0.HeaderLogo">@drawable/com_auth0_lock_ic_email</item> </style>

called the theme on manifest like this

<activity android:name="com.auth0.android.lock.LockActivity" android:label="@string/app_name" android:launchMode="singleTask" android:screenOrientation="portrait" android:theme="@style/CustomLock">`

lbalmaceda commented 7 years ago

Hello @sayed19. The snippet you shared is ok, but this feature got broken with an update of the AppCompat dependencies. It's already fixed on master. You can either use the latest source code from there or wait for the next release, prob next week.

sayed19 commented 7 years ago

@lbalmaceda thanks for the reply. Can you please tell me how to use the latest source code before the release. Should I compile a specific branch in gradle and how to do that?

joshuadutton commented 7 years ago

Not sure if this is the right place for this feedback:

I got stuck on this issue because the android lock version in the docs is out of date. This page https://auth0.com/docs/libraries/lock-android still says

compile 'com.auth0.android:lock:2.0.0'

when you are now on version 2.3.0

squarest commented 6 years ago

Can I remove/hide logo and title at Lock?

lbalmaceda commented 6 years ago

@squarest You can hide the title on the main screen only by using this method. Secondary screens would explain the purpose of the screen, such as a reset password case. You could set an empty string for those if you need so.

The logo can't be removed. But you can customize the asset so try setting a @null resource or a transparent image. Check this guide.