diff --git a/apidoc/Titanium/UI/iOS/ApplicationShortcuts.yml b/apidoc/Titanium/UI/iOS/ApplicationShortcuts.yml index 9754c0b65da..93eb058fef3 100644 --- a/apidoc/Titanium/UI/iOS/ApplicationShortcuts.yml +++ b/apidoc/Titanium/UI/iOS/ApplicationShortcuts.yml @@ -313,6 +313,8 @@ properties: The recommended size for image files is 35dp (@2px: 70dp, @3x: 105dp). Also check the [Apple documentation](https://developer.apple.com/documentation/uikit/uiapplicationshortcuticon) for more information on shortcut icons. + + On iOS 13 and higher, with SDK 8.2.1 or higher, you can pass in the Ti.Blob instance returned from . type: [Number,String,Titanium.Contacts.Person] constants: Titanium.UI.iOS.SHORTCUT_ICON_TYPE_* @@ -323,4 +325,4 @@ properties: description: | The userInfo is an object containing information about the shortcut like an ID or details about it. type: Object - optional: true \ No newline at end of file + optional: true diff --git a/iphone/Classes/TiUIApplicationShortcutsProxy.m b/iphone/Classes/TiUIApplicationShortcutsProxy.m index 485fd3381a5..3768d251cce 100644 --- a/iphone/Classes/TiUIApplicationShortcutsProxy.m +++ b/iphone/Classes/TiUIApplicationShortcutsProxy.m @@ -7,6 +7,7 @@ #if defined(USE_TI_UIIOSAPPLICATIONSHORTCUTS) || defined(USE_TI_UIAPPLICATIONSHORTCUTS) #import "TiUIApplicationShortcutsProxy.h" +#import #import #ifdef USE_TI_CONTACTS #import "TiContactsPerson.h" @@ -211,6 +212,14 @@ - (UIApplicationShortcutIcon *)findIcon:(id)value return [UIApplicationShortcutIcon iconWithTemplateImageName:[self urlInAssetCatalog:value]]; } +#ifdef IS_SDK_IOS_13 + if ([value isKindOfClass:[TiBlob class]] && [TiUtils isIOSVersionOrGreater:@"13.0"]) { + TiBlob *blob = (TiBlob *)value; + if (blob.type == TiBlobTypeSystemImage) { + return [UIApplicationShortcutIcon iconWithSystemImageName:blob.systemImageName]; + } + } +#endif NSLog(@"[ERROR] Ti.UI.ApplicationShortcuts: Invalid icon provided, defaulting to use no icon."); return nil; } diff --git a/iphone/Classes/TiUIiOSApplicationShortcutsProxy.m b/iphone/Classes/TiUIiOSApplicationShortcutsProxy.m index 669ccf4b2dd..cd355a1c00b 100644 --- a/iphone/Classes/TiUIiOSApplicationShortcutsProxy.m +++ b/iphone/Classes/TiUIiOSApplicationShortcutsProxy.m @@ -7,6 +7,7 @@ #ifdef USE_TI_UIIOSAPPLICATIONSHORTCUTS #import "TiUIiOSApplicationShortcutsProxy.h" +#import #import #ifdef USE_TI_CONTACTS #import "TiContactsPerson.h" @@ -211,6 +212,15 @@ - (UIApplicationShortcutIcon *)findIcon:(id)value return [UIApplicationShortcutIcon iconWithTemplateImageName:[self urlInAssetCatalog:value]]; } +#ifdef IS_SDK_IOS_13 + if ([value isKindOfClass:[TiBlob class]] && [TiUtils isIOSVersionOrGreater:@"13.0"]) { + TiBlob *blob = (TiBlob *)value; + if (blob.type == TiBlobTypeSystemImage) { + return [UIApplicationShortcutIcon iconWithSystemImageName:blob.systemImageName]; + } + } +#endif + NSLog(@"[ERROR] Ti.UI.iOS.ApplicationShortcuts: Invalid icon provided, defaulting to use no icon."); return nil; } diff --git a/iphone/Classes/TiUIiOSProxy.m b/iphone/Classes/TiUIiOSProxy.m index 10cbcfbfc2f..8ad86893507 100644 --- a/iphone/Classes/TiUIiOSProxy.m +++ b/iphone/Classes/TiUIiOSProxy.m @@ -394,8 +394,7 @@ - (TiBlob *)systemImage:(id)arg return nil; } ENSURE_SINGLE_ARG_OR_NIL(arg, NSString); - UIImage *image = [UIImage systemImageNamed:arg]; - TiBlob *blob = [[TiBlob alloc] initWithImage:image]; + TiBlob *blob = [[TiBlob alloc] initWithSystemImage:arg]; return blob; } #endif diff --git a/iphone/TitaniumKit/TitaniumKit/Sources/API/TiBlob.h b/iphone/TitaniumKit/TitaniumKit/Sources/API/TiBlob.h index 03b1f47f50d..d187d897e5a 100644 --- a/iphone/TitaniumKit/TitaniumKit/Sources/API/TiBlob.h +++ b/iphone/TitaniumKit/TitaniumKit/Sources/API/TiBlob.h @@ -81,7 +81,8 @@ JSExportAs(imageWithRoundedCorner, typedef enum { TiBlobTypeImage = 0, TiBlobTypeFile = 1, - TiBlobTypeData = 2 + TiBlobTypeData = 2, + TiBlobTypeSystemImage = 3 } TiBlobType; /** @@ -95,6 +96,7 @@ typedef enum { UIImage *image; NSString *path; BOOL imageLoadAttempted; + NSString *systemImageName; } /** @@ -125,6 +127,21 @@ typedef enum { */ - (id)initWithImage:(UIImage *)image; +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000 +/** +Initialize the blob with a system image. +@param imageName The system image name +*/ +- (id)initWithSystemImage:(NSString *)imageName; + +/** + Returns the System Image Name . + @return The string or nil. + */ +- (NSString *)systemImageName; + +#endif + /** Initialize the blob with data. @param data_ The raw data. diff --git a/iphone/TitaniumKit/TitaniumKit/Sources/API/TiBlob.m b/iphone/TitaniumKit/TitaniumKit/Sources/API/TiBlob.m index 2b6c5156fab..4d5c6eed290 100644 --- a/iphone/TitaniumKit/TitaniumKit/Sources/API/TiBlob.m +++ b/iphone/TitaniumKit/TitaniumKit/Sources/API/TiBlob.m @@ -26,6 +26,7 @@ - (void)dealloc RELEASE_TO_NIL(data); RELEASE_TO_NIL(image); RELEASE_TO_NIL(path); + RELEASE_TO_NIL(systemImageName); [super dealloc]; } @@ -136,6 +137,28 @@ - (id)initWithImage:(UIImage *)image_ return self; } +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000 +- (id)initWithSystemImage:(NSString *)imageName +{ + if (![TiUtils isIOSVersionOrGreater:@"13.0"]) { + return nil; + } + + if (self = [super init]) { + image = [[UIImage systemImageNamed:imageName] retain]; + type = TiBlobTypeSystemImage; + systemImageName = [imageName retain]; + mimetype = [([UIImageAlpha hasAlpha:image] ? MIMETYPE_PNG : MIMETYPE_JPEG)copy]; + } + return self; +} + +- (NSString *)systemImageName +{ + return systemImageName; +} +#endif + - (id)initWithData:(NSData *)data_ mimetype:(NSString *)mimetype_ { if (self = [super init]) {