Merge remote-tracking branch 'refs/remotes/origin/develop'

This commit is contained in:
Pfeil, Scott Robert 2020-07-16 17:09:10 -04:00
commit 28b13c2f39
16 changed files with 222 additions and 34 deletions

View File

@ -21,12 +21,15 @@
/* End PBXAggregateTarget section */
/* 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 */; };
01C851D123CF97FE0021F976 /* ActionBackModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01C851D023CF97FE0021F976 /* ActionBackModel.swift */; };
01DF561421F90ADC00CC099B /* Dictionary+MFConvenience.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01DF561321F90ADC00CC099B /* Dictionary+MFConvenience.swift */; };
01F2A03623A80A7300D954D8 /* ActionModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01F2A03523A80A7300D954D8 /* ActionModelProtocol.swift */; };
01F2A03923A812DD00D954D8 /* ActionOpenUrlModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01F2A03823A812DD00D954D8 /* ActionOpenUrlModel.swift */; };
01F2A03B23A8159900D954D8 /* ActionOpenAppModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01F2A03A23A8159900D954D8 /* ActionOpenAppModel.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 */; };
@ -170,12 +173,15 @@
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
0184D3DA24B7D5A600A05369 /* ActionAlertModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ActionAlertModel.swift; sourceTree = "<group>"; };
0184D3E224B8D0C600A05369 /* MVMCoreAlertObject+Swift.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MVMCoreAlertObject+Swift.swift"; sourceTree = "<group>"; };
0184D3FC24BE54A300A05369 /* UIAlertActionStyle+Codable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIAlertActionStyle+Codable.swift"; sourceTree = "<group>"; };
0184D3FE24BE554A00A05369 /* AlertModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlertModel.swift; sourceTree = "<group>"; };
01C851CE23CF7B260021F976 /* JSONMap.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JSONMap.swift; sourceTree = "<group>"; };
01C851D023CF97FE0021F976 /* ActionBackModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionBackModel.swift; sourceTree = "<group>"; };
01DF561321F90ADC00CC099B /* Dictionary+MFConvenience.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Dictionary+MFConvenience.swift"; sourceTree = "<group>"; };
01F2A03523A80A7300D954D8 /* ActionModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionModelProtocol.swift; sourceTree = "<group>"; };
01F2A03823A812DD00D954D8 /* ActionOpenUrlModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionOpenUrlModel.swift; sourceTree = "<group>"; };
01F2A03A23A8159900D954D8 /* ActionOpenAppModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionOpenAppModel.swift; sourceTree = "<group>"; };
01F2A04B23A82B1B00D954D8 /* ActionCallModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionCallModel.swift; sourceTree = "<group>"; };
01F2A04D23A82CF500D954D8 /* ActionPopupModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionPopupModel.swift; sourceTree = "<group>"; };
01F2A05123A8325100D954D8 /* ModelMapping.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModelMapping.swift; sourceTree = "<group>"; };
@ -460,7 +466,8 @@
01F2A03523A80A7300D954D8 /* ActionModelProtocol.swift */,
946EE1BB237B691A0036751F /* ActionOpenPageModel.swift */,
01F2A03823A812DD00D954D8 /* ActionOpenUrlModel.swift */,
01F2A03A23A8159900D954D8 /* ActionOpenAppModel.swift */,
0184D3DA24B7D5A600A05369 /* ActionAlertModel.swift */,
0184D3FC24BE54A300A05369 /* UIAlertActionStyle+Codable.swift */,
01F2A04B23A82B1B00D954D8 /* ActionCallModel.swift */,
01F2A04D23A82CF500D954D8 /* ActionPopupModel.swift */,
01C851D023CF97FE0021F976 /* ActionBackModel.swift */,
@ -469,6 +476,7 @@
94C014D2242119E6005811A9 /* ActionPreviousSubmitModel.swift */,
94C014D424211AF0005811A9 /* ActionCancelModel.swift */,
94C014D824212360005811A9 /* ActionSettingModel.swift */,
0184D3FE24BE554A00A05369 /* AlertModel.swift */,
);
path = ActionType;
sourceTree = "<group>";
@ -613,6 +621,7 @@
AFBB967F1FBA3A9A0008D868 /* MVMCoreAlertHandler.m */,
AFBB96801FBA3A9A0008D868 /* MVMCoreAlertObject.h */,
AFBB96811FBA3A9A0008D868 /* MVMCoreAlertObject.m */,
0184D3E224B8D0C600A05369 /* MVMCoreAlertObject+Swift.swift */,
AFBB96821FBA3A9A0008D868 /* MVMCoreAlertOperation.h */,
AFBB96831FBA3A9A0008D868 /* MVMCoreAlertOperation.m */,
AFBB96841FBA3A9A0008D868 /* MVMCoreTopAlertAnimationDelegateProtocol.h */,
@ -895,6 +904,7 @@
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 */,
@ -903,6 +913,7 @@
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 */,
AFBB965F1FBA3A570008D868 /* MFFreebeeOperation.m in Sources */,
AFBB96901FBA3A9A0008D868 /* MVMCoreNavigationObject.m in Sources */,
@ -916,6 +927,7 @@
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 */,
@ -925,6 +937,7 @@
AFBB96691FBA3A570008D868 /* MVMCoreRequestParameters.m in Sources */,
AFED77A31FCCA29400BAE689 /* MVMCoreViewControllerNibMappingObject.m 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 */,
@ -950,7 +963,6 @@
AF43A70A1FC4F415008E9347 /* MVMCoreCache.m in Sources */,
AF43A6FF1FBE3252008E9347 /* Reachability.m in Sources */,
01C851D123CF97FE0021F976 /* ActionBackModel.swift in Sources */,
01F2A03B23A8159900D954D8 /* ActionOpenAppModel.swift in Sources */,
AFBB96921FBA3A9A0008D868 /* MVMCoreNavigationOperation.m in Sources */,
AFBB96611FBA3A570008D868 /* MVMCoreLoadObject.m in Sources */,
946EE1B4237B619D0036751F /* Encoder.swift in Sources */,

