Skip to content

Commit

Permalink
Merge branch '8_2_X' into TIMOB-27419_8_2_X
Browse files Browse the repository at this point in the history
  • Loading branch information
ssekhri authored Oct 4, 2019
2 parents d2cef0d + 44074a8 commit ec5e9dd
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 56 deletions.
2 changes: 1 addition & 1 deletion iphone/Classes/TiUIApplicationShortcutsProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ - (UIApplicationShortcutIcon *)findIcon:(id)value
return [UIApplicationShortcutIcon iconWithTemplateImageName:[self urlInAssetCatalog:value]];
}

#ifdef IS_SDK_IOS_13
#if IS_SDK_IOS_13
if ([value isKindOfClass:[TiBlob class]] && [TiUtils isIOSVersionOrGreater:@"13.0"]) {
TiBlob *blob = (TiBlob *)value;
if (blob.type == TiBlobTypeSystemImage) {
Expand Down
2 changes: 1 addition & 1 deletion iphone/Classes/TiUIiOSApplicationShortcutsProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ - (UIApplicationShortcutIcon *)findIcon:(id)value
return [UIApplicationShortcutIcon iconWithTemplateImageName:[self urlInAssetCatalog:value]];
}

#ifdef IS_SDK_IOS_13
#if IS_SDK_IOS_13
if ([value isKindOfClass:[TiBlob class]] && [TiUtils isIOSVersionOrGreater:@"13.0"]) {
TiBlob *blob = (TiBlob *)value;
if (blob.type == TiBlobTypeSystemImage) {
Expand Down
6 changes: 0 additions & 6 deletions iphone/TitaniumKit/TitaniumKit/Sources/API/KrollBridge.m
Original file line number Diff line number Diff line change
Expand Up @@ -872,12 +872,6 @@ - (KrollWrapper *)loadJavascriptText:(NSString *)data fromFile:(NSString *)filen
userInfo:nil];
}

if (filename != nil && module != nil) {
// uri is optional but we point it to where we loaded it
[module replaceValue:[NSString stringWithFormat:@"app://%@", filename] forKey:@"uri" notification:NO];
[module replaceValue:filename forKey:@"id" notification:NO]; // set id to full path, originally this was the path from require call
}

return module;
}

Expand Down
15 changes: 12 additions & 3 deletions iphone/TitaniumKit/TitaniumKit/Sources/API/TiApp.m
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,12 @@ - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDiction
[launchOptions setObject:[url absoluteString] forKey:@"url"];
[launchOptions removeObjectForKey:UIApplicationLaunchOptionsSourceApplicationKey];

[launchOptions setObject:[options objectForKey:UIApplicationOpenURLOptionsSourceApplicationKey] ?: [NSNull null] forKey:@"source"];
id source = [options objectForKey:UIApplicationOpenURLOptionsSourceApplicationKey];
if (source != nil) {
[launchOptions setObject:source forKey:@"source"];
} else {
[launchOptions removeObjectForKey:@"source"];
}

