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

[TIMOB-11197] 3_0_X Add support for -568h@2x for imageView image #3641

Merged
merged 2 commits into from
Dec 27, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion iphone/Classes/MediaModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ -(void)showPicker:(NSDictionary*)args isCamera:(BOOL)isCamera
else if (cameraView!=nil)
{
// we use our own fullscreen transform if the developer didn't supply one
if ([[UIScreen mainScreen] bounds].size.height == 568) {
if ([TiUtils isRetinaFourInch]) {
picker.cameraViewTransform = CGAffineTransformScale(picker.cameraViewTransform, CAMERA_TRANSFORM_X, CAMERA_TRANSFORM_Y_ALT);
}
else {
Expand Down
2 changes: 1 addition & 1 deletion iphone/Classes/TiRootViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ - (UIImage*)defaultImageForOrientation:(UIDeviceOrientation) orientation resulti
*imageIdiom = UIUserInterfaceIdiomPhone;
// Default
image = nil;
if ([[UIScreen mainScreen] bounds].size.height == 568) {
if ([TiUtils isRetinaFourInch]) {
image = [UIImage imageNamed:@"Default-568h.png"];
if (image!=nil) {
return image;
Expand Down
6 changes: 6 additions & 0 deletions iphone/Classes/TiUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,12 @@ typedef enum {
*/
+(BOOL)isRetinaDisplay;

/**
Whether or not the current device has a 4 inch retina display (iPhone5).
@return _YES_ if the current device has a 4 inch retina display, _NO_ otherwise.
*/
+(BOOL)isRetinaFourInch;

+(int)dpi;

+(NSStringEncoding)charsetToEncoding:(NSString*)charset;
Expand Down
14 changes: 13 additions & 1 deletion iphone/Classes/TiUtils.m
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ +(int) dpi
}
}

+(BOOL)isRetinaFourInch
{
return ([[UIScreen mainScreen] bounds].size.height == 568);
}

+(BOOL)isRetinaDisplay
{
// since we call this alot, cache it
Expand Down Expand Up @@ -590,7 +595,7 @@ +(NSURL*)checkFor2XImage:(NSURL*)url

NSString *ext = [path pathExtension];

if(![ext isEqualToString:@"png"] && ![ext isEqualToString:@"jpg"])
if(![ext isEqualToString:@"png"] && ![ext isEqualToString:@"jpg"] && ![ext isEqualToString:@"jpeg"])
{ //It's not an image.
return url;
}
Expand All @@ -603,6 +608,13 @@ +(NSURL*)checkFor2XImage:(NSURL*)url
NSString *os = [TiUtils isIPad] ? @"~ipad" : @"~iphone";

if([TiUtils isRetinaDisplay]){
if ([TiUtils isRetinaFourInch]) {
// first try -568h@2x iphone5 specific
NSString *testpath = [NSString stringWithFormat:@"%@-568h@2x.%@",partial,ext];
if ([fm fileExistsAtPath:testpath]) {
return [NSURL fileURLWithPath:testpath];
}
}
// first try 2x device specific
NSString *testpath = [NSString stringWithFormat:@"%@@2x%@.%@",partial,os,ext];
if ([fm fileExistsAtPath:testpath])
Expand Down