View File

@ -50,9 +50,12 @@ 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
// 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;
// Shows a top alert
- (void)topAlertAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject;

View File

@ -92,6 +92,9 @@ NSString * const KeyActionTypeOpen = @"openPage";
} 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 (![self handleOtherActions:actionType actionInformation:actionInformation additionalData:additionalData delegateObject:delegateObject]) {
// not a known action type.
[self unknownAction:actionType actionInformation:actionInformation additionalData:additionalData delegateObject:delegateObject];
@ -310,6 +313,22 @@ NSString * const KeyActionTypeOpen = @"openPage";
}
}
- (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;
}

View File

@ -0,0 +1,37 @@
//
// MVMCoreAlertObject+Swift.swift
// MVMCore
//
// Created by Suresh, Kamlesh on 7/10/20.
// Copyright © 2020 myverizon. All rights reserved.
//
import UIKit
public extension MVMCoreAlertObject {
@objc static func alertObjectWith(action actionJson: [AnyHashable : Any]?, additionalData: [AnyHashable : Any]?, delegateObject: DelegateObject?, error: AutoreleasingUnsafeMutablePointer<MVMCoreErrorObject?>?) -> 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 alert = MVMCoreAlertObject(popupAlertWithTitle: alertJson.optionalStringForKey(KeyTitle),
message: alertJson.optionalStringForKey(KeyMessage),
actions: actionsForAlert,
isGreedy: false)
return alert
}
}

View File

@ -299,5 +299,4 @@
}
}
@end

View File

@ -41,6 +41,7 @@ extern NSString * const KeyActionTypeRedirect;
extern NSString * const KeyActionTypeTopAlert;
extern NSString * const KeyActionTypeSettings;
extern NSString * const KeyActionTypeCollapseNotification;
extern NSString * const KeyActionTypeAlert;
extern NSString * const KeyActionInformation;
extern NSString * const KeyLinkAwayAppURL;
extern NSString * const KeyLinkAwayURL;

View File

@ -41,6 +41,7 @@ NSString * const KeyActionTypeRedirect = @"switchApp";
NSString * const KeyActionTypeTopAlert = @"topAlert";
NSString * const KeyActionTypeSettings = @"openSettings";
NSString * const KeyActionTypeCollapseNotification = @"collapseNotification";
NSString * const KeyActionTypeAlert = @"alert";
NSString * const KeyActionInformation = @"actionInformation";
NSString * const KeyLinkAwayAppURL = @"appURL";
NSString * const KeyLinkAwayURL = @"browserUrl";

View File

