更换Unity SDK
This commit is contained in:
parent
fb78476fc9
commit
aeda180cc8
1
.gitignore
vendored
1
.gitignore
vendored
@ -15,3 +15,4 @@
|
||||
local.properties
|
||||
.idea/
|
||||
.safedk/
|
||||
app/debug/
|
||||
|
||||
@ -1,29 +1,36 @@
|
||||
|
||||
import java.util.Date
|
||||
import java.text.SimpleDateFormat
|
||||
plugins {
|
||||
id("com.android.application")
|
||||
id("org.jetbrains.kotlin.android")
|
||||
id("applovin-quality-service")
|
||||
id("com.google.gms.google-services")
|
||||
id("com.google.firebase.crashlytics")
|
||||
}
|
||||
applovin{
|
||||
apiKey = "10baBtdCVFTrdqwoQ7FR4KVx3t_Ik1LAkFM1K8kzJN5R9WEa1arWsJrInJTdTR2X8sXvG_dbl13EIvMMsmCkpq"
|
||||
}
|
||||
|
||||
val timestamp = SimpleDateFormat("MM_dd_HH_mm").format(Date())
|
||||
android {
|
||||
namespace = "com.input.board.appskey.keyboard"
|
||||
compileSdk = 34
|
||||
|
||||
defaultConfig {
|
||||
applicationId = "com.input.board.appskey.keyboard"
|
||||
applicationId = "com.nova.keyboard"
|
||||
minSdk = 23
|
||||
targetSdk = 34
|
||||
versionCode = 2
|
||||
versionName = "1.0.1"
|
||||
|
||||
versionCode = 3
|
||||
versionName = "1.0.2"
|
||||
setProperty("archivesBaseName", "Nova keyboard_V" + versionName + "(${versionCode})_$timestamp")
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
debug {
|
||||
isMinifyEnabled = true
|
||||
proguardFiles(
|
||||
getDefaultProguardFile("proguard-android-optimize.txt"),
|
||||
"proguard-rules.pro"
|
||||
)
|
||||
}
|
||||
release {
|
||||
isMinifyEnabled = true
|
||||
proguardFiles(
|
||||
@ -52,19 +59,18 @@ dependencies {
|
||||
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
|
||||
|
||||
|
||||
implementation ("com.squareup.okhttp3:okhttp:4.11.0")
|
||||
implementation ("com.github.bumptech.glide:glide:4.16.0")
|
||||
implementation("com.squareup.okhttp3:okhttp:4.11.0")
|
||||
implementation("com.github.bumptech.glide:glide:4.16.0")
|
||||
//Glide支持webp动图的库
|
||||
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.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("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
|
||||
# hide the original source file name.
|
||||
#-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 net.sf.sevenzipjbinding.** { *; }
|
||||
|
||||
# pangel
|
||||
-keep class com.bytedance.sdk.** { *; }
|
||||
#======================UNity 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,24 +1,41 @@
|
||||
package com.input.board.appskey.keyboard
|
||||
|
||||
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.deFile
|
||||
import com.input.board.appskey.keyboard.jsonBean.ChildBean
|
||||
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
|
||||
|
||||
class KeyBoardApp : Application() {
|
||||
companion object {
|
||||
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() {
|
||||
super.onCreate()
|
||||
appInstance = this
|
||||
initializeAppLovin()
|
||||
|
||||
initUNity()
|
||||
dealFile()
|
||||
}
|
||||
|
||||
@ -32,28 +49,29 @@ class KeyBoardApp : Application() {
|
||||
|
||||
private fun resolveJsonString(string: String) {
|
||||
val jsonData = JSONArray(string)
|
||||
var dataList:MutableList<MainBean> = mutableListOf()
|
||||
var dataList: MutableList<MainBean> = mutableListOf()
|
||||
for (i in 0 until jsonData.length()) {
|
||||
jsonData.getJSONObject(i).run {
|
||||
val pName = getString("parent_name")
|
||||
val listArray = getJSONArray("keyboard_list")
|
||||
var childBeanList:MutableList<ChildBean> = mutableListOf()
|
||||
for (listIndex in 0 until listArray.length()){
|
||||
var childBeanList: MutableList<ChildBean> = mutableListOf()
|
||||
for (listIndex in 0 until listArray.length()) {
|
||||
listArray.getJSONObject(listIndex).also {
|
||||
val title = it.getString("title")
|
||||
val thUrl = it.getString("thumbUrl")
|
||||
val thGif = it.getString("thumbUrlGif")
|
||||
var zipPath =""
|
||||
var imgPath =""
|
||||
var imgGif =""
|
||||
var zipPath = ""
|
||||
var imgPath = ""
|
||||
var imgGif = ""
|
||||
var imgPreviewGif = ""
|
||||
if(it.has("detail")){
|
||||
val contentObject = it.getJSONObject("detail").getJSONObject("themeContent")
|
||||
if (it.has("detail")) {
|
||||
val contentObject =
|
||||
it.getJSONObject("detail").getJSONObject("themeContent")
|
||||
zipPath = contentObject.getString("androidRawZipUrl")
|
||||
imgPath = contentObject.getString("img")
|
||||
imgGif = contentObject.getString("imgGif")
|
||||
imgPreviewGif = contentObject.getString("imgPreviewGif")
|
||||
}else{
|
||||
} else {
|
||||
|
||||
}
|
||||
childBeanList.add(ChildBean().apply {
|
||||
@ -82,16 +100,29 @@ class KeyBoardApp : Application() {
|
||||
|
||||
}
|
||||
|
||||
private fun updateDataList(mainList:MutableList<MainBean>){
|
||||
private fun updateDataList(mainList: MutableList<MainBean>) {
|
||||
list = mainList
|
||||
|
||||
}
|
||||
|
||||
private fun initializeAppLovin(){
|
||||
AppLovinSdk.getInstance(this).mediationProvider = "max"
|
||||
AppLovinSdk.getInstance(this).initializeSdk {
|
||||
private fun initUNity() {
|
||||
Log.d(UnityAdManager.TAG,"----------------------application init")
|
||||
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.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.applovin.mediation.ads.MaxInterstitialAd
|
||||
|
||||
import com.input.board.appskey.keyboard.KeyBoardApp
|
||||
import com.input.board.appskey.keyboard.R
|
||||
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.request.RequestListener
|
||||
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.unityad.UnityAdManager
|
||||
import com.input.board.appskey.keyboard.unityad.onShowCallBack
|
||||
import java.io.File
|
||||
|
||||
class ApplyActivity : AppCompatActivity() {
|
||||
@ -54,7 +55,7 @@ class ApplyActivity : AppCompatActivity() {
|
||||
private lateinit var imgData: ImageView
|
||||
private lateinit var imgBack: ImageView
|
||||
private lateinit var textName: TextView
|
||||
private lateinit var interAd:List<MaxInterstitialAd>
|
||||
|
||||
private lateinit var recommendedRecycler: RecyclerView
|
||||
private lateinit var viewAllLayout: LinearLayout
|
||||
|
||||
@ -70,26 +71,23 @@ class ApplyActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
|
||||
private fun showEnterAd(){
|
||||
interAd = IntersitialAd.loadInterAd(this).also {
|
||||
IntersitialAd.showInterAd(it)?.let { cacheAd ->
|
||||
cacheAd.showAd()
|
||||
IntersitialAd.setAdCallback(cacheAd, object : onAdShowCallback {
|
||||
override fun displayed() {
|
||||
interAd = IntersitialAd.loadInterAd(this@ApplyActivity)
|
||||
}
|
||||
private fun showEnterAd() {
|
||||
UnityAdManager.showUnityAd(this, UnityAdManager.unitAd2, object : onShowCallBack {
|
||||
override fun onShowFail() {
|
||||
|
||||
override fun displayFail() {
|
||||
|
||||
}
|
||||
|
||||
override fun hidden() {
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
override fun onShowClose() {
|
||||
UnityAdManager.loadAd(UnityAdManager.unitAd2)
|
||||
|
||||
}
|
||||
|
||||
override fun onShowSuccess() {
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun getExtraData() {
|
||||
displayUrl = intent.getStringExtra(DISPLAY_URL_KEY).toString()
|
||||
zipUrl = intent.getStringExtra(ZIP_URL_KEY).toString()
|
||||
@ -185,9 +183,13 @@ class ApplyActivity : AppCompatActivity() {
|
||||
applyBtn.setOnClickListener {
|
||||
val checkEnable = InputMethodCom.checkEnable(this)
|
||||
val checkSetDefault = InputMethodCom.checkSetDefault(this)
|
||||
if(!checkEnable || !checkSetDefault){
|
||||
Toast.makeText(this@ApplyActivity,getString(R.string.text_promt),Toast.LENGTH_SHORT).show()
|
||||
startActivity(Intent(this,KeyBoardSettingActivity::class.java))
|
||||
if (!checkEnable || !checkSetDefault) {
|
||||
Toast.makeText(
|
||||
this@ApplyActivity,
|
||||
getString(R.string.text_promt),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
startActivity(Intent(this, KeyBoardSettingActivity::class.java))
|
||||
return@setOnClickListener
|
||||
}
|
||||
startDown()
|
||||
@ -195,23 +197,25 @@ class ApplyActivity : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun startDown(){
|
||||
private fun startDown() {
|
||||
applyBtn.isEnabled = false
|
||||
DownloadZip.startDownloadZip(zipUrl, object : onApplyCallback {
|
||||
override fun onApplyResult(fileList: List<File?>?) {
|
||||
runOnUiThread {
|
||||
applyBtn.isEnabled = true
|
||||
}
|
||||
if(fileList.isNullOrEmpty()){
|
||||
if (fileList.isNullOrEmpty()) {
|
||||
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 {
|
||||
val skinParentPath = it.substringBeforeLast("res")
|
||||
SpSkin.updateSkinPath(skinParentPath)
|
||||
runOnUiThread{
|
||||
showInterAd()
|
||||
runOnUiThread {
|
||||
showInterAd(it)
|
||||
}
|
||||
|
||||
}
|
||||
@ -222,25 +226,32 @@ class ApplyActivity : AppCompatActivity() {
|
||||
|
||||
})
|
||||
}
|
||||
private fun showInterAd(){
|
||||
val iAd = IntersitialAd.showInterAd(interAd)
|
||||
if(iAd != null){
|
||||
iAd.showAd()
|
||||
IntersitialAd.setAdCallback(iAd,object :onAdShowCallback{
|
||||
override fun displayed() {
|
||||
}
|
||||
|
||||
override fun displayFail() {
|
||||
}
|
||||
private fun apply(path: String) {
|
||||
val skinParentPath = path.substringBeforeLast("res")
|
||||
SpSkin.updateSkinPath(skinParentPath)
|
||||
Toast.makeText(
|
||||
this@ApplyActivity,
|
||||
getString(R.string.theme_application_successful),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
|
||||
override fun hidden() {
|
||||
Toast.makeText(this@ApplyActivity,getString(R.string.theme_application_successful),Toast.LENGTH_SHORT).show()
|
||||
interAd = IntersitialAd.loadInterAd(this@ApplyActivity)
|
||||
}
|
||||
private fun showInterAd(path: String) {
|
||||
UnityAdManager.showUnityAd(this, UnityAdManager.unitAd3, object : onShowCallBack {
|
||||
override fun onShowFail() {
|
||||
apply(path)
|
||||
}
|
||||
|
||||
})
|
||||
}else{
|
||||
Toast.makeText(this@ApplyActivity,getString(R.string.theme_application_successful),Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
override fun onShowClose() {
|
||||
apply(path)
|
||||
UnityAdManager.loadAd(UnityAdManager.unitAd3)
|
||||
|
||||
}
|
||||
|
||||
override fun onShowSuccess() {
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -1,36 +1,111 @@
|
||||
package com.input.board.appskey.keyboard.viewUi
|
||||
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.content.IntentFilter
|
||||
import android.os.Bundle
|
||||
import android.os.CountDownTimer
|
||||
import android.util.Log
|
||||
import android.widget.ImageView
|
||||
import android.widget.ProgressBar
|
||||
import com.applovin.mediation.MaxAd
|
||||
import com.applovin.mediation.MaxAdListener
|
||||
import com.applovin.mediation.MaxError
|
||||
import com.applovin.mediation.ads.MaxInterstitialAd
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
||||
import com.input.board.appskey.keyboard.KeyBoardApp
|
||||
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.TimerTask
|
||||
|
||||
class NovaActivity : AppCompatActivity() ,MaxAdListener{
|
||||
class NovaActivity : AppCompatActivity() {
|
||||
|
||||
private lateinit var progressBar: ProgressBar
|
||||
private lateinit var novaIm: ImageView
|
||||
private var tim = 15
|
||||
private var countTime = 11000L
|
||||
private lateinit var myTimer: Timer
|
||||
private lateinit var timer: CountDownTimer
|
||||
private var needShow = true
|
||||
|
||||
private var isShowInterAd = false
|
||||
|
||||
private var hasRecice = false
|
||||
|
||||
private var count = 0
|
||||
|
||||
private var isShowInterAd = false
|
||||
|
||||
private lateinit var mAds:List<MaxInterstitialAd>
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
UnityAdManager.loadAd(UnityAdManager.unitAd1)
|
||||
UnityAdManager.loadAd(UnityAdManager.unitAd2)
|
||||
UnityAdManager.loadAd(UnityAdManager.unitAd3)
|
||||
setContentView(R.layout.activity_nova)
|
||||
mAds = IntersitialAd.loadInterAd(this)
|
||||
init()
|
||||
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() {
|
||||
@ -38,54 +113,36 @@ class NovaActivity : AppCompatActivity() ,MaxAdListener{
|
||||
progressBar = findViewById<ProgressBar>(R.id.nova_progress)
|
||||
}
|
||||
|
||||
private fun count(){
|
||||
myTimer.schedule(object :TimerTask(){
|
||||
override fun run() {
|
||||
tim -= 1
|
||||
IntersitialAd.showInterAd(mAds)?.let {
|
||||
isShowInterAd = true
|
||||
myTimer.cancel()
|
||||
it.showAd()
|
||||
it.setListener(this@NovaActivity)
|
||||
}
|
||||
if(tim == 0){
|
||||
myTimer.cancel()
|
||||
if(!isShowInterAd){
|
||||
toHome()
|
||||
}
|
||||
|
||||
}
|
||||
private fun startShowAd(id: String, action: (isSHow: Boolean) -> Unit) {
|
||||
UnityAdManager.showUnityAd(this, id, object : onShowCallBack {
|
||||
override fun onShowFail() {
|
||||
needShow = true
|
||||
UnityAdManager.loadAd(UnityAdManager.unitAd1)
|
||||
action.invoke(false)
|
||||
}
|
||||
|
||||
},0L,1000L)
|
||||
override fun onShowClose() {
|
||||
action.invoke(true)
|
||||
UnityAdManager.loadAd(UnityAdManager.unitAd1)
|
||||
UnityAdManager.loadAd(UnityAdManager.unitAd2)
|
||||
UnityAdManager.loadAd(UnityAdManager.unitAd3)
|
||||
|
||||
}
|
||||
|
||||
override fun onShowSuccess() {
|
||||
needShow = false
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun toHome(){
|
||||
startActivity(Intent(this,HomeActivity::class.java))
|
||||
private fun toHome() {
|
||||
startActivity(Intent(this, HomeActivity::class.java))
|
||||
finish()
|
||||
}
|
||||
|
||||
override fun onAdLoaded(p0: MaxAd) {
|
||||
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
// timer.cancel()
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -5,8 +5,4 @@ plugins {
|
||||
id("com.google.gms.google-services") version "4.3.15" 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()
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
maven{url = uri("https://artifacts.applovin.com/android")}
|
||||
|
||||
}
|
||||
}
|
||||
dependencyResolutionManagement {
|
||||
@ -12,11 +12,11 @@ dependencyResolutionManagement {
|
||||
google()
|
||||
mavenCentral()
|
||||
maven("https://jitpack.io")
|
||||
maven ("https://artifact.bytedance.com/repository/pangle")
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = "MyKeyBoard"
|
||||
rootProject.name = "Nova keyboard"
|
||||
include(":app")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user