Merge pull request #40 in BPHVB/mvm_core from release/6_9 to develop

* commit '85cc9a81c613be0223966d27c5d0b11f724d43b1': (26 commits)
  fix to use key
  clean load object change
  panel protocol available
  fix delegate nil
  instance method in core logging delegate protocol
  remove unused page type
  changes to the way popup delegacy works
  proper marking of delegate
  add tracking to alert protocol
  pass controller instead
  remove space
  revert
  revert and change slightly
  lenient bool.... web view clean up
  remove pageType in document
  remove alertPageType property
  fixes
  alert handler takes alert object
  fix warning
  adobe track alert
  ...
This commit is contained in:
Sommer, Patrick 2018-11-14 14:00:52 -05:00
commit f6793232b6
16 changed files with 52 additions and 3 deletions

View File

@ -219,7 +219,7 @@ NSString * const KeyActionTypeOpen = @"openPage";
NSDictionary *responseInfo = [jsonDictionary dict:KeyResponseInfo];
if (responseInfo) {
MVMCoreAlertObject *alertObject = [MVMCoreAlertObject alertObjectForPageType:pageTypeForTopAlert responseInfo:responseInfo additionalData:additionalData actionDelegate:delegate];
if ([delegate respondsToSelector:@selector(willShowPopupWithAlertObject:alertJson:)]) {
if ([delegate respondsToSelector:@selector(willShowTopAlertWithAlertObject:alertJson:)]) {
alertObject = [delegate willShowTopAlertWithAlertObject:alertObject alertJson:jsonDictionary];
}
[alertObject showAlert];

View File

@ -8,9 +8,11 @@
// Used by our alert handler. Not for subclassing. Simply keeps track of if it's visible. Tries to parallel the UIAlertView to make it easier for the MVMCoreAlertHandler.
#import <UIKit/UIKit.h>
@class MVMCoreAlertObject;
@interface MVMCoreAlertController : UIAlertController
@property (nonatomic, readonly, getter=isVisible) BOOL visible;
@property (nullable, nonatomic, strong) MVMCoreAlertObject *alertObject;
@end

View File

@ -7,6 +7,7 @@
//
#import "MVMCoreAlertController.h"
#import "MVMCoreLoggingHandler.h"
@interface MVMCoreAlertController ()
@ -22,6 +23,7 @@
[self willChangeValueForKey:@"isVisible"];
self.visible = YES;
[self didChangeValueForKey:@"isVisible"];
[MVMCoreLoggingHandler logAlertForAlertController:self];
}
- (void)viewDidDisappear:(BOOL)animated {

View File

@ -8,11 +8,15 @@
// Called for popup style alerts.
#import <Foundation/Foundation.h>
@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;

View File

@ -102,7 +102,9 @@
}
- (nonnull UIAlertController *)showAlertWithAlertObject:(nonnull MVMCoreAlertObject *)alertObject {
return [self showAlertWithTitle:alertObject.title message:alertObject.message actions:alertObject.actions alertStyle:alertObject.alertStyle isGreedy:alertObject.isGreedy alertDelegate:alertObject.alertDelegate];
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)removeAllAlertViews {

View File

@ -28,6 +28,7 @@ typedef void (^TextFieldErrorHandler)(NSArray * _Nonnull fieldErrors);
@interface MVMCoreAlertObject : NSObject
@property (nullable, strong, nonatomic) NSString *title;
@property (nullable, copy, nonatomic) NSDictionary *pageJson;
@property (nullable, strong, nonatomic) NSString *message;
@property (nonnull, strong, nonatomic) NSArray *actions;
@property (nonatomic) BOOL isGreedy;

View File

@ -71,7 +71,7 @@
// Perform a popup.
alert.type = MFAlertTypePopup;
alert.alertStyle = UIAlertControllerStyleAlert;
// Check if we have a popup driven by page object (otherwise by default it will just use response info title message with an OK button).
NSString *pageTypeForPopup = [responseInfo stringForKey:@"popupPageType"];
[[MVMCoreCache sharedCache] fetchJSONForPageType:pageTypeForPopup queue:nil waitUntilFinished:YES completionHandler:^(NSDictionary * _Nullable jsonDictionary) {
@ -99,6 +99,7 @@
alert.alertStyle = UIAlertControllerStyleAlert;
}
}
alert.alertDelegate = actionDelegate;
return alert;
}
@ -145,6 +146,7 @@
MVMCoreAlertObject *alert = [[MVMCoreAlertObject alloc] init];
alert.title = [page stringForKey:KeyTitle];
alert.pageJson = page;
alert.message = [page stringForKey:KeyMessage];
alert.isGreedy = isGreedy;
alert.type = MFAlertTypePopup;

View File

@ -24,6 +24,9 @@
- (CGFloat)floatForKey:(nonnull id<NSCopying>)key;
- (double)doubleForKey:(nonnull id<NSCopying>)key;
// Not strict, can accept either string or boolean.
- (BOOL)lenientBoolForKey:(nonnull id<NSCopying>)key;
// Gets an object that is nested using a series of keys or indexes to reach it.
// All keys should be of type NSString and is used for nested dictionaries.
// All indexes should be of type NSNumber and is used for nested arrays.

View File

@ -32,6 +32,15 @@
return [[self objectForKey:key ofType:[NSNumber class]] boolValue];
}
- (BOOL)lenientBoolForKey:(nonnull id<NSCopying>)key {
NSObject *object = [self objectForKey:key];
if ([object isKindOfClass:[NSString class]]) {
return [((NSString *)object) isEqualToString:@"true"];
} else {
return [((NSNumber *)([object isKindOfClass:[NSNumber class]] ? object : nil)) boolValue];
}
}
- (CGFloat)floatForKey:(nonnull id<NSCopying>)key {
return [[self objectForKey:key ofType:[NSNumber class]] floatValue];
}

