From 6b7d6047eca6cad4efb2e6cd97fe32c6f8ab911f Mon Sep 17 00:00:00 2001 From: zephyr2k Date: Mon, 25 Jan 2016 19:29:38 +0530 Subject: [PATCH 1/4] Add support for 3D touch 1. Use handler provided by apple when 3D Tocuh is triggered 2. Send event to PluginManager to handle event 3. Send action to appropriate function on game --- tealeaf/platform/PluginManager.h | 1 + tealeaf/platform/PluginManager.mm | 4 ++++ tealeaf/platform/TeaLeafAppDelegate.mm | 7 +++++++ 3 files changed, 12 insertions(+) diff --git a/tealeaf/platform/PluginManager.h b/tealeaf/platform/PluginManager.h index 2706f7b9..0218305d 100644 --- a/tealeaf/platform/PluginManager.h +++ b/tealeaf/platform/PluginManager.h @@ -39,6 +39,7 @@ - (void) handleOpenURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication; - (void) onPause; - (void) onResume; +- (void) performActionForShortcutItem: (NSString *) shortcutItem; @end diff --git a/tealeaf/platform/PluginManager.mm b/tealeaf/platform/PluginManager.mm index 7618fc0e..6aa7e189 100644 --- a/tealeaf/platform/PluginManager.mm +++ b/tealeaf/platform/PluginManager.mm @@ -200,6 +200,10 @@ - (void) onResume { [self postNotification:@"onResume" obj1:nil obj2:nil]; } +- (void) performActionForShortcutItem:(UIApplicationShortcutItem *) shortcutItem { + [self postNotification:@"performActionForShortcutItem:" obj1:shortcutItem obj2:nil]; +} + - (void) dispatchJSEventWithJSONString: (NSString*) str andRequestId:(NSNumber *)requestId { if (m_core) { JSContext *cx = m_core.cx; diff --git a/tealeaf/platform/TeaLeafAppDelegate.mm b/tealeaf/platform/TeaLeafAppDelegate.mm index f83d21a8..61082df3 100644 --- a/tealeaf/platform/TeaLeafAppDelegate.mm +++ b/tealeaf/platform/TeaLeafAppDelegate.mm @@ -457,6 +457,13 @@ - (void)application:(UIApplication *)app didReceiveLocalNotification:(UILocalNot [self.pluginManager didReceiveLocalNotification:notification application:app]; } +- (void) application: (UIApplication *) application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void (^)(BOOL succeeded))completionHandler +{ + [self.pluginManager performActionForShortcutItem:shortcutItem.type]; + if (completionHandler) { + completionHandler(true); + } +} //// Splash Screen From 42180583839c9502b607772caebcbf537299b410 Mon Sep 17 00:00:00 2001 From: zephyr2k Date: Fri, 29 Jan 2016 12:46:18 +0530 Subject: [PATCH 2/4] Change completionhandler response --- tealeaf/platform/TeaLeafAppDelegate.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tealeaf/platform/TeaLeafAppDelegate.mm b/tealeaf/platform/TeaLeafAppDelegate.mm index 61082df3..fc02bf01 100644 --- a/tealeaf/platform/TeaLeafAppDelegate.mm +++ b/tealeaf/platform/TeaLeafAppDelegate.mm @@ -461,7 +461,7 @@ - (void) application: (UIApplication *) application performActionForShortcutItem { [self.pluginManager performActionForShortcutItem:shortcutItem.type]; if (completionHandler) { - completionHandler(true); + completionHandler(YES); } } From 4a2c554ddbe9b6226226a003d5930366139d5b2c Mon Sep 17 00:00:00 2001 From: zephyr2k Date: Tue, 2 Feb 2016 15:59:06 +0530 Subject: [PATCH 3/4] Send UIApplicationShortcutItem object instead of string --- tealeaf/platform/PluginManager.h | 2 +- tealeaf/platform/TeaLeafAppDelegate.mm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tealeaf/platform/PluginManager.h b/tealeaf/platform/PluginManager.h index 0218305d..586176fa 100644 --- a/tealeaf/platform/PluginManager.h +++ b/tealeaf/platform/PluginManager.h @@ -39,7 +39,7 @@ - (void) handleOpenURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication; - (void) onPause; - (void) onResume; -- (void) performActionForShortcutItem: (NSString *) shortcutItem; +- (void) performActionForShortcutItem: (UIApplicationShortcutItem *) shortcutItem; @end diff --git a/tealeaf/platform/TeaLeafAppDelegate.mm b/tealeaf/platform/TeaLeafAppDelegate.mm index fc02bf01..df218784 100644 --- a/tealeaf/platform/TeaLeafAppDelegate.mm +++ b/tealeaf/platform/TeaLeafAppDelegate.mm @@ -459,7 +459,7 @@ - (void)application:(UIApplication *)app didReceiveLocalNotification:(UILocalNot - (void) application: (UIApplication *) application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void (^)(BOOL succeeded))completionHandler { - [self.pluginManager performActionForShortcutItem:shortcutItem.type]; + [self.pluginManager performActionForShortcutItem:shortcutItem]; if (completionHandler) { completionHandler(YES); } From 0151a411a55b57a312f920a8bff1208f56d455d8 Mon Sep 17 00:00:00 2001 From: Ramprasad Rajendran Date: Wed, 3 Feb 2016 15:01:55 +0530 Subject: [PATCH 4/4] spaces->tabs --- tealeaf/platform/PluginManager.mm | 2 +- tealeaf/platform/TeaLeafAppDelegate.mm | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tealeaf/platform/PluginManager.mm b/tealeaf/platform/PluginManager.mm index 6aa7e189..6dd0ea1b 100644 --- a/tealeaf/platform/PluginManager.mm +++ b/tealeaf/platform/PluginManager.mm @@ -201,7 +201,7 @@ - (void) onResume { } - (void) performActionForShortcutItem:(UIApplicationShortcutItem *) shortcutItem { - [self postNotification:@"performActionForShortcutItem:" obj1:shortcutItem obj2:nil]; + [self postNotification:@"performActionForShortcutItem:" obj1:shortcutItem obj2:nil]; } - (void) dispatchJSEventWithJSONString: (NSString*) str andRequestId:(NSNumber *)requestId { diff --git a/tealeaf/platform/TeaLeafAppDelegate.mm b/tealeaf/platform/TeaLeafAppDelegate.mm index df218784..084879ac 100644 --- a/tealeaf/platform/TeaLeafAppDelegate.mm +++ b/tealeaf/platform/TeaLeafAppDelegate.mm @@ -459,8 +459,8 @@ - (void)application:(UIApplication *)app didReceiveLocalNotification:(UILocalNot - (void) application: (UIApplication *) application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void (^)(BOOL succeeded))completionHandler { - [self.pluginManager performActionForShortcutItem:shortcutItem]; - if (completionHandler) { + [self.pluginManager performActionForShortcutItem:shortcutItem]; + if (completionHandler) { completionHandler(YES); } }