Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Attribution] Show attribution present in TileJson source in attribution modal sheet #1087

Merged
merged 3 commits into from
Feb 8, 2022

Conversation

ank27
Copy link
Contributor

@ank27 ank27 commented Jan 26, 2022

Summary of changes

if the user provides the source attribution in string literal (eg. {attribution: "OpenStreetMap contributors, CC-BY-SA"}), it doesn't populate in the attribution dialog, which should be shown. this pr fixes the issue.

Before After

Pull request checklist:

  • Briefly describe the changes in this PR.
  • Include before/after visuals or gifs if this PR includes visual changes.
  • Write tests for all new functionality. If tests were not written, please explain why.
  • Optimize code for java consumption (@JvmOverloads, @file:JvmName, etc).
  • Add example if relevant.
  • Document any changes to public APIs.
  • Apply changelog label ('breaking change', 'bug 🪲', 'build', 'docs', 'feature 🍏', 'performance ⚡', 'testing 💯') or use the label 'skip changelog'
  • Add an entry inside this element for inclusion in the mapbox-maps-android changelog: <changelog>Fix an issue where source attribution was not populated in attribution dialog.</changelog>.
  • If this PR is a v10.3 release branch fix / enhancement, merge it to main firstly and then port to v10.3 release branch.

Fixes: < Link to related issues that will be fixed by this pull request, if they exist >

PRs must be submitted under the terms of our Contributor License Agreement CLA.

@ank27 ank27 added the bug 🪲 Something isn't working label Jan 26, 2022
@ank27 ank27 self-assigned this Jan 26, 2022
@ank27 ank27 marked this pull request as ready for review January 27, 2022 12:29
@ank27 ank27 requested a review from a team as a code owner January 27, 2022 12:29
Copy link
Member

@tobrun tobrun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we try optimizing the UI to make non-html attribution, not clickable? (setting them to disabled so they turn grey?)

@ank27 ank27 force-pushed the ak-allow-custom-attribution branch from bbb3593 to 71a8727 Compare February 8, 2022 10:52
@ank27 ank27 requested review from tobrun and pengdev February 8, 2022 10:52
if (attribution.url.isEmpty()) {
setTextColor(Color.GRAY)
} else {
setTextColor(ContextCompat.getColor(context, R.color.mapbox_blue))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it necessary to set the blue color again? I think the default style defined in mapbox_attribution_list_item is mapbox_blue already.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, somehow the color GRAY was set to whole list, so added the condition.

Copy link
Member

@pengdev pengdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM % nit

attributionParser.createAttributionString(true)
);
}

@Test
public void testParseAttributionWithCustomStringAttribution() throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pretty unexpected to see test in Java here 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to convert it to kotlin, probably later :D

val attribution = attributions[position]
view.findViewById<TextView>(android.R.id.text1).apply {
// if attribution url is empty, we show them as disabled.
if (attribution.url.isEmpty()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: could put if inside:

setTextColor(if () ... else ...)

/**
* Parse string literal to attribution with empty url.
*/
private fun parseStringLiteralToAttributions(stringLiteralArray: MutableList<String>) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is indeed a mutable list needed here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

additionally naming stringLiteralArray with word array is not aligned well with actual list type

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I will update that.

Copy link
Contributor

@kiryldz kiryldz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor suggestions however dropping 🟢 in order not to block merging after those will be fixed.
Also missing checkpoint to port this to v10.3 branch - is this intended? I thought we want to have it in v10.3 stable however I don't have strong opinion here, imo it could wait until v10.4-beta.1

…Test.java

Co-authored-by: Kiryl Dzehtsiarenka <kiryl.dzehtsiarenka@mapbox.com>
@ank27
Copy link
Contributor Author

ank27 commented Feb 8, 2022

Some minor suggestions however dropping 🟢 in order not to block merging after those will be fixed. Also missing checkpoint to port this to v10.3 branch - is this intended? I thought we want to have it in v10.3 stable however I don't have strong opinion here, imo it could wait until v10.4-beta.1

Yes, added the check. this will be included in v10.3

@ank27 ank27 force-pushed the ak-allow-custom-attribution branch from 76ea168 to 061b830 Compare February 8, 2022 14:13
@ank27 ank27 merged commit 952832b into main Feb 8, 2022
@ank27 ank27 deleted the ak-allow-custom-attribution branch February 8, 2022 14:47
ank27 added a commit that referenced this pull request Feb 8, 2022
…ion modal sheet (#1087)

* allow string attribution

* Update sdk/src/test/java/com/mapbox/maps/attribution/AttributionParseTest.java

Co-authored-by: Kiryl Dzehtsiarenka <kiryl.dzehtsiarenka@mapbox.com>

* update attribute parser

Co-authored-by: Kiryl Dzehtsiarenka <kiryl.dzehtsiarenka@mapbox.com>
ank27 added a commit that referenced this pull request Feb 8, 2022
…ion modal sheet (#1087)

* allow string attribution

* Update sdk/src/test/java/com/mapbox/maps/attribution/AttributionParseTest.java

Co-authored-by: Kiryl Dzehtsiarenka <kiryl.dzehtsiarenka@mapbox.com>

* update attribute parser

Co-authored-by: Kiryl Dzehtsiarenka <kiryl.dzehtsiarenka@mapbox.com>
ank27 added a commit that referenced this pull request Feb 8, 2022
…ion modal sheet (#1087) (#1129)

* allow string attribution

* Update sdk/src/test/java/com/mapbox/maps/attribution/AttributionParseTest.java

Co-authored-by: Kiryl Dzehtsiarenka <kiryl.dzehtsiarenka@mapbox.com>

* update attribute parser

Co-authored-by: Kiryl Dzehtsiarenka <kiryl.dzehtsiarenka@mapbox.com>

Co-authored-by: Kiryl Dzehtsiarenka <kiryl.dzehtsiarenka@mapbox.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🪲 Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants