Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Add support for tinting UserLocationView and Attribution icon #3231

Closed

Description

@tobrun

iOS currently exposes a feature that allows tinting the UserLocationView and the Attribution Icon.

On Android we can support automatic tinting by using:

<resources>
  <!-- inherit from the material theme -->
  <style name="AppTheme" parent="android:Theme.Material">
    <!-- Main theme colors -->
    <!--   your app branding color for the app bar -->
    <item name="android:colorPrimary">@color/primary</item>
    <!--   darker variant for the status bar and contextual app bars -->
    <item name="android:colorPrimaryDark">@color/primary_dark</item>
    <!--   theme UI controls like checkboxes and text fields -->
    <item name="android:colorAccent">@color/accent</item>
  </style>
</resources>

cc @bleege @zugaldia

Activity

  1. added
    Android
    on Dec 9, 2015
  2. tobrun commented on Jan 13, 2016

    @tobrun
    MemberAuthor

    I have seen requests for this feature, going to add it now

  3. added
    GL JS parity
    on Jan 13, 2016
  4. added this to the android-v3.1.0 milestone on Jan 13, 2016
  5. tobrun commented on Jan 13, 2016

    @tobrun
    MemberAuthor

    I'm able to reference the client app from the library using colorPrimary, colorPrimaryDark and colorAccent as attributes:

        @ColorInt
        public static int getPrimaryColor(@NonNull Context context) {
            TypedValue typedValue = new TypedValue();
            Resources.Theme theme = context.getTheme();
            theme.resolveAttribute(R.attr.colorPrimary, typedValue, true);
            return typedValue.data;
        }
  6. tobrun commented on Jan 13, 2016

    @tobrun
    MemberAuthor

    Tinting the attribution icon will require creating a state selector programatically with tinted drawables.

    Tinting the UserLocationView will require some refactoring, it is using an image with multiple colors.

  7. tobrun commented on Jan 13, 2016

    @tobrun
    MemberAuthor

    Here is an example where I changed the colors of the testapp:

    • primary: #F44336
    • primaryDark: #D32F2F
    • accent: #536DFE

    device-2016-01-13-104553

    As you can see, we need to refactor UserLocationView to draw the outer white circle programatically.

  8. tobrun commented on Jan 13, 2016

    @tobrun
    MemberAuthor

    I forgot to mention the update to attribution dialog:

    device-2016-01-13-105203

  9. tobrun commented on Jan 13, 2016

    @tobrun
    MemberAuthor

    Above tests were done on a Marshmallow device containing the newer attributes, a quick test on a older device shows that this is not working on device prior to Lollipop:

    device-2016-01-13-110359

  10. tobrun commented on Jan 13, 2016

    @tobrun
    MemberAuthor

    My initial idea that attributes are not available is incorrect, these will probably be added by the support-v7 dependency. The code mentioned here is returning the correct value after I debugged it with Integer.toHexString(typedValue.data) -> #fff44336.

    The actual problem is related to wrapping drawables.

    Result after fix on pre-lollipop device:

    device-2016-01-13-113620

  11. tobrun commented on Jan 13, 2016

    @tobrun
    MemberAuthor

    Items required to close this issue:

    • test without having a support-v7 dependency
    • refactor UserLocationView to draw a white circle pragmatically
  12. added a commit that references this issue on Jan 13, 2016
  13. 17 remaining items

  14. modified the milestone: android-v4.1.0 on Mar 18, 2016
  15. tobrun commented on Apr 8, 2016

    @tobrun
    MemberAuthor

    The blocking part for this issue was not being able to tint UserLocationView.
    I'm picking that up as part of #4396 and I will merge in this functionality as part of that PR.

    Current tinting result can be seen in the third row:

    device-2016-04-08-084817

  16. tobrun commented on Apr 25, 2016

    @tobrun
    MemberAuthor

    User Location View tinting has landed in #4695.
    We can now start with integration of this feature.

  17. added this to the android-v4.1.0 milestone on Apr 25, 2016
  18. tobrun commented on Apr 26, 2016

    @tobrun
    MemberAuthor

    I resurrected the code form the related PR and cherrypicked in onto current master:

    Our testapp styles are now automatically applied using the primary,primaryDark and primaryAccent:

    device-2016-04-26-085020

    device-2016-04-26-085616

    Changing our theme colors to red, darkRed and yellow:

    device-2016-04-26-085401

    device-2016-04-26-085432

  19. bleege commented on Apr 26, 2016

    @bleege
    Contributor

    🚀 🚀 🚀 🚀

  20. p-fischer commented on Oct 17, 2018

    @p-fischer

    Automatic tinting worked great when I was using mapbox version 4.2.2. I just made a big version jump to 6.6.0 and the attribution icon as well as the dialog window ignore the app's primary color.
    @tobrun Is automatic tinting in primary color still supposed to work?

  21. tobrun commented on Oct 17, 2018

    @tobrun
    MemberAuthor

    we removed that at a point to not include certain support libraries, nowadays we are including them anyways and we could bring this feature back. For now you can set these colors yourself with using MapboxMap#getUiSettings()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

AndroidGL JS parityfeature

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions