Skip to content

Commit

Permalink
Revert "Format fix"
Browse files Browse the repository at this point in the history
This reverts commit d05e62c.
  • Loading branch information
LTPhantom committed Aug 9, 2024
1 parent 1c497e6 commit 612f8cb
Show file tree
Hide file tree
Showing 28 changed files with 1,263 additions and 934 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#import <GoogleMobileAds/GoogleMobileAds.h>
#import "FLTAd_Internal.h"
#import "FLTGoogleMobileAdsCollection_Internal.h"
#import "FLTGoogleMobileAdsReaderWriter_Internal.h"
#import <GoogleMobileAds/GoogleMobileAds.h>

@protocol FLTAd;
@class FLTBannerAd;
Expand All @@ -33,8 +33,9 @@
- (void)loadAd:(id<FLTAd> _Nonnull)ad;
- (void)dispose:(NSNumber *_Nonnull)adId;
- (void)showAdWithID:(NSNumber *_Nonnull)adId
rootViewController:(UIViewController *_Nonnull)rootViewController;
- (void)onAdLoaded:(id<FLTAd> _Nonnull)ad responseInfo:(GADResponseInfo *_Nonnull)responseInfo;
rootViewController:(UIViewController *_Nonnull)rootViewController;
- (void)onAdLoaded:(id<FLTAd> _Nonnull)ad
responseInfo:(GADResponseInfo *_Nonnull)responseInfo;
- (void)onAdFailedToLoad:(id<FLTAd> _Nonnull)ad error:(NSError *_Nonnull)error;
- (void)onAppEvent:(id<FLTAd> _Nonnull)ad
name:(NSString *_Nullable)name
Expand All @@ -45,8 +46,10 @@
- (void)onNativeAdWillDismissScreen:(FLTNativeAd *_Nonnull)ad;
- (void)onRewardedAdUserEarnedReward:(FLTRewardedAd *_Nonnull)ad
reward:(FLTRewardItem *_Nonnull)reward;
- (void)onRewardedInterstitialAdUserEarnedReward:(FLTRewardedInterstitialAd *_Nonnull)ad
reward:(FLTRewardItem *_Nonnull)reward;
- (void)onRewardedInterstitialAdUserEarnedReward:
(FLTRewardedInterstitialAd *_Nonnull)ad
reward:
(FLTRewardItem *_Nonnull)reward;
- (void)onPaidEvent:(id<FLTAd> _Nonnull)ad value:(FLTAdValue *_Nonnull)value;
- (void)onBannerImpression:(FLTBannerAd *_Nonnull)ad;
- (void)onBannerWillDismissScreen:(FLTBannerAd *_Nonnull)ad;
Expand All @@ -64,7 +67,9 @@
- (void)disposeAllAds;
@end

@interface FLTNewGoogleMobileAdsViewFactory : NSObject <FlutterPlatformViewFactory>
@interface FLTNewGoogleMobileAdsViewFactory
: NSObject <FlutterPlatformViewFactory>
@property(readonly) FLTAdInstanceManager *_Nonnull manager;
- (instancetype _Nonnull)initWithManager:(FLTAdInstanceManager *_Nonnull)manager;
- (instancetype _Nonnull)initWithManager:
(FLTAdInstanceManager *_Nonnull)manager;
@end
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ - (instancetype _Nonnull)initWithBinaryMessenger:
_ads = [[FLTGoogleMobileAdsCollection alloc] init];
NSObject<FlutterMethodCodec> *methodCodec = [FlutterStandardMethodCodec
codecWithReaderWriter:[[FLTGoogleMobileAdsReaderWriter alloc] init]];
_channel = [[FlutterMethodChannel alloc] initWithName:@"plugins.flutter.io/google_mobile_ads"
binaryMessenger:binaryMessenger
codec:methodCodec];
_channel = [[FlutterMethodChannel alloc]
initWithName:@"plugins.flutter.io/google_mobile_ads"
binaryMessenger:binaryMessenger
codec:methodCodec];
}
return self;
}
Expand Down Expand Up @@ -67,7 +68,7 @@ - (void)disposeAllAds {
}

