V1.0.6(6)TopOn 集成

This commit is contained in:
litingting 2024-07-19 14:34:09 +08:00
parent 3789b03f6b
commit 8c30de428f
9 changed files with 374 additions and 15 deletions

View File

@ -17,8 +17,8 @@ android {
applicationId "com.keyboards.journey"
minSdk 23
targetSdk 34
versionCode 5
versionName "1.0.5"
versionCode 6
versionName "1.0.6"
setProperty("archivesBaseName", "Keyboard Journey_V" + versionName + "(${versionCode})_$timestamp")
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
@ -77,4 +77,51 @@ dependencies {
implementation("com.google.firebase:firebase-analytics-ktx")
implementation("com.google.firebase:firebase-crashlytics-ktx")
implementation("com.google.firebase:firebase-config-ktx")
//-----------------------------TopOn mintegralunityadsliftoff(vungle)Bigo
//Anythink (Necessary)
implementation("com.anythink.sdk:core-tpn:6.3.68")
implementation("com.anythink.sdk:nativead-tpn:6.3.68")
implementation("com.anythink.sdk:banner-tpn:6.3.68")
implementation("com.anythink.sdk:interstitial-tpn:6.3.68")
implementation("com.anythink.sdk:rewardedvideo-tpn:6.3.68")
implementation("com.anythink.sdk:splash-tpn:6.3.68")
//Androidx (Necessary)
implementation("androidx.appcompat:appcompat:1.1.0")
implementation("androidx.browser:browser:1.4.0")
//Vungle
implementation("com.anythink.sdk:adapter-tpn-vungle:6.3.68")
implementation("com.vungle:vungle-ads:7.3.2")
implementation("com.google.android.gms:play-services-basement:18.1.0")
implementation("com.google.android.gms:play-services-ads-identifier:18.0.1")
//UnityAds
implementation("com.anythink.sdk:adapter-tpn-unityads:6.3.68")
implementation("com.unity3d.ads:unity-ads:4.9.3")
//Bigo
implementation("com.anythink.sdk:adapter-tpn-bigo:6.3.68")
implementation("com.bigossp:bigo-ads:4.7.4")
//Mintegral
implementation("com.anythink.sdk:adapter-tpn-mintegral-nonchina:6.3.68")
implementation("com.mbridge.msdk.oversea:reward:16.7.51")
implementation("com.mbridge.msdk.oversea:newinterstitial:16.7.51")
implementation("com.mbridge.msdk.oversea:mbnative:16.7.51")
implementation("com.mbridge.msdk.oversea:mbnativeadvanced:16.7.51")
implementation("com.mbridge.msdk.oversea:mbsplash:16.7.51")
implementation("com.mbridge.msdk.oversea:mbbanner:16.7.51")
implementation("com.mbridge.msdk.oversea:mbbid:16.7.51")
implementation("androidx.recyclerview:recyclerview:1.1.0")
//Tramini
implementation("com.anythink.sdk:tramini-plugin-tpn:6.3.68")
//-----------------------------TopOn
// Debugger UI Tools
// implementation ("com.anythink.sdk:debugger-ui:1.0.7")
}

View File

@ -24,3 +24,80 @@
-keep class androidx.exifinterface.** {*;}
-keep class com.omicronapplications.** { *; }
-keep class net.sf.sevenzipjbinding.** { *; }
#---------------------------------TopOn 聚合
# Vungle
-dontwarn com.vungle.ads.**
-keepclassmembers class com.vungle.ads.** {
*;
}
# Google
-keep class com.google.android.gms.** { *; }
-dontwarn com.google.android.gms.**
# START OkHttp + Okio
# JSR 305 annotations are for embedding nullability information.
-dontwarn javax.annotation.**
# A resource is loaded with a relative path so the package of this class must be preserved.
-adaptresourcefilenames okhttp3/internal/publicsuffix/PublicSuffixDatabase.gz
# Animal Sniffer compileOnly dependency to ensure APIs are compatible with older versions of Java.
-dontwarn org.codehaus.mojo.animal_sniffer.*
# OkHttp platform used only on JVM and when Conscrypt and other security providers are available.
-dontwarn okhttp3.internal.platform.**
-dontwarn org.conscrypt.**
-dontwarn org.bouncycastle.**
-dontwarn org.openjsse.**
# Animal Sniffer compileOnly dependency to ensure APIs are compatible with older versions of Java.
-dontwarn org.codehaus.mojo.animal_sniffer.*
# END OkHttp + Okio
# START Protobuf
-dontwarn com.google.protobuf.**
-keepclassmembers class com.google.protobuf.** {
*;
}
-keep class * extends com.google.protobuf.GeneratedMessageLite { *; }
# END Protobuf
-keepattributes Signature
-keepattributes *Annotation*
-keep class com.mbridge.** {*; }
-keep interface com.mbridge.** {*; }
-keep class android.support.v4.** { *; }
-dontwarn com.mbridge.**
-keep class **.R$* { public static final int mbridge*; }
-keep public class com.mbridge.* extends androidx.** { *; }
-keep public class androidx.viewpager.widget.PagerAdapter{ *; }
-keep public class androidx.viewpager.widget.ViewPager.OnPageChangeListener{ *; }
-keep interface androidx.annotation.IntDef{ *; }
-keep interface androidx.annotation.Nullable{ *; }
-keep interface androidx.annotation.CheckResult{ *; }
-keep interface androidx.annotation.NonNull{ *; }
-keep public class androidx.fragment.app.Fragment{ *; }
-keep public class androidx.core.content.FileProvider{ *; }
-keep public class androidx.core.app.NotificationCompat{ *; }
-keep public class androidx.appcompat.widget.AppCompatImageView { *; }
-keep public class androidx.recyclerview.*{ *; }
#---------------------------------TopOn 聚合

View File

@ -1,16 +1,45 @@
package com.keyboard.journey
import android.app.Application
import android.util.Log
import com.anythink.core.api.ATSDK
import com.anythink.core.api.NetTrafficeCallback
//import com.anythink.debug.api.ATDebuggerUITest
import com.keyboard.journey.topon.AdManager
class JourneyApp : Application() {
companion object {
lateinit var app: JourneyApp
const val TAG = "----------"
}
private val APPId="h6697811556e91"
private val APPKey="44f890794fdaec43c4df6cc60e345eb2"
private val debug_key="529b9d845e53ac839536d321c0b6be5f6928b24d"
override fun onCreate() {
super.onCreate()
app = this
initSDK()
}
private fun initSDK() {
ATSDK.checkIsEuTraffic(this, object : NetTrafficeCallback {
override fun onResultCallback(isEU: Boolean) {
Log.e(TAG, "onResultCallback:$isEU")
if (isEU && ATSDK.getGDPRDataLevel(this@JourneyApp) == ATSDK.UNKNOWN) {
ATSDK.showGdprAuth(this@JourneyApp)
}
}
override fun onErrorCallback(p0: String?) {
Log.e(TAG, "onErrorCallback:${p0}")
}
})
ATSDK.init( this, APPId, APPKey)
AdManager.loadAllAd()
//测试工具
// ATDebuggerUITest.showDebuggerUI(this,debug_key)
}
}

View File

@ -11,6 +11,7 @@ import com.keyboard.journey.bean.CategoryDataBean
import com.keyboard.journey.bean.ItemDataBean
import com.keyboard.journey.bean.MainDataBean
import com.keyboard.journey.databinding.JourneyCategoryDetailsActivityBinding
import com.keyboard.journey.topon.AdManager
import com.keyboard.journey.util.NetworkCallback
import com.keyboard.journey.util.NetworkUtil
import org.libpag.PAGFile
@ -35,7 +36,9 @@ class JourneyCategoryDetailsActivity : AppCompatActivity() {
super.onCreate(savedInstanceState)
binding = JourneyCategoryDetailsActivityBinding.inflate(layoutInflater)
setContentView(binding.root)
// TODO: showAd
AdManager.showAD(this@JourneyCategoryDetailsActivity){
}
bean = intent.getSerializableExtra(CATEGORY_DETAILS_BEAN_KEY) as MainDataBean?
if (bean == null) {
finish()

View File

@ -8,6 +8,7 @@ import com.gyf.immersionbar.ktx.immersionBar
import com.keyboard.journey.bean.DetailsBean
import com.keyboard.journey.bean.ItemDataBean
import com.keyboard.journey.databinding.JourneyDetailsActivityBinding
import com.keyboard.journey.topon.AdManager
import com.keyboard.journey.util.AppSharedPreferences
import com.keyboard.journey.util.NetworkCallback
import com.keyboard.journey.util.NetworkUtil
@ -31,7 +32,6 @@ class JourneyDetailsActivity : AppCompatActivity(), OnDownloadListener {
super.onCreate(savedInstanceState)
binding = JourneyDetailsActivityBinding.inflate(layoutInflater)
setContentView(binding.root)
// TODO: showAd
bean = intent.getSerializableExtra(KEY_JOURNEY_DETAILS_BEAN) as ItemDataBean?
initBar()
initView()
@ -58,12 +58,16 @@ class JourneyDetailsActivity : AppCompatActivity(), OnDownloadListener {
val imageUrl = it.themeContent.androidRawZipUrl
val b = fileIsDownload(this, imageUrl)
if (b) {
AppSharedPreferences(this).setCurrentlyThemeUrl(imageUrl)
AdManager.showAD(this@JourneyDetailsActivity){type->
if (type == AdManager.type_show_close || type == AdManager.type_show_fail || type == AdManager.type_no_cache){
AppSharedPreferences(this).setCurrentlyThemeUrl(imageUrl)
val intent = Intent(this, PreviewActivity::class.java)
intent.putExtra(PreviewActivity.KEY_PREVIEW_URL, imageUrl)
startActivity(intent)
finish()
}
}
val intent = Intent(this, PreviewActivity::class.java)
intent.putExtra(PreviewActivity.KEY_PREVIEW_URL, imageUrl)
startActivity(intent)
finish()
} else {
binding.loadingBar.visibility = View.VISIBLE
binding.downIcon.visibility = View.GONE

View File

@ -2,17 +2,20 @@ package com.keyboard.journey
import android.content.Intent
import android.os.Bundle
import android.os.CountDownTimer
import androidx.appcompat.app.AppCompatActivity
import com.gyf.immersionbar.ktx.immersionBar
import com.keyboard.journey.databinding.JourneyStartActivityBinding
import com.keyboard.journey.topon.AdManager
import org.libpag.PAGFile
class JourneyStartActivity : AppCompatActivity() {
companion object {
const val SPLASH_TIME_OUT: Long = 15000
}
private val SPLASH_TIME_OUT: Long = 11000
private lateinit var binding: JourneyStartActivityBinding
private lateinit var timer:CountDownTimer
override fun onCreate(savedInstanceState: Bundle?) {
@ -24,11 +27,16 @@ class JourneyStartActivity : AppCompatActivity() {
statusBarDarkFont(false)
}
timer = AdManager.showWelcomeAd(this@JourneyStartActivity, SPLASH_TIME_OUT) {
startMain()
}
timer.start()
loadingPlay()
startMain()
}
private fun startMain() {
val intent = Intent(this, JourneyMActivity::class.java)
startActivity(intent)
@ -51,6 +59,7 @@ class JourneyStartActivity : AppCompatActivity() {
override fun onDestroy() {
super.onDestroy()
loadingClose()
timer.cancel()
}
}

View File

@ -0,0 +1,9 @@
package com.keyboard.journey.topon
interface AdListener {
fun showSuccess()
fun showFail()
fun showClose()
}

View File

@ -0,0 +1,175 @@
package com.keyboard.journey.topon
import android.app.Activity
import android.os.CountDownTimer
import android.util.Log
import com.anythink.core.api.ATAdInfo
import com.anythink.core.api.AdError
import com.anythink.interstitial.api.ATInterstitial
import com.anythink.interstitial.api.ATInterstitialListener
import com.keyboard.journey.JourneyApp
object AdManager {
const val type_no_cache = 0
const val type_has_cache = 1
const val type_show_success = 2
const val type_show_close = 3
const val type_show_fail = 4
const val place1Id = "n669781bc9cd1e"
const val place2Id = "n669781bc3452e"
const val place3Id = "n669781bba00d8"
val list = mutableListOf<ATInterstitial>()
@JvmStatic
fun loadAllAd() {
if (list.size <= 0) {
val mInterstitialAd1 = ATInterstitial(JourneyApp.app, place1Id)
val mInterstitialAd2 = ATInterstitial(JourneyApp.app, place2Id)
val mInterstitialAd3 = ATInterstitial(JourneyApp.app, place3Id)
list.add(mInterstitialAd1)
list.add(mInterstitialAd2)
list.add(mInterstitialAd3)
}
for (ad in list) {
if (!ad.isAdReady) {
setCallBack(ad,object : AdListener {
override fun showSuccess() {
}
override fun showFail() {
}
override fun showClose() {
}
})
ad.load()
}
}
}
@JvmStatic
fun getReadyAd(): ATInterstitial? {
list.shuffle()
for (ad in list) {
if (ad.isAdReady) {
return ad
}
}
return null
}
@JvmStatic
fun showWelcomeAd(activity: Activity,totalTim: Long, goMain: () -> Unit): CountDownTimer {
var alreadyShow = false
var timer = object : CountDownTimer(totalTim, 100) {
override fun onTick(millisUntilFinished: Long) {
if (!alreadyShow) {
showAD(activity) {
if (it == type_has_cache) {
alreadyShow = true
}
if (it == type_show_close || it == type_show_fail) {
goMain.invoke()
}
}
}
}
override fun onFinish() {
if (!alreadyShow) {
showAD(activity) {
if (it == type_show_close || it == type_show_fail || it == type_no_cache) {
goMain.invoke()
}
}
}
}
}
return timer
}
private fun setCallBack(ad: ATInterstitial, listener: AdListener) {
ad.setAdListener(object : ATInterstitialListener {
override fun onInterstitialAdLoaded() {
Log.d(JourneyApp.TAG, "LoadLoaded ${ad.mPlacementId}")
}
override fun onInterstitialAdLoadFail(p0: AdError?) {
Log.d(JourneyApp.TAG, "LoadFail:${p0?.code} ${p0?.desc}")
}
override fun onInterstitialAdClicked(p0: ATAdInfo?) {
}
override fun onInterstitialAdShow(p0: ATAdInfo?) {
Log.d(JourneyApp.TAG, "AdShow ${p0?.showId} ")
listener.showSuccess()
ad.load()
}
override fun onInterstitialAdClose(p0: ATAdInfo?) {
listener.showClose()
}
override fun onInterstitialAdVideoStart(p0: ATAdInfo?) {
}
override fun onInterstitialAdVideoEnd(p0: ATAdInfo?) {
}
override fun onInterstitialAdVideoError(p0: AdError?) {
listener.showFail()
}
})
}
@JvmStatic
fun showAD(activity: Activity, action: (type: Int) -> Unit) {
val readyAd = getReadyAd()
if (readyAd!= null) {
Log.d(JourneyApp.TAG, "readyAd ${readyAd.mPlacementId} ")
action.invoke(type_has_cache)
setCallBack(readyAd,object : AdListener {
override fun showSuccess() {
action.invoke(type_show_success)
}
override fun showFail() {
action.invoke(type_show_fail)
}
override fun showClose() {
action.invoke(type_show_close)
}
})
readyAd.show(activity)
} else {
action.invoke(type_no_cache)
}
}
}

View File

@ -13,7 +13,13 @@ dependencyResolutionManagement {
mavenCentral()
maven { url 'https://jitpack.io' }
//Anythink(Core)
maven { url 'https://jfrog.anythinktech.com/artifactory/overseas_sdk'}
//Mintegral
maven { url 'https://dl-maven-android.mintegral.com/repository/mbridge_android_sdk_oversea'}
//TopOn集成测试工具
// maven { url 'https://jfrog.anythinktech.com/artifactory/debugger'}
}
}