Skip to content

Commit

Permalink
Merge pull request #3666 from osmandapp/fix_wikimedia_photos_4
Browse files Browse the repository at this point in the history
fix wikimedia photos 4
  • Loading branch information
vshcherb authored May 3, 2024
2 parents dcc4246 + a9f2354 commit bae9424
Show file tree
Hide file tree
Showing 4 changed files with 247 additions and 189 deletions.
4 changes: 1 addition & 3 deletions Sources/Cards/OAWikiImageCard.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,12 @@

- (instancetype)initWithWikiMediaTag:(NSString *)wikiMediaTag imageName:(NSString *)imageName imageStubUrl:(NSString *)imageStubUrl imageHiResUrl:(NSString *)imageHiResUrl;

- (NSString *)getUrlWithCommonAttributions:(BOOL)isWikimediaCategory;
- (NSString *)getUrlWithCommonAttributions;

@end

@interface OAWikiImageCard : OAImageCard

- (instancetype)initWithWikiImage:(OAWikiImage *)wikiImage type:(NSString *)type;

- (instancetype)initWithWikiImage:(OAWikiImage *)wikiImage type:(NSString *)type wikimediaCategory:(BOOL)isWikimediaCategory;

@end
22 changes: 3 additions & 19 deletions Sources/Cards/OAWikiImageCard.mm
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,9 @@ - (instancetype)initWithWikiMediaTag:(NSString *)wikiMediaTag imageName:(NSStrin
return self;
}

- (NSString *)getUrlWithCommonAttributions:(BOOL)isWikimediaCategory;
- (NSString *)getUrlWithCommonAttributions
{
if (!isWikimediaCategory)
{
NSString *url = [NSString stringWithFormat:@"%@%@%@", WIKIMEDIA_COMMONS_URL, WIKIMEDIA_FILE, _wikiMediaTag];
return url;
}
else
{
NSString *url = [NSString stringWithFormat:@"%@%@", WIKIMEDIA_COMMONS_URL, _wikiMediaTag];
return url;
}
return [NSString stringWithFormat:@"%@%@%@", WIKIMEDIA_COMMONS_URL, WIKIMEDIA_FILE, _wikiMediaTag];
}

@end
Expand All @@ -58,24 +49,17 @@ @interface OAWikiImageCard ()
@implementation OAWikiImageCard
{
NSString *_urlWithCommonAttributions;
BOOL _isWikimediaCategory;
}

@dynamic type, title, url, imageUrl, topIcon;

- (instancetype)initWithWikiImage:(OAWikiImage *)wikiImage type:(NSString *)type
{
return [self initWithWikiImage:wikiImage type:type wikimediaCategory:NO];
}

- (instancetype)initWithWikiImage:(OAWikiImage *)wikiImage type:(NSString *)type wikimediaCategory:(BOOL)isWikimediaCategory
{
self = [super init];
if (self)
{
_isWikimediaCategory = isWikimediaCategory;
self.type = type;
_urlWithCommonAttributions = [wikiImage getUrlWithCommonAttributions:_isWikimediaCategory];
_urlWithCommonAttributions = [wikiImage getUrlWithCommonAttributions];
if (self.topIcon.length == 0)
self.topIcon = @"ic_custom_logo_wikimedia.png";
[self setImageUrl:@""];
Expand Down
Loading

0 comments on commit bae9424

Please sign in to comment.