View File

@ -23,6 +23,9 @@
// The data for hte page that was loaded
@property (nullable, strong, nonatomic) NSDictionary *pageJSON;
// Contains the button map
@property (nullable, nonatomic, strong, readonly) NSDictionary *buttonMap;
// the modules that are needed
@property (nullable, strong, nonatomic) NSDictionary *modulesJSON;

View File

@ -22,6 +22,10 @@
return self;
}
- (NSDictionary *)buttonMap {
return [self.pageJSON dict:KeyButtonMap];
}
- (nullable instancetype)initWithRequestParameters:(nullable MVMCoreRequestParameters *)requestParameters dataForPage:(nullable NSDictionary *)dataForPage delegate:(nullable NSObject<MVMCoreLoadDelegateProtocol,MVMCorePresentationDelegateProtocol,MVMCoreActionDelegateProtocol>*)delegate {
if (self = [self initWithDelegate:delegate]) {
self.requestParameters = requestParameters;

View File

@ -67,6 +67,7 @@
if (self = [self initWithPageType:[actionMap stringForKey:KeyPageType] additionalModules:[actionMap array:KeyModuleList] extraParameters:[actionMap dict:KeyExtraParameters]]) {
self.contextRoot = [actionMap string:KeyContextRoot];
self.actionMap = actionMap;
self.customTimeoutTime = [actionMap objectForKey:@"customTimeoutTime" ofType:[NSNumber class]];
self.openSupportPanel = [actionMap boolForKey:KeyOpenSupport];
// Right now server is sending default.... can't uncomment this until they remove default
@ -132,6 +133,7 @@
copyObject.alternateBaseURL = self.alternateBaseURL;
copyObject.openSupportPanel = self.openSupportPanel;
copyObject.imageData = self.imageData;
copyObject.customTimeoutTime = self.customTimeoutTime;
return copyObject;
}

View File

@ -7,6 +7,7 @@
//
#import <UIKit/UIKit.h>
@class MVMCoreAlertController;
@protocol MVMCoreLoggingDelegateProtocol <NSObject>
@ -24,4 +25,7 @@
// Log that the load has finished.
- (void)logLoadFinished:(nullable MVMCoreLoadObject *)loadObject loadedViewController:(nullable UIViewController <MVMCoreViewControllerProtocol> *)loadedViewController error:(nullable MVMCoreErrorObject *)error;
// Log alert
- (void)logAlertForAlertController:(nullable MVMCoreAlertController *)alertController;
@end

View File

@ -14,6 +14,9 @@
@optional
// The panel can return if it should be available or not.
- (BOOL)panelAvailable;
- (void)panel:(UIViewController <MVMCoreViewControllerProtocol> *_Nullable)panel viewWillAppear:(BOOL)animated;
- (void)panel:(UIViewController <MVMCoreViewControllerProtocol> *_Nullable)panel viewDidAppear:(BOOL)animated;
- (void)panel:(UIViewController <MVMCoreViewControllerProtocol> *_Nullable)panel viewWillDisappear:(BOOL)animated;

View File

@ -10,6 +10,7 @@
#import <MVMCore/MVMCoreErrorObject.h>
#import <MVMCore/MVMCoreViewControllerProtocol.h>
#import <MVMCore/MVMCoreLoadObject.h>
@class MVMCoreAlertController;
#define MVMCoreLog(fmt, ...) \
[MVMCoreLoggingHandler logDebugMessageWithDelegate:[NSString stringWithFormat:(@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__]];
@ -20,5 +21,6 @@
+ (void)logDebugMessageWithDelegate:(nullable NSString *)message;
+ (void)logWithDelegateWithObject:(nullable id)object withName:(nullable NSString *)name withExtraInfo:(nullable NSDictionary *)extra;
+ (void)logWithDelegateLoadFinished:(nullable MVMCoreLoadObject *)loadObject loadedViewController:(nullable UIViewController <MVMCoreViewControllerProtocol> *)loadedViewController error:(nullable MVMCoreErrorObject *)error;
+ (void)logAlertForAlertController:(nullable MVMCoreAlertController *)alertController;
@end

View File

@ -35,5 +35,11 @@
}
}
+ (void)logAlertForAlertController:(nullable MVMCoreAlertController *)alertController {
if ([[MVMCoreObject sharedInstance].loggingDelegate respondsToSelector:@selector(logAlertForAlertController:)]) {
[[MVMCoreObject sharedInstance].loggingDelegate logAlertForAlertController:alertController];
}
}
@end