From 35a8a2988aca6ecc407ce2a4eab7426523680028 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 28 Oct 2020 10:18:48 -0400 Subject: [PATCH 01/11] checkout delete files --- MVMCore/MVMCore.xcodeproj/project.pbxproj | 28 -- ...MVMCoreTopAlertAnimationDelegateProtocol.h | 22 -- .../MVMCoreTopAlertDelegateProtocol.h | 23 -- .../AlertHandling/MVMCoreTopAlertObject.h | 64 ----- .../AlertHandling/MVMCoreTopAlertObject.m | 95 ------- .../AlertHandling/MVMCoreTopAlertOperation.h | 33 --- .../AlertHandling/MVMCoreTopAlertOperation.m | 264 ------------------ .../MVMCoreTopAlertViewProtocol.h | 28 -- 8 files changed, 557 deletions(-) delete mode 100644 MVMCore/MVMCore/AlertHandling/MVMCoreTopAlertAnimationDelegateProtocol.h delete mode 100644 MVMCore/MVMCore/AlertHandling/MVMCoreTopAlertDelegateProtocol.h delete mode 100644 MVMCore/MVMCore/AlertHandling/MVMCoreTopAlertObject.h delete mode 100644 MVMCore/MVMCore/AlertHandling/MVMCoreTopAlertObject.m delete mode 100644 MVMCore/MVMCore/AlertHandling/MVMCoreTopAlertOperation.h delete mode 100644 MVMCore/MVMCore/AlertHandling/MVMCoreTopAlertOperation.m delete mode 100644 MVMCore/MVMCore/AlertHandling/MVMCoreTopAlertViewProtocol.h diff --git a/MVMCore/MVMCore.xcodeproj/project.pbxproj b/MVMCore/MVMCore.xcodeproj/project.pbxproj index 12ade7f..ce873db 100644 --- a/MVMCore/MVMCore.xcodeproj/project.pbxproj +++ b/MVMCore/MVMCore.xcodeproj/project.pbxproj @@ -121,12 +121,6 @@ AFBB969E1FBA3A9A0008D868 /* MVMCoreAlertObject.m in Sources */ = {isa = PBXBuildFile; fileRef = AFBB96811FBA3A9A0008D868 /* MVMCoreAlertObject.m */; }; AFBB969F1FBA3A9A0008D868 /* MVMCoreAlertOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = AFBB96821FBA3A9A0008D868 /* MVMCoreAlertOperation.h */; settings = {ATTRIBUTES = (Public, ); }; }; AFBB96A01FBA3A9A0008D868 /* MVMCoreAlertOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = AFBB96831FBA3A9A0008D868 /* MVMCoreAlertOperation.m */; }; - AFBB96A11FBA3A9A0008D868 /* MVMCoreTopAlertAnimationDelegateProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = AFBB96841FBA3A9A0008D868 /* MVMCoreTopAlertAnimationDelegateProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AFBB96A21FBA3A9A0008D868 /* MVMCoreTopAlertDelegateProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = AFBB96851FBA3A9A0008D868 /* MVMCoreTopAlertDelegateProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AFBB96A31FBA3A9A0008D868 /* MVMCoreTopAlertObject.h in Headers */ = {isa = PBXBuildFile; fileRef = AFBB96861FBA3A9A0008D868 /* MVMCoreTopAlertObject.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AFBB96A41FBA3A9A0008D868 /* MVMCoreTopAlertObject.m in Sources */ = {isa = PBXBuildFile; fileRef = AFBB96871FBA3A9A0008D868 /* MVMCoreTopAlertObject.m */; }; - AFBB96A51FBA3A9A0008D868 /* MVMCoreTopAlertOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = AFBB96881FBA3A9A0008D868 /* MVMCoreTopAlertOperation.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AFBB96A61FBA3A9A0008D868 /* MVMCoreTopAlertOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = AFBB96891FBA3A9A0008D868 /* MVMCoreTopAlertOperation.m */; }; AFBB96B01FBA3B590008D868 /* MVMCoreDispatchUtility.h in Headers */ = {isa = PBXBuildFile; fileRef = AFBB96AC1FBA3B590008D868 /* MVMCoreDispatchUtility.h */; settings = {ATTRIBUTES = (Public, ); }; }; AFBB96B11FBA3B590008D868 /* MVMCoreDispatchUtility.m in Sources */ = {isa = PBXBuildFile; fileRef = AFBB96AD1FBA3B590008D868 /* MVMCoreDispatchUtility.m */; }; AFBB96B21FBA3B590008D868 /* MVMCoreGetterUtility.h in Headers */ = {isa = PBXBuildFile; fileRef = AFBB96AE1FBA3B590008D868 /* MVMCoreGetterUtility.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -137,7 +131,6 @@ AFBB96EC1FBA4A260008D868 /* MFHardCodedServerResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = AFBB96E91FBA4A260008D868 /* MFHardCodedServerResponse.h */; }; AFBB96ED1FBA4A260008D868 /* MFHardCodedServerResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = AFBB96EA1FBA4A260008D868 /* MFHardCodedServerResponse.m */; }; AFC5FA161FFC2E2A00C244CF /* MVMCoreGlobalTopAlertDelegateProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = AFC5FA141FFC2E2A00C244CF /* MVMCoreGlobalTopAlertDelegateProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AFC5FA1D1FFC39C700C244CF /* MVMCoreTopAlertViewProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = AFC5FA1C1FFC39C700C244CF /* MVMCoreTopAlertViewProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; AFEA17A8209B6A1C00BC6740 /* MVMCoreBlockOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = AFEA17A6209B6A1C00BC6740 /* MVMCoreBlockOperation.h */; settings = {ATTRIBUTES = (Public, ); }; }; AFEA17A9209B6A1C00BC6740 /* MVMCoreBlockOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = AFEA17A7209B6A1C00BC6740 /* MVMCoreBlockOperation.m */; }; AFED77A11FCCA29400BAE689 /* MVMCoreViewControllerNibMappingObject.h in Headers */ = {isa = PBXBuildFile; fileRef = AFED77991FCCA29300BAE689 /* MVMCoreViewControllerNibMappingObject.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -273,12 +266,6 @@ AFBB96811FBA3A9A0008D868 /* MVMCoreAlertObject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCoreAlertObject.m; sourceTree = ""; }; AFBB96821FBA3A9A0008D868 /* MVMCoreAlertOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreAlertOperation.h; sourceTree = ""; }; AFBB96831FBA3A9A0008D868 /* MVMCoreAlertOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCoreAlertOperation.m; sourceTree = ""; }; - AFBB96841FBA3A9A0008D868 /* MVMCoreTopAlertAnimationDelegateProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreTopAlertAnimationDelegateProtocol.h; sourceTree = ""; }; - AFBB96851FBA3A9A0008D868 /* MVMCoreTopAlertDelegateProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreTopAlertDelegateProtocol.h; sourceTree = ""; }; - AFBB96861FBA3A9A0008D868 /* MVMCoreTopAlertObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreTopAlertObject.h; sourceTree = ""; }; - AFBB96871FBA3A9A0008D868 /* MVMCoreTopAlertObject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCoreTopAlertObject.m; sourceTree = ""; }; - AFBB96881FBA3A9A0008D868 /* MVMCoreTopAlertOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreTopAlertOperation.h; sourceTree = ""; }; - AFBB96891FBA3A9A0008D868 /* MVMCoreTopAlertOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCoreTopAlertOperation.m; sourceTree = ""; }; AFBB96AC1FBA3B590008D868 /* MVMCoreDispatchUtility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreDispatchUtility.h; sourceTree = ""; }; AFBB96AD1FBA3B590008D868 /* MVMCoreDispatchUtility.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCoreDispatchUtility.m; sourceTree = ""; }; AFBB96AE1FBA3B590008D868 /* MVMCoreGetterUtility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreGetterUtility.h; sourceTree = ""; }; @@ -290,7 +277,6 @@ AFBB96E91FBA4A260008D868 /* MFHardCodedServerResponse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFHardCodedServerResponse.h; sourceTree = ""; }; AFBB96EA1FBA4A260008D868 /* MFHardCodedServerResponse.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFHardCodedServerResponse.m; sourceTree = ""; }; AFC5FA141FFC2E2A00C244CF /* MVMCoreGlobalTopAlertDelegateProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreGlobalTopAlertDelegateProtocol.h; sourceTree = ""; }; - AFC5FA1C1FFC39C700C244CF /* MVMCoreTopAlertViewProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreTopAlertViewProtocol.h; sourceTree = ""; }; AFEA17A6209B6A1C00BC6740 /* MVMCoreBlockOperation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreBlockOperation.h; sourceTree = ""; }; AFEA17A7209B6A1C00BC6740 /* MVMCoreBlockOperation.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreBlockOperation.m; sourceTree = ""; }; AFED77991FCCA29300BAE689 /* MVMCoreViewControllerNibMappingObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreViewControllerNibMappingObject.h; sourceTree = ""; }; @@ -603,13 +589,6 @@ 0184D3E224B8D0C600A05369 /* MVMCoreAlertObject+Swift.swift */, AFBB96821FBA3A9A0008D868 /* MVMCoreAlertOperation.h */, AFBB96831FBA3A9A0008D868 /* MVMCoreAlertOperation.m */, - AFBB96841FBA3A9A0008D868 /* MVMCoreTopAlertAnimationDelegateProtocol.h */, - AFBB96851FBA3A9A0008D868 /* MVMCoreTopAlertDelegateProtocol.h */, - AFC5FA1C1FFC39C700C244CF /* MVMCoreTopAlertViewProtocol.h */, - AFBB96861FBA3A9A0008D868 /* MVMCoreTopAlertObject.h */, - AFBB96871FBA3A9A0008D868 /* MVMCoreTopAlertObject.m */, - AFBB96881FBA3A9A0008D868 /* MVMCoreTopAlertOperation.h */, - AFBB96891FBA3A9A0008D868 /* MVMCoreTopAlertOperation.m */, ); path = AlertHandling; sourceTree = ""; @@ -708,7 +687,6 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( - AFBB96A21FBA3A9A0008D868 /* MVMCoreTopAlertDelegateProtocol.h in Headers */, AF43A7411FC5FA6F008E9347 /* MVMCoreViewProtocol.h in Headers */, AFBB96EC1FBA4A260008D868 /* MFHardCodedServerResponse.h in Headers */, AFBB96B21FBA3B590008D868 /* MVMCoreGetterUtility.h in Headers */, @@ -721,7 +699,6 @@ 8876D5EC1FB50AB000EB2E3D /* NSDictionary+MFConvenience.h in Headers */, AFFCFA651FCCC0D700FD0730 /* MVMCoreLoadingOverlayDelegateProtocol.h in Headers */, AF1201832108C9B400E2F592 /* MVMCoreViewManagerViewControllerProtocol.h in Headers */, - AFBB96A31FBA3A9A0008D868 /* MVMCoreTopAlertObject.h in Headers */, AFBB96981FBA3A9A0008D868 /* MVMCoreAlertController.h in Headers */, 881D26961FCC9D180079C521 /* MVMCoreOperation.h in Headers */, 8876D5EA1FB50AB000EB2E3D /* NSDecimalNumber+MFConvenience.h in Headers */, @@ -730,8 +707,6 @@ AFBB96341FBA34310008D868 /* MVMCoreErrorConstants.h in Headers */, A332F33F20C7231700DCD9D9 /* MVMCoreViewControllerAnimatedTransitioning.h in Headers */, AFBB968D1FBA3A9A0008D868 /* MVMCoreNavigationHandler.h in Headers */, - AFBB96A51FBA3A9A0008D868 /* MVMCoreTopAlertOperation.h in Headers */, - AFBB96A11FBA3A9A0008D868 /* MVMCoreTopAlertAnimationDelegateProtocol.h in Headers */, AFBB96951FBA3A9A0008D868 /* MVMCorePresentationDelegateProtocol.h in Headers */, AFED77A51FCCA29400BAE689 /* MVMCoreViewControllerProgrammaticMappingObject.h in Headers */, AF43A5871FBB67D6008E9347 /* MVMCoreActionUtility.h in Headers */, @@ -751,7 +726,6 @@ AF43A7011FC4B227008E9347 /* MVMCoreGlobalLoadProtocol.h in Headers */, AF43A5771FBA5B7C008E9347 /* MVMCoreJSONConstants.h in Headers */, AFBB96631FBA3A570008D868 /* MVMCoreLoadRequestOperation.h in Headers */, - AFC5FA1D1FFC39C700C244CF /* MVMCoreTopAlertViewProtocol.h in Headers */, AFBB969D1FBA3A9A0008D868 /* MVMCoreAlertObject.h in Headers */, 8876D5CE1FB50A9E00EB2E3D /* MVMCore.h in Headers */, AF43A57B1FBA5E6A008E9347 /* MVMCoreHardcodedStringsConstants.h in Headers */, @@ -892,7 +866,6 @@ AFBB96901FBA3A9A0008D868 /* MVMCoreNavigationObject.m in Sources */, 946EE1AB237B5C940036751F /* Decoder.swift in Sources */, 946EE1BC237B691A0036751F /* ActionOpenPageModel.swift in Sources */, - AFBB96A61FBA3A9A0008D868 /* MVMCoreTopAlertOperation.m in Sources */, 0A42538F23F3414800554656 /* Codable+Helpers.swift in Sources */, 881D26931FCC9D180079C521 /* MVMCoreErrorObject.m in Sources */, 94C014D124211869005811A9 /* ActionRestartModel.swift in Sources */, @@ -912,7 +885,6 @@ D2CAC7C82510F0C500C75681 /* MVMCoreAlertHandler+Extension.swift in Sources */, 8876D5EB1FB50AB000EB2E3D /* NSDecimalNumber+MFConvenience.m in Sources */, 0184D3DB24B7D5A600A05369 /* ActionAlertModel.swift in Sources */, - AFBB96A41FBA3A9A0008D868 /* MVMCoreTopAlertObject.m in Sources */, 01F2A03923A812DD00D954D8 /* ActionOpenUrlModel.swift in Sources */, AFBB96351FBA34310008D868 /* MVMCoreErrorConstants.m in Sources */, AFBB969C1FBA3A9A0008D868 /* MVMCoreAlertHandler.m in Sources */, diff --git a/MVMCore/MVMCore/AlertHandling/MVMCoreTopAlertAnimationDelegateProtocol.h b/MVMCore/MVMCore/AlertHandling/MVMCoreTopAlertAnimationDelegateProtocol.h deleted file mode 100644 index bb9f6df..0000000 --- a/MVMCore/MVMCore/AlertHandling/MVMCoreTopAlertAnimationDelegateProtocol.h +++ /dev/null @@ -1,22 +0,0 @@ -// -// MVMCoreTopAlertAnimationDelegateProtocol.h -// mobilefirst -// -// Created by Scott Pfeil on 6/4/16. -// Copyright © 2016 Verizon Wireless. All rights reserved. -// - -#import - -@protocol MVMCoreTopAlertAnimationDelegateProtocol - -// Called when the top alert is starting an animation -- (void)topAlertViewBeginAnimation; - -// Called when the top alert is ending an animation -- (void)topAlertViewFinishAnimation; - -// Called when the top alert close button was pressed by the user -- (void)topAlertCloseButtonPressed; - -@end diff --git a/MVMCore/MVMCore/AlertHandling/MVMCoreTopAlertDelegateProtocol.h b/MVMCore/MVMCore/AlertHandling/MVMCoreTopAlertDelegateProtocol.h deleted file mode 100644 index af09483..0000000 --- a/MVMCore/MVMCore/AlertHandling/MVMCoreTopAlertDelegateProtocol.h +++ /dev/null @@ -1,23 +0,0 @@ -// -// MVMCoreTopAlertDelegateProtocol.h -// mobilefirst -// -// Created by Scott Pfeil on 6/4/16. -// Copyright © 2016 Verizon Wireless. All rights reserved. -// - -#import - -@class MVMCoreTopAlertObject; - -@protocol MVMCoreTopAlertDelegateProtocol - -@optional - -- (void)topAlertViewShown:(nonnull id)topAlert topAlertObject:(nonnull MVMCoreTopAlertObject *)topAlertObject; -- (void)topAlertViewDismissed:(nonnull id)topAlert; - -// Called when the top alert is pressed. Determines if we should load the option the default way or not. -- (BOOL)shouldLoadTopAlertAction:(nullable NSDictionary *)actionMap additionalData:(nullable NSDictionary *)additionalData; - -@end diff --git a/MVMCore/MVMCore/AlertHandling/MVMCoreTopAlertObject.h b/MVMCore/MVMCore/AlertHandling/MVMCoreTopAlertObject.h deleted file mode 100644 index 350f6e1..0000000 --- a/MVMCore/MVMCore/AlertHandling/MVMCoreTopAlertObject.h +++ /dev/null @@ -1,64 +0,0 @@ -// -// MVMCoreTopAlertObject.h -// mobilefirst -// -// Created by Scott Pfeil on 5/24/16. -// Copyright © 2016 Verizon Wireless. All rights reserved. -// - -#import -#import - -extern NSUInteger const TopAlertDismissTime; - -@interface MVMCoreTopAlertObject : NSObject - -@property (nonatomic) BOOL persistent; -@property (nullable, nonatomic) NSString *type; -@property (nonatomic) NSOperationQueuePriority queuePriority; - -// The text -@property (nullable, strong, nonatomic) NSString *title; -@property (nullable, strong, nonatomic) NSString *message; -@property (nullable, strong, nonatomic) NSString *topMessage; - -// For the button. -@property (nullable, strong, nonatomic) NSDictionary *buttonMap; -@property (nullable, strong, nonatomic) NSDictionary *additionalData; -@property (nonatomic) BOOL useCloseButton; - -// For non action map driven button. -@property (nullable, strong, nonatomic) NSString *buttonTitle; -@property (nullable, copy, nonatomic) void (^userActionHandler)(id _Nonnull sender); - -@property (nullable, weak, nonatomic) NSObject *delegate; - -// This is used to ensure legacy style stays intact with new changes -@property (nonatomic) BOOL useNewStyle; - -// The page type used for the top alert -@property (nullable, strong, nonatomic) NSString *pageType; - -// image name or url used imageviews -@property (nullable, strong, nonatomic) NSString *imageNameOrURL; -@property (nullable, strong, nonatomic) NSString *aboveTextImageString; - -// If 0, uses default 5 seconds. -@property (nonatomic) NSInteger topAlertDismissTime; - -// Server can set color. -@property (nullable, strong, nonatomic) UIColor *backgroundColor; -@property (nullable, strong, nonatomic) UIColor *textColor; - -// The full top alert json. Currently only used for molecular. -@property (nullable, strong, nonatomic) NSDictionary *json; - -- (nullable instancetype)initWithResponseInfo:(nullable NSDictionary *)responseInfo; - -- (nullable instancetype)initWithType:(nullable NSString *)type message:(nullable NSString *)message; - -- (nullable instancetype)initWithType:(nullable NSString *)type message:(nullable NSString *)message subMessage:(nullable NSString *)subMessage persistent:(BOOL)persistent actionMap:(nullable NSDictionary *)actionMap additionalData:(nullable NSDictionary *)additionalData; - -- (nullable instancetype)initWithType:(nullable NSString *)type message:(nullable NSString *)message subMessage:(nullable NSString *)subMessage persistent:(BOOL)persistent buttonTitle:(nullable NSString *)buttonTitle userActionHandler:(nullable void (^)(id _Nonnull sender))userActionHandler; - -@end diff --git a/MVMCore/MVMCore/AlertHandling/MVMCoreTopAlertObject.m b/MVMCore/MVMCore/AlertHandling/MVMCoreTopAlertObject.m deleted file mode 100644 index 72b6de4..0000000 --- a/MVMCore/MVMCore/AlertHandling/MVMCoreTopAlertObject.m +++ /dev/null @@ -1,95 +0,0 @@ -// -// MVMCoreTopAlertObject.m -// mobilefirst -// -// Created by Scott Pfeil on 5/24/16. -// Copyright © 2016 Verizon Wireless. All rights reserved. -// - -#import "MVMCoreTopAlertObject.h" -#import -#import "MVMCoreGetterUtility.h" -#import "MVMCoreAlertHandler.h" -#import "MVMCoreJSONConstants.h" - - -NSUInteger const TopAlertDismissTime = 5; - -@implementation MVMCoreTopAlertObject - -- (nullable instancetype)initWithResponseInfo:(nullable NSDictionary *)responseInfo { - if (self = [super init]) { - - self.type = [responseInfo string:KeyType]; - self.persistent = [[responseInfo stringForKey:KeyMessageStyle] isEqualToString:ValueMessageStyleTopPersistent]; - - self.title = [responseInfo string:KeyMessage]; - self.message = [responseInfo string:KeyUserMessage]; - self.buttonMap = [responseInfo dict:KeyButtonMap]; - self.topMessage = [responseInfo string:KeyTopMessage]; - self.imageNameOrURL = [responseInfo string:@"topAlertImageUrl"]; - self.aboveTextImageString = [responseInfo string:@"topAlertImageURLAboveText"]; - - NSString *color = [responseInfo string:@"topAlertColor"]; - if (color) { - self.backgroundColor = [MVMCoreGetterUtility getColorForHexString:color]; - } - color = [responseInfo string:@"messageColor"]; - if (color) { - self.textColor = [MVMCoreGetterUtility getColorForHexString:color]; - } - - // The default is yes if not sent by server (for legacy to work as is) - NSNumber *closeButton = [responseInfo optionalNumberForKey:KeyCloseButton]; - if (closeButton != nil) { - self.useCloseButton = [closeButton boolValue]; - } else { - self.useCloseButton = YES; - } - - self.useNewStyle = [responseInfo boolForKey:@"newTopAlertStyle"]; - - // Server driven dismiss time. - NSNumber *topAlertTime = [responseInfo optionalNumberForKey:@"topAlertTime"]; - if (topAlertTime != nil) { - self.topAlertDismissTime = [topAlertTime integerValue]; - } - } - return self; -} - -- (nullable instancetype)initWithType:(nullable NSString *)type message:(nullable NSString *)message { - return [self initWithType:type message:nil subMessage:message persistent:NO actionMap:nil additionalData:nil]; -} - -- (nullable instancetype)initWithType:(nullable NSString *)type message:(nullable NSString *)message subMessage:(nullable NSString *)subMessage persistent:(BOOL)persistent actionMap:(nullable NSDictionary *)actionMap additionalData:(nullable NSDictionary *)additionalData { - - if (self = [super init]) { - - self.type = type; - self.persistent = persistent; - - self.title = message; - self.message = subMessage; - self.buttonMap = actionMap; - self.additionalData = additionalData; - } - return self; -} - -- (nullable instancetype)initWithType:(nullable NSString *)type message:(nullable NSString *)message subMessage:(nullable NSString *)subMessage persistent:(BOOL)persistent buttonTitle:(nullable NSString *)buttonTitle userActionHandler:(nullable void (^)(id _Nonnull sender))userActionHandler { - - if (self = [super init]) { - - self.type = type; - self.persistent = persistent; - - self.title = message; - self.message = subMessage; - self.buttonTitle = buttonTitle; - self.userActionHandler = userActionHandler; - } - return self; -} - -@end diff --git a/MVMCore/MVMCore/AlertHandling/MVMCoreTopAlertOperation.h b/MVMCore/MVMCore/AlertHandling/MVMCoreTopAlertOperation.h deleted file mode 100644 index 6dadc89..0000000 --- a/MVMCore/MVMCore/AlertHandling/MVMCoreTopAlertOperation.h +++ /dev/null @@ -1,33 +0,0 @@ -// -// MVMCoreTopAlertOperation.h -// mobilefirst -// -// Created by Scott Pfeil on 6/4/16. -// Copyright © 2016 Verizon Wireless. All rights reserved. -// - -#import "MVMCoreOperation.h" -#import "MVMCoreTopAlertAnimationDelegateProtocol.h" - -@class MVMCoreTopAlertObject; - -@interface MVMCoreTopAlertOperation : MVMCoreOperation - -@property (readonly, getter=isPaused) BOOL paused; - -@property (nonatomic) BOOL reAddAfterCancel; - -@property (nonnull, nonatomic, strong) MVMCoreTopAlertObject *topAlertObject; - -- (nullable instancetype)initWithTopAlertObject:(nonnull MVMCoreTopAlertObject *)topAlertObject; - -/// Updates the operation with a new object -- (void)updateWithTopAlertObject:(nonnull MVMCoreTopAlertObject *)topAlertObject; - -// Pauses the operation. Temporarily removes any alert. -- (void)pause; - -// Unpauses the operation, resuming any alert. -- (void)unpause; - -@end diff --git a/MVMCore/MVMCore/AlertHandling/MVMCoreTopAlertOperation.m b/MVMCore/MVMCore/AlertHandling/MVMCoreTopAlertOperation.m deleted file mode 100644 index 6eb8f04..0000000 --- a/MVMCore/MVMCore/AlertHandling/MVMCoreTopAlertOperation.m +++ /dev/null @@ -1,264 +0,0 @@ -// -// MVMCoreTopAlertOperation.m -// mobilefirst -// -// Created by Scott Pfeil on 6/4/16. -// Copyright © 2016 Verizon Wireless. All rights reserved. -// - -#import "MVMCoreTopAlertOperation.h" -#import "MVMCoreTopAlertObject.h" -#import "MVMCoreAlertHandler.h" -#import "MVMCoreObject.h" -#import "MVMCoreSessionObject.h" - -@interface MVMCoreTopAlertOperation () { - __block BOOL _paused; - __block BOOL _displayed; - __block BOOL _animating; -} - -@property (readwrite, getter=isPaused) BOOL paused; -@property (readwrite, getter=isDisplayed) BOOL displayed; -@property (readwrite, getter=isAnimating) BOOL animating; - -// For thread safety -@property (strong, nonatomic) dispatch_queue_t pausedQueue; -@property (strong, nonatomic) dispatch_queue_t displayedQueue; -@property (strong, nonatomic) dispatch_queue_t animatingQueue; - -@property (nonatomic, strong) dispatch_source_t timerSource; - -@end - -@implementation MVMCoreTopAlertOperation - -- (instancetype)init { - - self = [super init]; - if (self) { - self.pausedQueue = dispatch_queue_create("paused", DISPATCH_QUEUE_CONCURRENT); - self.displayedQueue = dispatch_queue_create("displayed", DISPATCH_QUEUE_CONCURRENT); - self.animatingQueue = dispatch_queue_create("animating", DISPATCH_QUEUE_CONCURRENT); - } - return self; -} - -- (nullable instancetype)initWithTopAlertObject:(nonnull MVMCoreTopAlertObject *)topAlertObject { - - if (self = [self init]) { - self.topAlertObject = topAlertObject; - - // Sets the queue priority for various types of alerts. - self.queuePriority = [[MVMCoreObject sharedInstance].globalTopAlertDelegate priorityForTopAlertByObject:topAlertObject]; - } - return self; -} - -- (void)updateWithTopAlertObject:(nonnull MVMCoreTopAlertObject *)topAlertObject { - self.topAlertObject = topAlertObject; - self.queuePriority = [[MVMCoreObject sharedInstance].globalTopAlertDelegate priorityForTopAlertByObject:topAlertObject]; - if (self.isExecuting && !self.isCancelled && !self.isPaused) { - [self updateDismissTimer]; - UIView *topAlertView = [[MVMCoreObject sharedInstance].globalTopAlertDelegate getTopAlertView]; - if ([topAlertView respondsToSelector:@selector(updateTopAlertWith:)]) { - [topAlertView updateTopAlertWith:topAlertObject]; - } - } -} - -- (BOOL)isPaused { - __block BOOL isPaused; - dispatch_sync(self.pausedQueue, ^{ - isPaused = self->_paused; - }); - return isPaused; -} - -- (void)setPaused:(BOOL)paused { - dispatch_barrier_async(self.pausedQueue, ^{ - self->_paused = paused; - }); -} - -- (BOOL)isDisplayed { - __block BOOL isDisplayed; - dispatch_sync(self.displayedQueue, ^{ - isDisplayed = self->_displayed; - }); - return isDisplayed; -} - -- (void)setDisplayed:(BOOL)displayed { - dispatch_barrier_async(self.displayedQueue, ^{ - self->_displayed = displayed; - }); -} - -- (BOOL)isAnimating { - __block BOOL isAnimating; - dispatch_sync(self.animatingQueue, ^{ - isAnimating = self->_animating; - }); - return isAnimating; -} - -- (void)setAnimating:(BOOL)animating { - dispatch_barrier_async(self.animatingQueue, ^{ - self->_animating = animating; - }); -} - -- (void)main { - - // Always check for cancellation before launching the task. - if ([self checkAndHandleForCancellation]) { - return; - } - - // Do nothing if paused - if (!self.isPaused) { - - // Display alert only if alerts aren't supressed. - if (![[MVMCoreAlertHandler sharedAlertHandler] mfAlertsSupressed]) { - - // Show - if (![[MVMCoreObject sharedInstance].globalTopAlertDelegate respondsToSelector:@selector(getTopAlertView)]) { - - // Needs to be a top alert view.... - [self markAsFinished]; - } else { - UIView *topAlertView = [[MVMCoreObject sharedInstance].globalTopAlertDelegate getTopAlertView]; - [topAlertView showWithTopAlertObject:self.topAlertObject animationDelegate:self completionHandler:^(BOOL finished) { - - self.displayed = YES; - if (self.isCancelled) { - - // Cancelled, dismiss immediately. - [self dismissAlertView:YES forceful:YES]; - } else if (self.isPaused) { - - // Paused, dismiss for the time being if persistent. - [self dismissAlertView:!self.topAlertObject.persistent forceful:YES]; - } else { - [self updateDismissTimer]; - } - }]; - } - } else { - [self pause]; - } - } -} - -/// Updates the timer to dismiss the top alert. -- (void)updateDismissTimer { - if (self.timerSource) { - dispatch_source_cancel(self.timerSource); - } - if (self.topAlertObject.persistent) { - return; - } - - NSInteger dismissTime; - if (self.topAlertObject.topAlertDismissTime > 0) { - dismissTime = self.topAlertObject.topAlertDismissTime; - } else { - dismissTime = TopAlertDismissTime; - } - - self.timerSource = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, dispatch_get_main_queue()); - dispatch_source_set_timer(self.timerSource, dispatch_time(DISPATCH_TIME_NOW, dismissTime * NSEC_PER_SEC), DISPATCH_TIME_FOREVER, (1ull * NSEC_PER_SEC) / 10); - - __weak typeof(self) weakSelf = self; - dispatch_source_set_event_handler(self.timerSource, ^{ - if (weakSelf.isFinished || [weakSelf checkAndHandleForCancellation]) { - return; - } - [weakSelf dismissAlertView:YES forceful:NO]; - }); - dispatch_resume(self.timerSource); -} - -- (void)cancel { - [super cancel]; - - // Do nothing if animating. - if (!self.isAnimating) { - - if (self.isDisplayed) { - [self dismissAlertView:YES forceful:YES]; - } else if (self.isExecuting) { - [self markAsFinished]; - } - } -} - -- (void)dismissAlertView:(BOOL)andFinish forceful:(BOOL)forceful { - if (self.timerSource) { - dispatch_source_cancel(self.timerSource); - } - if (self.isDisplayed && !self.isAnimating) { - - // Dismisses. - [[[MVMCoreObject sharedInstance].globalTopAlertDelegate getTopAlertView] hideAlertView:forceful completionHandler:^(BOOL finished) { - - self.displayed = NO; - if (andFinish) { - [self markAsFinished]; - } - }]; - } -} - -- (void)pause { - - if (!self.paused) { - [self willChangeValueForKey:@"isPaused"]; - self.paused = YES; - [self didChangeValueForKey:@"isPaused"]; - } - [self dismissAlertView:!self.topAlertObject.persistent forceful:YES]; -} - -- (void)unpause { - - if (self.paused) { - [self willChangeValueForKey:@"isPaused"]; - self.paused = NO; - [self didChangeValueForKey:@"isPaused"]; - } - if (self.executing) { - [self start]; - } -} - -#pragma mark - Delegate functions - -- (void)topAlertViewBeginAnimation { - self.animating = YES; -} - -- (void)topAlertViewFinishAnimation { - self.animating = NO; -} - -- (void)topAlertCloseButtonPressed { - [self dismissAlertView:YES forceful:YES]; -} - -- (id)copyWithZone:(nullable NSZone *)zone { - MVMCoreTopAlertOperation *copyObject = [[MVMCoreTopAlertOperation alloc] init]; - copyObject.topAlertObject = self.topAlertObject; - copyObject.paused = self.paused; - copyObject.reAddAfterCancel = self.reAddAfterCancel; - copyObject.queuePriority = self.queuePriority; - for (NSOperation *dependency in self.dependencies) { - [copyObject addDependency:dependency]; - } - copyObject.name = self.name; - copyObject.qualityOfService = self.qualityOfService; - return copyObject; -} - -@end diff --git a/MVMCore/MVMCore/AlertHandling/MVMCoreTopAlertViewProtocol.h b/MVMCore/MVMCore/AlertHandling/MVMCoreTopAlertViewProtocol.h deleted file mode 100644 index 2778971..0000000 --- a/MVMCore/MVMCore/AlertHandling/MVMCoreTopAlertViewProtocol.h +++ /dev/null @@ -1,28 +0,0 @@ -// -// MVMCoreTopAlertViewProtocol.h -// MVMCore -// -// Created by Pfeil, Scott Robert on 1/2/18. -// Copyright © 2018 myverizon. All rights reserved. -// - -#import -@class MVMCoreTopAlertObject; - -@protocol MVMCoreTopAlertViewProtocol - -@optional - -// Show based on the object -- (void)showWithTopAlertObject:(nullable MVMCoreTopAlertObject *)topAlertObject animationDelegate:(nonnull id )animationDelegate completionHandler:(void (^ __nullable)(BOOL finished))completionHandler; - -// Hides -- (void)hideAlertView:(BOOL)forceful completionHandler:(void (^ __nullable)(BOOL finished))completionHandler; - -// Collapses the notification if it has a short top message. Otherwise removes notification. -- (void)collapseNotification; - -/// Updates the existing top alert with the new object -- (void)updateTopAlertWith:(nullable MVMCoreTopAlertObject *)topAlertObject; - -@end From 60c1e0c467a296af2df6a09ca2ebc26aae9d0259 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 28 Oct 2020 10:41:01 -0400 Subject: [PATCH 02/11] missed file --- MVMCore/MVMCore.xcodeproj/project.pbxproj | 4 ---- .../MVMCoreGlobalTopAlertDelegateProtocol.h | 21 ------------------- 2 files changed, 25 deletions(-) delete mode 100644 MVMCore/MVMCore/MainProtocols/MVMCoreGlobalTopAlertDelegateProtocol.h diff --git a/MVMCore/MVMCore.xcodeproj/project.pbxproj b/MVMCore/MVMCore.xcodeproj/project.pbxproj index ce873db..0651f3a 100644 --- a/MVMCore/MVMCore.xcodeproj/project.pbxproj +++ b/MVMCore/MVMCore.xcodeproj/project.pbxproj @@ -130,7 +130,6 @@ AFBB96BA1FBA3CEC0008D868 /* MVMCoreActionHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = AFBB96B71FBA3CEC0008D868 /* MVMCoreActionHandler.m */; }; AFBB96EC1FBA4A260008D868 /* MFHardCodedServerResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = AFBB96E91FBA4A260008D868 /* MFHardCodedServerResponse.h */; }; AFBB96ED1FBA4A260008D868 /* MFHardCodedServerResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = AFBB96EA1FBA4A260008D868 /* MFHardCodedServerResponse.m */; }; - AFC5FA161FFC2E2A00C244CF /* MVMCoreGlobalTopAlertDelegateProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = AFC5FA141FFC2E2A00C244CF /* MVMCoreGlobalTopAlertDelegateProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; AFEA17A8209B6A1C00BC6740 /* MVMCoreBlockOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = AFEA17A6209B6A1C00BC6740 /* MVMCoreBlockOperation.h */; settings = {ATTRIBUTES = (Public, ); }; }; AFEA17A9209B6A1C00BC6740 /* MVMCoreBlockOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = AFEA17A7209B6A1C00BC6740 /* MVMCoreBlockOperation.m */; }; AFED77A11FCCA29400BAE689 /* MVMCoreViewControllerNibMappingObject.h in Headers */ = {isa = PBXBuildFile; fileRef = AFED77991FCCA29300BAE689 /* MVMCoreViewControllerNibMappingObject.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -276,7 +275,6 @@ AFBB96D21FBA44420008D868 /* VZWAuthentication.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = VZWAuthentication.framework; path = ../../SharedFrameworks/VZWAuthentication.framework; sourceTree = ""; }; AFBB96E91FBA4A260008D868 /* MFHardCodedServerResponse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFHardCodedServerResponse.h; sourceTree = ""; }; AFBB96EA1FBA4A260008D868 /* MFHardCodedServerResponse.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFHardCodedServerResponse.m; sourceTree = ""; }; - AFC5FA141FFC2E2A00C244CF /* MVMCoreGlobalTopAlertDelegateProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreGlobalTopAlertDelegateProtocol.h; sourceTree = ""; }; AFEA17A6209B6A1C00BC6740 /* MVMCoreBlockOperation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreBlockOperation.h; sourceTree = ""; }; AFEA17A7209B6A1C00BC6740 /* MVMCoreBlockOperation.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreBlockOperation.m; sourceTree = ""; }; AFED77991FCCA29300BAE689 /* MVMCoreViewControllerNibMappingObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreViewControllerNibMappingObject.h; sourceTree = ""; }; @@ -502,7 +500,6 @@ AF43A7401FC5FA6F008E9347 /* MVMCoreViewProtocol.h */, AFEEE8181FCDDE6B00B5EDD0 /* MVMCoreLoggingDelegateProtocol.h */, AF43A7001FC4B227008E9347 /* MVMCoreGlobalLoadProtocol.h */, - AFC5FA141FFC2E2A00C244CF /* MVMCoreGlobalTopAlertDelegateProtocol.h */, ); path = MainProtocols; sourceTree = ""; @@ -716,7 +713,6 @@ AFED77A11FCCA29400BAE689 /* MVMCoreViewControllerNibMappingObject.h in Headers */, AFBB969F1FBA3A9A0008D868 /* MVMCoreAlertOperation.h in Headers */, AF43A71B1FC5BEBB008E9347 /* MVMCoreViewControllerProtocol.h in Headers */, - AFC5FA161FFC2E2A00C244CF /* MVMCoreGlobalTopAlertDelegateProtocol.h in Headers */, AFBB96381FBA39E70008D868 /* MVMCoreLoadDelegateProtocol.h in Headers */, AFBB96B01FBA3B590008D868 /* MVMCoreDispatchUtility.h in Headers */, 8876D5E81FB50AB000EB2E3D /* NSArray+MFConvenience.h in Headers */, diff --git a/MVMCore/MVMCore/MainProtocols/MVMCoreGlobalTopAlertDelegateProtocol.h b/MVMCore/MVMCore/MainProtocols/MVMCoreGlobalTopAlertDelegateProtocol.h deleted file mode 100644 index 5ee82e7..0000000 --- a/MVMCore/MVMCore/MainProtocols/MVMCoreGlobalTopAlertDelegateProtocol.h +++ /dev/null @@ -1,21 +0,0 @@ -// -// MVMCoreGlobalTopAlertDelegateProtocol.h -// MVMCore -// -// Created by Pfeil, Scott Robert on 1/2/18. -// Copyright © 2018 myverizon. All rights reserved. -// - -#import -#import -@class MVMCoreTopAlertObject; - -@protocol MVMCoreGlobalTopAlertDelegateProtocol - -- (NSOperationQueuePriority)priorityForTopAlertByObject:(nonnull MVMCoreTopAlertObject *)object; - -@optional - -- (nonnull UIView *)getTopAlertView; - -@end From e92466c7cf17798b21f59dc0d8fd43005edfec6d Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 28 Oct 2020 11:13:26 -0400 Subject: [PATCH 03/11] moved files --- .../ActionHandling/MVMCoreActionHandler.h | 6 ----- .../ActionHandling/MVMCoreActionHandler.m | 27 ------------------- .../MVMCore/Constants/MVMCoreJSONConstants.h | 2 -- .../MVMCore/Constants/MVMCoreJSONConstants.m | 2 -- MVMCore/MVMCore/MVMCore.h | 5 ---- .../MainProtocols/DelegateObject.swift | 2 -- MVMCore/MVMCore/Singletons/MVMCoreObject.h | 2 -- 7 files changed, 46 deletions(-) diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h index 74b93a4..e4b169d 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h @@ -56,9 +56,6 @@ extern NSString * _Nonnull const KeyActionTypeOpen; // Shows popup alert from the alert object in the action map. The actionType of the action is 'alert' - (void)showAlert:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; -// Shows a top alert -- (void)topAlertAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; - // Redirects to another experience - (void)redirectAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; @@ -68,9 +65,6 @@ extern NSString * _Nonnull const KeyActionTypeOpen; // Goes to settings app - (void)settingsAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; -// Collapses the current top notification -- (void)collapseNotificationAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; - // Subclass this to handle other custom actions. Return YES if handled, and NO if not. - (BOOL)handleOtherActions:(nullable NSString *)actionType actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m index b03dcc4..f5b3807 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m @@ -290,13 +290,6 @@ NSString * const KeyActionTypeOpen = @"openPage"; [MVMCoreActionUtility linkAway:UIApplicationOpenSettingsURLString appURLString:nil]; } -- (void)collapseNotificationAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { - // Collapse the current notification. - if ([[MVMCoreObject sharedInstance].globalTopAlertDelegate respondsToSelector:@selector(getTopAlertView)]) { - [[[MVMCoreObject sharedInstance].globalTopAlertDelegate getTopAlertView] collapseNotification]; - } -} - - (void)showAlert:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { MVMCoreErrorObject *error = nil; @@ -469,16 +462,12 @@ NSString * const KeyActionTypeOpen = @"openPage"; [self previousSubmitAction:actionInformation additionalData:additionalData delegate:delegate]; } else if ([actionType isEqualToString:KeyActionTypePopup]) { [self popupAction:actionInformation additionalData:additionalData delegate:delegate]; - } else if ([actionType isEqualToString:KeyActionTypeTopAlert]) { - [self topAlertAction:actionInformation additionalData:additionalData delegate:delegate]; } else if ([actionType isEqualToString:KeyActionTypeRedirect]) { [self redirectAction:actionInformation additionalData:additionalData delegate:delegate]; } else if ([actionType isEqualToString:KeyActionTypeCancel]) { [self cancelAction:actionInformation additionalData:additionalData delegate:delegate]; } else if ([actionType isEqualToString:KeyActionTypeSettings]) { [self settingsAction:actionInformation additionalData:additionalData delegate:delegate]; - } else if ([actionType isEqualToString:KeyActionTypeCollapseNotification]) { - [self collapseNotificationAction:actionInformation additionalData:additionalData delegate:delegate]; } else if (![self handleOtherActions:actionType actionInformation:actionInformation additionalData:additionalData delegate:delegate]) { // not a known action type. [self unknownAction:actionType actionInformation:actionInformation additionalData:additionalData delegate:delegate]; @@ -591,22 +580,6 @@ NSString * const KeyActionTypeOpen = @"openPage"; }]; } -- (void)topAlertAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate { - // Perform a top alert. - NSString *pageTypeForTopAlert = [actionInformation stringForKey:KeyPageType]; - [[MVMCoreCache sharedCache] fetchJSONForPageType:pageTypeForTopAlert queue:nil waitUntilFinished:YES completionHandler:^(NSDictionary * _Nullable jsonDictionary) { - - NSDictionary *responseInfo = [jsonDictionary dict:KeyResponseInfo]; - if (responseInfo) { - MVMCoreAlertObject *alertObject = [MVMCoreAlertObject alertObjectForPageType:pageTypeForTopAlert responseInfo:responseInfo additionalData:additionalData actionDelegate:delegate]; - if ([delegate respondsToSelector:@selector(willShowTopAlertWithAlertObject:alertJson:)]) { - alertObject = [delegate willShowTopAlertWithAlertObject:alertObject alertJson:jsonDictionary]; - } - [alertObject showAlert]; - } - }]; -} - - (void)redirectAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate { // Have delegate redirect. [[MVMCoreSessionObject sharedGlobal] redirectWithInfo:actionInformation]; diff --git a/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.h b/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.h index da64130..ee8d4b4 100644 --- a/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.h +++ b/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.h @@ -38,9 +38,7 @@ extern NSString * const KeyActionTypePreviousSubmit; extern NSString * const KeyActionTypePopup; extern NSString * const KeyActionTypeCancel; extern NSString * const KeyActionTypeRedirect; -extern NSString * const KeyActionTypeTopAlert; extern NSString * const KeyActionTypeSettings; -extern NSString * const KeyActionTypeCollapseNotification; extern NSString * const KeyActionTypeAlert; extern NSString * const KeyActionTypeNoop; extern NSString * const KeyActionInformation; diff --git a/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.m b/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.m index 80122db..91ed8a3 100644 --- a/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.m +++ b/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.m @@ -38,9 +38,7 @@ NSString * const KeyActionTypePreviousSubmit = @"previousSubmit"; NSString * const KeyActionTypePopup = @"popup"; NSString * const KeyActionTypeCancel = @"cancel"; NSString * const KeyActionTypeRedirect = @"switchApp"; -NSString * const KeyActionTypeTopAlert = @"topAlert"; NSString * const KeyActionTypeSettings = @"openSettings"; -NSString * const KeyActionTypeCollapseNotification = @"collapseNotification"; NSString * const KeyActionTypeAlert = @"alert"; NSString * const KeyActionTypeNoop = @"noop"; NSString * const KeyActionInformation = @"actionInformation"; diff --git a/MVMCore/MVMCore/MVMCore.h b/MVMCore/MVMCore/MVMCore.h index f5636b3..b0b0cbb 100644 --- a/MVMCore/MVMCore/MVMCore.h +++ b/MVMCore/MVMCore/MVMCore.h @@ -56,13 +56,8 @@ FOUNDATION_EXPORT const unsigned char MVMCoreVersionString[]; // Alert Handling #import #import -#import #import #import -#import -#import -#import -#import #import // Presentation Handling diff --git a/MVMCore/MVMCore/MainProtocols/DelegateObject.swift b/MVMCore/MVMCore/MainProtocols/DelegateObject.swift index bd7b4c6..88d26b1 100644 --- a/MVMCore/MVMCore/MainProtocols/DelegateObject.swift +++ b/MVMCore/MVMCore/MainProtocols/DelegateObject.swift @@ -13,7 +13,6 @@ import UIKit public weak var actionDelegate: (MVMCoreActionDelegateProtocol & NSObjectProtocol)? public weak var loadDelegate: (MVMCoreLoadDelegateProtocol & NSObjectProtocol)? public weak var alertDelegate: (MVMCoreAlertDelegateProtocol & NSObjectProtocol)? - public weak var topAlertDelegate: (MVMCoreTopAlertDelegateProtocol & NSObjectProtocol)? public weak var presentationDelegate: (MVMCorePresentationDelegateProtocol & NSObjectProtocol)? required override public init() { @@ -24,7 +23,6 @@ import UIKit actionDelegate = delegate as? (MVMCoreActionDelegateProtocol & NSObjectProtocol) loadDelegate = delegate as? (MVMCoreLoadDelegateProtocol & NSObjectProtocol) alertDelegate = delegate as? (MVMCoreAlertDelegateProtocol & NSObjectProtocol) - topAlertDelegate = delegate as? (MVMCoreTopAlertDelegateProtocol & NSObjectProtocol) presentationDelegate = delegate as? (MVMCorePresentationDelegateProtocol & NSObjectProtocol) } diff --git a/MVMCore/MVMCore/Singletons/MVMCoreObject.h b/MVMCore/MVMCore/Singletons/MVMCoreObject.h index f7ad479..03a8411 100644 --- a/MVMCore/MVMCore/Singletons/MVMCoreObject.h +++ b/MVMCore/MVMCore/Singletons/MVMCoreObject.h @@ -15,7 +15,6 @@ #import #import #import -#import #import #import @@ -32,7 +31,6 @@ @property (nullable, strong, nonatomic) id globalLoadDelegate; @property (nullable, strong, nonatomic) id loadingProtocol; @property (nullable, strong, nonatomic) NSObject *loggingDelegate; -@property (nullable, strong, nonatomic) id globalTopAlertDelegate; // A reference to the calling application delegate that should be set. For a normal app, could be the UIApplicationDelegate. For watch, could be WKExtensionDelegate. For iMessage, could be MSMessagesAppViewController. etc, etc. Useful for the framework to call delegate specific functions. @property (nullable, weak, nonatomic) id applicationDelegate; From cf575681e24e4d9753ec2abca69c950e1d023103 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 28 Oct 2020 12:38:29 -0400 Subject: [PATCH 04/11] Move alert files --- MVMCore/MVMCore.xcodeproj/project.pbxproj | 36 --- .../ActionHandling/MVMCoreActionHandler.h | 15 - .../ActionHandling/MVMCoreActionHandler.m | 102 ------ .../MVMCoreAlertDelegateProtocol.h | 28 -- .../MVMCoreAlertHandler+Extension.swift | 95 ------ .../AlertHandling/MVMCoreAlertHandler.h | 119 ------- .../AlertHandling/MVMCoreAlertHandler.m | 262 --------------- .../MVMCoreAlertObject+Swift.swift | 45 --- .../AlertHandling/MVMCoreAlertObject.h | 72 ----- .../AlertHandling/MVMCoreAlertObject.m | 302 ------------------ .../AlertHandling/MVMCoreAlertOperation.h | 39 --- .../AlertHandling/MVMCoreAlertOperation.m | 242 -------------- .../MVMCore/Constants/MVMCoreJSONConstants.h | 2 - .../MVMCore/Constants/MVMCoreJSONConstants.m | 2 - .../MVMCore/LoadHandling/MVMCoreLoadHandler.m | 1 + .../MVMCoreLoadRequestOperation.m | 25 +- MVMCore/MVMCore/MVMCore.h | 8 - .../MainProtocols/DelegateObject.swift | 2 - .../MainProtocols/MVMCoreGlobalLoadProtocol.h | 3 + .../Session/MVMCoreSessionTimeHandler.m | 2 - 20 files changed, 7 insertions(+), 1395 deletions(-) delete mode 100644 MVMCore/MVMCore/AlertHandling/MVMCoreAlertDelegateProtocol.h delete mode 100644 MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler+Extension.swift delete mode 100644 MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.h delete mode 100644 MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.m delete mode 100644 MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject+Swift.swift delete mode 100644 MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.h delete mode 100644 MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.m delete mode 100644 MVMCore/MVMCore/AlertHandling/MVMCoreAlertOperation.h delete mode 100644 MVMCore/MVMCore/AlertHandling/MVMCoreAlertOperation.m diff --git a/MVMCore/MVMCore.xcodeproj/project.pbxproj b/MVMCore/MVMCore.xcodeproj/project.pbxproj index 0651f3a..53d2a96 100644 --- a/MVMCore/MVMCore.xcodeproj/project.pbxproj +++ b/MVMCore/MVMCore.xcodeproj/project.pbxproj @@ -22,7 +22,6 @@ /* Begin PBXBuildFile section */ 0184D3DB24B7D5A600A05369 /* ActionAlertModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0184D3DA24B7D5A600A05369 /* ActionAlertModel.swift */; }; - 0184D3E324B8D0C600A05369 /* MVMCoreAlertObject+Swift.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0184D3E224B8D0C600A05369 /* MVMCoreAlertObject+Swift.swift */; }; 0184D3FD24BE54A300A05369 /* UIAlertActionStyle+Codable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0184D3FC24BE54A300A05369 /* UIAlertActionStyle+Codable.swift */; }; 0184D3FF24BE554A00A05369 /* AlertModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0184D3FE24BE554A00A05369 /* AlertModel.swift */; }; 01C851CF23CF7B260021F976 /* JSONMap.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01C851CE23CF7B260021F976 /* JSONMap.swift */; }; @@ -114,13 +113,6 @@ AFBB96971FBA3A9A0008D868 /* MVMCorePresentViewControllerOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = AFBB96791FBA3A9A0008D868 /* MVMCorePresentViewControllerOperation.m */; }; AFBB96981FBA3A9A0008D868 /* MVMCoreAlertController.h in Headers */ = {isa = PBXBuildFile; fileRef = AFBB967B1FBA3A9A0008D868 /* MVMCoreAlertController.h */; settings = {ATTRIBUTES = (Public, ); }; }; AFBB96991FBA3A9A0008D868 /* MVMCoreAlertController.m in Sources */ = {isa = PBXBuildFile; fileRef = AFBB967C1FBA3A9A0008D868 /* MVMCoreAlertController.m */; }; - AFBB969A1FBA3A9A0008D868 /* MVMCoreAlertDelegateProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = AFBB967D1FBA3A9A0008D868 /* MVMCoreAlertDelegateProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AFBB969B1FBA3A9A0008D868 /* MVMCoreAlertHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = AFBB967E1FBA3A9A0008D868 /* MVMCoreAlertHandler.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AFBB969C1FBA3A9A0008D868 /* MVMCoreAlertHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = AFBB967F1FBA3A9A0008D868 /* MVMCoreAlertHandler.m */; }; - AFBB969D1FBA3A9A0008D868 /* MVMCoreAlertObject.h in Headers */ = {isa = PBXBuildFile; fileRef = AFBB96801FBA3A9A0008D868 /* MVMCoreAlertObject.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AFBB969E1FBA3A9A0008D868 /* MVMCoreAlertObject.m in Sources */ = {isa = PBXBuildFile; fileRef = AFBB96811FBA3A9A0008D868 /* MVMCoreAlertObject.m */; }; - AFBB969F1FBA3A9A0008D868 /* MVMCoreAlertOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = AFBB96821FBA3A9A0008D868 /* MVMCoreAlertOperation.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AFBB96A01FBA3A9A0008D868 /* MVMCoreAlertOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = AFBB96831FBA3A9A0008D868 /* MVMCoreAlertOperation.m */; }; AFBB96B01FBA3B590008D868 /* MVMCoreDispatchUtility.h in Headers */ = {isa = PBXBuildFile; fileRef = AFBB96AC1FBA3B590008D868 /* MVMCoreDispatchUtility.h */; settings = {ATTRIBUTES = (Public, ); }; }; AFBB96B11FBA3B590008D868 /* MVMCoreDispatchUtility.m in Sources */ = {isa = PBXBuildFile; fileRef = AFBB96AD1FBA3B590008D868 /* MVMCoreDispatchUtility.m */; }; AFBB96B21FBA3B590008D868 /* MVMCoreGetterUtility.h in Headers */ = {isa = PBXBuildFile; fileRef = AFBB96AE1FBA3B590008D868 /* MVMCoreGetterUtility.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -150,7 +142,6 @@ BB780ADF250F8C890030BD2F /* ActionNoopModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB780ADE250F8C890030BD2F /* ActionNoopModel.swift */; }; D282AAB62240085300C46919 /* MVMCoreGetterUtility+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D282AAB52240085300C46919 /* MVMCoreGetterUtility+Extension.swift */; }; D282AAB82240342D00C46919 /* NSNumber+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D282AAB72240342D00C46919 /* NSNumber+Extension.swift */; }; - D2CAC7C82510F0C500C75681 /* MVMCoreAlertHandler+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2CAC7C72510F0C500C75681 /* MVMCoreAlertHandler+Extension.swift */; }; D2DEDCB723C63F3B00C44CC4 /* Clamping.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2DEDCB623C63F3B00C44CC4 /* Clamping.swift */; }; D2DEDCB923C6400600C44CC4 /* UnitInterval.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2DEDCB823C6400600C44CC4 /* UnitInterval.swift */; }; D2DEDCBB23C65BC300C44CC4 /* Percent.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2DEDCBA23C65BC300C44CC4 /* Percent.swift */; }; @@ -159,7 +150,6 @@ /* Begin PBXFileReference section */ 0184D3DA24B7D5A600A05369 /* ActionAlertModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ActionAlertModel.swift; sourceTree = ""; }; - 0184D3E224B8D0C600A05369 /* MVMCoreAlertObject+Swift.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MVMCoreAlertObject+Swift.swift"; sourceTree = ""; }; 0184D3FC24BE54A300A05369 /* UIAlertActionStyle+Codable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIAlertActionStyle+Codable.swift"; sourceTree = ""; }; 0184D3FE24BE554A00A05369 /* AlertModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlertModel.swift; sourceTree = ""; }; 01C851CE23CF7B260021F976 /* JSONMap.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JSONMap.swift; sourceTree = ""; }; @@ -258,13 +248,6 @@ AFBB96791FBA3A9A0008D868 /* MVMCorePresentViewControllerOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCorePresentViewControllerOperation.m; sourceTree = ""; }; AFBB967B1FBA3A9A0008D868 /* MVMCoreAlertController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreAlertController.h; sourceTree = ""; }; AFBB967C1FBA3A9A0008D868 /* MVMCoreAlertController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCoreAlertController.m; sourceTree = ""; }; - AFBB967D1FBA3A9A0008D868 /* MVMCoreAlertDelegateProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreAlertDelegateProtocol.h; sourceTree = ""; }; - AFBB967E1FBA3A9A0008D868 /* MVMCoreAlertHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreAlertHandler.h; sourceTree = ""; }; - AFBB967F1FBA3A9A0008D868 /* MVMCoreAlertHandler.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCoreAlertHandler.m; sourceTree = ""; }; - AFBB96801FBA3A9A0008D868 /* MVMCoreAlertObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreAlertObject.h; sourceTree = ""; }; - AFBB96811FBA3A9A0008D868 /* MVMCoreAlertObject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCoreAlertObject.m; sourceTree = ""; }; - AFBB96821FBA3A9A0008D868 /* MVMCoreAlertOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreAlertOperation.h; sourceTree = ""; }; - AFBB96831FBA3A9A0008D868 /* MVMCoreAlertOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCoreAlertOperation.m; sourceTree = ""; }; AFBB96AC1FBA3B590008D868 /* MVMCoreDispatchUtility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreDispatchUtility.h; sourceTree = ""; }; AFBB96AD1FBA3B590008D868 /* MVMCoreDispatchUtility.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCoreDispatchUtility.m; sourceTree = ""; }; AFBB96AE1FBA3B590008D868 /* MVMCoreGetterUtility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreGetterUtility.h; sourceTree = ""; }; @@ -295,7 +278,6 @@ BB780ADE250F8C890030BD2F /* ActionNoopModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionNoopModel.swift; sourceTree = ""; }; D282AAB52240085300C46919 /* MVMCoreGetterUtility+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MVMCoreGetterUtility+Extension.swift"; sourceTree = ""; }; D282AAB72240342D00C46919 /* NSNumber+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSNumber+Extension.swift"; sourceTree = ""; }; - D2CAC7C72510F0C500C75681 /* MVMCoreAlertHandler+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MVMCoreAlertHandler+Extension.swift"; sourceTree = ""; }; D2DEDCB623C63F3B00C44CC4 /* Clamping.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Clamping.swift; sourceTree = ""; }; D2DEDCB823C6400600C44CC4 /* UnitInterval.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UnitInterval.swift; sourceTree = ""; }; D2DEDCBA23C65BC300C44CC4 /* Percent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Percent.swift; sourceTree = ""; }; @@ -577,15 +559,6 @@ children = ( AFBB967B1FBA3A9A0008D868 /* MVMCoreAlertController.h */, AFBB967C1FBA3A9A0008D868 /* MVMCoreAlertController.m */, - AFBB967D1FBA3A9A0008D868 /* MVMCoreAlertDelegateProtocol.h */, - AFBB967E1FBA3A9A0008D868 /* MVMCoreAlertHandler.h */, - AFBB967F1FBA3A9A0008D868 /* MVMCoreAlertHandler.m */, - D2CAC7C72510F0C500C75681 /* MVMCoreAlertHandler+Extension.swift */, - AFBB96801FBA3A9A0008D868 /* MVMCoreAlertObject.h */, - AFBB96811FBA3A9A0008D868 /* MVMCoreAlertObject.m */, - 0184D3E224B8D0C600A05369 /* MVMCoreAlertObject+Swift.swift */, - AFBB96821FBA3A9A0008D868 /* MVMCoreAlertOperation.h */, - AFBB96831FBA3A9A0008D868 /* MVMCoreAlertOperation.m */, ); path = AlertHandling; sourceTree = ""; @@ -711,7 +684,6 @@ AFBB96601FBA3A570008D868 /* MVMCoreLoadObject.h in Headers */, AF43A7061FC4D7A2008E9347 /* MVMCoreObject.h in Headers */, AFED77A11FCCA29400BAE689 /* MVMCoreViewControllerNibMappingObject.h in Headers */, - AFBB969F1FBA3A9A0008D868 /* MVMCoreAlertOperation.h in Headers */, AF43A71B1FC5BEBB008E9347 /* MVMCoreViewControllerProtocol.h in Headers */, AFBB96381FBA39E70008D868 /* MVMCoreLoadDelegateProtocol.h in Headers */, AFBB96B01FBA3B590008D868 /* MVMCoreDispatchUtility.h in Headers */, @@ -722,7 +694,6 @@ AF43A7011FC4B227008E9347 /* MVMCoreGlobalLoadProtocol.h in Headers */, AF43A5771FBA5B7C008E9347 /* MVMCoreJSONConstants.h in Headers */, AFBB96631FBA3A570008D868 /* MVMCoreLoadRequestOperation.h in Headers */, - AFBB969D1FBA3A9A0008D868 /* MVMCoreAlertObject.h in Headers */, 8876D5CE1FB50A9E00EB2E3D /* MVMCore.h in Headers */, AF43A57B1FBA5E6A008E9347 /* MVMCoreHardcodedStringsConstants.h in Headers */, AFBB96B81FBA3CEC0008D868 /* MVMCoreActionDelegateProtocol.h in Headers */, @@ -730,14 +701,12 @@ AF43A70B1FC4F415008E9347 /* MVMCoreCache.h in Headers */, AFEA17A8209B6A1C00BC6740 /* MVMCoreBlockOperation.h in Headers */, AF43A5831FBB66DE008E9347 /* MVMCoreConstants.h in Headers */, - AFBB969A1FBA3A9A0008D868 /* MVMCoreAlertDelegateProtocol.h in Headers */, AFED77A81FCCA29400BAE689 /* MVMCoreViewControllerStoryBoardMappingObject.h in Headers */, AFEEE8191FCDEB8D00B5EDD0 /* MVMCoreLoggingDelegateProtocol.h in Headers */, AFBB96B91FBA3CEC0008D868 /* MVMCoreActionHandler.h in Headers */, AF43A74C1FC6109F008E9347 /* MVMCoreSessionObject.h in Headers */, 8876D5F41FB50AB000EB2E3D /* UILabel+MFCustom.h in Headers */, AFFCFA681FCCC0D700FD0730 /* MVMCoreLoadingViewControllerProtocol.h in Headers */, - AFBB969B1FBA3A9A0008D868 /* MVMCoreAlertHandler.h in Headers */, AFED77A21FCCA29400BAE689 /* MVMCoreViewControllerMappingObject.h in Headers */, AFFCFA661FCCC0D700FD0730 /* MVMCoreLoadingOverlayHandler.h in Headers */, ); @@ -838,7 +807,6 @@ buildActionMask = 2147483647; files = ( AFED77A71FCCA29400BAE689 /* MVMCoreViewControllerProgrammaticMappingObject.m in Sources */, - AFBB96A01FBA3A9A0008D868 /* MVMCoreAlertOperation.m in Sources */, 946EE1A7237B5B1C0036751F /* ModelRegistry.swift in Sources */, AFBB96641FBA3A570008D868 /* MVMCoreLoadHandler.m in Sources */, AFFCFA671FCCC0D700FD0730 /* MVMCoreLoadingOverlayHandler.m in Sources */, @@ -857,7 +825,6 @@ AFBB96BA1FBA3CEC0008D868 /* MVMCoreActionHandler.m in Sources */, AFBB96ED1FBA4A260008D868 /* MFHardCodedServerResponse.m in Sources */, AF43A74D1FC6109F008E9347 /* MVMCoreSessionObject.m in Sources */, - 0184D3E324B8D0C600A05369 /* MVMCoreAlertObject+Swift.swift in Sources */, D282AAB62240085300C46919 /* MVMCoreGetterUtility+Extension.swift in Sources */, AFBB96901FBA3A9A0008D868 /* MVMCoreNavigationObject.m in Sources */, 946EE1AB237B5C940036751F /* Decoder.swift in Sources */, @@ -878,19 +845,16 @@ AF43A5781FBA5B7C008E9347 /* MVMCoreJSONConstants.m in Sources */, AFBB96691FBA3A570008D868 /* MVMCoreRequestParameters.m in Sources */, AFED77A31FCCA29400BAE689 /* MVMCoreViewControllerNibMappingObject.m in Sources */, - D2CAC7C82510F0C500C75681 /* MVMCoreAlertHandler+Extension.swift in Sources */, 8876D5EB1FB50AB000EB2E3D /* NSDecimalNumber+MFConvenience.m in Sources */, 0184D3DB24B7D5A600A05369 /* ActionAlertModel.swift in Sources */, 01F2A03923A812DD00D954D8 /* ActionOpenUrlModel.swift in Sources */, AFBB96351FBA34310008D868 /* MVMCoreErrorConstants.m in Sources */, - AFBB969C1FBA3A9A0008D868 /* MVMCoreAlertHandler.m in Sources */, AF43A5881FBB67D6008E9347 /* MVMCoreActionUtility.m in Sources */, AFED77A61FCCA29400BAE689 /* MVMCoreViewControllerStoryBoardMappingObject.m in Sources */, AF43A57C1FBA5E6A008E9347 /* MVMCoreHardcodedStringsConstants.m in Sources */, 0AFF597A23FC6E60005C24E8 /* ActionShareModel.swift in Sources */, AFEEE81F1FCDF3CA00B5EDD0 /* MVMCoreLoggingHandler.m in Sources */, 01F2A05223A8325100D954D8 /* ModelMapping.swift in Sources */, - AFBB969E1FBA3A9A0008D868 /* MVMCoreAlertObject.m in Sources */, 8876D5F51FB50AB000EB2E3D /* UILabel+MFCustom.m in Sources */, AFBB96B31FBA3B590008D868 /* MVMCoreGetterUtility.m in Sources */, AF43A7071FC4D7A2008E9347 /* MVMCoreObject.m in Sources */, diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h index e4b169d..a166d22 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h @@ -50,12 +50,6 @@ extern NSString * _Nonnull const KeyActionTypeOpen; // Makes the previous request, needs the delegate for this - (void)previousSubmitAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; -// Shows a popup alert by grabbing the content from the page map. -- (void)popupAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; - -// Shows popup alert from the alert object in the action map. The actionType of the action is 'alert' -- (void)showAlert:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; - // Redirects to another experience - (void)redirectAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; @@ -128,12 +122,6 @@ extern NSString * _Nonnull const KeyActionTypeOpen; // Makes the previous request, needs the delegate for this - (void)previousSubmitAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate __deprecated; -// Shows a popup -- (void)popupAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate __deprecated; - -// Shows a top alert -- (void)topAlertAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate __deprecated; - // Redirects to another experience - (void)redirectAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate __deprecated; @@ -143,9 +131,6 @@ extern NSString * _Nonnull const KeyActionTypeOpen; // Goes to settings app - (void)settingsAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate __deprecated; -// Collapses the current top notification -- (void)collapseNotificationAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate __deprecated; - // Subclass this to handle other custom actions. Return YES if handled, and NO if not. - (BOOL)handleOtherActions:(nullable NSString *)actionType actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate __deprecated; diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m index f5b3807..88744ab 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m @@ -8,9 +8,7 @@ #import #import "MVMCoreLoggingHandler.h" -#import "MVMCoreAlertHandler.h" #import "MVMCoreCache.h" -#import "MVMCoreAlertObject.h" #import "MVMCoreSessionTimeHandler.h" #import "MVMCoreLoadHandler.h" #import "MVMCoreNavigationHandler.h" @@ -73,12 +71,6 @@ NSString * const KeyActionTypeOpen = @"openPage"; } else if ([actionType isEqualToString:KeyActionTypePreviousSubmit]) { [self previousSubmitAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; - } else if ([actionType isEqualToString:KeyActionTypePopup]) { - [self popupAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; - - } else if ([actionType isEqualToString:KeyActionTypeTopAlert]) { - [self topAlertAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; - } else if ([actionType isEqualToString:KeyActionTypeRedirect]) { [self redirectAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; @@ -87,12 +79,6 @@ NSString * const KeyActionTypeOpen = @"openPage"; } else if ([actionType isEqualToString:KeyActionTypeSettings]) { [self settingsAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; - - } else if ([actionType isEqualToString:KeyActionTypeCollapseNotification]) { - [self collapseNotificationAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; - - } else if ([actionType isEqualToString:KeyActionTypeAlert]) { - [self showAlert:actionInformation additionalData:additionalData delegateObject:delegateObject]; } else if ([actionType isEqualToString:KeyActionTypeNoop]){ } else if (![self handleOtherActions:actionType actionInformation:actionInformation additionalData:additionalData delegateObject:delegateObject]) { @@ -240,41 +226,6 @@ NSString * const KeyActionTypeOpen = @"openPage"; } } -- (void)popupAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { - // Perform a popup. - NSString *pageTypeForPopup = [actionInformation stringForKey:KeyPageType]; - [[MVMCoreCache sharedCache] fetchJSONForPageType:pageTypeForPopup queue:nil waitUntilFinished:YES completionHandler:^(NSDictionary * _Nullable jsonDictionary) { - - MVMCoreErrorObject *error = nil; - MVMCoreAlertObject *alertObject = [MVMCoreAlertObject alertObjectWithPage:jsonDictionary isGreedy:NO additionalData:additionalData delegateObject:delegateObject error:&error]; - if ([delegateObject.actionDelegate respondsToSelector:@selector(willShowPopupWithAlertObject:alertJson:)]) { - [delegateObject.actionDelegate willShowPopupWithAlertObject:alertObject alertJson:jsonDictionary]; - } - - if (alertObject) { - [[MVMCoreAlertHandler sharedAlertHandler] showAlertWithAlertObject:alertObject]; - } else { - [self handleActionError:error actionInformation:actionInformation additionalData:additionalData delegateObject:delegateObject ]; - } - }]; -} - -- (void)topAlertAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { - // Perform a top alert. - NSString *pageTypeForTopAlert = [actionInformation stringForKey:KeyPageType]; - [[MVMCoreCache sharedCache] fetchJSONForPageType:pageTypeForTopAlert queue:nil waitUntilFinished:YES completionHandler:^(NSDictionary * _Nullable jsonDictionary) { - - NSDictionary *responseInfo = [jsonDictionary dict:KeyResponseInfo]; - if (responseInfo) { - MVMCoreAlertObject *alertObject = [MVMCoreAlertObject alertObjectForPageType:pageTypeForTopAlert responseInfo:responseInfo additionalData:additionalData delegateObject:delegateObject]; - if ([delegateObject.actionDelegate respondsToSelector:@selector(willShowTopAlertWithAlertObject:alertJson:)]) { - alertObject = [delegateObject.actionDelegate willShowTopAlertWithAlertObject:alertObject alertJson:jsonDictionary]; - } - [alertObject showAlert]; - } - }]; -} - - (void)redirectAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { // Have delegate redirect. [[MVMCoreSessionObject sharedGlobal] redirectWithInfo:actionInformation]; @@ -290,21 +241,6 @@ NSString * const KeyActionTypeOpen = @"openPage"; [MVMCoreActionUtility linkAway:UIApplicationOpenSettingsURLString appURLString:nil]; } -- (void)showAlert:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { - - MVMCoreErrorObject *error = nil; - MVMCoreAlertObject *alertObject = [MVMCoreAlertObject alertObjectWithAction:actionInformation additionalData:additionalData delegateObject:delegateObject error:&error]; - if ([delegateObject.actionDelegate respondsToSelector:@selector(willShowPopupWithAlertObject:alertJson:)]) { - [delegateObject.actionDelegate willShowPopupWithAlertObject:alertObject alertJson:actionInformation]; - } - - if (alertObject) { - [[MVMCoreAlertHandler sharedAlertHandler] showAlertWithAlertObject:alertObject]; - } else { - [self handleActionError:error actionInformation:actionInformation additionalData:additionalData delegateObject:delegateObject]; - } -} - - (BOOL)handleOtherActions:(nullable NSString *)actionType actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { return NO; } @@ -421,16 +357,6 @@ NSString * const KeyActionTypeOpen = @"openPage"; if (error.logError) { [MVMCoreLoggingHandler addErrorToLog:error]; } - - MVMCoreLog(@"Error: %@ %@ %@ %@",[error stringErrorCode], error.domain, error.location,error.messageToDisplay); - if (!error.silentError) { - - // Show alert - [MVMCoreDispatchUtility performBlockOnMainThread:^{ - MVMCoreAlertObject *alertObject = [[MVMCoreAlertObject alloc] initPopupAlertWithError:error isGreedy:NO]; - [[MVMCoreAlertHandler sharedAlertHandler] showAlertWithAlertObject:alertObject]; - }]; - } } #pragma mark - Deprecated @@ -460,8 +386,6 @@ NSString * const KeyActionTypeOpen = @"openPage"; [self callAction:actionInformation additionalData:additionalData delegate:delegate]; } else if ([actionType isEqualToString:KeyActionTypePreviousSubmit]) { [self previousSubmitAction:actionInformation additionalData:additionalData delegate:delegate]; - } else if ([actionType isEqualToString:KeyActionTypePopup]) { - [self popupAction:actionInformation additionalData:additionalData delegate:delegate]; } else if ([actionType isEqualToString:KeyActionTypeRedirect]) { [self redirectAction:actionInformation additionalData:additionalData delegate:delegate]; } else if ([actionType isEqualToString:KeyActionTypeCancel]) { @@ -561,25 +485,6 @@ NSString * const KeyActionTypeOpen = @"openPage"; } } -- (void)popupAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate { - // Perform a popup. - NSString *pageTypeForPopup = [actionInformation stringForKey:KeyPageType]; - [[MVMCoreCache sharedCache] fetchJSONForPageType:pageTypeForPopup queue:nil waitUntilFinished:YES completionHandler:^(NSDictionary * _Nullable jsonDictionary) { - - MVMCoreErrorObject *error = nil; - MVMCoreAlertObject *alertObject = [MVMCoreAlertObject alertObjectWithPage:jsonDictionary isGreedy:NO additionalData:additionalData delegate:delegate error:&error]; - if ([delegate respondsToSelector:@selector(willShowPopupWithAlertObject:alertJson:)]) { - [delegate willShowPopupWithAlertObject:alertObject alertJson:jsonDictionary]; - } - - if (alertObject) { - [[MVMCoreAlertHandler sharedAlertHandler] showAlertWithAlertObject:alertObject]; - } else { - [self handleActionError:error actionInformation:actionInformation additionalData:additionalData delegate:delegate]; - } - }]; -} - - (void)redirectAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate { // Have delegate redirect. [[MVMCoreSessionObject sharedGlobal] redirectWithInfo:actionInformation]; @@ -596,13 +501,6 @@ NSString * const KeyActionTypeOpen = @"openPage"; [MVMCoreActionUtility linkAway:UIApplicationOpenSettingsURLString appURLString:nil]; } -- (void)collapseNotificationAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate { - // Collapse the current notification. - if ([[MVMCoreObject sharedInstance].globalTopAlertDelegate respondsToSelector:@selector(getTopAlertView)]) { - [[[MVMCoreObject sharedInstance].globalTopAlertDelegate getTopAlertView] collapseNotification]; - } -} - - (BOOL)handleOtherActions:(nullable NSString *)actionType actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate { return NO; } diff --git a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertDelegateProtocol.h b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertDelegateProtocol.h deleted file mode 100644 index f4f05e5..0000000 --- a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertDelegateProtocol.h +++ /dev/null @@ -1,28 +0,0 @@ -// -// MVMCoreAlertDelegateProtocol.h -// mobilefirst -// -// Created by Pfeil, Scott Robert on 8/8/17. -// Copyright © 2017 Verizon Wireless. All rights reserved. -// -// 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; -- (void)alertDismissed:(nonnull UIAlertController *)alertController; -- (void)alertPaused:(nonnull UIAlertController *)alertController; -- (void)alertUnpaused:(nonnull UIAlertController *)alertController; - -@end - diff --git a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler+Extension.swift b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler+Extension.swift deleted file mode 100644 index 309ea8f..0000000 --- a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler+Extension.swift +++ /dev/null @@ -1,95 +0,0 @@ -// -// MVMCoreAlertHandler+Extension.swift -// MVMCore -// -// Created by Scott Pfeil on 9/15/20. -// Copyright © 2020 myverizon. All rights reserved. -// - -import Foundation - -// Temporary, until we can move page checking logic into isReady of topAlertOperation. -@objcMembers public class NotificationPagesOperation: Operation { - public let pages: [String] - - public init(with pages: [String]) { - self.pages = pages - } - - public override var isReady: Bool { - get { - return super.isReady && isCancelled - } - } -} - -// TODO: Move this type of logic into isReady for the top alert operation... then can remove this dependency operation. -public extension MVMCoreAlertHandler { - - /// Adds a page type dependency to the operation - @objc func addPagesDependency(to operation: MVMCoreTopAlertOperation) { - // This notification may only show for certain pages. - guard let pages = operation.topAlertObject.json?.optionalArrayForKey("pages") as? [String], - pages.count > 0 else { return } - let pagesOperation = NotificationPagesOperation(with: pages) - pageOperations.addOperation(pagesOperation) - operation.addDependency(pagesOperation) - } - - /// Updates the pages requirement for the operation - @objc func updatePages(for operation: MVMCoreTopAlertOperation, with topAlertObject: MVMCoreTopAlertObject) { - // Add new dependencies, remove old. - let previousPages = operation.dependencies.filter { $0 as? NotificationPagesOperation != nil } - addPagesDependency(to: operation) - for pageOperation in previousPages { - pageOperation.cancel() - operation.removeDependency(pageOperation) - } - } - - /// Handles page dependencies for all top alerts with the new pageType - @objc func handleAllPagesDependency(for pageType: String?) { - var currentOperation: MVMCoreTopAlertOperation? = nil - for case let operation as MVMCoreTopAlertOperation in topAlertQueue.operations { - // Handle the currently executing opration last to avoid race conditions. - guard !operation.isExecuting else { - currentOperation = operation - continue - } - handlePageDependency(for: operation, with: pageType) - } - if let operation = currentOperation { - handlePageDependency(for: operation, with: pageType) - } - } - - /// Updates the operation based on the page type and its dependencies. - @objc func handlePageDependency(for operation: MVMCoreTopAlertOperation, with pageType: String?) { - guard !operation.isCancelled else { return } - - if let pages = operation.topAlertObject.json?.optionalArrayForKey("pages") as? [String], - pages.count > 0, - (pageType == nil || !pages.contains(pageType!)) { - if let dependency = operation.dependencies.first(where: { $0.isFinished && ($0 as? NotificationPagesOperation)?.pages == pages }) { - // Re-add the dependency if it was previously cancelled. - let pagesOperation = NotificationPagesOperation(with: pages) - pageOperations.addOperation(pagesOperation) - operation.addDependency(pagesOperation) - operation.removeDependency(dependency) - } - if operation.isExecuting { - // If the current running operation should not show on the current page, cancel it. If it's persistent, re-add it - operation.reAddAfterCancel = operation.topAlertObject.persistent - operation.cancel() - } - } - - // Cancel any dependency if it contains the current page. - guard let pageType = pageType else { return } - for case let operation as NotificationPagesOperation in operation.dependencies { - if operation.pages.contains(pageType) { - operation.cancel() - } - } - } -} diff --git a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.h b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.h deleted file mode 100644 index bba7741..0000000 --- a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.h +++ /dev/null @@ -1,119 +0,0 @@ -// -// MVMCoreAlertHandler.h -// myverizon -// -// Created by Scott Pfeil on 3/10/14. -// Copyright (c) 2014 Verizon Wireless. All rights reserved. -// -// Keeps track of alerts and handles them. Should always use this to present alerts in mf. - -#import -#import -#import -#import - -@class MVMCoreAlertObject; -@class MVMCoreTopAlertOperation; - -@interface MVMCoreAlertHandler : NSObject - -// An operation queue for displaying popup alerts. -@property (nonnull, strong, nonatomic) NSOperationQueue *popupAlertQueue; - -// An operation queue for top alerts -@property (nonnull, strong, nonatomic) NSOperationQueue *topAlertQueue; - -/// Stores any page dependencies for top alerts -@property (nonnull, strong, nonatomic) NSOperationQueue *pageOperations; - -/// Returns the shared instance of this singleton -+ (nullable instancetype)sharedAlertHandler; - -#pragma mark - Popup Alert Functions - -/// Returns if any alert is currently showing (even if supressed). -- (BOOL)alertCurrentlyShowing; - -/// Returns if a greedy alert is currently showing (even if supressed). -- (BOOL)greedyAlertShowing; - -/** Shows the popup with the passed in parameter. - * @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; - -/** Shows the alert. - * @param title The title of the alert. - * @param message The message of the alert. - * @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; - -/** 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. - * @return Returns UIAlertController. - */ -- (nonnull UIAlertController *)showAlertWithAlertObject:(nonnull MVMCoreAlertObject *)alertObject; - -/** Cancels and removes an alert operation for the given alertObject. - * @param alertObject The alertObject scheduled to be shown. - */ -- (void)removeAlertViewForObject:(nonnull MVMCoreAlertObject *)alertObject; - -/** Iterates through all scheduled alerts and cancels any that match the provided predicate. -* @param predicate The predicate block to decide whether to cancel an alert. -*/ -- (void)removeAlertViewUsingPredicate:(BOOL(^_Nonnull)(MVMCoreAlertObject * _Nonnull obj))predicate; - -/// Removes all alerts. -- (void)removeAllAlertViews; - -#pragma mark - Supression Functions - -/// Returns true if alerts are supressed. -- (BOOL)mfAlertsSupressed; - -/// Supresses the alerts (Used by other "apps" in our app). -- (void)supressMFAlerts; - -/// Unsupresses the alerts (Used by other "apps" in our app). -- (void)unSupressMFAlerts; - -#pragma mark - Top Alert Functions - -/// Show based on the object. Will be used by the architecture. Creates an operation and calls addTopAlertOperation. -- (void)showTopAlertWithObject:(nullable MVMCoreTopAlertObject *)topAlertObject; - -/// Adds the top alert operation to the queue. -- (void)addTopAlertOperation:(nonnull MVMCoreTopAlertOperation *)topAlertOperation; - -/// Convenience functions -- (void)showTopAlertErrorWithMessage:(nullable NSString *)message; -- (void)showTopAlertConfirmationWithMessage:(nullable NSString *)message; -- (void)showTopAlertWithType:(nullable NSString *)type message:(nullable NSString *)message subMessage:(nullable NSString *)subMessage persistent:(BOOL)persistent actionMap:(nullable NSDictionary *)actionMap additionalData:(nullable NSDictionary *)additionalData; -- (void)showTopAlertWithType:(nullable NSString *)type message:(nullable NSString *)message subMessage:(nullable NSString *)subMessage persistent:(BOOL)persistent buttonTitle:(nullable NSString *)buttonTitle userActionHandler:(nullable void (^)(id _Nonnull sender))userActionHandler; - -/// Hides the current alert view. -- (void)hideTopAlertView; - -/// Hides a persistent alert based on the type string. -- (void)hidePersistentTopAlertViewOfType:(nullable NSString *)type; - -/// Removes a scheduled top alert given its top alert object. -- (void)removeTopAlertForObject:(nonnull MVMCoreTopAlertObject *)topAlertObject; - -/// Removes all top alerts. -- (void)removeAllTopAlerts; - -/// Returns YES if the persistent type is already registered in the alert queue. -- (BOOL)hasPersistentTopAlertOfType:(nullable NSString *)type; - -@end diff --git a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.m b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.m deleted file mode 100644 index dce4056..0000000 --- a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.m +++ /dev/null @@ -1,262 +0,0 @@ -// -// MVMCoreAlertHandler.m -// myverizon -// -// Created by Scott Pfeil on 3/10/14. -// Copyright (c) 2014 Verizon Wireless. All rights reserved. -// - -#import "MVMCoreAlertHandler.h" -#import "MVMCoreAlertObject.h" -#import "MVMCoreAlertController.h" -#import "MVMCoreAlertOperation.h" -#import "MVMCoreTopAlertOperation.h" -#import "MVMCoreJSONConstants.h" -#import "NSDictionary+MFConvenience.h" -#import "NSArray+MFConvenience.h" -#import - -@interface MVMCoreAlertHandler () - -// Flag that keeps track of if the alerts are supressed or not. -@property (assign, nonatomic) BOOL mfAlertsSupressed; - -@end - -@implementation MVMCoreAlertHandler - -+ (instancetype)sharedAlertHandler { - static dispatch_once_t once; - static id sharedInstance; - - dispatch_once(&once, ^{ - sharedInstance = [[self alloc] init]; - }); - - return sharedInstance; -} - -- (nullable instancetype)init { - if (self = [super init]) { - self.popupAlertQueue = [[NSOperationQueue alloc] init]; - self.popupAlertQueue.maxConcurrentOperationCount = 1; - self.topAlertQueue = [[NSOperationQueue alloc] init]; - self.topAlertQueue.maxConcurrentOperationCount = 1; - self.pageOperations = [[NSOperationQueue alloc] init]; - } - return self; -} - -#pragma mark - Popup Alert Functions - -- (BOOL)alertCurrentlyShowing { - return (self.popupAlertQueue.operationCount > 0); -} - -- (BOOL)greedyAlertShowing { - if ([self alertCurrentlyShowing]) { - NSInteger index = [self.popupAlertQueue.operations indexOfObjectPassingTest:^BOOL(__kindof MVMCoreAlertOperation * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { - if (obj.isExecuting && obj.isGreedy && stop) { - *stop = YES; - return YES; - } else { - return NO; - } - }]; - return (index != NSNotFound); - } - return NO; -} - -- (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 *)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 *)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]; - } - - // Create the alert. Adds the actions one by one. - MVMCoreAlertController *alertController = [MVMCoreAlertController alertControllerWithTitle:(title ?: @"") message:message preferredStyle:alertStyle]; - for (NSUInteger i = 0; i < [actions count]; i++) { - UIAlertAction *action = [actions objectAtIndex:i ofType:[UIAlertAction class]]; - if (action) { - [alertController addAction:action]; - } - } - - MVMCoreAlertOperation *alertOperation = [[MVMCoreAlertOperation alloc] initWithAlert:alertController isGreedy:isGreedy alertDelegate:alertDelegate]; - [self.popupAlertQueue addOperation:alertOperation]; - return alertController; -} - -- (nonnull UIAlertController *)showAlertWithAlertObject:(nonnull MVMCoreAlertObject *)alertObject { - 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; -} - -- (void)removeAlertViewForObject:(MVMCoreAlertObject *)alertObject { - for (MVMCoreAlertOperation *operation in self.popupAlertQueue.operations) { - if ([operation.currentAlertView isKindOfClass:[MVMCoreAlertController class]] && [(MVMCoreAlertController *)operation.currentAlertView alertObject] == alertObject) { - [operation cancel]; - } - } -} - -- (void)removeAlertViewUsingPredicate:(BOOL(^)(MVMCoreAlertObject *obj))predicate { - for (MVMCoreAlertOperation *operation in self.popupAlertQueue.operations) { - if ([operation.currentAlertView isKindOfClass:[MVMCoreAlertController class]]) { - MVMCoreAlertObject *alertObject = [(MVMCoreAlertController *)operation.currentAlertView alertObject]; - if (alertObject && predicate(alertObject)) { - [operation cancel]; - } - } - } -} - -- (void)removeAllAlertViews { - [self.popupAlertQueue cancelAllOperations]; -} - -#pragma mark - Supression Functions - -- (BOOL)mfAlertsSupressed { - return _mfAlertsSupressed; -} - -- (void)supressMFAlerts { - if (!self.mfAlertsSupressed) { - self.mfAlertsSupressed = YES; - for (MVMCoreAlertOperation *operation in self.popupAlertQueue.operations) { - [operation pause]; - } - for (MVMCoreTopAlertOperation *operation in self.topAlertQueue.operations) { - [operation pause]; - } - } -} - -- (void)unSupressMFAlerts { - if (self.mfAlertsSupressed) { - self.mfAlertsSupressed = NO; - for (MVMCoreAlertOperation *operation in self.popupAlertQueue.operations) { - [operation unpause]; - } - for (MVMCoreTopAlertOperation *operation in self.topAlertQueue.operations) { - [operation unpause]; - } - } -} - -#pragma mark - Top Alert Functions - -- (void)addTopAlertOperation:(nonnull MVMCoreTopAlertOperation *)topAlertOperation { - __block MVMCoreTopAlertOperation *alertOperation = topAlertOperation; - __weak typeof(self) weakSelf = self; - [alertOperation setCompletionBlock:^{ - - // If the alert was cancelled to show another with higher priority, re-add to the operation when cancelled to the queue. - if (alertOperation.reAddAfterCancel) { - MVMCoreTopAlertOperation *newOperation = [alertOperation copy]; - newOperation.reAddAfterCancel = NO; - [weakSelf addTopAlertOperation:newOperation]; - } - alertOperation = nil; - }]; - - [self.topAlertQueue addOperation:alertOperation]; - - // If the current running operation is persistent and has a lower queue priority then the added operation, cancel it and re-add it. - for (MVMCoreTopAlertOperation *operation in self.topAlertQueue.operations) { - - if (operation.isExecuting && !operation.isCancelled && operation.topAlertObject.persistent && operation.queuePriority < alertOperation.queuePriority && alertOperation.isReady) { - operation.reAddAfterCancel = YES; - [operation cancel]; - break; - } - } -} - -- (void)showTopAlertWithObject:(nullable MVMCoreTopAlertObject *)topAlertObject { - MVMCoreTopAlertOperation *alertOperation = [[MVMCoreTopAlertOperation alloc] initWithTopAlertObject:topAlertObject]; - [self addTopAlertOperation:alertOperation]; -} - -- (void)showTopAlertErrorWithMessage:(nullable NSString *)message { - - MVMCoreTopAlertObject *topAlertObject = [[MVMCoreTopAlertObject alloc] initWithType:ValueTypeError message:message]; - [self showTopAlertWithObject:topAlertObject]; -} - -- (void)showTopAlertConfirmationWithMessage:(nullable NSString *)message { - - MVMCoreTopAlertObject *topAlertObject = [[MVMCoreTopAlertObject alloc] initWithType:ValueTypeSuccess message:message]; - [self showTopAlertWithObject:topAlertObject]; -} - -- (void)showTopAlertWithType:(nullable NSString *)type message:(nullable NSString *)message subMessage:(nullable NSString *)subMessage persistent:(BOOL)persistent actionMap:(nullable NSDictionary *)actionMap additionalData:(nullable NSDictionary *)additionalData { - - MVMCoreTopAlertObject *topAlertObject = [[MVMCoreTopAlertObject alloc] initWithType:type message:message subMessage:subMessage persistent:persistent actionMap:actionMap additionalData:additionalData]; - [self showTopAlertWithObject:topAlertObject]; -} - -- (void)showTopAlertWithType:(nullable NSString *)type message:(nullable NSString *)message subMessage:(nullable NSString *)subMessage persistent:(BOOL)persistent buttonTitle:(nullable NSString *)buttonTitle userActionHandler:(nullable void (^)(id _Nonnull sender))userActionHandler { - - MVMCoreTopAlertObject *topAlertObject = [[MVMCoreTopAlertObject alloc] initWithType:type message:message subMessage:subMessage persistent:persistent buttonTitle:buttonTitle userActionHandler:userActionHandler]; - [self showTopAlertWithObject:topAlertObject]; -} - -- (void)hideTopAlertView { - - MVMCoreTopAlertOperation *currentOperation = [self.topAlertQueue.operations firstObject]; - currentOperation.topAlertObject.persistent = NO; - currentOperation.reAddAfterCancel = NO; - [currentOperation cancel]; -} - -- (BOOL)hasPersistentTopAlertOfType:(nullable NSString *)type { - BOOL hasAlert = NO; - for (MVMCoreTopAlertOperation *operation in self.topAlertQueue.operations) { - if (operation.topAlertObject.persistent && [operation.topAlertObject.type isEqualToString:type]) { - hasAlert = YES; - } - } - return hasAlert; -} - -- (void)hidePersistentTopAlertViewOfType:(nullable NSString *)type { - if (type) { - for (MVMCoreTopAlertOperation *operation in self.topAlertQueue.operations) { - - // Cancel all persistent operations of this type. - if (operation.topAlertObject.persistent && [operation.topAlertObject.type isEqualToString:type]) { - operation.reAddAfterCancel = NO; - [operation cancel]; - } - } - } -} - -- (void)removeTopAlertForObject:(MVMCoreTopAlertObject *)topAlertObject { - for (MVMCoreTopAlertOperation *operation in self.topAlertQueue.operations) { - // Finds an cancels top alerts associated with the object. - if (operation.topAlertObject == topAlertObject) { - operation.reAddAfterCancel = NO; - [operation cancel]; - } - } -} - -- (void)removeAllTopAlerts { - [self.topAlertQueue cancelAllOperations]; -} - -@end diff --git a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject+Swift.swift b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject+Swift.swift deleted file mode 100644 index 162dd2d..0000000 --- a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject+Swift.swift +++ /dev/null @@ -1,45 +0,0 @@ -// -// MVMCoreAlertObject+Swift.swift -// MVMCore -// -// Created by Suresh, Kamlesh on 7/10/20. -// Copyright © 2020 myverizon. All rights reserved. -// - - -public extension MVMCoreAlertObject { - - @objc static func alertObjectWith(action actionJson: [AnyHashable: Any]?, additionalData: [AnyHashable: Any]?, delegateObject: DelegateObject?, error: AutoreleasingUnsafeMutablePointer?) -> MVMCoreAlertObject? { - - guard let alertJson = actionJson?.optionalDictionaryForKey("alert"), - (alertJson.optionalStringForKey(KeyTitle) != nil || alertJson.optionalStringForKey(KeyMessage) != nil), - let actionsList = alertJson.optionalArrayForKey("alertActions") as? [[AnyHashable: Any]] - else { - error?.pointee = MVMCoreErrorObject(title: nil, message: MVMCoreGetterUtility.hardcodedString(withKey: HardcodedErrorUnableToProcess), code: ErrorCode.popupFailed.rawValue, domain: ErrorDomainNative, location: String(describing: self)) - return nil - } - - var actionsForAlert: [UIAlertAction] = [] - - for actionJson in actionsList { - let style = UIAlertAction.Style(rawValue: actionJson.stringForkey("style")) - let alertAction = UIAlertAction(title: actionJson.optionalStringForKey(KeyTitle), style: style) { action in - MVMCoreActionHandler.shared()?.handleAction(with: actionJson.optionalDictionaryForKey("action"), - additionalData: additionalData, - delegateObject: delegateObject) - } - actionsForAlert.append(alertAction) - } - - let alertObject = MVMCoreAlertObject(popupAlertWithTitle: alertJson.optionalStringForKey(KeyTitle), - message: alertJson.optionalStringForKey(KeyMessage), - actions: actionsForAlert, - isGreedy: false) - - if let alertStyle = alertJson.optionalStringForKey("style") { - alertObject?.alertStyle = UIAlertController.Style(rawValue: alertStyle) - } - - return alertObject - } -} diff --git a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.h b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.h deleted file mode 100644 index 161e123..0000000 --- a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.h +++ /dev/null @@ -1,72 +0,0 @@ -// -// MVMCoreAlertObject.h -// myverizon -// -// Created by Scott Pfeil on 11/21/14. -// Copyright (c) 2014 Verizon Wireless. All rights reserved. -// -// An object for keeping track of all alert variables. Easier to pass around. - -#import -#import -#import -#import -#import - -@class MVMCoreErrorObject; -@class MVMCoreLoadObject; -@class DelegateObject; - -typedef NS_ENUM(NSInteger, MFAlertType) { - MFAlertTypePopup = 0, - MFAlertTypeField, - MFAlertTypeTop, - MFAlertTypeNone -}; - -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 (nonnull, strong, nonatomic) NSArray *actions; -@property (nonatomic) BOOL isGreedy; -@property (nonatomic) UIAlertControllerStyle alertStyle; -@property (nonatomic) MFAlertType type; -@property (nonatomic) BOOL defaultAction; - -@property (nonnull, strong, nonatomic) NSArray *fieldErrors; -@property (nullable, nonatomic, copy) TextFieldErrorHandler textFieldErrorHandler; - -// Set to be notified of popup style alert events. -@property (nonatomic, weak, nullable) NSObject *alertDelegate; - -// Creates an alert object for an error with the passed in load object response info -+ (nullable instancetype)alertObjectForLoadObject:(nullable MVMCoreLoadObject *)loadObject error:(nullable MVMCoreErrorObject *)error delegateObject:(nullable DelegateObject *)delegateObject; -+ (nullable instancetype)alertObjectForPageType:(nullable NSString *)pageType responseInfo:(nullable NSDictionary *)responseInfo additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; - -// Initializes a popup style alert object. Look at the alert handler to see what each is used for. -- (nullable instancetype)initPopupAlertWithTitle:(nullable NSString *)title message:(nullable NSString *)message actions:(nonnull NSArray *)actions isGreedy:(BOOL)isGreedy; - -// Initializes a popup style alert object using the error passed in. Message is formatted default style. By defualt uses the Okay button to just dismiss the error. -- (nullable instancetype)initPopupAlertWithError:(nullable MVMCoreErrorObject *)error isGreedy:(BOOL)isGreedy; - -// Same as above but no default actions. They are passed in. -- (nullable instancetype)initPopupAlertWithError:(nullable MVMCoreErrorObject *)error actions:(nonnull NSArray *)actions isGreedy:(BOOL)isGreedy; - -// Returns the alert object made with the page json. If there is not enough data to make, we will set error -+ (nullable instancetype)alertObjectWithPage:(nullable NSDictionary *)page isGreedy:(BOOL)isGreedy additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject error:(MVMCoreErrorObject *_Nullable *_Nullable)error; - -// Will show this alert in it's appropriate type style. -- (void)showAlert; - -#pragma mark - Deprecated - -// Creates an alert object for an error with the passed in load object response info -+ (nullable instancetype)alertObjectForLoadObject:(nullable MVMCoreLoadObject *)loadObject error:(nullable MVMCoreErrorObject *)error actionDelegate:(nullable NSObject *)actionDelegate __deprecated; -+ (nullable instancetype)alertObjectForPageType:(nullable NSString *)pageType responseInfo:(nullable NSDictionary *)responseInfo additionalData:(nullable NSDictionary *)additionalData actionDelegate:(nullable NSObject *)actionDelegate __deprecated; -+ (nullable instancetype)alertObjectWithPage:(nullable NSDictionary *)page isGreedy:(BOOL)isGreedy additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate error:(MVMCoreErrorObject *_Nullable *_Nullable)error __deprecated; - -@end diff --git a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.m b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.m deleted file mode 100644 index c8deb7a..0000000 --- a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.m +++ /dev/null @@ -1,302 +0,0 @@ -// -// MVMCoreAlertObject.m -// myverizon -// -// Created by Scott Pfeil on 11/21/14. -// Copyright (c) 2014 Verizon Wireless. All rights reserved. -// - -#import "MVMCoreAlertObject.h" -#import "MVMCoreAlertHandler.h" -#import "MVMCoreTopAlertObject.h" -#import "MVMCoreCache.h" -#import "MVMCoreErrorConstants.h" -#import "MVMCoreErrorObject.h" -#import "MVMCoreLoadObject.h" -#import "MVMCoreGetterUtility.h" -#import "NSDictionary+MFConvenience.h" -#import "MVMCoreHardcodedStringsConstants.h" -#import "MVMCoreJSONConstants.h" -#import -#import - -@interface MVMCoreAlertObject () - -@property (strong, nonatomic) MVMCoreLoadObject *loadObject; -@property (nullable, strong, nonatomic) NSString *systemDomain; -@property (nullable, strong, nonatomic) MVMCoreTopAlertObject *topAlertObject; -@end - -@implementation MVMCoreAlertObject - -+ (nullable instancetype)alertObjectForLoadObject:(nullable MVMCoreLoadObject *)loadObject error:(nullable MVMCoreErrorObject *)error delegateObject:(nullable DelegateObject *)delegateObject { - - MVMCoreAlertObject *alert = nil; - if (!error || [ErrorDomainServer isEqualToString:error.domain]) { - alert = [MVMCoreAlertObject alertObjectForPageType:loadObject.pageType responseInfo:loadObject.responseInfoMap additionalData:loadObject.dataForPage delegateObject:delegateObject]; - } else { - alert = [[MVMCoreAlertObject alloc] initPopupAlertWithError:error isGreedy:NO]; - } - - // only if actions are empty, then go inside and set OK as default action - if (alert.type == MFAlertTypePopup && alert.actions.count == 0) { - alert.defaultAction = YES; - alert.actions = @[[UIAlertAction actionWithTitle:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedOK] style:UIAlertActionStyleDefault handler:nil]]; - } - return alert; -} - -+ (nullable instancetype)alertObjectForPageType:(nullable NSString *)pageType responseInfo:(nullable NSDictionary *)responseInfo additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { - - __block MVMCoreAlertObject *alert = [[MVMCoreAlertObject alloc] init]; - alert.title = [responseInfo stringForKey:KeyErrorHeading]; - alert.message = [responseInfo stringForKey:KeyUserMessage]; - - NSString *messageStyle = [responseInfo stringForKey:KeyMessageStyle]; - if ([ValueTypeFieldErrors isEqualToString:[responseInfo string:KeyType]]) { - - // field errors. - alert.type = MFAlertTypeField; - alert.fieldErrors = [responseInfo array:ValueTypeFieldErrors]; - } else { - - // Check for top alert (persistent or regular). - if ([messageStyle isEqualToString:ValueMessageStyleTopPersistent] || [messageStyle isEqualToString:ValueMessageStyleTop]) { - - alert.topAlertObject = [[MVMCoreTopAlertObject alloc] initWithResponseInfo:responseInfo]; - alert.topAlertObject.delegate = delegateObject.topAlertDelegate; - alert.topAlertObject.pageType = pageType; - alert.type = MFAlertTypeTop; - } else if ([messageStyle isEqualToString:ValueMessageStylePopup]) { - - // 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) { - - MVMCoreErrorObject *error = nil; - MVMCoreAlertObject *popupAlert = [MVMCoreAlertObject alertObjectWithPage:jsonDictionary isGreedy:NO additionalData:additionalData delegateObject:delegateObject error:&error]; - if (error) { - - // Error, popup page not found for page type. - popupAlert = [[MVMCoreAlertObject alloc] initPopupAlertWithError:error isGreedy:NO]; - } - - if (popupAlert) { - alert = popupAlert; - } - }]; - } else if (messageStyle.length == 0 && pageType) { - - // No message style! - alert.type = MFAlertTypeNone; - } else { - - // Default to popup - alert.type = MFAlertTypePopup; - alert.alertStyle = UIAlertControllerStyleAlert; - } - } - alert.alertDelegate = delegateObject.alertDelegate; - return alert; -} - -- (nullable instancetype)initPopupAlertWithTitle:(nullable NSString *)title message:(nullable NSString *)message actions:(nonnull NSArray *)actions isGreedy:(BOOL)isGreedy { - if (self = [super init]) { - self.title = title; - self.message = message; - self.actions = actions; - self.isGreedy = isGreedy; - self.type = MFAlertTypePopup; - self.alertStyle = UIAlertControllerStyleAlert; - } - return self; -} - -- (nullable instancetype)initPopupAlertWithError:(nullable MVMCoreErrorObject *)error isGreedy:(BOOL)isGreedy { - - if (self = [super init]) { - self.title = error.title; - self.message = [NSString stringWithFormat:@"%@ (%@)",error.messageToDisplay,[error stringErrorCode]]; - self.actions = @[[UIAlertAction actionWithTitle:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedOK] style:UIAlertActionStyleDefault handler:nil]]; - self.defaultAction = YES; - self.isGreedy = isGreedy; - self.type = MFAlertTypePopup; - self.alertStyle = UIAlertControllerStyleAlert; - } - return self; -} - -- (nullable instancetype)initPopupAlertWithError:(nullable MVMCoreErrorObject *)error actions:(nonnull NSArray *)actions isGreedy:(BOOL)isGreedy { - - if (self = [super init]) { - self.title = error.title; - self.message = [NSString stringWithFormat:@"%@ (%@)",error.messageToDisplay,[error stringErrorCode]]; - self.actions = actions; - self.isGreedy = isGreedy; - self.type = MFAlertTypePopup; - self.alertStyle = UIAlertControllerStyleAlert; - } - return self; -} - -+ (nullable instancetype)alertObjectWithPage:(nullable NSDictionary *)page isGreedy:(BOOL)isGreedy additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject error:(MVMCoreErrorObject *_Nullable *_Nullable)error { - - MVMCoreAlertObject *alert = [[MVMCoreAlertObject alloc] init]; - alert.title = [page stringForKey:KeyTitle]; - alert.pageJson = page; - alert.message = [page stringForKey:KeyMessage]; - alert.isGreedy = isGreedy; - alert.type = MFAlertTypePopup; - alert.alertStyle = UIAlertControllerStyleAlert; - - NSArray *actions = [page array:KeyLinks]; - NSMutableArray *actionsForAlert = [NSMutableArray array]; - for (NSDictionary *actionMap in actions) { - [actionsForAlert addObject:[UIAlertAction actionWithTitle:[actionMap stringForKey:KeyTitle] style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { - [[MVMCoreActionHandler sharedActionHandler] handleActionWithDictionary:actionMap additionalData:additionalData delegateObject:delegateObject]; - }]]; - } - alert.actions = actionsForAlert; - - if ((alert.title.length > 0 || alert.message.length > 0) && alert.actions.count > 0) { - return alert; - } else { - if (error) { - *error = [[MVMCoreErrorObject alloc] initWithTitle:nil messageToLog:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorUnableToProcess] code:ErrorCodePopupFailed domain:ErrorDomainNative location:[NSString stringWithFormat:@"%@_Popup_pageType:%@",NSStringFromClass([delegateObject.alertDelegate class]),[page stringForKey:KeyPageType]]]; - } - return nil; - } -} - -- (void)showAlert { - - switch (self.type) { - case MFAlertTypeField: - self.textFieldErrorHandler(self.fieldErrors); - break; - case MFAlertTypeTop: - [[MVMCoreAlertHandler sharedAlertHandler] showTopAlertWithObject:self.topAlertObject]; - break; - case MFAlertTypePopup: - [[MVMCoreAlertHandler sharedAlertHandler] showAlertWithAlertObject:self]; - break; - default: - break; - } -} - -#pragma mark - Deprecated - -+ (nullable instancetype)alertObjectForLoadObject:(nullable MVMCoreLoadObject *)loadObject error:(nullable MVMCoreErrorObject *)error actionDelegate:(nullable NSObject *)actionDelegate { - - MVMCoreAlertObject *alert = nil; - if (!error || [ErrorDomainServer isEqualToString:error.domain]) { - alert = [MVMCoreAlertObject alertObjectForPageType:loadObject.pageType responseInfo:loadObject.responseInfoMap additionalData:loadObject.dataForPage actionDelegate:actionDelegate]; - } else { - alert = [[MVMCoreAlertObject alloc] initPopupAlertWithError:error isGreedy:NO]; - } - - // only if actions are empty, then go inside and set OK as default action - if (alert.type == MFAlertTypePopup && alert.actions.count == 0) { - alert.defaultAction = YES; - alert.actions = @[[UIAlertAction actionWithTitle:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedOK] style:UIAlertActionStyleDefault handler:nil]]; - } - return alert; -} - -+ (nullable instancetype)alertObjectForPageType:(nullable NSString *)pageType responseInfo:(nullable NSDictionary *)responseInfo additionalData:(nullable NSDictionary *)additionalData actionDelegate:(nullable NSObject *)actionDelegate { - - __block MVMCoreAlertObject *alert = [[MVMCoreAlertObject alloc] init]; - alert.title = [responseInfo stringForKey:KeyErrorHeading]; - alert.message = [responseInfo stringForKey:KeyUserMessage]; - - NSString *messageStyle = [responseInfo stringForKey:KeyMessageStyle]; - if ([ValueTypeFieldErrors isEqualToString:[responseInfo string:KeyType]]) { - - // field errors. - alert.type = MFAlertTypeField; - alert.fieldErrors = [responseInfo array:ValueTypeFieldErrors]; - } else { - - // Check for top alert (persistent or regular). - if ([messageStyle isEqualToString:ValueMessageStyleTopPersistent] || [messageStyle isEqualToString:ValueMessageStyleTop]) { - - alert.topAlertObject = [[MVMCoreTopAlertObject alloc] initWithResponseInfo:responseInfo]; - if ([actionDelegate conformsToProtocol:@protocol(MVMCoreTopAlertDelegateProtocol)]) { - alert.topAlertObject.delegate = (NSObject *)actionDelegate; - } - alert.topAlertObject.pageType = pageType; - alert.type = MFAlertTypeTop; - } else if ([messageStyle isEqualToString:ValueMessageStylePopup]) { - - // 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) { - - MVMCoreErrorObject *error = nil; - MVMCoreAlertObject *popupAlert = [MVMCoreAlertObject alertObjectWithPage:jsonDictionary isGreedy:NO additionalData:additionalData delegate:actionDelegate error:&error]; - if (error) { - - // Error, popup page not found for page type. - popupAlert = [[MVMCoreAlertObject alloc] initPopupAlertWithError:error isGreedy:NO]; - } - - if (popupAlert) { - alert = popupAlert; - } - }]; - } else if (messageStyle.length == 0 && pageType) { - - // No message style! - alert.type = MFAlertTypeNone; - } else { - - // Default to popup - alert.type = MFAlertTypePopup; - alert.alertStyle = UIAlertControllerStyleAlert; - } - } - if ([actionDelegate conformsToProtocol:@protocol(MVMCoreAlertDelegateProtocol)]) { - alert.alertDelegate = (NSObject *)actionDelegate; - } - return alert; -} - -+ (nullable instancetype)alertObjectWithPage:(nullable NSDictionary *)page isGreedy:(BOOL)isGreedy additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate error:(MVMCoreErrorObject *_Nullable *_Nullable)error { - - MVMCoreAlertObject *alert = [[MVMCoreAlertObject alloc] init]; - alert.title = [page stringForKey:KeyTitle]; - alert.pageJson = page; - alert.message = [page stringForKey:KeyMessage]; - alert.isGreedy = isGreedy; - alert.type = MFAlertTypePopup; - alert.alertStyle = UIAlertControllerStyleAlert; - - NSArray *actions = [page array:KeyLinks]; - NSMutableArray *actionsForAlert = [NSMutableArray array]; - for (NSDictionary *actionMap in actions) { - [actionsForAlert addObject:[UIAlertAction actionWithTitle:[actionMap stringForKey:KeyTitle] style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { - [[MVMCoreActionHandler sharedActionHandler] handleActionWithDictionary:actionMap additionalData:additionalData delegate:delegate]; - }]]; - } - alert.actions = actionsForAlert; - - if ((alert.title.length > 0 || alert.message.length > 0) && alert.actions.count > 0) { - return alert; - } else { - if (error) { - *error = [[MVMCoreErrorObject alloc] initWithTitle:nil messageToLog:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorUnableToProcess] code:ErrorCodePopupFailed domain:ErrorDomainNative location:[NSString stringWithFormat:@"%@_Popup_pageType:%@",NSStringFromClass([delegate class]),[page stringForKey:KeyPageType]]]; - } - return nil; - } -} - -@end diff --git a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertOperation.h b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertOperation.h deleted file mode 100644 index c48fd86..0000000 --- a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertOperation.h +++ /dev/null @@ -1,39 +0,0 @@ -// -// MVMCoreAlertOperation.h -// myverizon -// -// Created by Scott Pfeil on 9/28/15. -// Copyright © 2015 Verizon Wireless. All rights reserved. -// -// Operation for handling an alert. Should NOT be on the main queue. - -#import -#import -#import "MVMCoreOperation.h" -#import "MVMCoreAlertDelegateProtocol.h" - -@interface MVMCoreAlertOperation : MVMCoreOperation - -/// Alert controller to be displayed. -@property (nonnull, readonly) UIAlertController *currentAlertView; - -/// If this operation is temporarily paused. -@property (readonly, getter=isPaused) BOOL paused; - -/// If this alert is a greedy alert (See MVMCoreAlertHandler). -@property (readonly, getter=isGreedy) BOOL greedy; - -/// The alert delegate if needed. -@property (readonly, nullable, nonatomic, weak) NSObject *alertDelegate; - -/// Initializes the operation with the alert to display and if it is greedy or not. -- (nullable instancetype)initWithAlert:(nonnull UIAlertController *)alert isGreedy:(BOOL)isGreedy; -- (nullable instancetype)initWithAlert:(nonnull UIAlertController *)alert isGreedy:(BOOL)isGreedy alertDelegate:(nullable id )alertDelegate; - -/// Pauses the operation. Temporarily removes any alert. -- (void)pause; - -/// Unpauses the operation, resuming any alert. -- (void)unpause; - -@end diff --git a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertOperation.m b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertOperation.m deleted file mode 100644 index 5aa9058..0000000 --- a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertOperation.m +++ /dev/null @@ -1,242 +0,0 @@ -// -// MVMCoreAlertOperation.m -// myverizon -// -// Created by Scott Pfeil on 9/28/15. -// Copyright © 2015 Verizon Wireless. All rights reserved. -// - -#import "MVMCoreAlertOperation.h" -#import "MVMCoreAlertHandler.h" -#import "MVMCoreAlertController.h" -#import "MVMCoreNavigationHandler.h" - -@interface MVMCoreAlertOperation () { - __block BOOL _paused; - __block BOOL _displayed; -} - -@property (readwrite, getter=isPaused) BOOL paused; - -@property (readwrite, getter=isGreedy) BOOL greedy; - -@property (readwrite, getter=isDisplayed) BOOL displayed; - -@property (readwrite, nullable, nonatomic, weak) NSObject *alertDelegate; - -// The currently displayed alert view. -@property (nullable, strong, nonatomic) UIAlertController *currentAlertView; - -// A boolean to keep track of if we alreadys signed up to observe. -@property (assign, nonatomic) BOOL alertBeingObserved; - -// For thread safety -@property (strong, nonatomic) dispatch_queue_t pausedQueue; -@property (strong, nonatomic) dispatch_queue_t displayedQueue; - -// Dismisses the alert. -- (void)dismissAlertView; - -// Begins observing for when the alert is dismissed. -- (void)observeForCurrentAlertViewDismissal; - -// Stops observing for when the alert is dismissed. -- (void)stopObservingAlertView; - -@end - -@implementation MVMCoreAlertOperation - -// The context for kvo -static void * XXContext = &XXContext; - -- (instancetype)init { - - self = [super init]; - if (self) { - self.pausedQueue = dispatch_queue_create("paused", DISPATCH_QUEUE_CONCURRENT); - self.displayedQueue = dispatch_queue_create("displayed", DISPATCH_QUEUE_CONCURRENT); - } - return self; -} - -- (nullable instancetype)initWithAlert:(nonnull UIAlertController *)alert isGreedy:(BOOL)isGreedy { - - if (self = [self init]) { - self.currentAlertView = alert; - self.greedy = isGreedy; - } - return self; -} - -- (nullable instancetype)initWithAlert:(nonnull UIAlertController *)alert isGreedy:(BOOL)isGreedy alertDelegate:(nullable NSObject *)alertDelegate { - if (self = [self initWithAlert:alert isGreedy:isGreedy]) { - self.alertDelegate = alertDelegate; - } - return self; -} - -- (void)dealloc { - [self stopObservingAlertView]; -} - -- (BOOL)isPaused { - __block BOOL isPaused; - dispatch_sync(self.pausedQueue, ^{ - isPaused = self->_paused; - }); - return isPaused; -} - -- (void)setPaused:(BOOL)paused { - dispatch_barrier_async(self.pausedQueue, ^{ - self->_paused = paused; - }); -} - -- (BOOL)isDisplayed { - __block BOOL isDisplayed; - dispatch_sync(self.displayedQueue, ^{ - isDisplayed = self->_displayed; - }); - return isDisplayed; -} - -- (void)setDisplayed:(BOOL)displayed { - dispatch_barrier_async(self.displayedQueue, ^{ - self->_displayed = displayed; - }); -} - -- (void)main { - - // Always check for cancellation before launching the task. - if ([self checkAndHandleForCancellation]) { - return; - } - - // Display alert only if alerts aren't supressed. - if (![[MVMCoreAlertHandler sharedAlertHandler] mfAlertsSupressed] && self.currentAlertView) { - - // Observe for when it is removed. - [self observeForCurrentAlertViewDismissal]; - - // Adds the presentation to the animation queue. - [[MVMCoreNavigationHandler sharedNavigationHandler] presentViewController:self.currentAlertView animated:YES delegate:nil completionHandler:^{ - - // We finished but it was not displayed yet. It's possible that it was cancelled. Finish this task - if (!self.isDisplayed) { - [self markAsFinished]; - } else if (self.isCancelled) { - [self dismissAlertView]; - } - }]; - } -} - -- (void)cancel { - [super cancel]; - - // Notify delegate that the alert is cancelled. - if ([self.alertDelegate respondsToSelector:@selector(alertCancelled:)]) { - dispatch_async(dispatch_get_main_queue(), ^{ - [self.alertDelegate alertCancelled:self.currentAlertView]; - }); - } - - [self dismissAlertView]; -} - -- (void)dismissAlertView { - - if (self.isDisplayed) { - - // Dismisses. - [[MVMCoreNavigationHandler sharedNavigationHandler] dismissViewController:self.currentAlertView animated:YES]; - } -} - -- (void)pause { - [self willChangeValueForKey:@"isPaused"]; - self.paused = YES; - [self didChangeValueForKey:@"isPaused"]; - - // Notify delegate of pause. - if ([self.alertDelegate respondsToSelector:@selector(alertPaused:)]) { - dispatch_async(dispatch_get_main_queue(), ^{ - [self.alertDelegate alertPaused:self.currentAlertView]; - }); - } - - // Dismiss until unpaused. - [self dismissAlertView]; -} - -- (void)unpause { - [self willChangeValueForKey:@"isPaused"]; - self.paused = NO; - [self didChangeValueForKey:@"isPaused"]; - - // Notify delegate of unpause. - if ([self.alertDelegate respondsToSelector:@selector(alertUnpaused:)]) { - dispatch_async(dispatch_get_main_queue(), ^{ - [self.alertDelegate alertUnpaused:self.currentAlertView]; - }); - } - - // Show alert... - if (self.currentAlertView) { - [self start]; - } -} - -#pragma mark - Observer Functions - -- (void)observeForCurrentAlertViewDismissal { - if (!self.alertBeingObserved && ![[MVMCoreAlertHandler sharedAlertHandler] mfAlertsSupressed] && self.currentAlertView && [self.currentAlertView isKindOfClass:[UIAlertController class]]) { - self.alertBeingObserved = YES; - [self.currentAlertView addObserver:self forKeyPath:@"visible" options:NSKeyValueObservingOptionOld | NSKeyValueObservingOptionNew context:XXContext]; - } -} - -- (void)stopObservingAlertView { - if (self.alertBeingObserved) { - [self.currentAlertView removeObserver:self forKeyPath:@"visible" context:XXContext]; - self.alertBeingObserved = NO; - } -} - -- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { - if (context == XXContext && [keyPath isEqualToString:@"visible"]) { - if (![object isVisible]) { - - self.displayed = NO; - - // Notify delegate that the alert is dismissed. - if ([self.alertDelegate respondsToSelector:@selector(alertDismissed:)]) { - dispatch_async(dispatch_get_main_queue(), ^{ - [self.alertDelegate alertDismissed:self.currentAlertView]; - }); - } - - // Is visible was set to NO, meaning that the alertview is no longer visible. - if (!self.isPaused) { - [self stopObservingAlertView]; - self.currentAlertView = nil; - [self markAsFinished]; - } - } else { - - self.displayed = YES; - - // Notify delegate that the alert is shown. - if ([self.alertDelegate respondsToSelector:@selector(alertShown:)]) { - dispatch_async(dispatch_get_main_queue(), ^{ - [self.alertDelegate alertShown:self.currentAlertView]; - }); - } - } - } -} - -@end diff --git a/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.h b/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.h index ee8d4b4..90f1854 100644 --- a/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.h +++ b/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.h @@ -35,11 +35,9 @@ extern NSString * const KeyShareType; extern NSString * const KeyShareText; extern NSString * const KeyActionTypeCall; extern NSString * const KeyActionTypePreviousSubmit; -extern NSString * const KeyActionTypePopup; extern NSString * const KeyActionTypeCancel; extern NSString * const KeyActionTypeRedirect; extern NSString * const KeyActionTypeSettings; -extern NSString * const KeyActionTypeAlert; extern NSString * const KeyActionTypeNoop; extern NSString * const KeyActionInformation; extern NSString * const KeyLinkAwayAppURL; diff --git a/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.m b/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.m index 91ed8a3..ac69a76 100644 --- a/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.m +++ b/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.m @@ -35,11 +35,9 @@ NSString * const KeyActionTypeBack = @"back"; NSString * const KeyActionTypeShare = @"share"; NSString * const KeyActionTypeCall = @"call"; NSString * const KeyActionTypePreviousSubmit = @"previousSubmit"; -NSString * const KeyActionTypePopup = @"popup"; NSString * const KeyActionTypeCancel = @"cancel"; NSString * const KeyActionTypeRedirect = @"switchApp"; NSString * const KeyActionTypeSettings = @"openSettings"; -NSString * const KeyActionTypeAlert = @"alert"; NSString * const KeyActionTypeNoop = @"noop"; NSString * const KeyActionInformation = @"actionInformation"; NSString * const KeyLinkAwayAppURL = @"appURL"; diff --git a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadHandler.m b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadHandler.m index d9d3171..ad33438 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadHandler.m +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadHandler.m @@ -21,6 +21,7 @@ #import "MVMCoreHardcodedStringsConstants.h" #import "MVMCoreObject.h" #import "MVMCoreConstants.h" +#import "MVMCoreActionUtility.h" #import @interface MVMCoreLoadHandler () diff --git a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m index b6e0ca9..7bce64d 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m @@ -13,10 +13,8 @@ #import "MVMCoreSessionTimeHandler.h" #import "MVMCoreLoggingHandler.h" #import "MVMCoreSessionObject.h" -#import "MVMCoreAlertHandler.h" #import "MVMCoreViewControllerMappingObject.h" #import "MVMCoreNavigationHandler.h" -#import "MVMCoreAlertObject.h" #import #import "MVMCoreLoadObject.h" #import "MVMCoreRequestParameters.h" @@ -327,7 +325,7 @@ + (void)notifyListenersOfNewResponse:(NSDictionary *)pages modules:(NSDictionary *)modules systemParameters:(NSDictionary *)systemParameters loadObject:(nonnull MVMCoreLoadObject *)loadObject { NSMutableDictionary *userInfo = nil; - if (pages.count > 0 || modules.count > 0 || systemParameters.count > 0) { + if (pages.count > 0 || modules.count > 0 || systemParameters.count > 0 || loadObject.responseJSON.count > 0) { userInfo = [NSMutableDictionary dictionary]; if (pages.count > 0) { [userInfo setObject:pages forKey:KeyPageMap]; @@ -376,9 +374,6 @@ if (loadObject.extendsAppSession) { [[MVMCoreSessionTimeHandler sharedSessionHandler] startSessionTimer]; } - - // Dismiss any top alerts that server wants us to dismiss - [[MVMCoreAlertHandler sharedAlertHandler] hidePersistentTopAlertViewOfType:[loadObject.responseInfoMap string:@"disableType"]]; // Adds the modules received from server to any modules we grabbed from the cache. NSDictionary *modules = [jsonDictionary dict:KeyModuleMap]; @@ -758,23 +753,9 @@ } + (void)createAndShowAlertForLoadObject:(nullable MVMCoreLoadObject *)loadObject error:(nullable MVMCoreErrorObject *)error delegateObject:(nullable DelegateObject *)delegateObject { - - // Check delegate for alert object to show. - MVMCoreAlertObject *alertObject; - if ([delegateObject.loadDelegate respondsToSelector:@selector(alertObjectToShow:error:)]) { - alertObject = [delegateObject.loadDelegate alertObjectToShow:loadObject error:error]; - } else { - alertObject = [MVMCoreAlertObject alertObjectForLoadObject:loadObject error:error delegateObject:delegateObject]; + if ([[MVMCoreObject sharedInstance].globalLoadDelegate respondsToSelector:@selector(createAndShowAlertForLoadObject:error:delegateObject:)]) { + [[MVMCoreObject sharedInstance].globalLoadDelegate createAndShowAlertForLoadObject:loadObject error:error delegateObject:delegateObject]; } - - // Set how we handle text field errors. - [alertObject setTextFieldErrorHandler:^(NSArray * _Nonnull fieldErrors) { - if ([loadObject.operation.delegateObject.loadDelegate respondsToSelector:@selector(handleFieldErrors:loadObject:)]) { - [loadObject.operation.delegateObject.loadDelegate handleFieldErrors:fieldErrors loadObject:loadObject]; - } - }]; - - [alertObject showAlert]; } + (void)loadAbortedWithError:(nonnull MVMCoreErrorObject *)error loadObject:(nonnull MVMCoreLoadObject *)loadObject { diff --git a/MVMCore/MVMCore/MVMCore.h b/MVMCore/MVMCore/MVMCore.h index b0b0cbb..fa613c5 100644 --- a/MVMCore/MVMCore/MVMCore.h +++ b/MVMCore/MVMCore/MVMCore.h @@ -52,13 +52,6 @@ FOUNDATION_EXPORT const unsigned char MVMCoreVersionString[]; #import #import #import - - // Alert Handling -#import -#import -#import -#import -#import // Presentation Handling #import @@ -74,7 +67,6 @@ FOUNDATION_EXPORT const unsigned char MVMCoreVersionString[]; #import #import #import -#import // Protocols #import diff --git a/MVMCore/MVMCore/MainProtocols/DelegateObject.swift b/MVMCore/MVMCore/MainProtocols/DelegateObject.swift index 88d26b1..9e4ac07 100644 --- a/MVMCore/MVMCore/MainProtocols/DelegateObject.swift +++ b/MVMCore/MVMCore/MainProtocols/DelegateObject.swift @@ -12,7 +12,6 @@ import UIKit @objcMembers open class DelegateObject: NSObject { public weak var actionDelegate: (MVMCoreActionDelegateProtocol & NSObjectProtocol)? public weak var loadDelegate: (MVMCoreLoadDelegateProtocol & NSObjectProtocol)? - public weak var alertDelegate: (MVMCoreAlertDelegateProtocol & NSObjectProtocol)? public weak var presentationDelegate: (MVMCorePresentationDelegateProtocol & NSObjectProtocol)? required override public init() { @@ -22,7 +21,6 @@ import UIKit open func setAll(withDelegate delegate: Any) { actionDelegate = delegate as? (MVMCoreActionDelegateProtocol & NSObjectProtocol) loadDelegate = delegate as? (MVMCoreLoadDelegateProtocol & NSObjectProtocol) - alertDelegate = delegate as? (MVMCoreAlertDelegateProtocol & NSObjectProtocol) presentationDelegate = delegate as? (MVMCorePresentationDelegateProtocol & NSObjectProtocol) } diff --git a/MVMCore/MVMCore/MainProtocols/MVMCoreGlobalLoadProtocol.h b/MVMCore/MVMCore/MainProtocols/MVMCoreGlobalLoadProtocol.h index ddf3db9..408a5b1 100644 --- a/MVMCore/MVMCore/MainProtocols/MVMCoreGlobalLoadProtocol.h +++ b/MVMCore/MVMCore/MainProtocols/MVMCoreGlobalLoadProtocol.h @@ -35,4 +35,7 @@ // Can return an error object. - (nonnull MVMCoreErrorObject *)createErrorObjectForRequestNSError:(nonnull NSError *)error forRequest:(nonnull NSURLRequest *)request location:(nullable NSString *)locationForError; +// Shows the appropriate alert style for the given response info and/or error. +- (void)createAndShowAlertForLoadObject:(nullable MVMCoreLoadObject *)loadObject error:(nullable MVMCoreErrorObject *)error delegateObject:(nullable DelegateObject *)delegateObject; + @end diff --git a/MVMCore/MVMCore/Session/MVMCoreSessionTimeHandler.m b/MVMCore/MVMCore/Session/MVMCoreSessionTimeHandler.m index fad63f3..d297d72 100644 --- a/MVMCore/MVMCore/Session/MVMCoreSessionTimeHandler.m +++ b/MVMCore/MVMCore/Session/MVMCoreSessionTimeHandler.m @@ -7,7 +7,6 @@ // #import "MVMCoreSessionTimeHandler.h" -#import "MVMCoreAlertHandler.h" #import "MVMCoreLoggingHandler.h" #import "MVMCoreSessionObject.h" #import "MVMCoreLoadHandler.h" @@ -147,7 +146,6 @@ if ((!fequal(0, self.secondsUntilWarning) && now > self.timeTimerStarted + self.secondsUntilWarning) || (fequal(0, self.secondsUntilWarning) && !fequal(0, self.secondsUntilTimeout) && now > self.timeTimerStarted + self.secondsUntilTimeout)) { // Timeout if we are passed the warning. - [[MVMCoreAlertHandler sharedAlertHandler] removeAllAlertViews]; [self sessionTimeout:YES]; } else if (!fequal(0, self.secondsUntilWarning)) { From ad3b749159bf5ab4d48edd3c945d20c2cfef608f Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 28 Oct 2020 12:53:38 -0400 Subject: [PATCH 05/11] moving files --- MVMCore/MVMCore.xcodeproj/project.pbxproj | 24 ---- .../UIAlertActionStyle+Codable.swift | 43 ------- .../UIAlertControllerStyle+Extension.swift | 37 ------ .../Models/ActionType/AlertModel.swift | 116 ------------------ MVMCore/MVMCore/Models/ModelMapping.swift | 2 - 5 files changed, 222 deletions(-) delete mode 100644 MVMCore/MVMCore/Models/ActionType/Alert Extensions/UIAlertActionStyle+Codable.swift delete mode 100644 MVMCore/MVMCore/Models/ActionType/Alert Extensions/UIAlertControllerStyle+Extension.swift delete mode 100644 MVMCore/MVMCore/Models/ActionType/AlertModel.swift diff --git a/MVMCore/MVMCore.xcodeproj/project.pbxproj b/MVMCore/MVMCore.xcodeproj/project.pbxproj index 53d2a96..0795ad2 100644 --- a/MVMCore/MVMCore.xcodeproj/project.pbxproj +++ b/MVMCore/MVMCore.xcodeproj/project.pbxproj @@ -21,9 +21,6 @@ /* End PBXAggregateTarget section */ /* Begin PBXBuildFile section */ - 0184D3DB24B7D5A600A05369 /* ActionAlertModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0184D3DA24B7D5A600A05369 /* ActionAlertModel.swift */; }; - 0184D3FD24BE54A300A05369 /* UIAlertActionStyle+Codable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0184D3FC24BE54A300A05369 /* UIAlertActionStyle+Codable.swift */; }; - 0184D3FF24BE554A00A05369 /* AlertModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0184D3FE24BE554A00A05369 /* AlertModel.swift */; }; 01C851CF23CF7B260021F976 /* JSONMap.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01C851CE23CF7B260021F976 /* JSONMap.swift */; }; 01C851D123CF97FE0021F976 /* ActionBackModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01C851D023CF97FE0021F976 /* ActionBackModel.swift */; }; 01DF561421F90ADC00CC099B /* Dictionary+MFConvenience.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01DF561321F90ADC00CC099B /* Dictionary+MFConvenience.swift */; }; @@ -33,7 +30,6 @@ 01F2A04E23A82CF500D954D8 /* ActionPopupModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01F2A04D23A82CF500D954D8 /* ActionPopupModel.swift */; }; 01F2A05223A8325100D954D8 /* ModelMapping.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01F2A05123A8325100D954D8 /* ModelMapping.swift */; }; 0A42538F23F3414800554656 /* Codable+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A42538E23F3414800554656 /* Codable+Helpers.swift */; }; - 0A62624824C1DFDC00C316B9 /* UIAlertControllerStyle+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A62624724C1DFDC00C316B9 /* UIAlertControllerStyle+Extension.swift */; }; 0AFF597A23FC6E60005C24E8 /* ActionShareModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AFF597923FC6E60005C24E8 /* ActionShareModel.swift */; }; 30349BF11FCCA78A00546A1E /* MVMCoreSessionTimeHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = 30349BEF1FCCA78A00546A1E /* MVMCoreSessionTimeHandler.h */; settings = {ATTRIBUTES = (Public, ); }; }; 30349BF21FCCA78A00546A1E /* MVMCoreSessionTimeHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 30349BF01FCCA78A00546A1E /* MVMCoreSessionTimeHandler.m */; }; @@ -149,9 +145,6 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ - 0184D3DA24B7D5A600A05369 /* ActionAlertModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ActionAlertModel.swift; sourceTree = ""; }; - 0184D3FC24BE54A300A05369 /* UIAlertActionStyle+Codable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIAlertActionStyle+Codable.swift"; sourceTree = ""; }; - 0184D3FE24BE554A00A05369 /* AlertModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlertModel.swift; sourceTree = ""; }; 01C851CE23CF7B260021F976 /* JSONMap.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JSONMap.swift; sourceTree = ""; }; 01C851D023CF97FE0021F976 /* ActionBackModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionBackModel.swift; sourceTree = ""; }; 01DF561321F90ADC00CC099B /* Dictionary+MFConvenience.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Dictionary+MFConvenience.swift"; sourceTree = ""; }; @@ -163,7 +156,6 @@ 0A11030B20864F94008ADD90 /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = es.lproj/Localizable.strings; sourceTree = ""; }; 0A11030C20864F9A008ADD90 /* es-MX */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "es-MX"; path = "es-MX.lproj/Localizable.strings"; sourceTree = ""; }; 0A42538E23F3414800554656 /* Codable+Helpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Codable+Helpers.swift"; sourceTree = ""; }; - 0A62624724C1DFDC00C316B9 /* UIAlertControllerStyle+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIAlertControllerStyle+Extension.swift"; sourceTree = ""; }; 0AFF597923FC6E60005C24E8 /* ActionShareModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionShareModel.swift; sourceTree = ""; }; 30349BEF1FCCA78A00546A1E /* MVMCoreSessionTimeHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreSessionTimeHandler.h; sourceTree = ""; }; 30349BF01FCCA78A00546A1E /* MVMCoreSessionTimeHandler.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCoreSessionTimeHandler.m; sourceTree = ""; }; @@ -296,15 +288,6 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ - 0A62624624C1DFB700C316B9 /* Alert Extensions */ = { - isa = PBXGroup; - children = ( - 0184D3FC24BE54A300A05369 /* UIAlertActionStyle+Codable.swift */, - 0A62624724C1DFDC00C316B9 /* UIAlertControllerStyle+Extension.swift */, - ); - path = "Alert Extensions"; - sourceTree = ""; - }; 8876D5BF1FB50A9E00EB2E3D = { isa = PBXGroup; children = ( @@ -424,11 +407,9 @@ 946EE1B6237B66630036751F /* ActionType */ = { isa = PBXGroup; children = ( - 0A62624624C1DFB700C316B9 /* Alert Extensions */, 01F2A03523A80A7300D954D8 /* ActionModelProtocol.swift */, 946EE1BB237B691A0036751F /* ActionOpenPageModel.swift */, 01F2A03823A812DD00D954D8 /* ActionOpenUrlModel.swift */, - 0184D3DA24B7D5A600A05369 /* ActionAlertModel.swift */, 01F2A04B23A82B1B00D954D8 /* ActionCallModel.swift */, 01F2A04D23A82CF500D954D8 /* ActionPopupModel.swift */, 01C851D023CF97FE0021F976 /* ActionBackModel.swift */, @@ -438,7 +419,6 @@ 94C014D424211AF0005811A9 /* ActionCancelModel.swift */, 94C014D824212360005811A9 /* ActionSettingModel.swift */, BB780ADE250F8C890030BD2F /* ActionNoopModel.swift */, - 0184D3FE24BE554A00A05369 /* AlertModel.swift */, ); path = ActionType; sourceTree = ""; @@ -816,7 +796,6 @@ 01F2A03623A80A7300D954D8 /* ActionModelProtocol.swift in Sources */, AFBB96991FBA3A9A0008D868 /* MVMCoreAlertController.m in Sources */, 881D26941FCC9D180079C521 /* MVMCoreOperation.m in Sources */, - 0184D3FD24BE54A300A05369 /* UIAlertActionStyle+Codable.swift in Sources */, AFED77A41FCCA29400BAE689 /* MVMCoreViewControllerMappingObject.m in Sources */, 01C851CF23CF7B260021F976 /* JSONMap.swift in Sources */, 01F2A04C23A82B1B00D954D8 /* ActionCallModel.swift in Sources */, @@ -836,17 +815,14 @@ 30349BF21FCCA78A00546A1E /* MVMCoreSessionTimeHandler.m in Sources */, D2DEDCB923C6400600C44CC4 /* UnitInterval.swift in Sources */, 94C014D3242119E6005811A9 /* ActionPreviousSubmitModel.swift in Sources */, - 0184D3FF24BE554A00A05369 /* AlertModel.swift in Sources */, 8876D5E91FB50AB000EB2E3D /* NSArray+MFConvenience.m in Sources */, 946EE1B2237B5F260036751F /* JSONValue.swift in Sources */, AFBB96971FBA3A9A0008D868 /* MVMCorePresentViewControllerOperation.m in Sources */, 01F2A04E23A82CF500D954D8 /* ActionPopupModel.swift in Sources */, - 0A62624824C1DFDC00C316B9 /* UIAlertControllerStyle+Extension.swift in Sources */, AF43A5781FBA5B7C008E9347 /* MVMCoreJSONConstants.m in Sources */, AFBB96691FBA3A570008D868 /* MVMCoreRequestParameters.m in Sources */, AFED77A31FCCA29400BAE689 /* MVMCoreViewControllerNibMappingObject.m in Sources */, 8876D5EB1FB50AB000EB2E3D /* NSDecimalNumber+MFConvenience.m in Sources */, - 0184D3DB24B7D5A600A05369 /* ActionAlertModel.swift in Sources */, 01F2A03923A812DD00D954D8 /* ActionOpenUrlModel.swift in Sources */, AFBB96351FBA34310008D868 /* MVMCoreErrorConstants.m in Sources */, AF43A5881FBB67D6008E9347 /* MVMCoreActionUtility.m in Sources */, diff --git a/MVMCore/MVMCore/Models/ActionType/Alert Extensions/UIAlertActionStyle+Codable.swift b/MVMCore/MVMCore/Models/ActionType/Alert Extensions/UIAlertActionStyle+Codable.swift deleted file mode 100644 index 266a305..0000000 --- a/MVMCore/MVMCore/Models/ActionType/Alert Extensions/UIAlertActionStyle+Codable.swift +++ /dev/null @@ -1,43 +0,0 @@ -// -// UIAlertActionStyle+Codable.swift -// MVMCore -// -// Created by Suresh, Kamlesh on 7/14/20. -// Copyright © 2020 myverizon. All rights reserved. -// - - -extension UIAlertAction.Style: Codable { - - init(rawValue: String) { - switch rawValue { - case "default": - self = .default - - case "cancel": - self = .cancel - - case "destructive": - self = .destructive - - default: - self = .default - } - } - - var rawValueString: String { - switch self { - case .default: - return "default" - - case .cancel: - return "cancel" - - case .destructive: - return "destructive" - - @unknown default: - return "default" - } - } -} diff --git a/MVMCore/MVMCore/Models/ActionType/Alert Extensions/UIAlertControllerStyle+Extension.swift b/MVMCore/MVMCore/Models/ActionType/Alert Extensions/UIAlertControllerStyle+Extension.swift deleted file mode 100644 index 1de084a..0000000 --- a/MVMCore/MVMCore/Models/ActionType/Alert Extensions/UIAlertControllerStyle+Extension.swift +++ /dev/null @@ -1,37 +0,0 @@ -// -// UIAlertControllerStyle+Extension.swift -// MVMCore -// -// Created by Kevin Christiano on 7/17/20. -// Copyright © 2020 myverizon. All rights reserved. -// - - -extension UIAlertController.Style: Codable { - - init(rawValue: String) { - switch rawValue { - case "alert": - self = .alert - - case "actionSheet": - self = .actionSheet - - default: - self = .alert - } - } - - var rawValueString: String { - switch self { - case .alert: - return "alert" - - case .actionSheet: - return "actionSheet" - - @unknown default: - return "alert" - } - } -} diff --git a/MVMCore/MVMCore/Models/ActionType/AlertModel.swift b/MVMCore/MVMCore/Models/ActionType/AlertModel.swift deleted file mode 100644 index 866bfb3..0000000 --- a/MVMCore/MVMCore/Models/ActionType/AlertModel.swift +++ /dev/null @@ -1,116 +0,0 @@ -// -// AlertModel.swift -// MVMCore -// -// Created by Suresh, Kamlesh on 7/14/20. -// Copyright © 2020 myverizon. All rights reserved. -// - -import UIKit - - -public class AlertButtonModel: Codable { - //-------------------------------------------------- - // MARK: - Properties - //-------------------------------------------------- - - public var title: String - public var action: ActionModelProtocol - public var style: UIAlertAction.Style = .default - - //-------------------------------------------------- - // MARK: - Initializer - //-------------------------------------------------- - - public init(_ title: String,_ action: ActionModelProtocol,_ style: UIAlertAction.Style = .default) { - self.title = title - self.action = action - self.style = style - } - - //-------------------------------------------------- - // MARK: - Keys - //-------------------------------------------------- - - private enum CodingKeys: String, CodingKey { - case title - case action - case style - } - - //-------------------------------------------------- - // MARK: - Codec - //-------------------------------------------------- - - required public init(from decoder: Decoder) throws { - let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - title = try typeContainer.decode(String.self, forKey: .title) - - if let style = try typeContainer.decodeIfPresent(String.self, forKey: .style) { - self.style = UIAlertAction.Style(rawValue: style) - } - action = try typeContainer.decodeModel(codingKey: .action) - } - - open func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(title, forKey: .title) - try container.encode(style.rawValueString, forKey: .style) - try container.encodeModel(action, forKey: .action) - } -} - -public class AlertModel: Codable { - //-------------------------------------------------- - // MARK: - Properties - //-------------------------------------------------- - - public var title: String - public var message: String - public var style: UIAlertController.Style = .alert - public var alertActions: [AlertButtonModel] - - //-------------------------------------------------- - // MARK: - Properties - //-------------------------------------------------- - - public init(_ title: String,_ message: String,_ alertActions: [AlertButtonModel]) { - self.title = title - self.message = message - self.alertActions = alertActions - } - - //-------------------------------------------------- - // MARK: - Keys - //-------------------------------------------------- - - private enum CodingKeys: String, CodingKey { - case title - case message - case alertActions - case style - } - - //-------------------------------------------------- - // MARK: - Codec - //-------------------------------------------------- - - required public init(from decoder: Decoder) throws { - let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - title = try typeContainer.decode(String.self, forKey: .title) - message = try typeContainer.decode(String.self, forKey: .message) - alertActions = try typeContainer.decode([AlertButtonModel].self, forKey: .alertActions) - - if let style = try typeContainer.decodeIfPresent(String.self, forKey: .style) { - self.style = UIAlertController.Style(rawValue: style) - } - } - - open func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(title, forKey: .title) - try container.encode(message, forKey: .message) - try container.encode(alertActions, forKey: .alertActions) - try container.encode(style.rawValueString, forKey: .style) - } -} diff --git a/MVMCore/MVMCore/Models/ModelMapping.swift b/MVMCore/MVMCore/Models/ModelMapping.swift index 21ff0c1..74acf80 100644 --- a/MVMCore/MVMCore/Models/ModelMapping.swift +++ b/MVMCore/MVMCore/Models/ModelMapping.swift @@ -14,14 +14,12 @@ import Foundation try? ModelRegistry.register(ActionOpenPageModel.self) try? ModelRegistry.register(ActionOpenUrlModel.self) try? ModelRegistry.register(ActionCallModel.self) - try? ModelRegistry.register(ActionPopupModel.self) try? ModelRegistry.register(ActionBackModel.self) try? ModelRegistry.register(ActionShareModel.self) try? ModelRegistry.register(ActionRestartModel.self) try? ModelRegistry.register(ActionPreviousSubmitModel.self) try? ModelRegistry.register(ActionCancelModel.self) try? ModelRegistry.register(ActionSettingModel.self) - try? ModelRegistry.register(ActionAlertModel.self) try? ModelRegistry.register(ActionNoopModel.self) } } From 52e4f19911d9b803b185ca9c063bfd2b239afb1a Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 28 Oct 2020 12:58:15 -0400 Subject: [PATCH 06/11] moving files action popup --- MVMCore/MVMCore.xcodeproj/project.pbxproj | 4 --- .../Models/ActionType/ActionPopupModel.swift | 30 ------------------- 2 files changed, 34 deletions(-) delete mode 100644 MVMCore/MVMCore/Models/ActionType/ActionPopupModel.swift diff --git a/MVMCore/MVMCore.xcodeproj/project.pbxproj b/MVMCore/MVMCore.xcodeproj/project.pbxproj index 0795ad2..fc17f77 100644 --- a/MVMCore/MVMCore.xcodeproj/project.pbxproj +++ b/MVMCore/MVMCore.xcodeproj/project.pbxproj @@ -27,7 +27,6 @@ 01F2A03623A80A7300D954D8 /* ActionModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01F2A03523A80A7300D954D8 /* ActionModelProtocol.swift */; }; 01F2A03923A812DD00D954D8 /* ActionOpenUrlModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01F2A03823A812DD00D954D8 /* ActionOpenUrlModel.swift */; }; 01F2A04C23A82B1B00D954D8 /* ActionCallModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01F2A04B23A82B1B00D954D8 /* ActionCallModel.swift */; }; - 01F2A04E23A82CF500D954D8 /* ActionPopupModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01F2A04D23A82CF500D954D8 /* ActionPopupModel.swift */; }; 01F2A05223A8325100D954D8 /* ModelMapping.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01F2A05123A8325100D954D8 /* ModelMapping.swift */; }; 0A42538F23F3414800554656 /* Codable+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A42538E23F3414800554656 /* Codable+Helpers.swift */; }; 0AFF597A23FC6E60005C24E8 /* ActionShareModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AFF597923FC6E60005C24E8 /* ActionShareModel.swift */; }; @@ -151,7 +150,6 @@ 01F2A03523A80A7300D954D8 /* ActionModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionModelProtocol.swift; sourceTree = ""; }; 01F2A03823A812DD00D954D8 /* ActionOpenUrlModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionOpenUrlModel.swift; sourceTree = ""; }; 01F2A04B23A82B1B00D954D8 /* ActionCallModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionCallModel.swift; sourceTree = ""; }; - 01F2A04D23A82CF500D954D8 /* ActionPopupModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionPopupModel.swift; sourceTree = ""; }; 01F2A05123A8325100D954D8 /* ModelMapping.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModelMapping.swift; sourceTree = ""; }; 0A11030B20864F94008ADD90 /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = es.lproj/Localizable.strings; sourceTree = ""; }; 0A11030C20864F9A008ADD90 /* es-MX */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "es-MX"; path = "es-MX.lproj/Localizable.strings"; sourceTree = ""; }; @@ -411,7 +409,6 @@ 946EE1BB237B691A0036751F /* ActionOpenPageModel.swift */, 01F2A03823A812DD00D954D8 /* ActionOpenUrlModel.swift */, 01F2A04B23A82B1B00D954D8 /* ActionCallModel.swift */, - 01F2A04D23A82CF500D954D8 /* ActionPopupModel.swift */, 01C851D023CF97FE0021F976 /* ActionBackModel.swift */, 0AFF597923FC6E60005C24E8 /* ActionShareModel.swift */, 94C014D024211869005811A9 /* ActionRestartModel.swift */, @@ -818,7 +815,6 @@ 8876D5E91FB50AB000EB2E3D /* NSArray+MFConvenience.m in Sources */, 946EE1B2237B5F260036751F /* JSONValue.swift in Sources */, AFBB96971FBA3A9A0008D868 /* MVMCorePresentViewControllerOperation.m in Sources */, - 01F2A04E23A82CF500D954D8 /* ActionPopupModel.swift in Sources */, AF43A5781FBA5B7C008E9347 /* MVMCoreJSONConstants.m in Sources */, AFBB96691FBA3A570008D868 /* MVMCoreRequestParameters.m in Sources */, AFED77A31FCCA29400BAE689 /* MVMCoreViewControllerNibMappingObject.m in Sources */, diff --git a/MVMCore/MVMCore/Models/ActionType/ActionPopupModel.swift b/MVMCore/MVMCore/Models/ActionType/ActionPopupModel.swift deleted file mode 100644 index 8cdbd83..0000000 --- a/MVMCore/MVMCore/Models/ActionType/ActionPopupModel.swift +++ /dev/null @@ -1,30 +0,0 @@ -// -// ActionPopupModel.swift -// MVMCore -// -// Created by Suresh, Kamlesh on 12/16/19. -// Copyright © 2019 myverizon. All rights reserved. -// - - -@objcMembers public class ActionPopupModel: ActionModelProtocol { - //-------------------------------------------------- - // MARK: - Properties - //-------------------------------------------------- - - public static var identifier: String = "popup" - public var actionType: String = ActionPopupModel.identifier - public var pageType: String - public var extraParameters: JSONValueDictionary? - public var analyticsData: JSONValueDictionary? - - //-------------------------------------------------- - // MARK: - Initializer - //-------------------------------------------------- - - public init(pageType: String, _ extraParameters: JSONValueDictionary? = nil, _ analyticsData: JSONValueDictionary? = nil) { - self.pageType = pageType - self.extraParameters = extraParameters - self.analyticsData = analyticsData - } -} From 3b05bbf44008c1f5ea8aa2683ffabfa0688a9465 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 28 Oct 2020 15:03:06 -0400 Subject: [PATCH 07/11] move alert files --- .../MVMCore/ActionHandling/MVMCoreActionDelegateProtocol.h | 7 ------- MVMCore/MVMCore/LoadHandling/MVMCoreLoadDelegateProtocol.h | 7 ------- 2 files changed, 14 deletions(-) diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionDelegateProtocol.h b/MVMCore/MVMCore/ActionHandling/MVMCoreActionDelegateProtocol.h index 35609a2..85616b7 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionDelegateProtocol.h +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionDelegateProtocol.h @@ -10,7 +10,6 @@ @class MVMCoreErrorObject; @class MVMCoreRequestParameters; -@class MVMCoreAlertObject; @protocol MVMCoreActionDelegateProtocol @@ -31,12 +30,6 @@ // Handles the linkaway action. Call the block to continue to linkaway. - (void)shouldLinkAwayWithURL:(nullable NSURL *)URL appURL:(nullable NSURL *)appURL actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData linkAwayBlock:(nonnull void (^)(NSURL * _Nullable appURL, NSURL * _Nullable URL, NSDictionary * _Nullable actionInformation, NSDictionary * _Nullable additionalData))linkAwayBlock; -// Gives the delegate a chance to alter the alert object -- (void)willShowPopupWithAlertObject:(nonnull MVMCoreAlertObject *)alertObject alertJson:(nonnull NSDictionary *)alertJson; - -// Gives the delegate a chance to alter the alert object -- (nullable MVMCoreAlertObject *)willShowTopAlertWithAlertObject:(nonnull MVMCoreAlertObject *)alertObject alertJson:(nonnull NSDictionary *)alertJson; - // Handle cancel - (void)handleCancel:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData; diff --git a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadDelegateProtocol.h b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadDelegateProtocol.h index c62d0b2..39ddc8b 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadDelegateProtocol.h +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadDelegateProtocol.h @@ -38,13 +38,6 @@ * @return True if the calling process should continue. */ - (BOOL)handleModuleError:(nonnull NSString *)module loadObject:(nonnull MVMCoreLoadObject *)loadObject error:(nonnull MVMCoreErrorObject *)error; -/** Get the alert object whose data will be presented. Overwrite this to alter how you want the alert to show. - * @param loadObject The load object. - * @param errorObject An error object if there was an error. - * @return Returns the alert object. - * Details: Gets the alert that will display to the screen. Easier to subclass here to avoid subclassing the displaying logic. */ -- (nullable MVMCoreAlertObject *)alertObjectToShow:(nonnull MVMCoreLoadObject *)loadObject error:(nullable MVMCoreErrorObject *)errorObject; - /** Allows the delegate to handle any field errors. * @param fieldErrors The field errors. * @param loadObject The load object.*/ From 53147eee1cbc75015d47492a5c26bf2ddc4e73d4 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 28 Oct 2020 15:45:39 -0400 Subject: [PATCH 08/11] Fixes for alert --- MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.h | 3 --- MVMCore/MVMCore/MainProtocols/MVMCoreGlobalLoadProtocol.h | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.h b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.h index f7a274b..17b6d1e 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.h +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.h @@ -91,9 +91,6 @@ // Handles the error based on the error object passed in. May log and/or display the error. + (void)handleError:(nonnull MVMCoreErrorObject *)error loadObject:(nonnull MVMCoreLoadObject *)loadObject showAlertForErrorIfApplicable:(BOOL)showAlertForErrorIfApplicable; -// Shows the appropriate alert tyle for the given response info and/or error. -+ (void)createAndShowAlertForLoadObject:(nullable MVMCoreLoadObject *)loadObject error:(nullable MVMCoreErrorObject *)error delegateObject:(nullable DelegateObject *)delegateObject; - /** Called when the load was finished due to an error. Handles the error and ends the load. * @param error The error that occured. May be logged depending. * @param loadObject The load data for the error. **/ diff --git a/MVMCore/MVMCore/MainProtocols/MVMCoreGlobalLoadProtocol.h b/MVMCore/MVMCore/MainProtocols/MVMCoreGlobalLoadProtocol.h index 408a5b1..027d6b7 100644 --- a/MVMCore/MVMCore/MainProtocols/MVMCoreGlobalLoadProtocol.h +++ b/MVMCore/MVMCore/MainProtocols/MVMCoreGlobalLoadProtocol.h @@ -36,6 +36,6 @@ - (nonnull MVMCoreErrorObject *)createErrorObjectForRequestNSError:(nonnull NSError *)error forRequest:(nonnull NSURLRequest *)request location:(nullable NSString *)locationForError; // Shows the appropriate alert style for the given response info and/or error. -- (void)createAndShowAlertForLoadObject:(nullable MVMCoreLoadObject *)loadObject error:(nullable MVMCoreErrorObject *)error delegateObject:(nullable DelegateObject *)delegateObject; +- (void)createAndShowAlertForLoadObject:(nullable MVMCoreLoadObject *)loadObject error:(nullable MVMCoreErrorObject *)error delegateObject:(nullable DelegateObject *)delegateObject; @end From 0fa356614abe1492406534b8efe922690eaf162d Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 28 Oct 2020 17:08:13 -0400 Subject: [PATCH 09/11] Fixes for alerts --- MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m index 88744ab..64e61b3 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m @@ -258,7 +258,7 @@ NSString * const KeyActionTypeOpen = @"openPage"; if ([delegateObject.actionDelegate respondsToSelector:@selector(handleActionError:additionalData:)]) { [delegateObject.actionDelegate handleActionError:error additionalData:additionalData]; } else { - [MVMCoreActionHandler defaultHandleActionError:error additionalData:additionalData]; + [[self class] defaultHandleActionError:error additionalData:additionalData]; } } } @@ -348,7 +348,7 @@ NSString * const KeyActionTypeOpen = @"openPage"; + (void)defaultHandleUnknownActionType:(nullable NSString *)actionType actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { MVMCoreErrorObject *error = [[MVMCoreErrorObject alloc] initWithTitle:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorTitle] message:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorUnableToProcess] code:ErrorCodeUnknownActionType domain:ErrorDomainNative location:[NSString stringWithFormat:@"%@Requests_%@",NSStringFromClass([delegateObject.actionDelegate class]),actionType]]; - [MVMCoreActionHandler defaultHandleActionError:error additionalData:additionalData]; + [[self class] defaultHandleActionError:error additionalData:additionalData]; } + (void)defaultHandleActionError:(nonnull MVMCoreErrorObject *)error additionalData:(nullable NSDictionary *)additionalData { @@ -518,7 +518,7 @@ NSString * const KeyActionTypeOpen = @"openPage"; if ([delegate respondsToSelector:@selector(handleActionError:additionalData:)]) { [delegate handleActionError:error additionalData:additionalData]; } else { - [MVMCoreActionHandler defaultHandleActionError:error additionalData:additionalData]; + [[self class] defaultHandleActionError:error additionalData:additionalData]; } } } @@ -604,7 +604,7 @@ NSString * const KeyActionTypeOpen = @"openPage"; + (void)defaultHandleUnknownActionType:(nullable NSString *)actionType actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate { MVMCoreErrorObject *error = [[MVMCoreErrorObject alloc] initWithTitle:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorTitle] message:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorUnableToProcess] code:ErrorCodeUnknownActionType domain:ErrorDomainNative location:[NSString stringWithFormat:@"%@Requests_%@",NSStringFromClass([delegate class]),actionType]]; - [MVMCoreActionHandler defaultHandleActionError:error additionalData:additionalData]; + [[self class] defaultHandleActionError:error additionalData:additionalData]; } @end From 6d71ab36fd13aa8cf8a38138739c2d02d6af80d3 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 30 Oct 2020 10:56:32 -0400 Subject: [PATCH 10/11] review changes --- MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h | 4 ++-- MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h index a166d22..c677e53 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.h @@ -93,8 +93,8 @@ extern NSString * _Nonnull const KeyActionTypeOpen; // By default, throws an error, calling defaultHandleActionError. + (void)defaultHandleUnknownActionType:(nullable NSString *)actionType actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; -// Shows a popup error -+ (void)defaultHandleActionError:(nonnull MVMCoreErrorObject *)error additionalData:(nullable NSDictionary *)additionalData; +// Logs the error. +- (void)defaultHandleActionError:(nonnull MVMCoreErrorObject *)error additionalData:(nullable NSDictionary *)additionalData; #pragma mark - Deprecated diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m index 64e61b3..ee539d0 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.m @@ -258,7 +258,7 @@ NSString * const KeyActionTypeOpen = @"openPage"; if ([delegateObject.actionDelegate respondsToSelector:@selector(handleActionError:additionalData:)]) { [delegateObject.actionDelegate handleActionError:error additionalData:additionalData]; } else { - [[self class] defaultHandleActionError:error additionalData:additionalData]; + [self defaultHandleActionError:error additionalData:additionalData]; } } } @@ -348,10 +348,10 @@ NSString * const KeyActionTypeOpen = @"openPage"; + (void)defaultHandleUnknownActionType:(nullable NSString *)actionType actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { MVMCoreErrorObject *error = [[MVMCoreErrorObject alloc] initWithTitle:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorTitle] message:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorUnableToProcess] code:ErrorCodeUnknownActionType domain:ErrorDomainNative location:[NSString stringWithFormat:@"%@Requests_%@",NSStringFromClass([delegateObject.actionDelegate class]),actionType]]; - [[self class] defaultHandleActionError:error additionalData:additionalData]; + [[self sharedActionHandler] defaultHandleActionError:error additionalData:additionalData]; } -+ (void)defaultHandleActionError:(nonnull MVMCoreErrorObject *)error additionalData:(nullable NSDictionary *)additionalData { +- (void)defaultHandleActionError:(nonnull MVMCoreErrorObject *)error additionalData:(nullable NSDictionary *)additionalData { // Logs the error. if (error.logError) { @@ -518,7 +518,7 @@ NSString * const KeyActionTypeOpen = @"openPage"; if ([delegate respondsToSelector:@selector(handleActionError:additionalData:)]) { [delegate handleActionError:error additionalData:additionalData]; } else { - [[self class] defaultHandleActionError:error additionalData:additionalData]; + [self defaultHandleActionError:error additionalData:additionalData]; } } } @@ -604,7 +604,7 @@ NSString * const KeyActionTypeOpen = @"openPage"; + (void)defaultHandleUnknownActionType:(nullable NSString *)actionType actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate { MVMCoreErrorObject *error = [[MVMCoreErrorObject alloc] initWithTitle:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorTitle] message:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorUnableToProcess] code:ErrorCodeUnknownActionType domain:ErrorDomainNative location:[NSString stringWithFormat:@"%@Requests_%@",NSStringFromClass([delegate class]),actionType]]; - [[self class] defaultHandleActionError:error additionalData:additionalData]; + [[self sharedActionHandler] defaultHandleActionError:error additionalData:additionalData]; } @end From e32299bee49dbe5053a0fbd98e72689b49346da2 Mon Sep 17 00:00:00 2001 From: Kyle Matthew Hedden Date: Fri, 30 Oct 2020 14:13:01 -0400 Subject: [PATCH 11/11] logging for set-cookie --- MVMCore/MVMCore/LoadHandling/MVMCoreLoadHandler.m | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadHandler.m b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadHandler.m index d9d3171..1392d93 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadHandler.m +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadHandler.m @@ -320,7 +320,7 @@ NSURLSessionTask *task = [session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) { - MVMCoreLog(@"Request Time %f",[NSDate timeIntervalSinceReferenceDate] - startTime); + MVMCoreLog(@"Request Time %f", [NSDate timeIntervalSinceReferenceDate] - startTime); NSDate *startTimeDate = [NSDate dateWithTimeIntervalSinceReferenceDate:startTime]; @@ -333,6 +333,8 @@ [trackInfo setObject:error.localizedDescription forKey:@"error"]; } + MVMCoreLog(@"Set-Cookie %@ Value: %@", requestParameters.pageType, [(NSHTTPURLResponse *)response allHeaderFields][@"Set-Cookie"]); + [MVMCoreLoggingHandler logWithDelegateWithObject:nil withName:@"httpRequestStatus" withExtraInfo:trackInfo]; id jsonObject = nil;