Skip to content

Commit

Permalink
Fixed Incorrect AdChoicesPlacement int value. (#896)
Browse files Browse the repository at this point in the history
* Fixed Incorrect AdChoicesPlacement int value.

As per the gms ads library docs  (https://developers.google.com/android/reference/com/google/android/gms/ads/nativead/NativeAdOptions#public-static-final-int-adchoices_top_left) the int value for `ADCHOICES_TOP_LEFT ` is `0` and `ADCHOICES_TOP_RIGHT` is `1`. It causes the AdChoicesIcon to be in the opposite position in native ads.

* Updated AdChoicesPlacement values to match platform based values.
  • Loading branch information
sarankumar-ns authored Nov 2, 2023
1 parent 6f329ad commit fa86e70
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions packages/google_mobile_ads/lib/src/ad_instance_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,25 @@

import 'dart:async';
import 'dart:collection';
import 'dart:io';

import 'package:google_mobile_ads/src/ad_inspector_containers.dart';
import 'package:google_mobile_ads/src/ad_listeners.dart';
import 'package:google_mobile_ads/src/mobile_ads.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'package:google_mobile_ads/src/ad_inspector_containers.dart';
import 'package:google_mobile_ads/src/ad_listeners.dart';
import 'package:google_mobile_ads/src/mobile_ads.dart';
import 'package:google_mobile_ads/src/nativetemplates/template_type.dart';
import 'package:google_mobile_ads/src/webview_controller_util.dart';
import 'package:webview_flutter/webview_flutter.dart';
import 'package:webview_flutter_android/webview_flutter_android.dart';
import 'package:webview_flutter_wkwebview/webview_flutter_wkwebview.dart';

import 'ad_containers.dart';
import 'nativetemplates/native_template_font_style.dart';
import 'nativetemplates/native_template_style.dart';
import 'nativetemplates/native_template_text_style.dart';
import 'request_configuration.dart';
import 'ad_containers.dart';

/// Loads and disposes [BannerAds] and [InterstitialAds].
AdInstanceManager instanceManager = AdInstanceManager(
Expand Down Expand Up @@ -1317,9 +1318,9 @@ extension AdChoicesPlacementExtension on AdChoicesPlacement {
int get intValue {
switch (this) {
case AdChoicesPlacement.topRightCorner:
return 0;
return Platform.isAndroid ? 1 : 0;
case AdChoicesPlacement.topLeftCorner:
return 1;
return Platform.isAndroid ? 0 : 1;
case AdChoicesPlacement.bottomRightCorner:
return 2;
case AdChoicesPlacement.bottomLeftCorner:
Expand All @@ -1331,9 +1332,13 @@ extension AdChoicesPlacementExtension on AdChoicesPlacement {
static AdChoicesPlacement? fromInt(int? intValue) {
switch (intValue) {
case 0:
return AdChoicesPlacement.topRightCorner;
return Platform.isAndroid
? AdChoicesPlacement.topLeftCorner
: AdChoicesPlacement.topRightCorner;
case 1:
return AdChoicesPlacement.topLeftCorner;
return Platform.isAndroid
? AdChoicesPlacement.topRightCorner
: AdChoicesPlacement.topLeftCorner;
case 2:
return AdChoicesPlacement.bottomRightCorner;
case 3:
Expand Down

0 comments on commit fa86e70

Please sign in to comment.