-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[ios, macos] Update the attribution format for small snapshots. #10456
Conversation
e23d217
to
90f6cc7
Compare
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. |
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. |
d8413c5
to
f25bb65
Compare
@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]; |
There was a problem hiding this comment.
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]; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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"; |
There was a problem hiding this comment.
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).
f25bb65
to
ab8203a
Compare
There was a problem hiding this 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) { |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
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$@"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for catching this!
ab8203a
to
e8d8e1f
Compare
I updated the path to Localizable.strings in Transifex to point to the release-agua branch, so that translators can get started right away. |
9a248de
to
c85fc0a
Compare
} | ||
MGLAttributionInfo *attribution = [info copy]; | ||
NSMutableAttributedString *title = [[NSMutableAttributedString alloc] initWithAttributedString:info.title]; | ||
[title removeAttribute:NSUnderlineStyleAttributeName range:NSMakeRange(0, [title.string length])]; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
c85fc0a
to
aadd25c
Compare
Fixes #10423