Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove resource bundle #818

Merged
merged 15 commits into from
May 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions PrebidMobile.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,6 @@ Pod::Spec.new do |s|
s.subspec 'core' do |core|
core.source_files = 'PrebidMobile/**/*.{h,m,swift}'

core.resource_bundles = {
'PrebidSDKCoreResources' => ['PrebidMobile/PrebidMobileRendering/Assets/**/*.{js,html,xib,xcassets}']
}
core.private_header_files = [
'PrebidMobile/PrebidMobileRendering/Networking/Parameters/PBMParameterBuilderService.h',
'PrebidMobile/PrebidMobileRendering/Prebid+TestExtension.h',
Expand Down
72 changes: 24 additions & 48 deletions PrebidMobile.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion PrebidMobile/ConfigurationAndTargeting/Prebid.swift
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public class Prebid: NSObject {
let _ = PBMLocationManager.shared
let _ = UserConsentDataManager.shared

PBMOpenMeasurementWrapper.shared.initializeJSLib(with: PBMFunctions.bundleForSDK())
PrebidJSLibraryManager.shared.downloadLibraries()

serverStatusRequester.requestStatus { completion?($0, $1) }

Expand Down
14 changes: 14 additions & 0 deletions PrebidMobile/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,18 @@ public class PrebidConstants: NSObject {
public static var supportedRenderingBannerAPISignals: [Signals.Api] {
return [.MRAID_1, .MRAID_2, .MRAID_3, .OMID_1]
}

public static var companionHTMLTemplate: String {
"""
<html>
<body>
<div id="ad" align="center">
<a href="%@">
<img src="%@" align="center" style="max-width:100%vw; width:auto; max-height:100%vh">
</a>
</div>
</body>
</html>
"""
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ NS_ASSUME_NONNULL_BEGIN

#pragma mark - PBMMeasurementProtocol

- (void)initializeJSLibWithBundle:(NSBundle *)bundle
completion:(nullable PBMVoidBlock)completion;

- (nullable NSString *)injectJSLib:(NSString *)html error:(NSError * __nullable * __null_unspecified)error;

- (nullable PBMOpenMeasurementSession *)initializeWebViewSession:(WKWebView *)webView
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -261,22 +261,9 @@ - (NSString*) buildStaticResource: (PBMVastCreativeCompanionAdsCompanion*)compan
if (companion == nil) {
return nil;
}
NSBundle * sdkBundle = [PBMFunctions bundleForSDK];
if (sdkBundle == nil) {
return nil;
}
NSString *path = [sdkBundle pathForResource:@"companion" ofType:@"html"];
if (!path) {
// error reading html
return nil;
}

NSString *templateHtmlString = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
if (!templateHtmlString) {
return nil;
}
NSString * html = [NSString stringWithFormat:PrebidConstants.companionHTMLTemplate, companion.clickThroughURI, companion.resource];

NSString * html = [NSString stringWithFormat:templateHtmlString, companion.clickThroughURI, companion.resource];
return html;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#import <UIKit/UIKit.h>
#import "PBMInterstitialLayout.h"

@class PrebidImagesRepository;

NS_ASSUME_NONNULL_BEGIN
@interface PBMInterstitialDisplayProperties : NSObject <NSCopying>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@
#import "PBMInterstitialDisplayProperties.h"
#import "PBMFunctions+Private.h"

#import "PrebidMobileSwiftHeaders.h"

#if __has_include("PrebidMobile-Swift.h")
#import "PrebidMobile-Swift.h"
#else
#import <PrebidMobile/PrebidMobile-Swift.h>
#endif

@interface PBMInterstitialDisplayProperties()
@property (nonatomic, strong) UIImage *closeButtonImage;
@end
Expand All @@ -31,7 +39,7 @@ - (instancetype)init {
self.closeDelayLeft = 0;
self.contentFrame = CGRectInfinite;
self.contentViewColor = [UIColor clearColor];
self.closeButtonImage = [UIImage imageNamed:@"PBM_closeButton" inBundle:[PBMFunctions bundleForSDK] compatibleWithTraitCollection:nil];
self.closeButtonImage = PrebidImagesRepository.closeButton.base64DecodedImage;
self.interstitialLayout = PBMInterstitialLayoutUndefined;
}
return self;
Expand Down
32 changes: 12 additions & 20 deletions PrebidMobile/PrebidMobileRendering/AdTypes/AdView/PBMVideoView.m
Original file line number Diff line number Diff line change
Expand Up @@ -403,12 +403,13 @@ - (void)setupMuteControls {
return;
}

UIButton * const muteButton = [self createButtonWithImageName:@"mute_disabled"
accessibilityLabel:@"pbmMute"
action:@selector(btnMuteClick:)];
UIButton * const unmuteButton = [self createButtonWithImageName:@"mute_enabled"
accessibilityLabel:@"pbmUnmute"
action:@selector(btnUnmuteClick:)];
UIButton * const muteButton = [self createButtonWithString:PrebidImagesRepository.muteDisabled
accessibilityLabel:@"pbmMute"
action:@selector(btnMuteClick:)];

UIButton * const unmuteButton = [self createButtonWithString:PrebidImagesRepository.muteEnabled
accessibilityLabel:@"pbmUnmute"
action:@selector(btnUnmuteClick:)];

muteButton.translatesAutoresizingMaskIntoConstraints = NO;
unmuteButton.translatesAutoresizingMaskIntoConstraints = NO;
Expand Down Expand Up @@ -467,7 +468,7 @@ - (void)setupSkipButton {
self.skipButtonDecorator.buttonArea = self.creative.creativeModel.adConfiguration.videoControlsConfig.skipButtonArea;
self.skipButtonDecorator.buttonPosition = self.creative.creativeModel.adConfiguration.videoControlsConfig.skipButtonPosition;

UIImage *skipButtonImage = [UIImage imageNamed:@"PBM_skipButton" inBundle:[PBMFunctions bundleForSDK] compatibleWithTraitCollection:nil];
UIImage *skipButtonImage = PrebidImagesRepository.skipButton.base64DecodedImage;

[self.skipButtonDecorator setImage:skipButtonImage];
[self.skipButtonDecorator addButtonTo:self displayView:self];
Expand Down Expand Up @@ -508,27 +509,18 @@ - (void)handleSkipDelay:(NSTimeInterval)skipDelay videoDuration:(NSTimeInterval)
});
}

- (UIButton *)createButtonWithImageName:(NSString *)imageName
accessibilityLabel:(NSString *)accessibilityLabel
action:(SEL)action
- (UIButton *)createButtonWithString:(NSString *)encodedString
accessibilityLabel:(NSString *)accessibilityLabel
action:(SEL)action
{
UIButton * const button = [[UIButton alloc] init];
button.backgroundColor = [UIColor clearColor];
[button setImage:[UIImage imageNamed:imageName
inBundle:[PBMFunctions bundleForSDK]
compatibleWithTraitCollection:[UIScreen mainScreen].traitCollection]
forState:UIControlStateNormal];
[button setImage:encodedString.base64DecodedImage forState:UIControlStateNormal];
[button addTarget:self action:action forControlEvents:UIControlEventTouchUpInside];
[button setIsAccessibilityElement:YES];
[button setAccessibilityLabel:accessibilityLabel];

button.layer.cornerRadius = 5;
// button.layer.borderWidth = 2;
//
// button.layer.borderColor = [[UIColor colorWithRed:1.0f green:1.0f blue:1.0f alpha:1.0f] CGColor];
button.layer.backgroundColor = [[UIColor colorWithRed:51.0f/255.0f green:51.0f/255.0f blue:51.0f/255.0f alpha:0.75] CGColor];

// button.contentEdgeInsets = UIEdgeInsetsMake(10, 20, 10, 20);
[button sizeToFit];

return button;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#import "PBMError.h"
#import "PBMFunctions+Private.h"
#import "PBMInterstitialDisplayProperties.h"
#import "PBMJSLibraryManager.h"
#import "PBMLocationManager.h"
#import "PBMMRAIDController.h"
#import "PBMMRAIDJavascriptCommands.h"
Expand Down Expand Up @@ -75,6 +74,8 @@ @interface PBMWebView ()
// the last frame sent to an ad via onSizeChange
@property (nonatomic, assign) CGRect mraidLastSentFrame;

@property (nonatomic, strong, nullable) PrebidJSLibraryManager *libraryManager;

// Need to avoid warnings
- (nullable instancetype)initWithCoder:(NSCoder *)aDecoder NS_DESIGNATED_INITIALIZER;

Expand Down Expand Up @@ -108,6 +109,7 @@ - (nonnull instancetype)initWithFrame:(CGRect)frame
WKUserContentController * const wkUserContentController = [[WKUserContentController alloc] init];
self.wkUserContentController = wkUserContentController;
_targeting = targeting;
_libraryManager = PrebidJSLibraryManager.shared;
_lastTapTimestamp = NSDate.distantPast;
_viewable = NO;
_isMRAID = NO;
Expand Down Expand Up @@ -461,8 +463,7 @@ - (void)layoutSubviews {
#pragma mark - MRAID Injection

- (BOOL)injectMRAIDForExpandContent:(BOOL)isForExpandContent error:(NSError **)error {
[PBMJSLibraryManager sharedManager].bundle = self.bundle;
NSString *mraidScript = [[PBMJSLibraryManager sharedManager] getMRAIDLibrary];
NSString *mraidScript = [self.libraryManager getMRAIDLibrary];
if (!mraidScript) {
[PBMError createError:error message:@"Could not load mraid.js from library manager" type:PBMErrorTypeInternalError];
return false;
Expand Down
Loading