@capacitor-community/admob 6.2.0-1 → 7.0.0-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,21 +1,21 @@
1
1
  ext {
2
2
  junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
3
- androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.6.1'
3
+ androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.7.0'
4
4
  androidxCoordinatorLayoutVersion = project.hasProperty('androidxCoordinatorLayoutVersion') ? rootProject.ext.androidxCoordinatorLayoutVersion : '1.2.0'
5
- androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.5'
6
- androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.5.1'
5
+ androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.2.1'
6
+ androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.6.1'
7
7
  playServicesAdsVersion = project.hasProperty('playServicesAdsVersion') ? rootProject.ext.playServicesAdsVersion : '23.0.0'
8
8
  androidxCoreKTXVersion = project.hasProperty('androidxCoreKTXVersion') ? rootProject.ext.androidxCoreKTXVersion : '1.13.0'
9
9
  }
10
10
 
11
11
  buildscript {
12
- ext.kotlin_version = project.hasProperty("kotlin_version") ? rootProject.ext.kotlin_version : '1.9.10'
12
+ ext.kotlin_version = project.hasProperty("kotlin_version") ? rootProject.ext.kotlin_version : '1.9.25'
13
13
  repositories {
14
14
  google()
15
15
  mavenCentral()
16
16
  }
17
17
  dependencies {
18
- classpath 'com.android.tools.build:gradle:8.2.1'
18
+ classpath 'com.android.tools.build:gradle:8.7.2'
19
19
  classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
20
20
  }
21
21
  }
@@ -25,10 +25,10 @@ apply plugin: 'kotlin-android'
25
25
 
