From cf575681e24e4d9753ec2abca69c950e1d023103 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 28 Oct 2020 12:38:29 -0400 Subject: [PATCH] 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)) {