@ -398,9 +398,13 @@
#pragma mark - Loading Functions
- (MVMCoreLoadRequestOperation *)loadRequest:(nonnull MVMCoreRequestParameters *)requestParameters dataForPage:(nullable NSDictionary *)dataForPage delegateObject:(nullable DelegateObject *)delegateObject {
MVMCoreLoadRequestOperation *loadOperation = [[MVMCoreLoadRequestOperation alloc] initWithRequestParameters:requestParameters dataForPage:dataForPage delegateObject:delegateObject backgroundLoad:NO];
[self.blockingLoadQueue addOperation:loadOperation];
return loadOperation;
if (requestParameters.backgroundRequest) {
return [self loadBackgroundRequest:requestParameters dataForPage:dataForPage delegateObject:delegateObject];
} else {
MVMCoreLoadRequestOperation *loadOperation = [[MVMCoreLoadRequestOperation alloc] initWithRequestParameters:requestParameters dataForPage:dataForPage delegateObject:delegateObject backgroundLoad:NO];
[self.blockingLoadQueue addOperation:loadOperation];
return loadOperation;
}
}
- (MVMCoreLoadRequestOperation *)loadBackgroundRequest:(nonnull MVMCoreRequestParameters *)requestParameters dataForPage:(nullable NSDictionary *)dataForPage delegateObject:(nullable DelegateObject *)delegateObject {

View File

@ -93,6 +93,9 @@ typedef NS_ENUM(NSInteger, MFLoadStyle) {
// A list of page types that this operation should NOT be loaded in parallel with.
@property (nullable, strong, nonatomic) NSArray<NSString *> * successivePageTypes;
/// A flag for if it should be a background request or not.
@property (assign, nonatomic) BOOL backgroundRequest;
// Creates an object with the given page type and extra parameters. Adds the extra parameters to the standard request parameters. Will add any modules needed by the page type by default.
- (nullable instancetype)initWithPageType:(nonnull NSString *)pageType extraParameters:(nullable NSDictionary *)extraParameters;

View File

@ -134,6 +134,7 @@
copyObject.openSupportPanel = self.openSupportPanel;
copyObject.imageData = self.imageData;
copyObject.customTimeoutTime = self.customTimeoutTime;
copyObject.backgroundRequest = self.backgroundRequest;
return copyObject;
}

View File

@ -0,0 +1,18 @@
//
// ActionAlertModel.swift
// MVMCoreUI
//
// Created by Suresh, Kamlesh on 7/9/20.
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
import UIKit
@objcMembers public class ActionAlertModel: ActionModelProtocol {
public static var identifier: String = "alert"
public var actionType: String = ActionAlertModel.identifier
public var alert: AlertModel
public var extraParameters: JSONValueDictionary?
public var analyticsData: JSONValueDictionary?
}

View File

@ -1,24 +0,0 @@
//
// ActionOpenAppModel.swift
// MVMCore
//
// Created by Suresh, Kamlesh on 12/16/19.
// Copyright © 2019 myverizon. All rights reserved.
//
import Foundation
@objcMembers public class ActionOpenAppModel: ActionModelProtocol {
public static var identifier: String = "openApp"
public var actionType: String = ActionOpenAppModel.identifier
// TODO: decode into url once action handler is re-written
public var appURL: String
public var extraParameters: JSONValueDictionary?
public var analyticsData: JSONValueDictionary?
public init(appURL: String, _ extraParameters: JSONValueDictionary? = nil, _ analyticsData: JSONValueDictionary? = nil) {
self.appURL = appURL
self.extraParameters = extraParameters
self.analyticsData = analyticsData
}
}

View File

@ -15,6 +15,7 @@ import Foundation
public var browserUrl: String
public var extraParameters: JSONValueDictionary?
public var analyticsData: JSONValueDictionary?
public var appURL: String?
//TODO: Should be removed in future releases. This should be MF specific.
//Missing params

View File

@ -0,0 +1,75 @@
//
// AlertModel.swift
// MVMCore
//
// Created by Suresh, Kamlesh on 7/14/20.
// Copyright © 2020 myverizon. All rights reserved.
//
import UIKit
public class AlertButtonModel: Codable {
public var title: String
public var action: ActionModelProtocol
public var style: UIAlertAction.Style = .default
public init(_ title: String,_ action: ActionModelProtocol,_ style: UIAlertAction.Style = .default) {
self.title = title
self.action = action
self.style = style
}
private enum CodingKeys: String, CodingKey {
case title
case action
case style
}
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 {
public var title: String
public var message: String
public var alertActions: [AlertButtonModel]
public init(_ title: String,_ message: String,_ alertActions: [AlertButtonModel]) {
self.title = title
self.message = message
self.alertActions = alertActions
}
private enum CodingKeys: String, CodingKey {
case title
case message
case alertActions
}
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)
}
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)
}
}

View File

@ -0,0 +1,38 @@
//
// UIAlertActionStyle+Codable.swift
// MVMCore
//
// Created by Suresh, Kamlesh on 7/14/20.
// Copyright © 2020 myverizon. All rights reserved.
//
import UIKit
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"
}
}
}

View File

@ -13,7 +13,6 @@ import Foundation
public static func registerObjects() {
try? ModelRegistry.register(ActionOpenPageModel.self)
try? ModelRegistry.register(ActionOpenUrlModel.self)
try? ModelRegistry.register(ActionOpenAppModel.self)
try? ModelRegistry.register(ActionCallModel.self)
try? ModelRegistry.register(ActionPopupModel.self)
try? ModelRegistry.register(ActionBackModel.self)
@ -22,5 +21,6 @@ import Foundation
try? ModelRegistry.register(ActionPreviousSubmitModel.self)
try? ModelRegistry.register(ActionCancelModel.self)
try? ModelRegistry.register(ActionSettingModel.self)
try? ModelRegistry.register(ActionAlertModel.self)
}
}