26
26
  android {
27
27
  namespace "com.getcapacitor.community.admob.admob"
28
- compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 34
28
+ compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 35
29
29
  defaultConfig {
30
- minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 22
31
- targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 34
30
+ minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 23
31
+ targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 35
32
32
  versionCode 1
33
33
  versionName "1.0"
34
34
  testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
@@ -43,11 +43,11 @@ android {
43
43
  abortOnError false
44
44
  }
45
45
  compileOptions {
46
- sourceCompatibility JavaVersion.VERSION_17
47
- targetCompatibility JavaVersion.VERSION_17
46
+ sourceCompatibility JavaVersion.VERSION_21
47
+ targetCompatibility JavaVersion.VERSION_21
48
48
  }
49
49
  kotlinOptions {
50
- jvmTarget = JavaVersion.VERSION_17
50
+ jvmTarget = JavaVersion.VERSION_21
51
51
  }
52
52
  }
53
53
 
@@ -140,20 +140,18 @@ public class BannerExecutor extends Executor {
140
140
  try {
141
141
  activitySupplier
142
142
  .get()
143
- .runOnUiThread(
144
- () -> {
145
- if (mAdViewLayout != null) {
146
- mAdViewLayout.setVisibility(View.GONE);
147
- mAdView.pause();
143
+ .runOnUiThread(() -> {
144
+ if (mAdViewLayout != null) {
145
+ mAdViewLayout.setVisibility(View.GONE);
146
+ mAdView.pause();
148
147
 
149
- final BannerAdSizeInfo sizeInfo = new BannerAdSizeInfo(0, 0);
148
+ final BannerAdSizeInfo sizeInfo = new BannerAdSizeInfo(0, 0);
150
149
 
151
- notifyListeners(BannerAdPluginEvents.SizeChanged.getWebEventName(), sizeInfo);
150
+ notifyListeners(BannerAdPluginEvents.SizeChanged.getWebEventName(), sizeInfo);
152
151
 
153
- call.resolve();
154
- }
152
+ call.resolve();
155
153
  }
156
- );
154
+ });
157
155
  } catch (Exception ex) {
158
156
  call.reject(ex.getLocalizedMessage(), ex);
159
157
  }
@@ -163,19 +161,17 @@ public class BannerExecutor extends Executor {
163
161
  try {
164
162
  activitySupplier
165
163
  .get()
166
- .runOnUiThread(
167
- () -> {
168
- if (mAdViewLayout != null && mAdView != null) {
169
- mAdViewLayout.setVisibility(View.VISIBLE);
170
- mAdView.resume();
164
+ .runOnUiThread(() -> {
165
+ if (mAdViewLayout != null && mAdView != null) {
166
+ mAdViewLayout.setVisibility(View.VISIBLE);
167
+ mAdView.resume();
171
168
 
172
- final BannerAdSizeInfo sizeInfo = new BannerAdSizeInfo(mAdView);
173
- notifyListeners(BannerAdPluginEvents.SizeChanged.getWebEventName(), sizeInfo);
169
+ final BannerAdSizeInfo sizeInfo = new BannerAdSizeInfo(mAdView);
170
+ notifyListeners(BannerAdPluginEvents.SizeChanged.getWebEventName(), sizeInfo);
174
171
 
175
- Log.d(logTag, "Banner AD Resumed");
176
- }
172
+ Log.d(logTag, "Banner AD Resumed");
177
173
  }
178
- );
174
+ });
179
175
 
180
176
  call.resolve();
181
177
  } catch (Exception ex) {
@@ -188,19 +184,17 @@ public class BannerExecutor extends Executor {
188
184
  if (mAdView != null) {
189
185
  activitySupplier
190
186
  .get()
191
- .runOnUiThread(
192
- () -> {
193
- if (mAdView != null) {
194
- mViewGroup.removeView(mAdViewLayout);
195
- mAdViewLayout.removeView(mAdView);
196
- mAdView.destroy();
197
- mAdView = null;
198
- Log.d(logTag, "Banner AD Removed");
199
- final BannerAdSizeInfo sizeInfo = new BannerAdSizeInfo(0, 0);
200
- notifyListeners(BannerAdPluginEvents.SizeChanged.getWebEventName(), sizeInfo);
201
- }
187
+ .runOnUiThread(() -> {
188
+ if (mAdView != null) {
189
+ mViewGroup.removeView(mAdViewLayout);
190
+ mAdViewLayout.removeView(mAdView);
191
+ mAdView.destroy();
192
+ mAdView = null;
193
+ Log.d(logTag, "Banner AD Removed");
194
+ final BannerAdSizeInfo sizeInfo = new BannerAdSizeInfo(0, 0);
195
+ notifyListeners(BannerAdPluginEvents.SizeChanged.getWebEventName(), sizeInfo);
202
196
  }
203
- );
197
+ });
204
198
  }
205
199
 
206
200
  call.resolve();
@@ -212,12 +206,10 @@ public class BannerExecutor extends Executor {
212
206
  private void updateExistingAdView(AdOptions adOptions) {
213
207
  activitySupplier
214
208
  .get()
215
- .runOnUiThread(
216
- () -> {
217
- final AdRequest adRequest = RequestHelper.createRequest(adOptions);
218
- mAdView.loadAd(adRequest);
219
- }
220
- );
209
+ .runOnUiThread(() -> {
210
+ final AdRequest adRequest = RequestHelper.createRequest(adOptions);
211
+ mAdView.loadAd(adRequest);
212
+ });
221
213
  }
222
214
 
223
215
  /**
@@ -228,67 +220,65 @@ public class BannerExecutor extends Executor {
228
220
  // Run AdMob In Main UI Thread
229
221
  activitySupplier
230
222
  .get()
231
- .runOnUiThread(
232
- () -> {
233
- final AdRequest adRequest = RequestHelper.createRequest(adOptions);
234
- // Assign the correct id needed
235
- AdViewIdHelper.assignIdToAdView(mAdView, adOptions, adRequest, logTag, contextSupplier.get());
236
- // Add the AdView to the view hierarchy.
237
- mAdViewLayout.addView(mAdView);
238
- // Start loading the ad.
239
- mAdView.loadAd(adRequest);
240
- mAdView.setAdListener(
241
- new AdListener() {
242
- @Override
243
- public void onAdLoaded() {
244
- final BannerAdSizeInfo sizeInfo = new BannerAdSizeInfo(mAdView);
245
-
246
- notifyListeners(BannerAdPluginEvents.SizeChanged.getWebEventName(), sizeInfo);
247
- notifyListeners(BannerAdPluginEvents.Loaded.getWebEventName(), emptyObject);
248
- super.onAdLoaded();
249
- }
223
+ .runOnUiThread(() -> {
224
+ final AdRequest adRequest = RequestHelper.createRequest(adOptions);
225
+ // Assign the correct id needed
226
+ AdViewIdHelper.assignIdToAdView(mAdView, adOptions, adRequest, logTag, contextSupplier.get());
227
+ // Add the AdView to the view hierarchy.
228
+ mAdViewLayout.addView(mAdView);
229
+ // Start loading the ad.
230
+ mAdView.loadAd(adRequest);
231
+ mAdView.setAdListener(
232
+ new AdListener() {
233
+ @Override
234
+ public void onAdLoaded() {
235
+ final BannerAdSizeInfo sizeInfo = new BannerAdSizeInfo(mAdView);
236
+
237
+ notifyListeners(BannerAdPluginEvents.SizeChanged.getWebEventName(), sizeInfo);
238
+ notifyListeners(BannerAdPluginEvents.Loaded.getWebEventName(), emptyObject);
239
+ super.onAdLoaded();
240
+ }
250
241
 
251
- @Override
252
- public void onAdFailedToLoad(@NonNull LoadAdError adError) {
253
- if (mAdView != null) {
254
- mViewGroup.removeView(mAdViewLayout);
255
- mAdViewLayout.removeView(mAdView);
256
- mAdView.destroy();
257
- mAdView = null;
258
- }
242
+ @Override
243
+ public void onAdFailedToLoad(@NonNull LoadAdError adError) {
244
+ if (mAdView != null) {
245
+ mViewGroup.removeView(mAdViewLayout);
246
+ mAdViewLayout.removeView(mAdView);
247
+ mAdView.destroy();
248
+ mAdView = null;
249
+ }
259
250
 
260
- final BannerAdSizeInfo sizeInfo = new BannerAdSizeInfo(0, 0);
261
- notifyListeners(BannerAdPluginEvents.SizeChanged.getWebEventName(), sizeInfo);
251
+ final BannerAdSizeInfo sizeInfo = new BannerAdSizeInfo(0, 0);
252
+ notifyListeners(BannerAdPluginEvents.SizeChanged.getWebEventName(), sizeInfo);
262
253
 
263
- final AdMobPluginError adMobPluginError = new AdMobPluginError(adError);
264
- notifyListeners(BannerAdPluginEvents.FailedToLoad.getWebEventName(), adMobPluginError);
254
+ final AdMobPluginError adMobPluginError = new AdMobPluginError(adError);
255
+ notifyListeners(BannerAdPluginEvents.FailedToLoad.getWebEventName(), adMobPluginError);
265
256
 
266
- super.onAdFailedToLoad(adError);
267
- }
257
+ super.onAdFailedToLoad(adError);
258
+ }
268
259
 
269
- @Override
270
- public void onAdOpened() {
271
- notifyListeners(BannerAdPluginEvents.Opened.getWebEventName(), emptyObject);
272
- super.onAdOpened();
273
- }
260
+ @Override
261
+ public void onAdOpened() {
262
+ notifyListeners(BannerAdPluginEvents.Opened.getWebEventName(), emptyObject);
263
+ super.onAdOpened();
264
+ }
274
265
 
275
- @Override
276
- public void onAdClosed() {
277
- notifyListeners(BannerAdPluginEvents.Closed.getWebEventName(), emptyObject);
278
- super.onAdClosed();
279
- }
266
+ @Override
267
+ public void onAdClosed() {
268
+ notifyListeners(BannerAdPluginEvents.Closed.getWebEventName(), emptyObject);
269
+ super.onAdClosed();
270
+ }
280
271
 
281
- @Override
282
- public void onAdImpression() {
283
- notifyListeners(BannerAdPluginEvents.AdImpression.getWebEventName(), emptyObject);
284
- super.onAdImpression();
285
- }
272
+ @Override
273
+ public void onAdImpression() {
274
+ notifyListeners(BannerAdPluginEvents.AdImpression.getWebEventName(), emptyObject);
275
+ super.onAdImpression();
286
276
  }
287
- );
277
+ }
278
+ );
288
279
 
289
- // Add AdViewLayout top of the WebView
290
- mViewGroup.addView(mAdViewLayout);
291
- }
292
- );
280
+ // Add AdViewLayout top of the WebView
281
+ mViewGroup.addView(mAdViewLayout);
282
+ });
293
283
  }
294
284
  }
@@ -90,26 +90,22 @@ public class AdConsentExecutor extends Executor {
90
90
  ensureConsentInfo();
91
91
  activitySupplier
92
92
  .get()
93
- .runOnUiThread(
94
- () ->
95
- UserMessagingPlatform.loadConsentForm(
96
- contextSupplier.get(),
97
- consentForm ->
98
- consentForm.show(
99
- activitySupplier.get(),
100
- formError -> {
101
- if (formError != null) {
102
- call.reject("Error when show consent form", formError.getMessage());
103
- } else {
104
- JSObject consentFormInfo = new JSObject();
105
- consentFormInfo.put("status", getConsentStatusString(consentInformation.getConsentStatus()));
106
-
107
- call.resolve(consentFormInfo);
108
- }
109
- }
110
- ),
111
- formError -> call.reject("Error when show consent form", formError.getMessage())
112
- )
93
+ .runOnUiThread(() ->
94
+ UserMessagingPlatform.loadConsentForm(
95
+ contextSupplier.get(),
96
+ consentForm ->
97
+ consentForm.show(activitySupplier.get(), formError -> {
98
+ if (formError != null) {
99
+ call.reject("Error when show consent form", formError.getMessage());
100
+ } else {
101
+ JSObject consentFormInfo = new JSObject();
102
+ consentFormInfo.put("status", getConsentStatusString(consentInformation.getConsentStatus()));
103
+
104
+ call.resolve(consentFormInfo);
105
+ }
106
+ }),
107
+ formError -> call.reject("Error when show consent form", formError.getMessage())
108
+ )
113
109
  );
114
110
  } catch (Exception ex) {
115
111
  call.reject(ex.getLocalizedMessage(), ex);
@@ -38,18 +38,16 @@ public class AdInterstitialExecutor extends Executor {
38
38
  try {
39
39
  activitySupplier
40
40
  .get()
41
- .runOnUiThread(
42
- () -> {
43
- final AdRequest adRequest = RequestHelper.createRequest(adOptions);
44
- final String id = AdViewIdHelper.getFinalAdId(adOptions, adRequest, logTag, contextSupplier.get());
45
- InterstitialAd.load(
46
- activitySupplier.get(),
47
- id,
48
- adRequest,
49
- adCallbackAndListeners.getInterstitialAdLoadCallback(call, notifyListenersFunction)
50
- );
51
- }
52
- );
41
+ .runOnUiThread(() -> {
42
+ final AdRequest adRequest = RequestHelper.createRequest(adOptions);
43
+ final String id = AdViewIdHelper.getFinalAdId(adOptions, adRequest, logTag, contextSupplier.get());
44
+ InterstitialAd.load(
45
+ activitySupplier.get(),
46
+ id,
47
+ adRequest,
48
+ adCallbackAndListeners.getInterstitialAdLoadCallback(call, notifyListenersFunction)
49
+ );
50
+ });
53
51
  } catch (Exception ex) {
54
52
  call.reject(ex.getLocalizedMessage(), ex);
55
53
  }
@@ -66,15 +64,13 @@ public class AdInterstitialExecutor extends Executor {
66
64
 
67
65
  activitySupplier
68
66
  .get()
69
- .runOnUiThread(
70
- () -> {
71
- try {
72
- interstitialAd.show(activitySupplier.get());
73
- call.resolve();
74
- } catch (Exception ex) {
75
- call.reject(ex.getLocalizedMessage(), ex);
76
- }
67
+ .runOnUiThread(() -> {
68
+ try {
69
+ interstitialAd.show(activitySupplier.get());
70
+ call.resolve();
71
+ } catch (Exception ex) {
72
+ call.reject(ex.getLocalizedMessage(), ex);
77
73
  }
78
- );
74
+ });
79
75
  }
80
76
  }
@@ -34,22 +34,20 @@ public class AdRewardExecutor extends Executor {
34
34
 
35
35
  activitySupplier
36
36
  .get()
37
- .runOnUiThread(
38
- () -> {
39
- try {
40
- final AdRequest adRequest = RequestHelper.createRequest(adOptions);
41
- final String id = AdViewIdHelper.getFinalAdId(adOptions, adRequest, logTag, contextSupplier.get());
42
- RewardedAd.load(
43
- contextSupplier.get(),
44
- id,
45
- adRequest,
46
- RewardedAdCallbackAndListeners.INSTANCE.getRewardedAdLoadCallback(call, notifyListenersFunction, adOptions)
47
- );
48
- } catch (Exception ex) {
49
- call.reject(ex.getLocalizedMessage(), ex);
50
- }
37
+ .runOnUiThread(() -> {
38
+ try {
39
+ final AdRequest adRequest = RequestHelper.createRequest(adOptions);
40
+ final String id = AdViewIdHelper.getFinalAdId(adOptions, adRequest, logTag, contextSupplier.get());
41
+ RewardedAd.load(
42
+ contextSupplier.get(),
43
+ id,
44
+ adRequest,
45
+ RewardedAdCallbackAndListeners.INSTANCE.getRewardedAdLoadCallback(call, notifyListenersFunction, adOptions)
46
+ );
47
+ } catch (Exception ex) {
48
+ call.reject(ex.getLocalizedMessage(), ex);
51
49
  }
52
- );
50
+ });
53
51
  }
54
52
 
55
53
  @PluginMethod
@@ -65,14 +63,12 @@ public class AdRewardExecutor extends Executor {
65
63
  try {
66
64
  activitySupplier
67
65
  .get()
68
- .runOnUiThread(
69
- () -> {
70
- mRewardedAd.show(
71
- activitySupplier.get(),
72
- RewardedAdCallbackAndListeners.INSTANCE.getOnUserEarnedRewardListener(call, notifyListenersFunction)
73
- );
74
- }
75
- );
66
+ .runOnUiThread(() -> {
67
+ mRewardedAd.show(
68
+ activitySupplier.get(),
69
+ RewardedAdCallbackAndListeners.INSTANCE.getOnUserEarnedRewardListener(call, notifyListenersFunction)
70
+ );
71
+ });
76
72
  } catch (Exception ex) {
77
73
  call.reject(ex.getLocalizedMessage(), ex);
78
74
  }
@@ -34,26 +34,24 @@ public class AdRewardInterstitialExecutor extends Executor {
34
34
 
35
35
  activitySupplier
36
36
  .get()
37
- .runOnUiThread(
38
- () -> {
39
- try {
40
- final AdRequest adRequest = RequestHelper.createRequest(adOptions);
41
- final String id = AdViewIdHelper.getFinalAdId(adOptions, adRequest, logTag, contextSupplier.get());
42
- RewardedInterstitialAd.load(
43
- contextSupplier.get(),
44
- id,
45
- adRequest,
46
- RewardedInterstitialAdCallbackAndListeners.INSTANCE.getRewardedAdLoadCallback(
47
- call,
48
- notifyListenersFunction,
49
- adOptions
50
- )
51
- );
52
- } catch (Exception ex) {
53
- call.reject(ex.getLocalizedMessage(), ex);
54
- }
37
+ .runOnUiThread(() -> {
38
+ try {
39
+ final AdRequest adRequest = RequestHelper.createRequest(adOptions);
40
+ final String id = AdViewIdHelper.getFinalAdId(adOptions, adRequest, logTag, contextSupplier.get());
41
+ RewardedInterstitialAd.load(
42
+ contextSupplier.get(),
43
+ id,
44
+ adRequest,
45
+ RewardedInterstitialAdCallbackAndListeners.INSTANCE.getRewardedAdLoadCallback(
46
+ call,
47
+ notifyListenersFunction,
48
+ adOptions
49
+ )
50
+ );
51
+ } catch (Exception ex) {
52
+ call.reject(ex.getLocalizedMessage(), ex);
55
53
  }
56
- );
54
+ });
57
55
  }
58
56
 
59
57
  @PluginMethod
@@ -69,14 +67,12 @@ public class AdRewardInterstitialExecutor extends Executor {
69
67
  try {
70
68
  activitySupplier
71
69
  .get()
72
- .runOnUiThread(
73
- () -> {
74
- mRewardedInterstitialAd.show(
75
- activitySupplier.get(),
76
- RewardedInterstitialAdCallbackAndListeners.INSTANCE.getOnUserEarnedRewardListener(call, notifyListenersFunction)
77
- );
78
- }
79
- );
70
+ .runOnUiThread(() -> {
71
+ mRewardedInterstitialAd.show(
72
+ activitySupplier.get(),
73
+ RewardedInterstitialAdCallbackAndListeners.INSTANCE.getOnUserEarnedRewardListener(call, notifyListenersFunction)
74
+ );
75
+ });
80
76
  } catch (Exception ex) {
81
77
  call.reject(ex.getLocalizedMessage(), ex);
82
78
  }