删掉 Liftoff SDK
This commit is contained in:
parent
5891a561d2
commit
f1b4823a53
@ -65,8 +65,7 @@ dependencies {
|
||||
implementation("com.google.firebase:firebase-analytics-ktx")
|
||||
implementation("com.google.firebase:firebase-crashlytics-ktx")
|
||||
|
||||
//----------------------Liftoff SDK
|
||||
implementation (libs.vungle.ads)
|
||||
|
||||
|
||||
|
||||
}
|
||||
34
app/proguard-rules.pro
vendored
34
app/proguard-rules.pro
vendored
@ -23,37 +23,3 @@
|
||||
-keep class com.sunny.app.soft.timberkeyboardnew.data.entity.BackgroundEntity { *; }
|
||||
|
||||
|
||||
#=======================================UNity SDK
|
||||
# Keep filenames and line numbers for stack traces
|
||||
-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# Keep JavascriptInterface for WebView bridge
|
||||
-keepattributes JavascriptInterface
|
||||
|
||||
|
||||
-keep class android.webkit.JavascriptInterface {
|
||||
*;
|
||||
}
|
||||
|
||||
# Keep all classes in Unity Ads package
|
||||
|
||||
-keep class com.unity3d.ads.** {
|
||||
*;
|
||||
}
|
||||
|
||||
# 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
|
||||
@ -2,11 +2,6 @@ package com.sunny.app.soft.timberkeyboardnew
|
||||
|
||||
import android.app.Application
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import com.sunny.app.soft.timberkeyboardnew.liftoff.AdManager
|
||||
import com.vungle.ads.InitializationListener
|
||||
import com.vungle.ads.VungleAds
|
||||
import com.vungle.ads.VungleError
|
||||
|
||||
class App : Application() {
|
||||
|
||||
@ -36,15 +31,7 @@ class App : Application() {
|
||||
|
||||
|
||||
private fun initLiftoff() {
|
||||
VungleAds.init(this, APP_ID, object : InitializationListener {
|
||||
override fun onSuccess() {
|
||||
Log.d(TAG, "Vungle SDK init onSuccess()")
|
||||
AdManager.loadAllAd()
|
||||
}
|
||||
override fun onError(vungleError: VungleError) {
|
||||
Log.d(TAG, "onError(): ${vungleError.localizedMessage}")
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,10 +0,0 @@
|
||||
package com.sunny.app.soft.timberkeyboardnew.liftoff
|
||||
|
||||
interface AdCallBack {
|
||||
|
||||
fun onLoaded()
|
||||
|
||||
fun onShowFail()
|
||||
|
||||
fun onClose()
|
||||
}
|
||||
@ -1,199 +0,0 @@
|
||||
package com.sunny.app.soft.timberkeyboardnew.liftoff
|
||||
|
||||
import android.content.Context
|
||||
import android.os.CountDownTimer
|
||||
import android.util.Log
|
||||
import com.sunny.app.soft.timberkeyboardnew.App
|
||||
import com.vungle.ads.AdConfig
|
||||
import com.vungle.ads.BaseAd
|
||||
import com.vungle.ads.BaseAdListener
|
||||
import com.vungle.ads.InterstitialAd
|
||||
import com.vungle.ads.InterstitialAdListener
|
||||
import com.vungle.ads.VungleError
|
||||
|
||||
object AdManager {
|
||||
/**
|
||||
* CUSTOM_KEYBOARD_ANDROID_INTER_OPEN-6034009
|
||||
* CUSTOM_KEYBOARD_ANDROID_INTER_SET-7095031
|
||||
* CUSTOM_KEYBOARD_ANDROID_INTER_THEME-1069696
|
||||
*/
|
||||
const val TAG = "============="
|
||||
const val placementId1 = "CUSTOM_KEYBOARD_ANDROID_INTER_OPEN-6034009"
|
||||
const val placementId2 = "CUSTOM_KEYBOARD_ANDROID_INTER_SET-7095031"
|
||||
const val placementId3 = "CUSTOM_KEYBOARD_ANDROID_INTER_THEME-1069696"
|
||||
|
||||
|
||||
const val adPos_0 = 0
|
||||
const val adPos_1 = 1
|
||||
const val adPos_2 = 2
|
||||
|
||||
const val NO_CACHE = 0
|
||||
const val HAS_CACHE = 1
|
||||
const val SHOW_FAIL = 2
|
||||
const val SHOW_SUCCESS = 3
|
||||
const val SHOW_CLOSE = 4
|
||||
|
||||
val list: MutableList<InterstitialAd> = mutableListOf()
|
||||
fun loadAllAd() {
|
||||
if (list.size <= 0) {
|
||||
var interstitialAd1 = InterstitialAd(App.appContext, placementId1, AdConfig().apply { })
|
||||
var interstitialAd2 = InterstitialAd(App.appContext, placementId2, AdConfig().apply { })
|
||||
var interstitialAd3 = InterstitialAd(App.appContext, placementId3, AdConfig().apply { })
|
||||
list.add(interstitialAd1)
|
||||
list.add(interstitialAd2)
|
||||
list.add(interstitialAd3)
|
||||
}
|
||||
for (ad in list) {
|
||||
if (!ad.canPlayAd()) {
|
||||
//一个广告对象show之后,不能再次load,需要新建对象
|
||||
val newAd = getNewAd(ad.placementId)
|
||||
list[list.indexOf(ad)] = newAd
|
||||
setCallBack(newAd, object : AdCallBack {
|
||||
override fun onLoaded() {
|
||||
|
||||
}
|
||||
|
||||
override fun onShowFail() {
|
||||
|
||||
}
|
||||
|
||||
override fun onClose() {
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
newAd.load()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private fun getNewAd(place: String): InterstitialAd {
|
||||
|
||||
return InterstitialAd(App.appContext, place, AdConfig().apply { })
|
||||
}
|
||||
|
||||
|
||||
private fun getReadyAd(pos: Int): InterstitialAd? {
|
||||
if (list.size <= 0) {
|
||||
return null
|
||||
}
|
||||
if (list[pos].canPlayAd()) {
|
||||
return list[pos]
|
||||
}
|
||||
for (ad in list) {
|
||||
if (ad.canPlayAd()) {
|
||||
return ad
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun showWelComeAd(totalTim: Long, actionGoMain: () -> Unit): CountDownTimer {
|
||||
var needShow = true
|
||||
val myTimer = object : CountDownTimer(totalTim, 100) {
|
||||
override fun onTick(millisUntilFinished: Long) {
|
||||
if (needShow) {
|
||||
showAd(adPos_0) {
|
||||
if (it == HAS_CACHE) {
|
||||
needShow = false
|
||||
}
|
||||
if (it == SHOW_FAIL) {
|
||||
needShow = true
|
||||
}
|
||||
if (it == SHOW_CLOSE) {
|
||||
actionGoMain.invoke()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun onFinish() {
|
||||
if (needShow) {
|
||||
showAd(adPos_0) {
|
||||
if (it == SHOW_FAIL || it == NO_CACHE || it == SHOW_CLOSE) {
|
||||
actionGoMain.invoke()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
myTimer.start()
|
||||
return myTimer
|
||||
}
|
||||
|
||||
fun showAd(firstPos: Int, action: (result: Int) -> Unit) {
|
||||
val readyAd = getReadyAd(firstPos)
|
||||
if (readyAd == null) {
|
||||
action.invoke(NO_CACHE)
|
||||
} else {
|
||||
Log.d(TAG, "-----show Ad=${readyAd.placementId}")
|
||||
action.invoke(HAS_CACHE)
|
||||
setCallBack(readyAd, object : AdCallBack {
|
||||
override fun onLoaded() {
|
||||
|
||||
}
|
||||
|
||||
override fun onShowFail() {
|
||||
action.invoke(SHOW_FAIL)
|
||||
}
|
||||
|
||||
override fun onClose() {
|
||||
action.invoke(SHOW_CLOSE)
|
||||
}
|
||||
|
||||
})
|
||||
readyAd.play()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun setCallBack(ad: InterstitialAd, callBack: AdCallBack) {
|
||||
ad.adListener = object : InterstitialAdListener {
|
||||
override fun onAdClicked(baseAd: BaseAd) {
|
||||
|
||||
}
|
||||
|
||||
override fun onAdEnd(baseAd: BaseAd) {
|
||||
callBack.onClose()
|
||||
Log.d(TAG, "onAdEnd:" + baseAd.placementId)
|
||||
loadAllAd()
|
||||
}
|
||||
|
||||
override fun onAdFailedToLoad(baseAd: BaseAd, adError: VungleError) {
|
||||
Log.d(
|
||||
TAG,
|
||||
"onAdFailedToLoad:-----${baseAd.placementId}---------${adError.code} ----${adError.errorMessage}"
|
||||
)
|
||||
}
|
||||
|
||||
override fun onAdFailedToPlay(baseAd: BaseAd, adError: VungleError) {
|
||||
callBack.onShowFail()
|
||||
Log.d(TAG, "onAdFailedToPlay:" + baseAd.placementId)
|
||||
}
|
||||
|
||||
override fun onAdImpression(baseAd: BaseAd) {
|
||||
|
||||
}
|
||||
|
||||
override fun onAdLeftApplication(baseAd: BaseAd) {
|
||||
Log.d(TAG, "onAdLeftApplication:" + baseAd.placementId)
|
||||
}
|
||||
|
||||
override fun onAdLoaded(baseAd: BaseAd) {
|
||||
callBack.onLoaded()
|
||||
Log.d(TAG, "onAdLoaded:" + baseAd.placementId)
|
||||
}
|
||||
|
||||
override fun onAdStart(baseAd: BaseAd) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -16,7 +16,6 @@ import com.bumptech.glide.request.target.Target
|
||||
import com.sunny.app.soft.timberkeyboardnew.R
|
||||
import com.sunny.app.soft.timberkeyboardnew.data.entity.BackgroundEntity
|
||||
import com.sunny.app.soft.timberkeyboardnew.databinding.ActivityDownloadBinding
|
||||
import com.sunny.app.soft.timberkeyboardnew.liftoff.AdManager
|
||||
import com.sunny.app.soft.timberkeyboardnew.tools.AppConstant
|
||||
import com.sunny.app.soft.timberkeyboardnew.tools.KeyboardManager
|
||||
import com.sunny.app.soft.timberkeyboardnew.tools.ZipTools
|
||||
@ -88,11 +87,11 @@ class DownloadActivity :
|
||||
|
||||
private fun onShowAd() {
|
||||
|
||||
AdManager.showAd(AdManager.adPos_2) {
|
||||
if (it == AdManager.SHOW_FAIL || it == AdManager.NO_CACHE || it == AdManager.SHOW_CLOSE) {
|
||||
// AdManager.showAd(AdManager.adPos_2) {
|
||||
// if (it == AdManager.SHOW_FAIL || it == AdManager.NO_CACHE || it == AdManager.SHOW_CLOSE) {
|
||||
startSetSkin()
|
||||
}
|
||||
}
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -4,7 +4,6 @@ import android.content.Intent
|
||||
import android.os.CountDownTimer
|
||||
import android.view.View
|
||||
import com.sunny.app.soft.timberkeyboardnew.databinding.ActivityLoadingBinding
|
||||
import com.sunny.app.soft.timberkeyboardnew.liftoff.AdManager
|
||||
|
||||
class LoadingActivity : BaseActivity() {
|
||||
|
||||
@ -28,9 +27,9 @@ class LoadingActivity : BaseActivity() {
|
||||
override fun initView() {
|
||||
super.initView()
|
||||
|
||||
timer = AdManager.showWelComeAd(time) {
|
||||
// timer = AdManager.showWelComeAd(time) {
|
||||
intoMainActivity()
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1,19 +1,13 @@
|
||||
package com.sunny.app.soft.timberkeyboardnew.ui.activity
|
||||
|
||||
import android.view.View
|
||||
import android.view.ViewParent
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.viewpager.widget.ViewPager
|
||||
import com.sunny.app.soft.timberkeyboardnew.App
|
||||
import com.sunny.app.soft.timberkeyboardnew.R
|
||||
import com.sunny.app.soft.timberkeyboardnew.databinding.ActivityMainBinding
|
||||
import com.sunny.app.soft.timberkeyboardnew.liftoff.AdCallBack
|
||||
import com.sunny.app.soft.timberkeyboardnew.liftoff.AdManager
|
||||
import com.sunny.app.soft.timberkeyboardnew.ui.adapter.MainViewPagerAdapter
|
||||
import com.sunny.app.soft.timberkeyboardnew.ui.fragment.HomeFragment
|
||||
import com.sunny.app.soft.timberkeyboardnew.ui.fragment.SettingFragment
|
||||
import com.vungle.ads.AdConfig
|
||||
import com.vungle.ads.InterstitialAd
|
||||
|
||||
class MainActivity :
|
||||
BaseActivity(),
|
||||
@ -30,23 +24,23 @@ class MainActivity :
|
||||
|
||||
override fun initView() {
|
||||
super.initView()
|
||||
InterstitialAd(this, AdManager.placementId1, AdConfig().apply { }).apply {
|
||||
AdManager.setCallBack(this, object : AdCallBack {
|
||||
override fun onLoaded() {
|
||||
|
||||
}
|
||||
|
||||
override fun onShowFail() {
|
||||
|
||||
}
|
||||
|
||||
override fun onClose() {
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
load()
|
||||
}
|
||||
// InterstitialAd(this, AdManager.placementId1, AdConfig().apply { }).apply {
|
||||
// AdManager.setCallBack(this, object : AdCallBack {
|
||||
// override fun onLoaded() {
|
||||
//
|
||||
// }
|
||||
//
|
||||
// override fun onShowFail() {
|
||||
//
|
||||
// }
|
||||
//
|
||||
// override fun onClose() {
|
||||
//
|
||||
// }
|
||||
//
|
||||
// })
|
||||
// load()
|
||||
// }
|
||||
|
||||
initViewPager()
|
||||
initTabButton()
|
||||
|
||||
@ -7,7 +7,6 @@ import androidx.recyclerview.widget.GridLayoutManager
|
||||
import com.sunny.app.soft.timberkeyboardnew.data.entity.BackgroundEntity
|
||||
import com.sunny.app.soft.timberkeyboardnew.data.entity.CategoryEntity
|
||||
import com.sunny.app.soft.timberkeyboardnew.databinding.ActivitySelectBinding
|
||||
import com.sunny.app.soft.timberkeyboardnew.liftoff.AdManager
|
||||
import com.sunny.app.soft.timberkeyboardnew.tools.AppConstant
|
||||
import com.sunny.app.soft.timberkeyboardnew.ui.adapter.SelectAdapter
|
||||
import com.sunny.app.soft.timberkeyboardnew.ui.listener.OnBgItemClickListener
|
||||
|
||||
@ -8,7 +8,6 @@ import com.sunny.app.soft.timberkeyboardnew.R
|
||||
import com.sunny.app.soft.timberkeyboardnew.data.DataManager
|
||||
import com.sunny.app.soft.timberkeyboardnew.data.entity.CategoryEntity
|
||||
import com.sunny.app.soft.timberkeyboardnew.databinding.FragmentHomeBinding
|
||||
import com.sunny.app.soft.timberkeyboardnew.liftoff.AdManager
|
||||
import com.sunny.app.soft.timberkeyboardnew.tools.AppConstant
|
||||
import com.sunny.app.soft.timberkeyboardnew.ui.activity.SelectActivity
|
||||
import com.sunny.app.soft.timberkeyboardnew.ui.adapter.HomeViewAdapter
|
||||
@ -61,11 +60,11 @@ class HomeFragment :
|
||||
|
||||
|
||||
fun onShowAd() {
|
||||
AdManager.showAd(AdManager.adPos_1) {
|
||||
if (it == AdManager.SHOW_FAIL || it == AdManager.NO_CACHE || it == AdManager.SHOW_CLOSE) {
|
||||
// AdManager.showAd(AdManager.adPos_1) {
|
||||
// if (it == AdManager.SHOW_FAIL || it == AdManager.NO_CACHE || it == AdManager.SHOW_CLOSE) {
|
||||
enterList()
|
||||
}
|
||||
}
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user