更换Unity SDK
This commit is contained in:
parent
fb78476fc9
commit
aeda180cc8
1
.gitignore
vendored
1
.gitignore
vendored
@ -15,3 +15,4 @@
|
|||||||
local.properties
|
local.properties
|
||||||
.idea/
|
.idea/
|
||||||
.safedk/
|
.safedk/
|
||||||
|
app/debug/
|
||||||
|
|||||||
@ -1,29 +1,36 @@
|
|||||||
|
|
||||||
|
import java.util.Date
|
||||||
|
import java.text.SimpleDateFormat
|
||||||
plugins {
|
plugins {
|
||||||
id("com.android.application")
|
id("com.android.application")
|
||||||
id("org.jetbrains.kotlin.android")
|
id("org.jetbrains.kotlin.android")
|
||||||
id("applovin-quality-service")
|
|
||||||
id("com.google.gms.google-services")
|
id("com.google.gms.google-services")
|
||||||
id("com.google.firebase.crashlytics")
|
id("com.google.firebase.crashlytics")
|
||||||
}
|
}
|
||||||
applovin{
|
|
||||||
apiKey = "10baBtdCVFTrdqwoQ7FR4KVx3t_Ik1LAkFM1K8kzJN5R9WEa1arWsJrInJTdTR2X8sXvG_dbl13EIvMMsmCkpq"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
val timestamp = SimpleDateFormat("MM_dd_HH_mm").format(Date())
|
||||||
android {
|
android {
|
||||||
namespace = "com.input.board.appskey.keyboard"
|
namespace = "com.input.board.appskey.keyboard"
|
||||||
compileSdk = 34
|
compileSdk = 34
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId = "com.input.board.appskey.keyboard"
|
applicationId = "com.nova.keyboard"
|
||||||
minSdk = 23
|
minSdk = 23
|
||||||
targetSdk = 34
|
targetSdk = 34
|
||||||
versionCode = 2
|
versionCode = 3
|
||||||
versionName = "1.0.1"
|
versionName = "1.0.2"
|
||||||
|
setProperty("archivesBaseName", "Nova keyboard_V" + versionName + "(${versionCode})_$timestamp")
|
||||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
|
|
||||||
buildTypes {
|
buildTypes {
|
||||||
|
debug {
|
||||||
|
isMinifyEnabled = true
|
||||||
|
proguardFiles(
|
||||||
|
getDefaultProguardFile("proguard-android-optimize.txt"),
|
||||||
|
"proguard-rules.pro"
|
||||||
|
)
|
||||||
|
}
|
||||||
release {
|
release {
|
||||||
isMinifyEnabled = true
|
isMinifyEnabled = true
|
||||||
proguardFiles(
|
proguardFiles(
|
||||||
@ -58,13 +65,12 @@ dependencies {
|
|||||||
implementation("com.github.zjupure:webpdecoder:2.0.4.12.0")
|
implementation("com.github.zjupure:webpdecoder:2.0.4.12.0")
|
||||||
implementation("com.github.omicronapps:7-Zip-JBinding-4Android:Release-16.02-2.02")
|
implementation("com.github.omicronapps:7-Zip-JBinding-4Android:Release-16.02-2.02")
|
||||||
|
|
||||||
implementation("com.applovin:applovin-sdk:+")
|
|
||||||
implementation("com.applovin.mediation:vungle-adapter:+")
|
|
||||||
implementation("com.applovin.mediation:bytedance-adapter:+")
|
|
||||||
implementation(platform("com.google.firebase:firebase-bom:32.3.1"))
|
implementation(platform("com.google.firebase:firebase-bom:32.3.1"))
|
||||||
implementation("com.google.firebase:firebase-analytics-ktx")
|
implementation("com.google.firebase:firebase-analytics-ktx")
|
||||||
implementation("com.google.firebase:firebase-crashlytics-ktx")
|
implementation("com.google.firebase:firebase-crashlytics-ktx")
|
||||||
|
|
||||||
|
//-----------------------------Unity Ads SDK
|
||||||
|
implementation("com.unity3d.ads:unity-ads:4.9.1")
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
82
app/proguard-rules.pro
vendored
82
app/proguard-rules.pro
vendored
@ -19,8 +19,86 @@
|
|||||||
# If you keep the line number information, uncomment this to
|
# If you keep the line number information, uncomment this to
|
||||||
# hide the original source file name.
|
# hide the original source file name.
|
||||||
#-renamesourcefileattribute SourceFile
|
#-renamesourcefileattribute SourceFile
|
||||||
|
|
||||||
|
|
||||||
|
-ignorewarnings
|
||||||
|
#----------------------------Part-----基本指令区----------------------------------
|
||||||
|
# 代码混淆压缩比,在0~7之间,默认为5,一般不做修改
|
||||||
|
-optimizationpasses 5
|
||||||
|
|
||||||
|
# 混合时不使用大小写混合,混合后的类名为小写
|
||||||
|
-dontusemixedcaseclassnames
|
||||||
|
|
||||||
|
# 指定不去忽略非公共库的类
|
||||||
|
-dontskipnonpubliclibraryclasses
|
||||||
|
|
||||||
|
# 这句话能够使我们的项目混淆后产生映射文件
|
||||||
|
# 包含有类名->混淆后类名的映射关系
|
||||||
|
-verbose
|
||||||
|
|
||||||
|
# 指定不去忽略非公共库的类成员
|
||||||
|
-dontskipnonpubliclibraryclassmembers
|
||||||
|
|
||||||
|
# 不做预校验,preverify是proguard的四个步骤之一,Android不需要preverify,去掉这一步能够加快混淆速度。
|
||||||
|
-dontpreverify
|
||||||
|
|
||||||
|
# 保留Annotation不混淆
|
||||||
|
-keepattributes *Annotation*,InnerClasses
|
||||||
|
|
||||||
|
# 避免混淆泛型
|
||||||
|
-keepattributes Signature
|
||||||
|
|
||||||
|
# 抛出异常时保留代码行号
|
||||||
|
-keepattributes SourceFile,LineNumberTable
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-keep class com.omicronapplications.** { *; }
|
-keep class com.omicronapplications.** { *; }
|
||||||
-keep class net.sf.sevenzipjbinding.** { *; }
|
-keep class net.sf.sevenzipjbinding.** { *; }
|
||||||
|
|
||||||
# pangel
|
#======================UNity SDK
|
||||||
-keep class com.bytedance.sdk.** { *; }
|
# Keep filenames and line numbers for stack traces
|
||||||
|
-keepattributes SourceFile,LineNumberTable
|
||||||
|
|
||||||
|
# Keep JavascriptInterface for WebView bridge
|
||||||
|
-keepattributes JavascriptInterface
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-keepclassmembers class com.input.board.appskey.keyboard.KeyBoardApp{
|
||||||
|
public static final java.lang.String unityGameID;
|
||||||
|
|
||||||
|
}
|
||||||
|
-keep class android.webkit.JavascriptInterface {
|
||||||
|
*;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Keep all classes in Unity Ads package
|
||||||
|
|
||||||
|
-keep class com.unity3d.ads.** {
|
||||||
|
*;
|
||||||
|
}
|
||||||
|
-keep public class com.unity3d.ads.** {
|
||||||
|
public *;
|
||||||
|
}
|
||||||
|
-keep public class com.unity3d.services.** {
|
||||||
|
public *;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Keep all classes in Unity Services package
|
||||||
|
-keep class com.unity3d.services.** {
|
||||||
|
*;
|
||||||
|
}
|
||||||
|
|
||||||
|
-keep class com.google.android.gms.ads.initialization.** {
|
||||||
|
*;
|
||||||
|
}
|
||||||
|
|
||||||
|
-keep class com.google.android.gms.ads.MobileAds {
|
||||||
|
*;
|
||||||
|
}
|
||||||
|
|
||||||
|
-dontwarn com.google.ads.mediation.admob.*
|
||||||
|
-dontwarn com.google.android.gms.ads.**
|
||||||
|
#==================================UNity SDK
|
||||||
@ -1,11 +1,17 @@
|
|||||||
package com.input.board.appskey.keyboard
|
package com.input.board.appskey.keyboard
|
||||||
|
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
import com.applovin.sdk.AppLovinSdk
|
import android.content.Intent
|
||||||
|
import android.util.Log
|
||||||
|
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
||||||
import com.input.board.appskey.keyboard.fileTools.DesFile
|
import com.input.board.appskey.keyboard.fileTools.DesFile
|
||||||
import com.input.board.appskey.keyboard.fileTools.DesFile.deFile
|
import com.input.board.appskey.keyboard.fileTools.DesFile.deFile
|
||||||
import com.input.board.appskey.keyboard.jsonBean.ChildBean
|
import com.input.board.appskey.keyboard.jsonBean.ChildBean
|
||||||
import com.input.board.appskey.keyboard.jsonBean.MainBean
|
import com.input.board.appskey.keyboard.jsonBean.MainBean
|
||||||
|
import com.input.board.appskey.keyboard.unityad.UnityAdManager
|
||||||
|
import com.input.board.appskey.keyboard.unityad.onLoadCallBack
|
||||||
|
import com.unity3d.ads.IUnityAdsInitializationListener
|
||||||
|
import com.unity3d.ads.UnityAds
|
||||||
import org.json.JSONArray
|
import org.json.JSONArray
|
||||||
|
|
||||||
class KeyBoardApp : Application() {
|
class KeyBoardApp : Application() {
|
||||||
@ -13,12 +19,23 @@ class KeyBoardApp : Application() {
|
|||||||
lateinit var appInstance: KeyBoardApp
|
lateinit var appInstance: KeyBoardApp
|
||||||
|
|
||||||
lateinit var list: MutableList<MainBean>
|
lateinit var list: MutableList<MainBean>
|
||||||
|
|
||||||
|
const val unityGameID = "5649398"
|
||||||
|
|
||||||
|
const val testMode = false
|
||||||
|
|
||||||
|
var SDKOK = false
|
||||||
|
|
||||||
|
var AD1Ready = false
|
||||||
|
var AD2Ready = false
|
||||||
|
var AD3Ready = false
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
super.onCreate()
|
super.onCreate()
|
||||||
appInstance = this
|
appInstance = this
|
||||||
initializeAppLovin()
|
|
||||||
|
initUNity()
|
||||||
dealFile()
|
dealFile()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,7 +65,8 @@ class KeyBoardApp : Application() {
|
|||||||
var imgGif = ""
|
var imgGif = ""
|
||||||
var imgPreviewGif = ""
|
var imgPreviewGif = ""
|
||||||
if (it.has("detail")) {
|
if (it.has("detail")) {
|
||||||
val contentObject = it.getJSONObject("detail").getJSONObject("themeContent")
|
val contentObject =
|
||||||
|
it.getJSONObject("detail").getJSONObject("themeContent")
|
||||||
zipPath = contentObject.getString("androidRawZipUrl")
|
zipPath = contentObject.getString("androidRawZipUrl")
|
||||||
imgPath = contentObject.getString("img")
|
imgPath = contentObject.getString("img")
|
||||||
imgGif = contentObject.getString("imgGif")
|
imgGif = contentObject.getString("imgGif")
|
||||||
@ -87,11 +105,24 @@ class KeyBoardApp : Application() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initializeAppLovin(){
|
private fun initUNity() {
|
||||||
AppLovinSdk.getInstance(this).mediationProvider = "max"
|
Log.d(UnityAdManager.TAG,"----------------------application init")
|
||||||
AppLovinSdk.getInstance(this).initializeSdk {
|
UnityAds.initialize(this, unityGameID, testMode, object : IUnityAdsInitializationListener {
|
||||||
|
override fun onInitializationComplete() {
|
||||||
|
|
||||||
|
SDKOK = true
|
||||||
|
UnityAdManager.loadAllAd()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onInitializationFailed(
|
||||||
|
error: UnityAds.UnityAdsInitializationError?,
|
||||||
|
message: String?
|
||||||
|
) {
|
||||||
|
SDKOK = false
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1,92 +0,0 @@
|
|||||||
package com.input.board.appskey.keyboard.customer;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
|
|
||||||
import com.applovin.mediation.MaxAd;
|
|
||||||
import com.applovin.mediation.MaxAdListener;
|
|
||||||
import com.applovin.mediation.MaxError;
|
|
||||||
import com.applovin.mediation.ads.MaxInterstitialAd;
|
|
||||||
import com.input.board.appskey.keyboard.interf.onAdShowCallback;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class IntersitialAd {
|
|
||||||
|
|
||||||
private static String unitAd1 = "06bd48bfaba9b6ec";
|
|
||||||
private static String unitAd2 = "66a8f5e488c3adac";
|
|
||||||
private static String unitAd3 = "16413a54ebedc530";
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private static MaxInterstitialAd createAd(String unitAd, Activity act) {
|
|
||||||
MaxInterstitialAd maxInterAd = new MaxInterstitialAd(unitAd, act);
|
|
||||||
if (!maxInterAd.isReady()) {
|
|
||||||
maxInterAd.loadAd();
|
|
||||||
}else {
|
|
||||||
|
|
||||||
}
|
|
||||||
return maxInterAd;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<MaxInterstitialAd> loadInterAd(Activity act) {
|
|
||||||
MaxInterstitialAd ad1 = createAd(unitAd1, act);
|
|
||||||
MaxInterstitialAd ad2 = createAd(unitAd2, act);
|
|
||||||
MaxInterstitialAd ad3 = createAd(unitAd3, act);
|
|
||||||
List<MaxInterstitialAd> list = new ArrayList<>();
|
|
||||||
list.add(ad1);
|
|
||||||
list.add(ad2);
|
|
||||||
list.add(ad3);
|
|
||||||
Collections.shuffle(list);
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static MaxInterstitialAd showInterAd(List<MaxInterstitialAd> ads) {
|
|
||||||
Collections.shuffle(ads);
|
|
||||||
for (int index = 0; index < ads.size(); index++) {
|
|
||||||
MaxInterstitialAd interstitialAd = ads.get(index);
|
|
||||||
if (interstitialAd.isReady()) {
|
|
||||||
return interstitialAd;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setAdCallback(MaxInterstitialAd ad, onAdShowCallback showCallback) {
|
|
||||||
ad.setListener(new MaxAdListener() {
|
|
||||||
@Override
|
|
||||||
public void onAdLoaded(@NonNull MaxAd maxAd) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAdDisplayed(@NonNull MaxAd maxAd) {
|
|
||||||
showCallback.displayed();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAdHidden(@NonNull MaxAd maxAd) {
|
|
||||||
showCallback.hidden();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAdClicked(@NonNull MaxAd maxAd) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAdLoadFailed(@NonNull String s, @NonNull MaxError maxError) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAdDisplayFailed(@NonNull MaxAd maxAd, @NonNull MaxError maxError) {
|
|
||||||
showCallback.displayFail();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,34 +0,0 @@
|
|||||||
package com.input.board.appskey.keyboard.jsonBean;
|
|
||||||
|
|
||||||
public class InfoBean {
|
|
||||||
private String titleName;
|
|
||||||
|
|
||||||
private String thumbUrl;
|
|
||||||
|
|
||||||
private String thumbGif;
|
|
||||||
|
|
||||||
public String getTitleName(){
|
|
||||||
|
|
||||||
return titleName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getThumbUrl(){
|
|
||||||
|
|
||||||
return thumbUrl;
|
|
||||||
}
|
|
||||||
public String getThumbGif(){
|
|
||||||
|
|
||||||
return thumbUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void setTitleName(String name){
|
|
||||||
this.titleName = name;
|
|
||||||
}
|
|
||||||
public void setThumbUrl(String name){
|
|
||||||
this.thumbUrl = name;
|
|
||||||
}
|
|
||||||
public void setThumbGif(String name){
|
|
||||||
this.thumbGif = name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -0,0 +1,133 @@
|
|||||||
|
package com.input.board.appskey.keyboard.unityad;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||||
|
|
||||||
|
import com.input.board.appskey.keyboard.KeyBoardApp;
|
||||||
|
import com.unity3d.ads.IUnityAdsLoadListener;
|
||||||
|
import com.unity3d.ads.IUnityAdsShowListener;
|
||||||
|
import com.unity3d.ads.UnityAds;
|
||||||
|
import com.unity3d.ads.UnityAdsShowOptions;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class UnityAdManager {
|
||||||
|
|
||||||
|
|
||||||
|
public static String unitAd1 = "Nova_keyboard_ad_unity_inst_open";
|
||||||
|
public static String unitAd2 = "Nova_keyboard_ad_unity_inst_set";
|
||||||
|
public static String unitAd3 = "Nova_keyboard_ad_unity_inst_theme";
|
||||||
|
|
||||||
|
public static String ACTION = "----";
|
||||||
|
|
||||||
|
|
||||||
|
public static String TAG = "-----------------tt";
|
||||||
|
|
||||||
|
public static String KEY_UNIT ="unitAD";
|
||||||
|
|
||||||
|
public static String KEY_OK ="unit_ready";
|
||||||
|
|
||||||
|
|
||||||
|
public static void loadAllAd(){
|
||||||
|
loadAd(unitAd1, new onLoadCallBack() {
|
||||||
|
@Override
|
||||||
|
public void onIsLoad(boolean loaded) {
|
||||||
|
Log.d(TAG, "-------unitAd1" + loaded);
|
||||||
|
|
||||||
|
Intent intent = new Intent(ACTION);
|
||||||
|
intent.putExtra(KEY_UNIT,unitAd1);
|
||||||
|
intent.putExtra(KEY_OK,loaded);
|
||||||
|
LocalBroadcastManager.getInstance(KeyBoardApp.appInstance).sendBroadcast(intent);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
loadAd(unitAd2, new onLoadCallBack() {
|
||||||
|
@Override
|
||||||
|
public void onIsLoad(boolean loaded) {
|
||||||
|
|
||||||
|
Intent intent = new Intent(ACTION);
|
||||||
|
intent.putExtra(KEY_UNIT,unitAd2);
|
||||||
|
intent.putExtra(KEY_OK,loaded);
|
||||||
|
LocalBroadcastManager.getInstance(KeyBoardApp.appInstance).sendBroadcast(intent);
|
||||||
|
|
||||||
|
Log.d("------------------tt", "-------unitAd2" + loaded);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
loadAd(unitAd3, new onLoadCallBack() {
|
||||||
|
@Override
|
||||||
|
public void onIsLoad(boolean loaded) {
|
||||||
|
|
||||||
|
Intent intent = new Intent(ACTION);
|
||||||
|
intent.putExtra(KEY_UNIT,unitAd3);
|
||||||
|
intent.putExtra(KEY_OK,loaded);
|
||||||
|
LocalBroadcastManager.getInstance(KeyBoardApp.appInstance).sendBroadcast(intent);
|
||||||
|
|
||||||
|
Log.d(TAG, "-------unitAd3" + loaded);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void loadAd(String adUnitId) {
|
||||||
|
UnityAds.load(adUnitId, new IUnityAdsLoadListener() {
|
||||||
|
@Override
|
||||||
|
public void onUnityAdsAdLoaded(String placementId) {
|
||||||
|
Log.d(TAG, "------loaded-unit"+placementId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUnityAdsFailedToLoad(String placementId, UnityAds.UnityAdsLoadError error, String message) {
|
||||||
|
Log.d(TAG, "------load fail-unit"+placementId+"-----" + message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
private static void loadAd(String adUnitId, onLoadCallBack callBack) {
|
||||||
|
UnityAds.load(adUnitId, new IUnityAdsLoadListener() {
|
||||||
|
@Override
|
||||||
|
public void onUnityAdsAdLoaded(String placementId) {
|
||||||
|
Log.d(TAG, "------loaded-unit"+placementId);
|
||||||
|
callBack.onIsLoad(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUnityAdsFailedToLoad(String placementId, UnityAds.UnityAdsLoadError error, String message) {
|
||||||
|
Log.d(TAG, "------load fail-unit"+placementId+"-----" + message);
|
||||||
|
callBack.onIsLoad(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void showUnityAd(Activity activity,String adUnitId, onShowCallBack onShowCallBack) {
|
||||||
|
UnityAds.show(activity, adUnitId, new UnityAdsShowOptions(), new IUnityAdsShowListener() {
|
||||||
|
@Override
|
||||||
|
public void onUnityAdsShowFailure(String placementId, UnityAds.UnityAdsShowError error, String message) {
|
||||||
|
onShowCallBack.onShowFail();
|
||||||
|
Log.d("------------------tt", "--------onUnityAdsShowFailure---message=" + message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUnityAdsShowStart(String placementId) {
|
||||||
|
|
||||||
|
onShowCallBack.onShowSuccess();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUnityAdsShowClick(String placementId) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUnityAdsShowComplete(String placementId, UnityAds.UnityAdsShowCompletionState state) {
|
||||||
|
onShowCallBack.onShowClose();
|
||||||
|
Log.d("------------------tt", "--------onUnityAdsShowComplete---");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
package com.input.board.appskey.keyboard.unityad;
|
||||||
|
|
||||||
|
public interface onLoadCallBack {
|
||||||
|
|
||||||
|
void onIsLoad(boolean loaded);
|
||||||
|
}
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
package com.input.board.appskey.keyboard.unityad;
|
||||||
|
|
||||||
|
public interface onShowCallBack {
|
||||||
|
|
||||||
|
void onShowFail( );
|
||||||
|
void onShowClose( );
|
||||||
|
void onShowSuccess( );
|
||||||
|
}
|
||||||
@ -11,7 +11,7 @@ import android.widget.Toast
|
|||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.recyclerview.widget.GridLayoutManager
|
import androidx.recyclerview.widget.GridLayoutManager
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.applovin.mediation.ads.MaxInterstitialAd
|
|
||||||
import com.input.board.appskey.keyboard.KeyBoardApp
|
import com.input.board.appskey.keyboard.KeyBoardApp
|
||||||
import com.input.board.appskey.keyboard.R
|
import com.input.board.appskey.keyboard.R
|
||||||
import com.input.board.appskey.keyboard.fileTools.DownloadZip
|
import com.input.board.appskey.keyboard.fileTools.DownloadZip
|
||||||
@ -26,8 +26,9 @@ import com.bumptech.glide.load.DataSource
|
|||||||
import com.bumptech.glide.load.engine.GlideException
|
import com.bumptech.glide.load.engine.GlideException
|
||||||
import com.bumptech.glide.request.RequestListener
|
import com.bumptech.glide.request.RequestListener
|
||||||
import com.bumptech.glide.request.target.Target
|
import com.bumptech.glide.request.target.Target
|
||||||
import com.input.board.appskey.keyboard.customer.IntersitialAd
|
|
||||||
import com.input.board.appskey.keyboard.interf.onAdShowCallback
|
import com.input.board.appskey.keyboard.interf.onAdShowCallback
|
||||||
|
import com.input.board.appskey.keyboard.unityad.UnityAdManager
|
||||||
|
import com.input.board.appskey.keyboard.unityad.onShowCallBack
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
class ApplyActivity : AppCompatActivity() {
|
class ApplyActivity : AppCompatActivity() {
|
||||||
@ -54,7 +55,7 @@ class ApplyActivity : AppCompatActivity() {
|
|||||||
private lateinit var imgData: ImageView
|
private lateinit var imgData: ImageView
|
||||||
private lateinit var imgBack: ImageView
|
private lateinit var imgBack: ImageView
|
||||||
private lateinit var textName: TextView
|
private lateinit var textName: TextView
|
||||||
private lateinit var interAd:List<MaxInterstitialAd>
|
|
||||||
private lateinit var recommendedRecycler: RecyclerView
|
private lateinit var recommendedRecycler: RecyclerView
|
||||||
private lateinit var viewAllLayout: LinearLayout
|
private lateinit var viewAllLayout: LinearLayout
|
||||||
|
|
||||||
@ -71,25 +72,22 @@ class ApplyActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
|
|
||||||
private fun showEnterAd() {
|
private fun showEnterAd() {
|
||||||
interAd = IntersitialAd.loadInterAd(this).also {
|
UnityAdManager.showUnityAd(this, UnityAdManager.unitAd2, object : onShowCallBack {
|
||||||
IntersitialAd.showInterAd(it)?.let { cacheAd ->
|
override fun onShowFail() {
|
||||||
cacheAd.showAd()
|
|
||||||
IntersitialAd.setAdCallback(cacheAd, object : onAdShowCallback {
|
|
||||||
override fun displayed() {
|
|
||||||
interAd = IntersitialAd.loadInterAd(this@ApplyActivity)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun displayFail() {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun hidden() {
|
override fun onShowClose() {
|
||||||
|
UnityAdManager.loadAd(UnityAdManager.unitAd2)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onShowSuccess() {
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
private fun getExtraData() {
|
private fun getExtraData() {
|
||||||
displayUrl = intent.getStringExtra(DISPLAY_URL_KEY).toString()
|
displayUrl = intent.getStringExtra(DISPLAY_URL_KEY).toString()
|
||||||
zipUrl = intent.getStringExtra(ZIP_URL_KEY).toString()
|
zipUrl = intent.getStringExtra(ZIP_URL_KEY).toString()
|
||||||
@ -186,7 +184,11 @@ class ApplyActivity : AppCompatActivity() {
|
|||||||
val checkEnable = InputMethodCom.checkEnable(this)
|
val checkEnable = InputMethodCom.checkEnable(this)
|
||||||
val checkSetDefault = InputMethodCom.checkSetDefault(this)
|
val checkSetDefault = InputMethodCom.checkSetDefault(this)
|
||||||
if (!checkEnable || !checkSetDefault) {
|
if (!checkEnable || !checkSetDefault) {
|
||||||
Toast.makeText(this@ApplyActivity,getString(R.string.text_promt),Toast.LENGTH_SHORT).show()
|
Toast.makeText(
|
||||||
|
this@ApplyActivity,
|
||||||
|
getString(R.string.text_promt),
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
startActivity(Intent(this, KeyBoardSettingActivity::class.java))
|
startActivity(Intent(this, KeyBoardSettingActivity::class.java))
|
||||||
return@setOnClickListener
|
return@setOnClickListener
|
||||||
}
|
}
|
||||||
@ -204,14 +206,16 @@ class ApplyActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
if (fileList.isNullOrEmpty()) {
|
if (fileList.isNullOrEmpty()) {
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
Toast.makeText(this@ApplyActivity,getString(R.string.download_fail),Toast.LENGTH_SHORT).show()
|
Toast.makeText(
|
||||||
|
this@ApplyActivity,
|
||||||
|
getString(R.string.download_fail),
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fileList[0]?.path?.let {
|
fileList[0]?.path?.let {
|
||||||
val skinParentPath = it.substringBeforeLast("res")
|
|
||||||
SpSkin.updateSkinPath(skinParentPath)
|
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
showInterAd()
|
showInterAd(it)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -222,25 +226,32 @@ class ApplyActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
private fun showInterAd(){
|
|
||||||
val iAd = IntersitialAd.showInterAd(interAd)
|
private fun apply(path: String) {
|
||||||
if(iAd != null){
|
val skinParentPath = path.substringBeforeLast("res")
|
||||||
iAd.showAd()
|
SpSkin.updateSkinPath(skinParentPath)
|
||||||
IntersitialAd.setAdCallback(iAd,object :onAdShowCallback{
|
Toast.makeText(
|
||||||
override fun displayed() {
|
this@ApplyActivity,
|
||||||
|
getString(R.string.theme_application_successful),
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun displayFail() {
|
private fun showInterAd(path: String) {
|
||||||
|
UnityAdManager.showUnityAd(this, UnityAdManager.unitAd3, object : onShowCallBack {
|
||||||
|
override fun onShowFail() {
|
||||||
|
apply(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun hidden() {
|
override fun onShowClose() {
|
||||||
Toast.makeText(this@ApplyActivity,getString(R.string.theme_application_successful),Toast.LENGTH_SHORT).show()
|
apply(path)
|
||||||
interAd = IntersitialAd.loadInterAd(this@ApplyActivity)
|
UnityAdManager.loadAd(UnityAdManager.unitAd3)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onShowSuccess() {
|
||||||
|
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}else{
|
|
||||||
Toast.makeText(this@ApplyActivity,getString(R.string.theme_application_successful),Toast.LENGTH_SHORT).show()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,36 +1,111 @@
|
|||||||
package com.input.board.appskey.keyboard.viewUi
|
package com.input.board.appskey.keyboard.viewUi
|
||||||
|
|
||||||
|
import android.content.BroadcastReceiver
|
||||||
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import android.content.IntentFilter
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.os.CountDownTimer
|
||||||
|
import android.util.Log
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
import android.widget.ProgressBar
|
import android.widget.ProgressBar
|
||||||
import com.applovin.mediation.MaxAd
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import com.applovin.mediation.MaxAdListener
|
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
||||||
import com.applovin.mediation.MaxError
|
import com.input.board.appskey.keyboard.KeyBoardApp
|
||||||
import com.applovin.mediation.ads.MaxInterstitialAd
|
|
||||||
import com.input.board.appskey.keyboard.R
|
import com.input.board.appskey.keyboard.R
|
||||||
import com.input.board.appskey.keyboard.customer.IntersitialAd
|
import com.input.board.appskey.keyboard.unityad.UnityAdManager
|
||||||
|
import com.input.board.appskey.keyboard.unityad.onShowCallBack
|
||||||
import java.util.Timer
|
import java.util.Timer
|
||||||
import java.util.TimerTask
|
|
||||||
|
|
||||||
class NovaActivity : AppCompatActivity() ,MaxAdListener{
|
class NovaActivity : AppCompatActivity() {
|
||||||
|
|
||||||
private lateinit var progressBar: ProgressBar
|
private lateinit var progressBar: ProgressBar
|
||||||
private lateinit var novaIm: ImageView
|
private lateinit var novaIm: ImageView
|
||||||
private var tim = 15
|
private var countTime = 11000L
|
||||||
private lateinit var myTimer: Timer
|
private lateinit var myTimer: Timer
|
||||||
|
private lateinit var timer: CountDownTimer
|
||||||
|
private var needShow = true
|
||||||
|
|
||||||
private var isShowInterAd = false
|
private var isShowInterAd = false
|
||||||
|
|
||||||
private lateinit var mAds:List<MaxInterstitialAd>
|
private var hasRecice = false
|
||||||
|
|
||||||
|
private var count = 0
|
||||||
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
UnityAdManager.loadAd(UnityAdManager.unitAd1)
|
||||||
|
UnityAdManager.loadAd(UnityAdManager.unitAd2)
|
||||||
|
UnityAdManager.loadAd(UnityAdManager.unitAd3)
|
||||||
setContentView(R.layout.activity_nova)
|
setContentView(R.layout.activity_nova)
|
||||||
mAds = IntersitialAd.loadInterAd(this)
|
init()
|
||||||
findView()
|
findView()
|
||||||
myTimer = Timer()
|
}
|
||||||
count()
|
|
||||||
|
private fun init() {
|
||||||
|
|
||||||
|
if (KeyBoardApp.SDKOK) {
|
||||||
|
Log.d(UnityAdManager.TAG, "-----SDKOK")
|
||||||
|
startShowAd(UnityAdManager.unitAd1) {
|
||||||
|
if (it) {
|
||||||
|
toHome()
|
||||||
|
} else {
|
||||||
|
startShowAd(UnityAdManager.unitAd2) {
|
||||||
|
toHome()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Log.d(UnityAdManager.TAG, "-----SDKOK false")
|
||||||
|
LocalBroadcastManager.getInstance(this).registerReceiver(object : BroadcastReceiver() {
|
||||||
|
override fun onReceive(context: Context?, intent: Intent?) {
|
||||||
|
Log.d(UnityAdManager.TAG, "-----onReceive")
|
||||||
|
count++
|
||||||
|
if (hasRecice) return
|
||||||
|
if (intent != null) {
|
||||||
|
val unitAd = intent.getStringExtra(UnityAdManager.KEY_UNIT)
|
||||||
|
val booleanExtra = intent.getBooleanExtra(UnityAdManager.KEY_OK, false)
|
||||||
|
if (unitAd != null && booleanExtra) {
|
||||||
|
hasRecice = true
|
||||||
|
startShowAd(unitAd) {
|
||||||
|
toHome()
|
||||||
|
Log.d(UnityAdManager.TAG, "-----111toHome")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (count == 3 && !hasRecice) {
|
||||||
|
Log.d(UnityAdManager.TAG, "-----2222toHome")
|
||||||
|
toHome()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}, IntentFilter(UnityAdManager.ACTION))
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// timer = object : CountDownTimer(countTime, 500) {
|
||||||
|
// override fun onTick(millisUntilFinished: Long) {
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// override fun onFinish() {
|
||||||
|
// if (needShow) {
|
||||||
|
// startShowAd {
|
||||||
|
// toHome()
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
startAd()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun startAd() {
|
||||||
|
// timer.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun findView() {
|
private fun findView() {
|
||||||
@ -38,54 +113,36 @@ class NovaActivity : AppCompatActivity() ,MaxAdListener{
|
|||||||
progressBar = findViewById<ProgressBar>(R.id.nova_progress)
|
progressBar = findViewById<ProgressBar>(R.id.nova_progress)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun count(){
|
private fun startShowAd(id: String, action: (isSHow: Boolean) -> Unit) {
|
||||||
myTimer.schedule(object :TimerTask(){
|
UnityAdManager.showUnityAd(this, id, object : onShowCallBack {
|
||||||
override fun run() {
|
override fun onShowFail() {
|
||||||
tim -= 1
|
needShow = true
|
||||||
IntersitialAd.showInterAd(mAds)?.let {
|
UnityAdManager.loadAd(UnityAdManager.unitAd1)
|
||||||
isShowInterAd = true
|
action.invoke(false)
|
||||||
myTimer.cancel()
|
|
||||||
it.showAd()
|
|
||||||
it.setListener(this@NovaActivity)
|
|
||||||
}
|
|
||||||
if(tim == 0){
|
|
||||||
myTimer.cancel()
|
|
||||||
if(!isShowInterAd){
|
|
||||||
toHome()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
override fun onShowClose() {
|
||||||
|
action.invoke(true)
|
||||||
|
UnityAdManager.loadAd(UnityAdManager.unitAd1)
|
||||||
|
UnityAdManager.loadAd(UnityAdManager.unitAd2)
|
||||||
|
UnityAdManager.loadAd(UnityAdManager.unitAd3)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
},0L,1000L)
|
override fun onShowSuccess() {
|
||||||
|
needShow = false
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun toHome() {
|
private fun toHome() {
|
||||||
startActivity(Intent(this, HomeActivity::class.java))
|
startActivity(Intent(this, HomeActivity::class.java))
|
||||||
|
finish()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onAdLoaded(p0: MaxAd) {
|
override fun onDestroy() {
|
||||||
|
super.onDestroy()
|
||||||
}
|
// timer.cancel()
|
||||||
|
|
||||||
override fun onAdDisplayed(p0: MaxAd) {
|
|
||||||
IntersitialAd.loadInterAd(this)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onAdHidden(p0: MaxAd) {
|
|
||||||
toHome()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onAdClicked(p0: MaxAd) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onAdLoadFailed(p0: String, p1: MaxError) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onAdDisplayFailed(p0: MaxAd, p1: MaxError) {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -5,8 +5,4 @@ plugins {
|
|||||||
id("com.google.gms.google-services") version "4.3.15" apply false
|
id("com.google.gms.google-services") version "4.3.15" apply false
|
||||||
id ("com.google.firebase.crashlytics") version "2.9.2" apply false
|
id ("com.google.firebase.crashlytics") version "2.9.2" apply false
|
||||||
}
|
}
|
||||||
buildscript{
|
|
||||||
dependencies{
|
|
||||||
classpath("com.applovin.quality:AppLovinQualityServiceGradlePlugin:+")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@ pluginManagement {
|
|||||||
google()
|
google()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
gradlePluginPortal()
|
gradlePluginPortal()
|
||||||
maven{url = uri("https://artifacts.applovin.com/android")}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dependencyResolutionManagement {
|
dependencyResolutionManagement {
|
||||||
@ -12,11 +12,11 @@ dependencyResolutionManagement {
|
|||||||
google()
|
google()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
maven("https://jitpack.io")
|
maven("https://jitpack.io")
|
||||||
maven ("https://artifact.bytedance.com/repository/pangle")
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rootProject.name = "MyKeyBoard"
|
rootProject.name = "Nova keyboard"
|
||||||
include(":app")
|
include(":app")
|
||||||
|
|
||||||
Loading…
Reference in New Issue
Block a user