From e0a704ec517fcbfabdc395077941030d780f1faa Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Thu, 25 Oct 2018 16:50:06 -0400 Subject: [PATCH 01/16] adobe track alert --- MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.h | 2 ++ MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.m | 2 ++ MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.m | 6 ++++-- MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.h | 1 + MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.m | 3 ++- .../MVMCore/MainProtocols/MVMCoreLoggingDelegateProtocol.h | 2 ++ MVMCore/MVMCore/OtherHandlers/MVMCoreLoggingHandler.h | 1 + MVMCore/MVMCore/OtherHandlers/MVMCoreLoggingHandler.m | 6 ++++++ 8 files changed, 20 insertions(+), 3 deletions(-) diff --git a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.h b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.h index 977911f..7d7aa25 100644 --- a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.h +++ b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.h @@ -12,5 +12,7 @@ @interface MVMCoreAlertController : UIAlertController @property (nonatomic, readonly, getter=isVisible) BOOL visible; +@property (nullable, nonatomic, copy) NSString *alertPageType; +@property (nullable, nonatomic, weak) id delegate; @end diff --git a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.m b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.m index 89352a4..3a67b54 100644 --- a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.m +++ b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.m @@ -7,6 +7,7 @@ // #import "MVMCoreAlertController.h" +#import "MVMCoreLoggingHandler.h" @interface MVMCoreAlertController () @@ -22,6 +23,7 @@ [self willChangeValueForKey:@"isVisible"]; self.visible = YES; [self didChangeValueForKey:@"isVisible"]; + [MVMCoreLoggingHandler logAlertForAlertPageType:self.alertPageType delegate:self.delegate]; } - (void)viewDidDisappear:(BOOL)animated { diff --git a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.m b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.m index bbbda62..2be088e 100644 --- a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.m +++ b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.m @@ -80,7 +80,7 @@ return [self showAlertWithTitle:title message:message actions:actions alertStyle:UIAlertControllerStyleAlert isGreedy:isGreedy alertDelegate:alertDelegate]; } -- (nonnull UIAlertController *)showAlertWithTitle:(nullable NSString *)title message:(nullable NSString *)message actions:(nullable NSArray*)actions alertStyle:(UIAlertControllerStyle)alertStyle isGreedy:(BOOL)isGreedy alertDelegate:(nullable NSObject *)alertDelegate { +- (nonnull UIAlertController *)showAlertWithTitle:(nullable NSString *)title message:(nullable NSString *)message pageType:(nullable NSString *)pageType actions:(nullable NSArray*)actions alertStyle:(UIAlertControllerStyle)alertStyle isGreedy:(BOOL)isGreedy alertDelegate:(nullable NSObject *)alertDelegate { // It's a greedy alert! Clear all alerts that are queued up and the one that is showing if (isGreedy) { @@ -89,6 +89,8 @@ // Create the alert. Adds the actions one by one. MVMCoreAlertController *alertController = [MVMCoreAlertController alertControllerWithTitle:(title ?: @"") message:message preferredStyle:alertStyle]; + alertController.alertPageType = pageType; + alertController.delegate = alertDelegate; for (NSUInteger i = 0; i < [actions count]; i++) { UIAlertAction *action = [actions objectAtIndex:i ofType:[UIAlertAction class]]; if (action) { @@ -102,7 +104,7 @@ } - (nonnull UIAlertController *)showAlertWithAlertObject:(nonnull MVMCoreAlertObject *)alertObject { - return [self showAlertWithTitle:alertObject.title message:alertObject.message actions:alertObject.actions alertStyle:alertObject.alertStyle isGreedy:alertObject.isGreedy alertDelegate:alertObject.alertDelegate]; + return [self showAlertWithTitle:alertObject.title message:alertObject.message pageType:alertObject.pageType actions:alertObject.actions alertStyle:alertObject.alertStyle isGreedy:alertObject.isGreedy alertDelegate:alertObject.alertDelegate]; } - (void)removeAllAlertViews { diff --git a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.h b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.h index 4b9d12c..b730e60 100644 --- a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.h +++ b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.h @@ -29,6 +29,7 @@ typedef void (^TextFieldErrorHandler)(NSArray * _Nonnull fieldErrors); @property (nullable, strong, nonatomic) NSString *title; @property (nullable, strong, nonatomic) NSString *message; +@property (nullable, strong, nonatomic) NSString *pageType; @property (nonnull, strong, nonatomic) NSArray *actions; @property (nonatomic) BOOL isGreedy; @property (nonatomic) UIAlertControllerStyle alertStyle; diff --git a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.m b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.m index 5599049..424616b 100644 --- a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.m +++ b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.m @@ -71,7 +71,6 @@ // Perform a popup. alert.type = MFAlertTypePopup; alert.alertStyle = UIAlertControllerStyleAlert; - // Check if we have a popup driven by page object (otherwise by default it will just use response info title message with an OK button). NSString *pageTypeForPopup = [responseInfo stringForKey:@"popupPageType"]; [[MVMCoreCache sharedCache] fetchJSONForPageType:pageTypeForPopup queue:nil waitUntilFinished:YES completionHandler:^(NSDictionary * _Nullable jsonDictionary) { @@ -88,6 +87,8 @@ alert = popupAlert; } }]; + alert.pageType = pageTypeForPopup; + alert.alertDelegate = actionDelegate; } else if (messageStyle.length == 0 && pageType) { // No message style! diff --git a/MVMCore/MVMCore/MainProtocols/MVMCoreLoggingDelegateProtocol.h b/MVMCore/MVMCore/MainProtocols/MVMCoreLoggingDelegateProtocol.h index fc0e353..476c497 100644 --- a/MVMCore/MVMCore/MainProtocols/MVMCoreLoggingDelegateProtocol.h +++ b/MVMCore/MVMCore/MainProtocols/MVMCoreLoggingDelegateProtocol.h @@ -24,4 +24,6 @@ // Log that the load has finished. - (void)logLoadFinished:(nullable MVMCoreLoadObject *)loadObject loadedViewController:(nullable UIViewController *)loadedViewController error:(nullable MVMCoreErrorObject *)error; +// Log alert +- (void)logAlertForAlertPageType:(nullable NSString *)pageType delegate:(nullable id)delegate; @end diff --git a/MVMCore/MVMCore/OtherHandlers/MVMCoreLoggingHandler.h b/MVMCore/MVMCore/OtherHandlers/MVMCoreLoggingHandler.h index 48700ec..e15d1f2 100644 --- a/MVMCore/MVMCore/OtherHandlers/MVMCoreLoggingHandler.h +++ b/MVMCore/MVMCore/OtherHandlers/MVMCoreLoggingHandler.h @@ -20,5 +20,6 @@ + (void)logDebugMessageWithDelegate:(nullable NSString *)message; + (void)logWithDelegateWithObject:(nullable id)object withName:(nullable NSString *)name withExtraInfo:(nullable NSDictionary *)extra; + (void)logWithDelegateLoadFinished:(nullable MVMCoreLoadObject *)loadObject loadedViewController:(nullable UIViewController *)loadedViewController error:(nullable MVMCoreErrorObject *)error; ++ (void)logAlertForAlertPageType:(nullable NSString *)pageType delegate:(_Nullable id)delegate; @end diff --git a/MVMCore/MVMCore/OtherHandlers/MVMCoreLoggingHandler.m b/MVMCore/MVMCore/OtherHandlers/MVMCoreLoggingHandler.m index 3c1daf8..b2026da 100644 --- a/MVMCore/MVMCore/OtherHandlers/MVMCoreLoggingHandler.m +++ b/MVMCore/MVMCore/OtherHandlers/MVMCoreLoggingHandler.m @@ -35,5 +35,11 @@ } } ++ (void)logAlertForAlertPageType:(nullable NSString *)pageType delegate:(_Nullable id)delegate { + if ([[MVMCoreObject sharedInstance].loggingDelegate respondsToSelector:@selector(logAlertForAlertPageType:delegate:)]) { + [[MVMCoreObject sharedInstance].loggingDelegate logAlertForAlertPageType:pageType delegate:delegate]; + } +} + @end From d12df0b7538042d1e6080b743f0aa74c9e8107fa Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Sat, 27 Oct 2018 17:29:05 -0400 Subject: [PATCH 02/16] fix warning --- MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.h | 3 ++- MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.m | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.h b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.h index 9e80bb0..4ed194f 100644 --- a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.h +++ b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.h @@ -40,13 +40,14 @@ /** Shows the alert. * @param title The title of the alert. * @param message The message of the alert. + * @param pageType The page type used for tracking. * @param actions An array of actions for the alert. * @param alertStyle Popup or action sheet * @param isGreedy Sets up a greedy alert. In other words, any alerts currently shown or queued are dismissed. * @param alertDelegate The delegate to be notified. * @return Returns the UIAlertController. */ -- (nonnull UIAlertController *)showAlertWithTitle:(nullable NSString *)title message:(nullable NSString *)message actions:(nullable NSArray*)actions alertStyle:(UIAlertControllerStyle)alertStyle isGreedy:(BOOL)isGreedy alertDelegate:(nullable NSObject *)alertDelegate; +- (nonnull UIAlertController *)showAlertWithTitle:(nullable NSString *)title message:(nullable NSString *)message pageType:(nullable NSString *)pageType actions:(nullable NSArray*)actions alertStyle:(UIAlertControllerStyle)alertStyle isGreedy:(BOOL)isGreedy alertDelegate:(nullable NSObject *)alertDelegate; /** Shows the popup with the passed in alert object. This is a convenience method that automatically handles using the proper alert type based on what's available. * @param alertObject The alert object to use for the alert. diff --git a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.m b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.m index 2be088e..0fb3b64 100644 --- a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.m +++ b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.m @@ -77,7 +77,7 @@ } - (nonnull UIAlertController *)showAlertWithTitle:(nullable NSString *)title message:(nullable NSString *)message actions:(nullable NSArray*)actions isGreedy:(BOOL)isGreedy alertDelegate:(nullable NSObject *)alertDelegate { - return [self showAlertWithTitle:title message:message actions:actions alertStyle:UIAlertControllerStyleAlert isGreedy:isGreedy alertDelegate:alertDelegate]; + return [self showAlertWithTitle:title message:message pageType:nil actions:actions alertStyle:UIAlertControllerStyleAlert isGreedy:isGreedy alertDelegate:alertDelegate]; } - (nonnull UIAlertController *)showAlertWithTitle:(nullable NSString *)title message:(nullable NSString *)message pageType:(nullable NSString *)pageType actions:(nullable NSArray*)actions alertStyle:(UIAlertControllerStyle)alertStyle isGreedy:(BOOL)isGreedy alertDelegate:(nullable NSObject *)alertDelegate { From 636417b31753028d9b238b1c3f7228015dbb345f Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Tue, 30 Oct 2018 12:21:28 -0400 Subject: [PATCH 03/16] alert handler takes alert object --- MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m | 2 +- .../MVMCore/AlertHandling/MVMCoreAlertController.h | 2 ++ .../MVMCore/AlertHandling/MVMCoreAlertController.m | 2 ++ MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.h | 6 ++++-- MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.m | 11 ++++++----- MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.h | 1 + MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.m | 1 + 7 files changed, 17 insertions(+), 8 deletions(-) diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m index e6932bf..94211c8 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m @@ -219,7 +219,7 @@ NSString * const KeyActionTypeOpen = @"openPage"; NSDictionary *responseInfo = [jsonDictionary dict:KeyResponseInfo]; if (responseInfo) { MVMCoreAlertObject *alertObject = [MVMCoreAlertObject alertObjectForPageType:pageTypeForTopAlert responseInfo:responseInfo additionalData:additionalData actionDelegate:delegate]; - if ([delegate respondsToSelector:@selector(willShowPopupWithAlertObject:alertJson:)]) { + if ([delegate respondsToSelector:@selector(willShowTopAlertWithAlertObject:alertJson:)]) { alertObject = [delegate willShowTopAlertWithAlertObject:alertObject alertJson:jsonDictionary]; } [alertObject showAlert]; diff --git a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.h b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.h index 7d7aa25..23ff9ac 100644 --- a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.h +++ b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.h @@ -8,11 +8,13 @@ // Used by our alert handler. Not for subclassing. Simply keeps track of if it's visible. Tries to parallel the UIAlertView to make it easier for the MVMCoreAlertHandler. #import +@class MVMCoreAlertObject; @interface MVMCoreAlertController : UIAlertController @property (nonatomic, readonly, getter=isVisible) BOOL visible; @property (nullable, nonatomic, copy) NSString *alertPageType; +@property (nullable, nonatomic, strong) MVMCoreAlertObject *alertObject; @property (nullable, nonatomic, weak) id delegate; @end diff --git a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.m b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.m index 3a67b54..d2a4986 100644 --- a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.m +++ b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.m @@ -8,11 +8,13 @@ #import "MVMCoreAlertController.h" #import "MVMCoreLoggingHandler.h" +#import "MVMCoreAlertObject.h" @interface MVMCoreAlertController () @property (nonatomic, readwrite, getter=isVisible) BOOL visible; + @end @implementation MVMCoreAlertController diff --git a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.h b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.h index 9e80bb0..7247245 100644 --- a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.h +++ b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.h @@ -29,15 +29,17 @@ - (BOOL)greedyAlertShowing; /** Shows the popup with the passed in parameter. + * @param alertObject The origonal alertObject * @param title The title of the alert. * @param message The message of the alert. * @param actions An array of actions for the alert. * @param isGreedy Sets up a greedy popup. In other words, any popups currently shown or queued are dismissed. * @return Returns the UIAlertController. */ -- (nonnull UIAlertController *)showAlertWithTitle:(nullable NSString *)title message:(nullable NSString *)message actions:(nullable NSArray*)actions isGreedy:(BOOL)isGreedy; +- (nonnull UIAlertController *)showAlertWithAlertObject:(nullable MVMCoreAlertObject *)alertObject title:(nullable NSString *)title message:(nullable NSString *)message actions:(nullable NSArray*)actions isGreedy:(BOOL)isGreedy; /** Shows the alert. + * @param alertObject The origonal alertObject * @param title The title of the alert. * @param message The message of the alert. * @param actions An array of actions for the alert. @@ -46,7 +48,7 @@ * @param alertDelegate The delegate to be notified. * @return Returns the UIAlertController. */ -- (nonnull UIAlertController *)showAlertWithTitle:(nullable NSString *)title message:(nullable NSString *)message actions:(nullable NSArray*)actions alertStyle:(UIAlertControllerStyle)alertStyle isGreedy:(BOOL)isGreedy alertDelegate:(nullable NSObject *)alertDelegate; +- (nonnull UIAlertController *)showAlertWithAlertObject:(nullable MVMCoreAlertObject *)alertObject title:(nullable NSString *)title message:(nullable NSString *)message actions:(nullable NSArray*)actions alertStyle:(UIAlertControllerStyle)alertStyle isGreedy:(BOOL)isGreedy alertDelegate:(nullable NSObject *)alertDelegate; /** Shows the popup with the passed in alert object. This is a convenience method that automatically handles using the proper alert type based on what's available. * @param alertObject The alert object to use for the alert. diff --git a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.m b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.m index 2be088e..a4de58c 100644 --- a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.m +++ b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.m @@ -72,15 +72,15 @@ return NO; } -- (nonnull UIAlertController *)showAlertWithTitle:(nullable NSString *)title message:(nullable NSString *)message actions:(nullable NSArray*)actions isGreedy:(BOOL)isGreedy { +- (nonnull UIAlertController *)showAlertWithAlertObject:(nullable MVMCoreAlertObject *)alertObject title:(nullable NSString *)title message:(nullable NSString *)message actions:(nullable NSArray*)actions isGreedy:(BOOL)isGreedy { return [self showAlertWithTitle:title message:message actions:actions isGreedy:isGreedy alertDelegate:nil]; } -- (nonnull UIAlertController *)showAlertWithTitle:(nullable NSString *)title message:(nullable NSString *)message actions:(nullable NSArray*)actions isGreedy:(BOOL)isGreedy alertDelegate:(nullable NSObject *)alertDelegate { +- (nonnull UIAlertController *)showAlertWithAlertObject:(nullable MVMCoreAlertObject *)alertObject title:(nullable NSString *)title message:(nullable NSString *)message actions:(nullable NSArray*)actions isGreedy:(BOOL)isGreedy alertDelegate:(nullable NSObject *)alertDelegate { return [self showAlertWithTitle:title message:message actions:actions alertStyle:UIAlertControllerStyleAlert isGreedy:isGreedy alertDelegate:alertDelegate]; } -- (nonnull UIAlertController *)showAlertWithTitle:(nullable NSString *)title message:(nullable NSString *)message pageType:(nullable NSString *)pageType actions:(nullable NSArray*)actions alertStyle:(UIAlertControllerStyle)alertStyle isGreedy:(BOOL)isGreedy alertDelegate:(nullable NSObject *)alertDelegate { +- (nonnull UIAlertController *)showAlertWithAlertObject:(nullable MVMCoreAlertObject *)alertObject title:(nullable NSString *)title message:(nullable NSString *)message actions:(nullable NSArray*)actions alertStyle:(UIAlertControllerStyle)alertStyle isGreedy:(BOOL)isGreedy alertDelegate:(nullable NSObject *)alertDelegate { // It's a greedy alert! Clear all alerts that are queued up and the one that is showing if (isGreedy) { @@ -89,7 +89,8 @@ // Create the alert. Adds the actions one by one. MVMCoreAlertController *alertController = [MVMCoreAlertController alertControllerWithTitle:(title ?: @"") message:message preferredStyle:alertStyle]; - alertController.alertPageType = pageType; + alertController.alertObject = alertObject; + alertController.alertPageType = alertObject.pageType; alertController.delegate = alertDelegate; for (NSUInteger i = 0; i < [actions count]; i++) { UIAlertAction *action = [actions objectAtIndex:i ofType:[UIAlertAction class]]; @@ -104,7 +105,7 @@ } - (nonnull UIAlertController *)showAlertWithAlertObject:(nonnull MVMCoreAlertObject *)alertObject { - return [self showAlertWithTitle:alertObject.title message:alertObject.message pageType:alertObject.pageType actions:alertObject.actions alertStyle:alertObject.alertStyle isGreedy:alertObject.isGreedy alertDelegate:alertObject.alertDelegate]; + return [self showAlertWithAlertObject:alertObject title:alertObject.title message:alertObject.message pageType:alertObject.pageType actions:alertObject.actions alertStyle:alertObject.alertStyle isGreedy:alertObject.isGreedy alertDelegate:alertObject.alertDelegate]; } - (void)removeAllAlertViews { diff --git a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.h b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.h index b730e60..8edc6a2 100644 --- a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.h +++ b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.h @@ -28,6 +28,7 @@ typedef void (^TextFieldErrorHandler)(NSArray * _Nonnull fieldErrors); @interface MVMCoreAlertObject : NSObject @property (nullable, strong, nonatomic) NSString *title; +@property (nullable, copy, nonatomic) NSDictionary *pageJson; @property (nullable, strong, nonatomic) NSString *message; @property (nullable, strong, nonatomic) NSString *pageType; @property (nonnull, strong, nonatomic) NSArray *actions; diff --git a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.m b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.m index 424616b..aa82631 100644 --- a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.m +++ b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.m @@ -146,6 +146,7 @@ MVMCoreAlertObject *alert = [[MVMCoreAlertObject alloc] init]; alert.title = [page stringForKey:KeyTitle]; + alert.pageJson = page; alert.message = [page stringForKey:KeyMessage]; alert.isGreedy = isGreedy; alert.type = MFAlertTypePopup; From c7e3364399dcc5a7e256252bac7c526b1481f885 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Tue, 30 Oct 2018 13:59:30 -0400 Subject: [PATCH 04/16] fixes --- MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.m | 2 +- MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.m | 6 +++--- .../MVMCore/MainProtocols/MVMCoreLoggingDelegateProtocol.h | 2 +- MVMCore/MVMCore/OtherHandlers/MVMCoreLoggingHandler.h | 2 +- MVMCore/MVMCore/OtherHandlers/MVMCoreLoggingHandler.m | 6 +++--- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.m b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.m index d2a4986..55d2efa 100644 --- a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.m +++ b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.m @@ -25,7 +25,7 @@ [self willChangeValueForKey:@"isVisible"]; self.visible = YES; [self didChangeValueForKey:@"isVisible"]; - [MVMCoreLoggingHandler logAlertForAlertPageType:self.alertPageType delegate:self.delegate]; + [MVMCoreLoggingHandler logAlertForAlertObject:self.alertObject delegate:self.delegate]; } - (void)viewDidDisappear:(BOOL)animated { diff --git a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.m b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.m index a4de58c..ad2acfe 100644 --- a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.m +++ b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.m @@ -73,11 +73,11 @@ } - (nonnull UIAlertController *)showAlertWithAlertObject:(nullable MVMCoreAlertObject *)alertObject title:(nullable NSString *)title message:(nullable NSString *)message actions:(nullable NSArray*)actions isGreedy:(BOOL)isGreedy { - return [self showAlertWithTitle:title message:message actions:actions isGreedy:isGreedy alertDelegate:nil]; + return [self showAlertWithAlertObject:alertObject title:title message:message actions:actions isGreedy:isGreedy alertDelegate:nil]; } - (nonnull UIAlertController *)showAlertWithAlertObject:(nullable MVMCoreAlertObject *)alertObject title:(nullable NSString *)title message:(nullable NSString *)message actions:(nullable NSArray*)actions isGreedy:(BOOL)isGreedy alertDelegate:(nullable NSObject *)alertDelegate { - return [self showAlertWithTitle:title message:message actions:actions alertStyle:UIAlertControllerStyleAlert isGreedy:isGreedy alertDelegate:alertDelegate]; + return [self showAlertWithAlertObject:alertObject title:title message:message actions:actions alertStyle:UIAlertControllerStyleAlert isGreedy:isGreedy alertDelegate:alertDelegate]; } - (nonnull UIAlertController *)showAlertWithAlertObject:(nullable MVMCoreAlertObject *)alertObject title:(nullable NSString *)title message:(nullable NSString *)message actions:(nullable NSArray*)actions alertStyle:(UIAlertControllerStyle)alertStyle isGreedy:(BOOL)isGreedy alertDelegate:(nullable NSObject *)alertDelegate { @@ -105,7 +105,7 @@ } - (nonnull UIAlertController *)showAlertWithAlertObject:(nonnull MVMCoreAlertObject *)alertObject { - return [self showAlertWithAlertObject:alertObject title:alertObject.title message:alertObject.message pageType:alertObject.pageType actions:alertObject.actions alertStyle:alertObject.alertStyle isGreedy:alertObject.isGreedy alertDelegate:alertObject.alertDelegate]; + return [self showAlertWithAlertObject:alertObject title:alertObject.title message:alertObject.message actions:alertObject.actions alertStyle:alertObject.alertStyle isGreedy:alertObject.isGreedy alertDelegate:alertObject.alertDelegate]; } - (void)removeAllAlertViews { diff --git a/MVMCore/MVMCore/MainProtocols/MVMCoreLoggingDelegateProtocol.h b/MVMCore/MVMCore/MainProtocols/MVMCoreLoggingDelegateProtocol.h index 476c497..43c0e0a 100644 --- a/MVMCore/MVMCore/MainProtocols/MVMCoreLoggingDelegateProtocol.h +++ b/MVMCore/MVMCore/MainProtocols/MVMCoreLoggingDelegateProtocol.h @@ -25,5 +25,5 @@ - (void)logLoadFinished:(nullable MVMCoreLoadObject *)loadObject loadedViewController:(nullable UIViewController *)loadedViewController error:(nullable MVMCoreErrorObject *)error; // Log alert -- (void)logAlertForAlertPageType:(nullable NSString *)pageType delegate:(nullable id)delegate; ++ (void)logAlertForAlertObject:(nullable MVMCoreAlertObject *)alertObject delegate:(_Nullable id)delegate; @end diff --git a/MVMCore/MVMCore/OtherHandlers/MVMCoreLoggingHandler.h b/MVMCore/MVMCore/OtherHandlers/MVMCoreLoggingHandler.h index e15d1f2..b20ef75 100644 --- a/MVMCore/MVMCore/OtherHandlers/MVMCoreLoggingHandler.h +++ b/MVMCore/MVMCore/OtherHandlers/MVMCoreLoggingHandler.h @@ -20,6 +20,6 @@ + (void)logDebugMessageWithDelegate:(nullable NSString *)message; + (void)logWithDelegateWithObject:(nullable id)object withName:(nullable NSString *)name withExtraInfo:(nullable NSDictionary *)extra; + (void)logWithDelegateLoadFinished:(nullable MVMCoreLoadObject *)loadObject loadedViewController:(nullable UIViewController *)loadedViewController error:(nullable MVMCoreErrorObject *)error; -+ (void)logAlertForAlertPageType:(nullable NSString *)pageType delegate:(_Nullable id)delegate; ++ (void)logAlertForAlertObject:(nullable MVMCoreAlertObject *)alertObject delegate:(_Nullable id)delegate; @end diff --git a/MVMCore/MVMCore/OtherHandlers/MVMCoreLoggingHandler.m b/MVMCore/MVMCore/OtherHandlers/MVMCoreLoggingHandler.m index b2026da..5df86d2 100644 --- a/MVMCore/MVMCore/OtherHandlers/MVMCoreLoggingHandler.m +++ b/MVMCore/MVMCore/OtherHandlers/MVMCoreLoggingHandler.m @@ -35,9 +35,9 @@ } } -+ (void)logAlertForAlertPageType:(nullable NSString *)pageType delegate:(_Nullable id)delegate { - if ([[MVMCoreObject sharedInstance].loggingDelegate respondsToSelector:@selector(logAlertForAlertPageType:delegate:)]) { - [[MVMCoreObject sharedInstance].loggingDelegate logAlertForAlertPageType:pageType delegate:delegate]; ++ (void)logAlertForAlertObject:(nullable MVMCoreAlertObject *)alertObject delegate:(_Nullable id)delegate { + if ([[MVMCoreObject sharedInstance].loggingDelegate respondsToSelector:@selector(logAlertForAlertObject:delegate:)]) { + [[MVMCoreObject sharedInstance].loggingDelegate logAlertForAlertObject:alertObject delegate:delegate]; } } From 05561e9cbf89cc95d1c9d166706db3a5ad7f9786 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Tue, 30 Oct 2018 14:25:06 -0400 Subject: [PATCH 05/16] remove alertPageType property --- MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.h | 1 - MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.m | 1 - 2 files changed, 2 deletions(-) diff --git a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.h b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.h index 23ff9ac..c3763d8 100644 --- a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.h +++ b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.h @@ -13,7 +13,6 @@ @interface MVMCoreAlertController : UIAlertController @property (nonatomic, readonly, getter=isVisible) BOOL visible; -@property (nullable, nonatomic, copy) NSString *alertPageType; @property (nullable, nonatomic, strong) MVMCoreAlertObject *alertObject; @property (nullable, nonatomic, weak) id delegate; diff --git a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.m b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.m index ad2acfe..eabd816 100644 --- a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.m +++ b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.m @@ -90,7 +90,6 @@ // Create the alert. Adds the actions one by one. MVMCoreAlertController *alertController = [MVMCoreAlertController alertControllerWithTitle:(title ?: @"") message:message preferredStyle:alertStyle]; alertController.alertObject = alertObject; - alertController.alertPageType = alertObject.pageType; alertController.delegate = alertDelegate; for (NSUInteger i = 0; i < [actions count]; i++) { UIAlertAction *action = [actions objectAtIndex:i ofType:[UIAlertAction class]]; From 0105a5d45000c167a9d8435fde7a8dc988048aab Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Tue, 30 Oct 2018 14:25:53 -0400 Subject: [PATCH 06/16] remove pageType in document --- MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.h | 1 - 1 file changed, 1 deletion(-) diff --git a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.h b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.h index b60cb42..7247245 100644 --- a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.h +++ b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.h @@ -42,7 +42,6 @@ * @param alertObject The origonal alertObject * @param title The title of the alert. * @param message The message of the alert. - * @param pageType The page type used for tracking. * @param actions An array of actions for the alert. * @param alertStyle Popup or action sheet * @param isGreedy Sets up a greedy alert. In other words, any alerts currently shown or queued are dismissed. From ea08526ce7331b29be7c3b371c47d4fd72d540cb Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 30 Oct 2018 16:11:28 -0400 Subject: [PATCH 07/16] revert and change slightly --- .../MVMCore/AlertHandling/MVMCoreAlertHandler.h | 6 ++---- .../MVMCore/AlertHandling/MVMCoreAlertHandler.m | 17 +++++++++-------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.h b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.h index 7247245..9e80bb0 100644 --- a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.h +++ b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.h @@ -29,17 +29,15 @@ - (BOOL)greedyAlertShowing; /** Shows the popup with the passed in parameter. - * @param alertObject The origonal alertObject * @param title The title of the alert. * @param message The message of the alert. * @param actions An array of actions for the alert. * @param isGreedy Sets up a greedy popup. In other words, any popups currently shown or queued are dismissed. * @return Returns the UIAlertController. */ -- (nonnull UIAlertController *)showAlertWithAlertObject:(nullable MVMCoreAlertObject *)alertObject title:(nullable NSString *)title message:(nullable NSString *)message actions:(nullable NSArray*)actions isGreedy:(BOOL)isGreedy; +- (nonnull UIAlertController *)showAlertWithTitle:(nullable NSString *)title message:(nullable NSString *)message actions:(nullable NSArray*)actions isGreedy:(BOOL)isGreedy; /** Shows the alert. - * @param alertObject The origonal alertObject * @param title The title of the alert. * @param message The message of the alert. * @param actions An array of actions for the alert. @@ -48,7 +46,7 @@ * @param alertDelegate The delegate to be notified. * @return Returns the UIAlertController. */ -- (nonnull UIAlertController *)showAlertWithAlertObject:(nullable MVMCoreAlertObject *)alertObject title:(nullable NSString *)title message:(nullable NSString *)message actions:(nullable NSArray*)actions alertStyle:(UIAlertControllerStyle)alertStyle isGreedy:(BOOL)isGreedy alertDelegate:(nullable NSObject *)alertDelegate; +- (nonnull UIAlertController *)showAlertWithTitle:(nullable NSString *)title message:(nullable NSString *)message actions:(nullable NSArray*)actions alertStyle:(UIAlertControllerStyle)alertStyle isGreedy:(BOOL)isGreedy alertDelegate:(nullable NSObject *)alertDelegate; /** Shows the popup with the passed in alert object. This is a convenience method that automatically handles using the proper alert type based on what's available. * @param alertObject The alert object to use for the alert. diff --git a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.m b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.m index eabd816..ccc30ae 100644 --- a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.m +++ b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.m @@ -72,16 +72,16 @@ return NO; } -- (nonnull UIAlertController *)showAlertWithAlertObject:(nullable MVMCoreAlertObject *)alertObject title:(nullable NSString *)title message:(nullable NSString *)message actions:(nullable NSArray*)actions isGreedy:(BOOL)isGreedy { - return [self showAlertWithAlertObject:alertObject title:title message:message actions:actions isGreedy:isGreedy alertDelegate:nil]; +- (nonnull UIAlertController *)showAlertWithTitle:(nullable NSString *)title message:(nullable NSString *)message actions:(nullable NSArray*)actions isGreedy:(BOOL)isGreedy { + return [self showAlertWithTitle:title message:message actions:actions isGreedy:isGreedy alertDelegate:nil]; } -- (nonnull UIAlertController *)showAlertWithAlertObject:(nullable MVMCoreAlertObject *)alertObject title:(nullable NSString *)title message:(nullable NSString *)message actions:(nullable NSArray*)actions isGreedy:(BOOL)isGreedy alertDelegate:(nullable NSObject *)alertDelegate { - return [self showAlertWithAlertObject:alertObject title:title message:message actions:actions alertStyle:UIAlertControllerStyleAlert isGreedy:isGreedy alertDelegate:alertDelegate]; +- (nonnull UIAlertController *)showAlertWithTitle:(nullable NSString *)title message:(nullable NSString *)message actions:(nullable NSArray*)actions isGreedy:(BOOL)isGreedy alertDelegate:(nullable NSObject *)alertDelegate { + return [self showAlertWithTitle:title message:message actions:actions alertStyle:UIAlertControllerStyleAlert isGreedy:isGreedy alertDelegate:alertDelegate]; } -- (nonnull UIAlertController *)showAlertWithAlertObject:(nullable MVMCoreAlertObject *)alertObject title:(nullable NSString *)title message:(nullable NSString *)message actions:(nullable NSArray*)actions alertStyle:(UIAlertControllerStyle)alertStyle isGreedy:(BOOL)isGreedy alertDelegate:(nullable NSObject *)alertDelegate { - +- (nonnull UIAlertController *)showAlertWithTitle:(nullable NSString *)title message:(nullable NSString *)message actions:(nullable NSArray*)actions alertStyle:(UIAlertControllerStyle)alertStyle isGreedy:(BOOL)isGreedy alertDelegate:(nullable NSObject *)alertDelegate { + // It's a greedy alert! Clear all alerts that are queued up and the one that is showing if (isGreedy) { [self removeAllAlertViews]; @@ -89,7 +89,6 @@ // Create the alert. Adds the actions one by one. MVMCoreAlertController *alertController = [MVMCoreAlertController alertControllerWithTitle:(title ?: @"") message:message preferredStyle:alertStyle]; - alertController.alertObject = alertObject; alertController.delegate = alertDelegate; for (NSUInteger i = 0; i < [actions count]; i++) { UIAlertAction *action = [actions objectAtIndex:i ofType:[UIAlertAction class]]; @@ -104,7 +103,9 @@ } - (nonnull UIAlertController *)showAlertWithAlertObject:(nonnull MVMCoreAlertObject *)alertObject { - return [self showAlertWithAlertObject:alertObject title:alertObject.title message:alertObject.message actions:alertObject.actions alertStyle:alertObject.alertStyle isGreedy:alertObject.isGreedy alertDelegate:alertObject.alertDelegate]; + MVMCoreAlertController *controller = [self showAlertWithAlertObject:alertObject title:alertObject.title message:alertObject.message actions:alertObject.actions alertStyle:alertObject.alertStyle isGreedy:alertObject.isGreedy alertDelegate:alertObject.alertDelegate]; + controller.alertObject = alertObject; + return controller; } - (void)removeAllAlertViews { From a0e08ad7e0e87af79b3bf2d01fcb757f82295a81 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Tue, 30 Oct 2018 16:21:14 -0400 Subject: [PATCH 08/16] revert --- MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.m b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.m index ccc30ae..642b073 100644 --- a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.m +++ b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.m @@ -103,7 +103,7 @@ } - (nonnull UIAlertController *)showAlertWithAlertObject:(nonnull MVMCoreAlertObject *)alertObject { - MVMCoreAlertController *controller = [self showAlertWithAlertObject:alertObject title:alertObject.title message:alertObject.message actions:alertObject.actions alertStyle:alertObject.alertStyle isGreedy:alertObject.isGreedy alertDelegate:alertObject.alertDelegate]; + MVMCoreAlertController *controller = (MVMCoreAlertController *)[self showAlertWithTitle:alertObject.title message:alertObject.message actions:alertObject.actions alertStyle:alertObject.alertStyle isGreedy:alertObject.isGreedy alertDelegate:alertObject.alertDelegate]; controller.alertObject = alertObject; return controller; } From cbe2ad2f57c156804c0a2eb8c37f18beec4af8ca Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 30 Oct 2018 16:35:50 -0400 Subject: [PATCH 09/16] remove space --- MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.m | 1 - 1 file changed, 1 deletion(-) diff --git a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.m b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.m index 55d2efa..d9ab5f9 100644 --- a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.m +++ b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.m @@ -14,7 +14,6 @@ @property (nonatomic, readwrite, getter=isVisible) BOOL visible; - @end @implementation MVMCoreAlertController From 71523fe67670cd6309777f8e5f1fb19473e638bf Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 30 Oct 2018 16:48:05 -0400 Subject: [PATCH 10/16] pass controller instead --- MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.m | 2 +- .../MVMCore/MainProtocols/MVMCoreLoggingDelegateProtocol.h | 4 +++- MVMCore/MVMCore/OtherHandlers/MVMCoreLoggingHandler.h | 3 ++- MVMCore/MVMCore/OtherHandlers/MVMCoreLoggingHandler.m | 6 +++--- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.m b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.m index d9ab5f9..684a382 100644 --- a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.m +++ b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.m @@ -24,7 +24,7 @@ [self willChangeValueForKey:@"isVisible"]; self.visible = YES; [self didChangeValueForKey:@"isVisible"]; - [MVMCoreLoggingHandler logAlertForAlertObject:self.alertObject delegate:self.delegate]; + [MVMCoreLoggingHandler logAlertForAlertController:self]; } - (void)viewDidDisappear:(BOOL)animated { diff --git a/MVMCore/MVMCore/MainProtocols/MVMCoreLoggingDelegateProtocol.h b/MVMCore/MVMCore/MainProtocols/MVMCoreLoggingDelegateProtocol.h index 43c0e0a..647c154 100644 --- a/MVMCore/MVMCore/MainProtocols/MVMCoreLoggingDelegateProtocol.h +++ b/MVMCore/MVMCore/MainProtocols/MVMCoreLoggingDelegateProtocol.h @@ -7,6 +7,7 @@ // #import +@class MVMCoreAlertController; @protocol MVMCoreLoggingDelegateProtocol @@ -25,5 +26,6 @@ - (void)logLoadFinished:(nullable MVMCoreLoadObject *)loadObject loadedViewController:(nullable UIViewController *)loadedViewController error:(nullable MVMCoreErrorObject *)error; // Log alert -+ (void)logAlertForAlertObject:(nullable MVMCoreAlertObject *)alertObject delegate:(_Nullable id)delegate; ++ (void)logAlertForAlertController:(nullable MVMCoreAlertController *)alertController; + @end diff --git a/MVMCore/MVMCore/OtherHandlers/MVMCoreLoggingHandler.h b/MVMCore/MVMCore/OtherHandlers/MVMCoreLoggingHandler.h index b20ef75..12d0e2a 100644 --- a/MVMCore/MVMCore/OtherHandlers/MVMCoreLoggingHandler.h +++ b/MVMCore/MVMCore/OtherHandlers/MVMCoreLoggingHandler.h @@ -10,6 +10,7 @@ #import #import #import +@class MVMCoreAlertController; #define MVMCoreLog(fmt, ...) \ [MVMCoreLoggingHandler logDebugMessageWithDelegate:[NSString stringWithFormat:(@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__]]; @@ -20,6 +21,6 @@ + (void)logDebugMessageWithDelegate:(nullable NSString *)message; + (void)logWithDelegateWithObject:(nullable id)object withName:(nullable NSString *)name withExtraInfo:(nullable NSDictionary *)extra; + (void)logWithDelegateLoadFinished:(nullable MVMCoreLoadObject *)loadObject loadedViewController:(nullable UIViewController *)loadedViewController error:(nullable MVMCoreErrorObject *)error; -+ (void)logAlertForAlertObject:(nullable MVMCoreAlertObject *)alertObject delegate:(_Nullable id)delegate; ++ (void)logAlertForAlertController:(nullable MVMCoreAlertController *)alertController; @end diff --git a/MVMCore/MVMCore/OtherHandlers/MVMCoreLoggingHandler.m b/MVMCore/MVMCore/OtherHandlers/MVMCoreLoggingHandler.m index 5df86d2..65e2659 100644 --- a/MVMCore/MVMCore/OtherHandlers/MVMCoreLoggingHandler.m +++ b/MVMCore/MVMCore/OtherHandlers/MVMCoreLoggingHandler.m @@ -35,9 +35,9 @@ } } -+ (void)logAlertForAlertObject:(nullable MVMCoreAlertObject *)alertObject delegate:(_Nullable id)delegate { - if ([[MVMCoreObject sharedInstance].loggingDelegate respondsToSelector:@selector(logAlertForAlertObject:delegate:)]) { - [[MVMCoreObject sharedInstance].loggingDelegate logAlertForAlertObject:alertObject delegate:delegate]; ++ (void)logAlertForAlertController:(nullable MVMCoreAlertController *)alertController { + if ([[MVMCoreObject sharedInstance].loggingDelegate respondsToSelector:@selector(logAlertForAlertController:)]) { + [[MVMCoreObject sharedInstance].loggingDelegate logAlertForAlertController:alertController]; } } From 3504a12e6110ecf1ffa2613a88123e9d6a4b09f5 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 30 Oct 2018 17:02:35 -0400 Subject: [PATCH 11/16] add tracking to alert protocol --- MVMCore/MVMCore/AlertHandling/MVMCoreAlertDelegateProtocol.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertDelegateProtocol.h b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertDelegateProtocol.h index 2bd6a6b..f4f05e5 100644 --- a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertDelegateProtocol.h +++ b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertDelegateProtocol.h @@ -8,11 +8,15 @@ // Called for popup style alerts. #import +@class MVMCoreAlertObject; @protocol MVMCoreAlertDelegateProtocol @optional +// helps tracking alert state +- (nullable NSDictionary *)additionalAlertDataToTrackForAlertWithObject:(nullable MVMCoreAlertObject *)alertObject; + // All are performed on the main thread. - (void)alertShown:(nonnull UIAlertController *)alertController; - (void)alertCancelled:(nonnull UIAlertController *)alertController; From cbcab0ea1c9fe4e07a9cfc423291fe2c01e2694f Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 30 Oct 2018 17:21:24 -0400 Subject: [PATCH 12/16] proper marking of delegate --- MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.h b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.h index c3763d8..21ea9e6 100644 --- a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.h +++ b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.h @@ -8,12 +8,13 @@ // Used by our alert handler. Not for subclassing. Simply keeps track of if it's visible. Tries to parallel the UIAlertView to make it easier for the MVMCoreAlertHandler. #import +#import @class MVMCoreAlertObject; @interface MVMCoreAlertController : UIAlertController @property (nonatomic, readonly, getter=isVisible) BOOL visible; @property (nullable, nonatomic, strong) MVMCoreAlertObject *alertObject; -@property (nullable, nonatomic, weak) id delegate; +@property (nullable, nonatomic, weak) NSObject *delegate; @end From bffb93660d295c6a843d7486bc7d7daaa8107151 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 30 Oct 2018 17:32:59 -0400 Subject: [PATCH 13/16] changes to the way popup delegacy works --- MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.h | 2 -- MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.m | 1 - MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.m | 3 +-- MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.m | 4 ++-- 4 files changed, 3 insertions(+), 7 deletions(-) diff --git a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.h b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.h index 21ea9e6..e38bedf 100644 --- a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.h +++ b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.h @@ -8,13 +8,11 @@ // Used by our alert handler. Not for subclassing. Simply keeps track of if it's visible. Tries to parallel the UIAlertView to make it easier for the MVMCoreAlertHandler. #import -#import @class MVMCoreAlertObject; @interface MVMCoreAlertController : UIAlertController @property (nonatomic, readonly, getter=isVisible) BOOL visible; @property (nullable, nonatomic, strong) MVMCoreAlertObject *alertObject; -@property (nullable, nonatomic, weak) NSObject *delegate; @end diff --git a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.m b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.m index 684a382..673c591 100644 --- a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.m +++ b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.m @@ -8,7 +8,6 @@ #import "MVMCoreAlertController.h" #import "MVMCoreLoggingHandler.h" -#import "MVMCoreAlertObject.h" @interface MVMCoreAlertController () diff --git a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.m b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.m index 642b073..5d5f93b 100644 --- a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.m +++ b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.m @@ -81,7 +81,7 @@ } - (nonnull UIAlertController *)showAlertWithTitle:(nullable NSString *)title message:(nullable NSString *)message actions:(nullable NSArray*)actions alertStyle:(UIAlertControllerStyle)alertStyle isGreedy:(BOOL)isGreedy alertDelegate:(nullable NSObject *)alertDelegate { - + // It's a greedy alert! Clear all alerts that are queued up and the one that is showing if (isGreedy) { [self removeAllAlertViews]; @@ -89,7 +89,6 @@ // Create the alert. Adds the actions one by one. MVMCoreAlertController *alertController = [MVMCoreAlertController alertControllerWithTitle:(title ?: @"") message:message preferredStyle:alertStyle]; - alertController.delegate = alertDelegate; for (NSUInteger i = 0; i < [actions count]; i++) { UIAlertAction *action = [actions objectAtIndex:i ofType:[UIAlertAction class]]; if (action) { diff --git a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.m b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.m index aa82631..06cec60 100644 --- a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.m +++ b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.m @@ -50,6 +50,7 @@ __block MVMCoreAlertObject *alert = [[MVMCoreAlertObject alloc] init]; alert.title = [responseInfo stringForKey:KeyErrorHeading]; alert.message = [responseInfo stringForKey:KeyUserMessage]; + alert.alertDelegate = actionDelegate; NSString *messageStyle = [responseInfo stringForKey:KeyMessageStyle]; if ([ValueTypeFieldErrors isEqualToString:[responseInfo string:KeyType]]) { @@ -71,6 +72,7 @@ // Perform a popup. alert.type = MFAlertTypePopup; alert.alertStyle = UIAlertControllerStyleAlert; + // Check if we have a popup driven by page object (otherwise by default it will just use response info title message with an OK button). NSString *pageTypeForPopup = [responseInfo stringForKey:@"popupPageType"]; [[MVMCoreCache sharedCache] fetchJSONForPageType:pageTypeForPopup queue:nil waitUntilFinished:YES completionHandler:^(NSDictionary * _Nullable jsonDictionary) { @@ -87,8 +89,6 @@ alert = popupAlert; } }]; - alert.pageType = pageTypeForPopup; - alert.alertDelegate = actionDelegate; } else if (messageStyle.length == 0 && pageType) { // No message style! From d825927486c922c413a607097c122d1558dcfc1f Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 30 Oct 2018 17:34:46 -0400 Subject: [PATCH 14/16] remove unused page type --- MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.h | 1 - 1 file changed, 1 deletion(-) diff --git a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.h b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.h index 8edc6a2..9735c7c 100644 --- a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.h +++ b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.h @@ -30,7 +30,6 @@ typedef void (^TextFieldErrorHandler)(NSArray * _Nonnull fieldErrors); @property (nullable, strong, nonatomic) NSString *title; @property (nullable, copy, nonatomic) NSDictionary *pageJson; @property (nullable, strong, nonatomic) NSString *message; -@property (nullable, strong, nonatomic) NSString *pageType; @property (nonnull, strong, nonatomic) NSArray *actions; @property (nonatomic) BOOL isGreedy; @property (nonatomic) UIAlertControllerStyle alertStyle; From fa4e23f330a366deccfae3e35f701b4eaff73726 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Tue, 30 Oct 2018 17:44:56 -0400 Subject: [PATCH 15/16] instance method in core logging delegate protocol --- MVMCore/MVMCore/MainProtocols/MVMCoreLoggingDelegateProtocol.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCore/MVMCore/MainProtocols/MVMCoreLoggingDelegateProtocol.h b/MVMCore/MVMCore/MainProtocols/MVMCoreLoggingDelegateProtocol.h index 647c154..b8ae254 100644 --- a/MVMCore/MVMCore/MainProtocols/MVMCoreLoggingDelegateProtocol.h +++ b/MVMCore/MVMCore/MainProtocols/MVMCoreLoggingDelegateProtocol.h @@ -26,6 +26,6 @@ - (void)logLoadFinished:(nullable MVMCoreLoadObject *)loadObject loadedViewController:(nullable UIViewController *)loadedViewController error:(nullable MVMCoreErrorObject *)error; // Log alert -+ (void)logAlertForAlertController:(nullable MVMCoreAlertController *)alertController; +- (void)logAlertForAlertController:(nullable MVMCoreAlertController *)alertController; @end From b8374bee5ff7dcde3f29a09f63bd6d156d4ffdf1 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Tue, 30 Oct 2018 18:26:25 -0400 Subject: [PATCH 16/16] fix delegate nil --- MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.m b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.m index 06cec60..0a5d8ca 100644 --- a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.m +++ b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.m @@ -50,7 +50,6 @@ __block MVMCoreAlertObject *alert = [[MVMCoreAlertObject alloc] init]; alert.title = [responseInfo stringForKey:KeyErrorHeading]; alert.message = [responseInfo stringForKey:KeyUserMessage]; - alert.alertDelegate = actionDelegate; NSString *messageStyle = [responseInfo stringForKey:KeyMessageStyle]; if ([ValueTypeFieldErrors isEqualToString:[responseInfo string:KeyType]]) { @@ -100,6 +99,7 @@ alert.alertStyle = UIAlertControllerStyleAlert; } } + alert.alertDelegate = actionDelegate; return alert; }