if (appBooted) {
[[NSNotificationCenter defaultCenter] postNotificationName:kTiApplicationLaunchedFromURL object:self userInfo:launchOptions];
Expand All @@ -453,7 +458,11 @@ - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceAppl
[launchOptions setObject:[url absoluteString] forKey:@"url"];
[launchOptions removeObjectForKey:UIApplicationLaunchOptionsSourceApplicationKey];

[launchOptions setObject:sourceApplication ?: [NSNull null] forKey:@"source"];
if (sourceApplication != nil) {
[launchOptions setObject:sourceApplication forKey:@"source"];
} else {
[launchOptions removeObjectForKey:@"source"];
}

if (appBooted) {
[[NSNotificationCenter defaultCenter] postNotificationName:kTiApplicationLaunchedFromURL object:self userInfo:launchOptions];
Expand Down Expand Up @@ -1376,7 +1385,7 @@ + (NSDictionary *)dictionaryWithUserNotification:(UNNotification *)notification
[event setObject:NULL_IF_NIL(notification.request.content.userInfo) forKey:@"userInfo"];
[event setObject:NULL_IF_NIL(notification.request.content.categoryIdentifier) forKey:@"category"];
[event setObject:NULL_IF_NIL(notification.request.content.threadIdentifier) forKey:@"threadIdentifier"];
[event setObject:NULL_IF_NIL(notification.request.identifier) forKey:@"identifier"];
[event setObject:NULL_IF_NIL(identifier) forKey:@"identifier"];

// iOS 10+ does have "soundName" but "sound" which is a native object. But if we find
// a sound in the APS dictionary, we can provide that one for parity
Expand Down
81 changes: 36 additions & 45 deletions iphone/TitaniumKit/TitaniumKit/Sources/API/TiBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,24 @@ NSString *JavascriptNameForClass(Class c);

#define NULL_IF_NIL(x) ({ id xx = (x); (xx==nil)?[NSNull null]:xx; })

#define IS_NULL_OR_NIL(x) ((x == nil) || ((id)x == [NSNull null]))

#define ENSURE_CLASS_OR_NIL(x, t) \
if (IS_NULL_OR_NIL(x)) { \
x = nil; \
} else if (![x isKindOfClass:t]) { \
[self throwException:TiExceptionInvalidType subreason:[NSString stringWithFormat:@"expected: %@ or nil, was: %@", CLASS2JS(t), OBJTYPE2JS(x)] location:CODELOCATION]; \
}

#define ENSURE_TYPE_OR_NIL(x, t) ENSURE_CLASS_OR_NIL(x, [t class])

#define ENSURE_CLASS(x, t) \
if (![x isKindOfClass:t]) { \
[self throwException:TiExceptionInvalidType subreason:[NSString stringWithFormat:@"expected: %@, was: %@", CLASS2JS(t), OBJTYPE2JS(x)] location:CODELOCATION]; \
}

#define ENSURE_TYPE(x, t) ENSURE_CLASS(x, [t class])

//NOTE: these checks can be pulled out of production build type

//Question: Given that some of these silently massage the data during development but not production,
Expand All @@ -141,40 +159,31 @@ NSString *JavascriptNameForClass(Class c);
ENSURE_TYPE_OR_NIL(x, NSString); \
}

#define ENSURE_SINGLE_ARG(x, t) \
if ([x isKindOfClass:[NSArray class]] && [x count] > 0) { \
x = (t *)[x objectAtIndex:0]; \
} \
if (![x isKindOfClass:[t class]]) { \
[self throwException:TiExceptionInvalidType subreason:[NSString stringWithFormat:@"expected: %@, was: %@", CLASS2JS([t class]), OBJTYPE2JS(x)] location:CODELOCATION]; \
}
#define ENSURE_SINGLE_ARG(x, t) \
if ([x isKindOfClass:[NSArray class]] && [(NSArray *)x count] > 0) { \
x = (t *)[x objectAtIndex:0]; \
} \
ENSURE_TYPE(x, t);

#define ENSURE_SINGLE_ARG_OR_NIL(x, t) \
if (x == nil || x == [NSNull null]) { \
x = nil; \
} else { \
if ([x isKindOfClass:[NSArray class]] && [x count] > 0) { \
x = (t *)[x objectAtIndex:0]; \
} \
if (![x isKindOfClass:[t class]]) { \
[self throwException:TiExceptionInvalidType subreason:[NSString stringWithFormat:@"expected: %@, was: %@", CLASS2JS([t class]), OBJTYPE2JS(x)] location:CODELOCATION]; \
} \
#define ENSURE_SINGLE_ARG_OR_NIL(x, t) \
if (IS_NULL_OR_NIL(x)) { \
x = nil; \
} else { \
ENSURE_SINGLE_ARG(x, t); \
}

#define ENSURE_ARG_AT_INDEX(out, args, index, type) \
if ([args isKindOfClass:[NSArray class]] && [args count] > index) { \
out = (type *)[args objectAtIndex:index]; \
} \
if (![out isKindOfClass:[type class]]) { \
[self throwException:TiExceptionInvalidType subreason:[NSString stringWithFormat:@"expected: %@, was: %@", CLASS2JS([type class]), OBJTYPE2JS(out)] location:CODELOCATION]; \
}
#define ENSURE_ARG_AT_INDEX(out, args, index, type) \
if ([args isKindOfClass:[NSArray class]] && [(NSArray *)args count] > index) { \
out = (type *)[(NSArray *)args objectAtIndex:index]; \
} \
ENSURE_TYPE(out, type);

#define ENSURE_ARG_OR_NIL_AT_INDEX(out, args, index, type) \
if (args == nil || args == [NSNull null]) { \
if (IS_NULL_OR_NIL(args)) { \
out = nil; \
} else if ([args isKindOfClass:[NSArray class]]) { \
if ([args count] > index) { \
out = [args objectAtIndex:index]; \
if ([(NSArray *)args count] > index) { \
out = [(NSArray *)args objectAtIndex:index]; \
} else { \
out = nil; \
} \
Expand Down Expand Up @@ -239,30 +248,12 @@ NSString *JavascriptNameForClass(Class c);
} \
}

#define ENSURE_CLASS(x, t) \
if (![x isKindOfClass:t]) { \
[self throwException:TiExceptionInvalidType subreason:[NSString stringWithFormat:@"expected: %@, was: %@", CLASS2JS(t), OBJTYPE2JS(x)] location:CODELOCATION]; \
}

#define ENSURE_TYPE(x, t) ENSURE_CLASS(x, [t class])

//Because both NSString and NSNumber respond to intValue, etc, this is a wider net
#define ENSURE_METHOD(x, t) \
if (![x respondsToSelector:@selector(t)]) { \
[self throwException:TiExceptionInvalidType subreason:[NSString stringWithFormat:@"%@ doesn't respond to method: %@", OBJTYPE2JS(x), @ #t] location:CODELOCATION]; \
}

#define IS_NULL_OR_NIL(x) ((x == nil) || ((id)x == [NSNull null]))

#define ENSURE_CLASS_OR_NIL(x, t) \
if (IS_NULL_OR_NIL(x)) { \
x = nil; \
} else if (![x isKindOfClass:t]) { \
[self throwException:TiExceptionInvalidType subreason:[NSString stringWithFormat:@"expected: %@ or nil, was: %@", CLASS2JS(t), OBJTYPE2JS(x)] location:CODELOCATION]; \
}

#define ENSURE_TYPE_OR_NIL(x, t) ENSURE_CLASS_OR_NIL(x, [t class])

#define ENSURE_ARG_COUNT(x, c) \
if ([x count] < c) { \
[self throwException:TiExceptionNotEnoughArguments subreason:[NSString stringWithFormat:@"expected %d arguments, received: %lu", c, (unsigned long)[x count]] location:CODELOCATION]; \
Expand Down
12 changes: 12 additions & 0 deletions iphone/TitaniumKit/TitaniumKit/Sources/Modules/TiUIWindowProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -455,11 +455,23 @@ - (void)updateBarImage
if (theImage != nil) {
UIImage *resizableImage = [theImage resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0) resizingMode:UIImageResizingModeStretch];
ourNB.shadowImage = resizableImage;
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
if ([TiUtils isIOSVersionOrGreater:@"13.0"]) {
ourNB.standardAppearance.shadowImage = resizableImage;
ourNB.scrollEdgeAppearance.shadowImage = resizableImage;
}
#endif
} else {
BOOL clipValue = [TiUtils boolValue:[self valueForUndefinedKey:@"hideShadow"] def:NO];
if (clipValue) {
//Set an empty Image.
ourNB.shadowImage = [[[UIImage alloc] init] autorelease];
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
if ([TiUtils isIOSVersionOrGreater:@"13.0"]) {
ourNB.standardAppearance.shadowColor = nil;
ourNB.scrollEdgeAppearance.shadowColor = nil;
}
#endif
} else {
ourNB.shadowImage = nil;
}
Expand Down

0 comments on commit ec5e9dd

Please sign in to comment.