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

[ios, macos] Update the attribution format for small snapshots. #10456

Merged
merged 1 commit into from
Nov 17, 2017

Conversation

fabian-guerra
Copy link
Contributor

@fabian-guerra fabian-guerra commented Nov 13, 2017

Fixes #10423

  • Update helmet image
  • macOS impl
  • iOS impl
  • test cases

@fabian-guerra fabian-guerra self-assigned this Nov 13, 2017
@1ec5 1ec5 added iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS labels Nov 14, 2017
@fabian-guerra fabian-guerra force-pushed the fabian-narrow-attribution-10423 branch from e23d217 to 90f6cc7 Compare November 16, 2017 01:43
@fabian-guerra fabian-guerra requested a review from 1ec5 November 16, 2017 01:46
@fabian-guerra
Copy link
Contributor Author

This is how it looks.
No logo.
nologo

Small logo.
small

@1ec5
Copy link
Contributor

1ec5 commented Nov 16, 2017

What changed in mapbox.pdf, other than downgrading from PDF version 1.5 to 1.4?

Also, helmet.pdf appears to be slightly off-center.

@fabian-guerra
Copy link
Contributor Author

I didn't realize mapbox.pdf was changed. I only opened in Xcode. The helmet is an image I made to test. I need the design team give me the right version.

@fabian-guerra fabian-guerra force-pushed the fabian-narrow-attribution-10423 branch 2 times, most recently from d8413c5 to f25bb65 Compare November 17, 2017 15:54
@fabian-guerra
Copy link
Contributor Author

@1ec5 do you think this is OK to go on the final version?

return [[NSImage alloc] initWithCGImage:cgimg size:[backgroundImage extent].size];
#endif
}

- (MGLSnapshotAttributionOptions *)attributionOptionsForSize:(CGSize)snapshotSize attributionInfo:(NSArray *)attributionInfo
{
NSMutableArray *attributionOptions = [NSMutableArray array];
Copy link
Contributor

Choose a reason for hiding this comment

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

It’s a bit confusing that an array of attribution options is called attributionOptions, as though it were only a single MGLSnapshotAttributionOptions object.


[attributionOptions addObject:largeLogoAttribution];
[attributionOptions addObject:smallLogoAttribution];
[attributionOptions addObject:noLogoAttribution];
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you think of a way to defer the logoImage logic above until we know which size to use, so that we don’t have to put together three MGLSnapshotAttributionOptions objects?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What do you mean? Each of these attribution options represent a rule as in #10423 (comment) which I use to get the best size.

Copy link
Contributor

Choose a reason for hiding this comment

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

Currently, we precompute the attribution styles before selecting the most appropriate one. My suggestion was to figure out which style would be most appropriate before loading the relevant resources, like the logo, since we ultimately only care about one of the styles. That way, the attributionOptions array becomes unnecessary.

Copy link
Contributor

Choose a reason for hiding this comment

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

We’re in a hurry to get v3.7.0 out the door, so I’ve outlined the refactor that needs to take place for v3.7.1 in #10490.

- (MGLSnapshotAttributionOptions *)attributionOptionsForAttributionInfo:(NSArray *)attributionInfo abbreviated:(BOOL)abbreviated
{
NSString *openStreetMap = @"OpenStreetMap";
NSString *OSM = @"OSM";
Copy link
Contributor

Choose a reason for hiding this comment

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

Make these strings localizable, in case one of the localizations translates “OpenStreetMap” and “OSM” into a different script (as Chinese and Japanese probably should).

Copy link
Contributor

@1ec5 1ec5 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 changes, but the big stuff is in #10490 now, since we’re in a hurry.

continue;
}
MGLAttributionInfo *attribution = [info copy];
if (abbreviated && [[info.title string] rangeOfString:openStreetMap].location != NSNotFound) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The string we’re looking for is “OpenStreetMap”, unlocalized, because the most common OpenStreetMap-based sources have this string baked in (mapbox/tilejson-spec#20). If we see “OpenStreetMap” (unlocalized), we should replace it with “OpenStreetMap” (localized) or “OSM” (localized) depending on isAbbreviated.

return noLogoAttribution;
}

- (MGLSnapshotAttributionOptions *)attributionOptionsForAttributionInfo:(NSArray *)attributionInfo abbreviated:(BOOL)abbreviated
Copy link
Contributor

Choose a reason for hiding this comment

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

abbreviated:(BOOL)isAbbreviated

- (MGLSnapshotAttributionOptions *)attributionOptionsForAttributionInfo:(NSArray *)attributionInfo abbreviated:(BOOL)abbreviated
{
NSString *openStreetMap = NSLocalizedStringWithDefaultValue(@"OPEN_STREET_MAP_ATTRIBUTION", nil, nil, @"OpenStreetMap", @"Open Street Map full name attribution");
NSString *OSM = NSLocalizedStringWithDefaultValue(@"OSM_ATTRIBUTION", nil, nil, @"OSM", @"Open Street Map short name attribution");
Copy link
Contributor

Choose a reason for hiding this comment

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

“OpenStreetMap” has no spaces. The keys should be OSM_LONG_NAME and OSM_SHORT_NAME, respectively, and the comments should be “Full/abbreviated name of OpenStreetMap in attribution text.”

@@ -64,6 +64,9 @@
/* User-friendly error description */
"PARSE_STYLE_FAILED_DESC" = "The map failed to load because the style is corrupted.";

/* String format for accessibility value for road feature; {starting compass direction}, {ending compass direction} */
"ROAD_DIRECTION_A11Y_FMT" = "%1$@ to %2$@";
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for catching this!

@fabian-guerra fabian-guerra force-pushed the fabian-narrow-attribution-10423 branch from ab8203a to e8d8e1f Compare November 17, 2017 19:13
@1ec5
Copy link
Contributor

1ec5 commented Nov 17, 2017

I updated the path to Localizable.strings in Transifex to point to the release-agua branch, so that translators can get started right away.

@fabian-guerra fabian-guerra force-pushed the fabian-narrow-attribution-10423 branch 2 times, most recently from 9a248de to c85fc0a Compare November 17, 2017 20:07
}
MGLAttributionInfo *attribution = [info copy];
NSMutableAttributedString *title = [[NSMutableAttributedString alloc] initWithAttributedString:info.title];
[title removeAttribute:NSUnderlineStyleAttributeName range:NSMakeRange(0, [title.string length])];
Copy link
Contributor

Choose a reason for hiding this comment

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

Technically a source can underline something that isn’t a link, using <u> for example. The more correct attribute to remove is the link attribute, which would be nonfunctional on an image.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've tried that NSLinkAttributeName but didn't work that's why I used NSUnderlineStyleAttributeName

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, it probably has to do with the HTML-to-attributed-string conversion. I think that step started forcefully applying an underline (and color) around the Sierra timeframe. I’m fine with this change (which fixes #10493), but can you add a comment explaining the removal, in case we need to accommodate intentional underlining in the future?

@fabian-guerra fabian-guerra force-pushed the fabian-narrow-attribution-10423 branch from c85fc0a to aadd25c Compare November 17, 2017 20:08
@fabian-guerra fabian-guerra merged commit 5eb050d into release-agua Nov 17, 2017
@fabian-guerra fabian-guerra deleted the fabian-narrow-attribution-10423 branch November 17, 2017 21:40
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants