Skip to content

Commit

Permalink
update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
m1ga committed Nov 26, 2021
1 parent d2d6646 commit fe202ba
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 36 deletions.
20 changes: 10 additions & 10 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ dependencies {
/* Facebook */
implementation 'androidx.annotation:annotation:1.0.0'
implementation 'com.facebook.android:audience-network-sdk:6.+'
implementation 'com.google.ads.mediation:facebook:6.3.0.1'
implementation 'com.google.ads.mediation:facebook:6.8.0.0'
/* inMobi */
implementation 'com.inmobi.monetization:inmobi-ads:9.1.7'
implementation 'com.google.ads.mediation:inmobi:9.1.6.0'
implementation 'com.inmobi.monetization:inmobi-ads:10.0.1'
implementation 'com.google.ads.mediation:inmobi:10.0.1.0'
//implementation 'com.google.android.gms:play-services-ads-identifier:17.0.0'
implementation 'com.google.android.gms:play-services-location:17.1.0'//optional dependency for better targeting
implementation 'com.google.android.gms:play-services-location:18.0.0'//optional dependency for better targeting
/****/
implementation 'com.google.android.gms:play-services-base:17.6.0'
implementation 'com.google.android.gms:play-services-ads:19.8.0'
implementation 'com.google.android.gms:play-services-ads-base:19.8.0'
implementation 'com.google.android.gms:play-services-ads-identifier:17.0.0'
implementation 'com.google.android.gms:play-services-ads-lite:19.8.0'
implementation 'com.google.firebase:firebase-ads:19.8.0'
implementation 'com.google.firebase:firebase-ads-lite:19.8.0'
implementation 'com.google.android.gms:play-services-ads:20.5.0'
implementation 'com.google.android.gms:play-services-ads-base:20.5.0'
implementation 'com.google.android.gms:play-services-ads-identifier:17.1.0'
implementation 'com.google.android.gms:play-services-ads-lite:20.5.0'
implementation 'com.google.firebase:firebase-ads:20.5.0'
implementation 'com.google.firebase:firebase-ads-lite:20.5.0'
}
2 changes: 1 addition & 1 deletion android/manifest
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# during compilation, packaging, distribution, etc.
#

version: 5.0.6
version: 5.1.0
apiversion: 4
architectures: arm64-v8a armeabi-v7a x86 x86_64
description: Titanium Admob module for Android
Expand Down
16 changes: 13 additions & 3 deletions android/src/ti/admob/AdmobModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;

import androidx.annotation.NonNull;

import com.google.ads.consent.AdProvider;
import com.google.ads.consent.ConsentForm;
import com.google.ads.consent.ConsentFormListener;
Expand All @@ -21,6 +24,8 @@
import com.google.ads.consent.ConsentStatus;
import com.google.ads.consent.DebugGeography;
import com.google.ads.mediation.admob.AdMobAdapter;
import com.google.android.gms.ads.initialization.InitializationStatus;
import com.google.android.gms.ads.initialization.OnInitializationCompleteListener;
import com.inmobi.sdk.InMobiSdk;
import com.google.ads.mediation.inmobi.InMobiConsent;
import com.google.android.gms.ads.AdRequest;
Expand Down Expand Up @@ -156,7 +161,12 @@ public AdmobModule()
@Kroll.method
public void initialize(String appID)
{
MobileAds.initialize(TiApplication.getInstance(), appID);
MobileAds.initialize(TiApplication.getInstance(), new OnInitializationCompleteListener() {
@Override
public void onInitializationComplete(@NonNull InitializationStatus initializationStatus) {

}
});
}

@Kroll.method
Expand Down Expand Up @@ -557,7 +567,7 @@ public static AdRequest.Builder createRequestBuilderWithOptions(KrollDict option
}
// Handle tagForChildDirectedTreatment
if (options.containsKeyAndNotNull("tagForChildDirectedTreatment")) {
adRequestBuilder.tagForChildDirectedTreatment(options.getBoolean("tagForChildDirectedTreatment"));
//adRequestBuilder.tagForChildDirectedTreatment(options.getBoolean("tagForChildDirectedTreatment"));
}
// Handle requestAgent
if (options.containsKeyAndNotNull("requestAgent")) {
Expand All @@ -567,7 +577,7 @@ public static AdRequest.Builder createRequestBuilderWithOptions(KrollDict option
if (options.containsKeyAndNotNull("testDevices")) {
String[] testDevices = options.getStringArray("testDevices");
for (int i = 0; i < testDevices.length; i++) {
adRequestBuilder.addTestDevice(testDevices[i]);
//adRequestBuilder.addTestDevice(testDevices[i]);
}
}
return adRequestBuilder;
Expand Down
4 changes: 2 additions & 2 deletions android/src/ti/admob/AdmobView.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class AdmobView extends TiUIView

AdmobSizeProxy prop_adSize = AdmobSizeEnum.BANNER.getAdmobSizeProxy();
String prop_adUnitId;
// Put these in extras bundle of laod
// Put these in extras bundle of load
Boolean prop_debugEnabled = false;
int prop_top;
int prop_left;
Expand Down Expand Up @@ -72,7 +72,7 @@ public void run()
final AdRequest.Builder adRequestBuilder = new AdRequest.Builder();
Log.d(TAG, "requestAd(Boolean testing) -- testing:" + testing);
if (testing) {
adRequestBuilder.addTestDevice(AdRequest.DEVICE_ID_EMULATOR);
//adRequestBuilder.addTestDevice(AdRequest.DEVICE_ID_EMULATOR);
}
Bundle bundle = createAdRequestProperties();
if (bundle.size() > 0) {
Expand Down
20 changes: 10 additions & 10 deletions android/src/ti/admob/CommonAdListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@

package ti.admob;

import androidx.annotation.NonNull;

import com.google.android.gms.ads.AdListener;
import com.google.android.gms.ads.LoadAdError;

import org.appcelerator.kroll.KrollDict;
import org.appcelerator.kroll.KrollProxy;
import org.appcelerator.kroll.common.Log;
Expand Down Expand Up @@ -36,12 +40,11 @@ public void onAdLoaded()
}

@Override
public void onAdFailedToLoad(int errorCode)
{
super.onAdFailedToLoad(errorCode);
Log.d(this.sourceTag, "onAdFailedToLoad(): " + errorCode);
public void onAdFailedToLoad(@NonNull LoadAdError loadAdError) {
super.onAdFailedToLoad(loadAdError);
Log.d(this.sourceTag, "onAdFailedToLoad(): " + loadAdError);
KrollDict eventData = new KrollDict();
eventData.put("errorCode", String.valueOf(errorCode));
eventData.put("errorCode", loadAdError);
warnForDeprecatedConstant(AdmobModule.AD_NOT_RECEIVED, AdmobModule.EVENT_AD_FAIL);
this.sourceProxy.fireEvent(AdmobModule.AD_NOT_RECEIVED, eventData);
this.sourceProxy.fireEvent(AdmobModule.EVENT_AD_FAIL, eventData);
Expand All @@ -66,11 +69,8 @@ public void onAdOpened()
}

@Override
public void onAdLeftApplication()
{
super.onAdLeftApplication();
warnForDeprecatedConstant(AdmobModule.AD_LEFT_APPLICATION, AdmobModule.EVENT_AD_LEFT_APP);
this.sourceProxy.fireEvent(AdmobModule.AD_LEFT_APPLICATION, new KrollDict());
public void onAdClicked() {
super.onAdClicked();
this.sourceProxy.fireEvent(AdmobModule.EVENT_AD_LEFT_APP, new KrollDict());
}

Expand Down
40 changes: 30 additions & 10 deletions android/src/ti/admob/InterstitialAdProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,15 @@
package ti.admob;

import android.os.Bundle;

import androidx.annotation.NonNull;

import com.google.ads.mediation.admob.AdMobAdapter;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.InterstitialAd;
import com.google.android.gms.ads.LoadAdError;
import com.google.android.gms.ads.interstitial.InterstitialAd;
import com.google.android.gms.ads.interstitial.InterstitialAdLoadCallback;

import org.appcelerator.kroll.KrollDict;
import org.appcelerator.kroll.KrollProxy;
import org.appcelerator.kroll.annotations.Kroll;
Expand All @@ -21,20 +27,22 @@ public class InterstitialAdProxy extends KrollProxy
{

private final String TAG = "InterstitialAd";
private InterstitialAd interstitialAd;
private InterstitialAd mInterstitialAd;
String adId = "";

public InterstitialAdProxy()
{
this.interstitialAd = new InterstitialAd(getActivity());
this.interstitialAd.setAdListener(new CommonAdListener(this, TAG));
//this.interstitialAd = new InterstitialAd(getActivity());
//this.interstitialAd.setAdListener(new CommonAdListener(this, TAG));
}

@Override
public void handleCreationDict(KrollDict dict)
{
super.handleCreationDict(dict);
if (dict.containsKeyAndNotNull(AdmobModule.PROPERTY_AD_UNIT_ID)) {
this.interstitialAd.setAdUnitId(dict.getString(AdmobModule.PROPERTY_AD_UNIT_ID));
//this.interstitialAd.setAdUnitId(dict.getString(AdmobModule.PROPERTY_AD_UNIT_ID));
adId = dict.getString(AdmobModule.PROPERTY_AD_UNIT_ID);
}
}

Expand All @@ -46,7 +54,7 @@ public void setAdUnitId(String adUnitId)
{
// Validate the parameter
if (adUnitId != null && adUnitId instanceof String) {
this.interstitialAd.setAdUnitId(adUnitId);
//
}
}

Expand All @@ -56,21 +64,33 @@ public void setAdUnitId(String adUnitId)
public String getAdUnitId()
// clang format on
{
return this.interstitialAd.getAdUnitId();
return mInterstitialAd.getAdUnitId();
}

@Kroll.method
public void load(@Kroll.argument(optional = true) KrollDict options)
{
AdRequest.Builder adRequestBuilder = AdmobModule.createRequestBuilderWithOptions(options);
interstitialAd.loadAd(adRequestBuilder.build());
mInterstitialAd.load(getActivity(), adId, adRequestBuilder.build(), new InterstitialAdLoadCallback() {
@Override
public void onAdLoaded(@NonNull InterstitialAd interstitialAd) {
super.onAdLoaded(interstitialAd);
mInterstitialAd = interstitialAd;
}

@Override
public void onAdFailedToLoad(@NonNull LoadAdError loadAdError) {
super.onAdFailedToLoad(loadAdError);
mInterstitialAd = null;
}
});
}

@Kroll.method
public void show()
{
if (this.interstitialAd.isLoaded()) {
this.interstitialAd.show();
if (this.mInterstitialAd != null) {
this.mInterstitialAd.show(getActivity());
} else {
Log.w(TAG, "Trying to show an ad that has not been loaded.");
}
Expand Down

0 comments on commit fe202ba

Please sign in to comment.