- (void)showAdWithID:(NSNumber *_Nonnull)adId
rootViewController:(UIViewController *_Nonnull)rootViewController {
rootViewController:(UIViewController *_Nonnull)rootViewController{
id<FLTAdWithoutView> ad = (id<FLTAdWithoutView>)[self adFor:adId];

if (!ad) {
Expand All @@ -78,12 +79,14 @@ - (void)showAdWithID:(NSNumber *_Nonnull)adId
[ad showFromRootViewController:rootViewController];
}

- (void)onAdLoaded:(id<FLTAd> _Nonnull)ad responseInfo:(GADResponseInfo *_Nonnull)responseInfo {
- (void)onAdLoaded:(id<FLTAd> _Nonnull)ad
responseInfo:(GADResponseInfo *_Nonnull)responseInfo {
[_channel invokeMethod:@"onAdEvent"
arguments:@{
@"adId" : ad.adId,
@"eventName" : @"onAdLoaded",
@"responseInfo" : [[FLTGADResponseInfo alloc] initWithResponseInfo:responseInfo]
@"responseInfo" : [[FLTGADResponseInfo alloc]
initWithResponseInfo:responseInfo]
}];
}

Expand All @@ -96,7 +99,9 @@ - (void)onAdFailedToLoad:(id<FLTAd> _Nonnull)ad error:(NSError *_Nonnull)error {
}];
}

- (void)onAppEvent:(id<FLTAd> _Nonnull)ad name:(NSString *)name data:(NSString *)data {
- (void)onAppEvent:(id<FLTAd> _Nonnull)ad
name:(NSString *)name
data:(NSString *)data {
[_channel invokeMethod:@"onAdEvent"
arguments:@{
@"adId" : ad.adId,
Expand Down Expand Up @@ -132,8 +137,10 @@ - (void)onRewardedAdUserEarnedReward:(FLTRewardedAd *_Nonnull)ad
}];
}

- (void)onRewardedInterstitialAdUserEarnedReward:(FLTRewardedInterstitialAd *_Nonnull)ad
reward:(FLTRewardItem *_Nonnull)reward {
- (void)onRewardedInterstitialAdUserEarnedReward:
(FLTRewardedInterstitialAd *_Nonnull)ad
reward:
(FLTRewardItem *_Nonnull)reward {
[_channel invokeMethod:@"onAdEvent"
arguments:@{
@"adId" : ad.adId,
Expand Down Expand Up @@ -232,12 +239,17 @@ - (instancetype)initWithManager:(FLTAdInstanceManager *_Nonnull)manager {
viewIdentifier:(int64_t)viewId
arguments:(id _Nullable)args {
NSNumber *adId = args;
NSObject<FlutterPlatformView> *view = (NSObject<FlutterPlatformView> *)[_manager adFor:adId];
NSObject<FlutterPlatformView> *view =
(NSObject<FlutterPlatformView> *)[_manager adFor:adId];

if (!view) {
NSString *reason = [NSString
stringWithFormat:@"Could not find an ad with id: %@. Was this ad already disposed?", adId];
@throw [NSException exceptionWithName:NSInvalidArgumentException reason:reason userInfo:nil];
stringWithFormat:
@"Could not find an ad with id: %@. Was this ad already disposed?",
adId];
@throw [NSException exceptionWithName:NSInvalidArgumentException
reason:reason
userInfo:nil];
}
return view;
}
Expand Down
3 changes: 2 additions & 1 deletion packages/google_mobile_ads/ios/Classes/FLTAdUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
+ (BOOL)isNotNull:(_Nullable id)object;

+ (WKWebView *_Nullable)getWebView:(NSNumber *_Nonnull)webViewId
flutterPluginRegistry:(id<FlutterPluginRegistry> _Nonnull)flutterPluginRegistry;
flutterPluginRegistry:
(id<FlutterPluginRegistry> _Nonnull)flutterPluginRegistry;

@property(readonly, class) NSString *_Nonnull requestAgent;

Expand Down
18 changes: 10 additions & 8 deletions packages/google_mobile_ads/ios/Classes/FLTAdUtil.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,22 @@ + (BOOL)isNotNull:(id)object {

+ (NSString *)requestAgent {
NSString *newsTemplateString = @"";
id newsTemplateVersion =
[NSBundle.mainBundle objectForInfoDictionaryKey:@"FLTNewsTemplateVersion"];
id newsTemplateVersion = [NSBundle.mainBundle
objectForInfoDictionaryKey:@"FLTNewsTemplateVersion"];
if ([newsTemplateVersion isKindOfClass:[NSString class]]) {
newsTemplateString = [NSString stringWithFormat:@"_News-%@", newsTemplateVersion];
newsTemplateString =
[NSString stringWithFormat:@"_News-%@", newsTemplateVersion];
}

NSString *gameTemplateString = @"";
id gameTemplateVersion =
[NSBundle.mainBundle objectForInfoDictionaryKey:@"FLTGameTemplateVersion"];
id gameTemplateVersion = [NSBundle.mainBundle
objectForInfoDictionaryKey:@"FLTGameTemplateVersion"];
if ([gameTemplateVersion isKindOfClass:[NSString class]]) {
gameTemplateString = [NSString stringWithFormat:@"_Game-%@", gameTemplateVersion];
gameTemplateString =
[NSString stringWithFormat:@"_Game-%@", gameTemplateVersion];
}
return [NSString stringWithFormat:@"%@%@%@", FLT_REQUEST_AGENT_VERSIONED, newsTemplateString,
gameTemplateString];
return [NSString stringWithFormat:@"%@%@%@", FLT_REQUEST_AGENT_VERSIONED,
newsTemplateString, gameTemplateString];
}

+ (WKWebView *)getWebView:(NSNumber *)webViewId
Expand Down
108 changes: 66 additions & 42 deletions packages/google_mobile_ads/ios/Classes/FLTAd_Internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#import <GoogleMobileAds/GoogleMobileAds.h>
#import <UIKit/UIKit.h>
#import "FLTAdInstanceManager_Internal.h"
#import "FLTGoogleMobileAdsPlugin.h"
#import "FLTMediationExtras.h"
#import "FLTMediationNetworkExtrasProvider.h"
#import "FLTMobileAds_Internal.h"
#import "FLTNativeTemplateStyle.h"
#import "GADTTemplateView.h"
#import <GoogleMobileAds/GoogleMobileAds.h>
#import <UIKit/UIKit.h>

@class FLTAdInstanceManager;
@protocol FLTNativeAdFactory;
Expand All @@ -29,7 +29,8 @@
@property(readonly) GADAdSize size;
@property(readonly) NSNumber *_Nonnull width;
@property(readonly) NSNumber *_Nonnull height;
- (instancetype _Nonnull)initWithWidth:(NSNumber *_Nonnull)width height:(NSNumber *_Nonnull)height;
- (instancetype _Nonnull)initWithWidth:(NSNumber *_Nonnull)width
height:(NSNumber *_Nonnull)height;
- (instancetype _Nonnull)initWithAdSize:(GADAdSize)size;
@end

Expand All @@ -38,14 +39,22 @@
* Plugin.
*/
@interface FLTAdSizeFactory : NSObject
- (GADAdSize)portraitAnchoredAdaptiveBannerAdSizeWithWidth:(NSNumber *_Nonnull)width;
- (GADAdSize)landscapeAnchoredAdaptiveBannerAdSizeWithWidth:(NSNumber *_Nonnull)width;
- (GADAdSize)currentOrientationAnchoredAdaptiveBannerAdSizeWithWidth:(NSNumber *_Nonnull)width;
- (GADAdSize)currentOrientationInlineAdaptiveBannerSizeWithWidth:(NSNumber *_Nonnull)width;
- (GADAdSize)portraitOrientationInlineAdaptiveBannerSizeWithWidth:(NSNumber *_Nonnull)width;
- (GADAdSize)landscapeInlineAdaptiveBannerAdSizeWithWidth:(NSNumber *_Nonnull)width;
- (GADAdSize)inlineAdaptiveBannerAdSizeWithWidthAndMaxHeight:(NSNumber *_Nonnull)width
maxHeight:(NSNumber *_Nonnull)maxHeight;
- (GADAdSize)portraitAnchoredAdaptiveBannerAdSizeWithWidth:
(NSNumber *_Nonnull)width;
- (GADAdSize)landscapeAnchoredAdaptiveBannerAdSizeWithWidth:
(NSNumber *_Nonnull)width;
- (GADAdSize)currentOrientationAnchoredAdaptiveBannerAdSizeWithWidth:
(NSNumber *_Nonnull)width;
- (GADAdSize)currentOrientationInlineAdaptiveBannerSizeWithWidth:
(NSNumber *_Nonnull)width;
- (GADAdSize)portraitOrientationInlineAdaptiveBannerSizeWithWidth:
(NSNumber *_Nonnull)width;
- (GADAdSize)landscapeInlineAdaptiveBannerAdSizeWithWidth:
(NSNumber *_Nonnull)width;
- (GADAdSize)
inlineAdaptiveBannerAdSizeWithWidthAndMaxHeight:(NSNumber *_Nonnull)width
maxHeight:
(NSNumber *_Nonnull)maxHeight;

@end

Expand Down Expand Up @@ -78,9 +87,10 @@
@property NSString *_Nullable contentURL;
@property BOOL nonPersonalizedAds;
@property NSArray<NSString *> *_Nullable neighboringContentURLs;
@property NSString *_Nullable mediationExtrasIdentifier DEPRECATED_MSG_ATTRIBUTE(
"Use mediationExtras instead.");
@property id<FLTMediationNetworkExtrasProvider> _Nullable mediationNetworkExtrasProvider
@property NSString *_Nullable mediationExtrasIdentifier
DEPRECATED_MSG_ATTRIBUTE("Use mediationExtras instead.");
@property id<
FLTMediationNetworkExtrasProvider> _Nullable mediationNetworkExtrasProvider
DEPRECATED_MSG_ATTRIBUTE("Use mediationExtras instead.");
@property NSDictionary<NSString *, NSString *> *_Nullable adMobExtras;
@property NSString *_Nonnull requestAgent;
Expand All @@ -104,7 +114,8 @@
@property NSString *_Nullable adSourceName;
@property NSString *_Nullable adSourceInstanceName;

- (instancetype _Nonnull)initWithResponseInfo:(GADAdNetworkResponseInfo *_Nonnull)responseInfo;
- (instancetype _Nonnull)initWithResponseInfo:
(GADAdNetworkResponseInfo *_Nonnull)responseInfo;
@end

/**
Expand All @@ -117,7 +128,8 @@
@property FLTGADAdNetworkResponseInfo *_Nullable loadedAdNetworkResponseInfo;
@property NSDictionary<NSString *, id> *_Nullable extrasDictionary;

- (instancetype _Nonnull)initWithResponseInfo:(GADResponseInfo *_Nonnull)responseInfo;
- (instancetype _Nonnull)initWithResponseInfo:
(GADResponseInfo *_Nonnull)responseInfo;
@end

/**
Expand All @@ -138,7 +150,8 @@
*/
@interface FLTGAMAdRequest : FLTAdRequest
@property NSDictionary<NSString *, NSString *> *_Nullable customTargeting;
@property NSDictionary<NSString *, NSArray<NSString *> *> *_Nullable customTargetingLists;
@property NSDictionary<NSString *, NSArray<NSString *> *>
*_Nullable customTargetingLists;
@property NSString *_Nullable pubProvidedID;

- (GAMRequest *_Nonnull)asGAMRequest:(NSString *_Nonnull)adUnitId;
Expand All @@ -158,11 +171,13 @@
@property(readonly) NSNumber *_Nonnull adId;
@end

@interface FLTBannerAd : FLTBaseAd <FLTAd, FlutterPlatformView, GADBannerViewDelegate>
@interface FLTBannerAd
: FLTBaseAd <FLTAd, FlutterPlatformView, GADBannerViewDelegate>
- (instancetype _Nonnull)initWithAdUnitId:(NSString *_Nonnull)adUnitId
size:(FLTAdSize *_Nonnull)size
request:(FLTAdRequest *_Nonnull)request
rootViewController:(UIViewController *_Nonnull)rootViewController
rootViewController:
(UIViewController *_Nonnull)rootViewController
adId:(NSNumber *_Nonnull)adId;
- (FLTAdSize *_Nullable)getAdSize;
- (GADBannerView *_Nonnull)bannerView;
Expand All @@ -175,7 +190,8 @@
- (instancetype _Nonnull)initWithAdUnitId:(NSString *_Nonnull)adUnitId
sizes:(NSArray<FLTAdSize *> *_Nonnull)sizes
request:(FLTGAMAdRequest *_Nonnull)request
rootViewController:(UIViewController *_Nonnull)rootViewController
rootViewController:
(UIViewController *_Nonnull)rootViewController
adId:(NSNumber *_Nonnull)adId;

@end
Expand All @@ -186,11 +202,13 @@
@interface FLTFluidGAMBannerAd : FLTGAMBannerAd <GADAdSizeDelegate>
- (instancetype _Nonnull)initWithAdUnitId:(NSString *_Nonnull)adUnitId
request:(FLTGAMAdRequest *_Nonnull)request
rootViewController:(UIViewController *_Nonnull)rootViewController
rootViewController:
(UIViewController *_Nonnull)rootViewController
adId:(NSNumber *_Nonnull)adId;
@end

@interface FLTFullScreenAd : FLTBaseAd <FLTAd, FLTAdWithoutView, GADFullScreenContentDelegate>
@interface FLTFullScreenAd
: FLTBaseAd <FLTAd, FLTAdWithoutView, GADFullScreenContentDelegate>
@end

@interface FLTInterstitialAd : FLTFullScreenAd
Expand Down Expand Up @@ -238,9 +256,10 @@
@property(readonly) NSNumber *_Nullable clickToExpandRequested;
@property(readonly) NSNumber *_Nullable customControlsRequested;
@property(readonly) NSNumber *_Nullable startMuted;
- (instancetype _Nonnull)initWithClickToExpandRequested:(NSNumber *_Nullable)clickToExpandRequested
customControlsRequested:(NSNumber *_Nullable)customControlsRequested
startMuted:(NSNumber *_Nullable)startMuted;
- (instancetype _Nonnull)
initWithClickToExpandRequested:(NSNumber *_Nullable)clickToExpandRequested
customControlsRequested:(NSNumber *_Nullable)customControlsRequested
startMuted:(NSNumber *_Nullable)startMuted;
- (GADVideoOptions *_Nonnull)asGADVideoOptions;

@end
Expand All @@ -253,34 +272,39 @@
@property(readonly) NSNumber *_Nullable shouldRequestMultipleImages;
@property(readonly) NSNumber *_Nullable shouldReturnUrlsForImageAssets;

- (instancetype _Nonnull)initWithAdChoicesPlacement:(NSNumber *_Nullable)adChoicesPlacement
mediaAspectRatio:(NSNumber *_Nullable)mediaAspectRatio
videoOptions:(FLTVideoOptions *_Nullable)videoOptions
requestCustomMuteThisAd:(NSNumber *_Nullable)requestCustomMuteThisAd
shouldRequestMultipleImages:(NSNumber *_Nullable)shouldRequestMultipleImages
shouldReturnUrlsForImageAssets:
(NSNumber *_Nullable)shouldReturnUrlsForImageAssets;
- (instancetype _Nonnull)
initWithAdChoicesPlacement:(NSNumber *_Nullable)adChoicesPlacement
mediaAspectRatio:(NSNumber *_Nullable)mediaAspectRatio
videoOptions:(FLTVideoOptions *_Nullable)videoOptions
requestCustomMuteThisAd:(NSNumber *_Nullable)requestCustomMuteThisAd
shouldRequestMultipleImages:
(NSNumber *_Nullable)shouldRequestMultipleImages
shouldReturnUrlsForImageAssets:
(NSNumber *_Nullable)shouldReturnUrlsForImageAssets;

- (NSArray<GADAdLoaderOptions *> *_Nonnull)asGADAdLoaderOptions;
@end

@interface FLTNativeAd
: FLTBaseAd <FLTAd, FlutterPlatformView, GADNativeAdDelegate, GADNativeAdLoaderDelegate>
- (instancetype _Nonnull)initWithAdUnitId:(NSString *_Nonnull)adUnitId
request:(FLTAdRequest *_Nonnull)request
nativeAdFactory:(NSObject<FLTNativeAdFactory> *_Nonnull)nativeAdFactory
customOptions:(NSDictionary<NSString *, id> *_Nullable)customOptions
rootViewController:(UIViewController *_Nonnull)rootViewController
adId:(NSNumber *_Nonnull)adId
nativeAdOptions:(FLTNativeAdOptions *_Nullable)nativeAdOptions
nativeTemplateStyle:(FLTNativeTemplateStyle *_Nullable)nativeTemplateStyle;
: FLTBaseAd <FLTAd, FlutterPlatformView, GADNativeAdDelegate,
GADNativeAdLoaderDelegate>
- (instancetype _Nonnull)
initWithAdUnitId:(NSString *_Nonnull)adUnitId
request:(FLTAdRequest *_Nonnull)request
nativeAdFactory:(NSObject<FLTNativeAdFactory> *_Nonnull)nativeAdFactory
customOptions:(NSDictionary<NSString *, id> *_Nullable)customOptions
rootViewController:(UIViewController *_Nonnull)rootViewController
adId:(NSNumber *_Nonnull)adId
nativeAdOptions:(FLTNativeAdOptions *_Nullable)nativeAdOptions
nativeTemplateStyle:(FLTNativeTemplateStyle *_Nullable)nativeTemplateStyle;
- (GADAdLoader *_Nonnull)adLoader;
@end

@interface FLTRewardItem : NSObject
@property(readonly) NSNumber *_Nonnull amount;
@property(readonly) NSString *_Nonnull type;
- (instancetype _Nonnull)initWithAmount:(NSNumber *_Nonnull)amount type:(NSString *_Nonnull)type;
- (instancetype _Nonnull)initWithAmount:(NSNumber *_Nonnull)amount
type:(NSString *_Nonnull)type;
@end

@interface FLTAdValue : NSObject
Expand Down
Loading

0 comments on commit 612f8cb

Please sign in to comment.