V1.1(2)TradPlus

This commit is contained in:
litingting 2025-11-13 10:07:49 +08:00
parent fcf6ed186b
commit e2588fde54
18 changed files with 624 additions and 48 deletions

View File

@ -5,18 +5,20 @@ plugins {
alias(libs.plugins.kotlin.android) alias(libs.plugins.kotlin.android)
alias(libs.plugins.kotlin.compose) alias(libs.plugins.kotlin.compose)
id("io.objectbox") id("io.objectbox")
id("com.google.gms.google-services")
id("com.google.firebase.crashlytics")
} }
val timestamp = SimpleDateFormat("MM_dd_HH_mm").format(Date()) val timestamp = SimpleDateFormat("MM_dd_HH_mm").format(Date())
android { android {
namespace = "com.prank.funky.voice" namespace = "com.prank.funky.voice"
compileSdk = 35 compileSdk = 36
defaultConfig { defaultConfig {
applicationId = "com.prank.funky.voice" applicationId = "com.prank.funky.voice"
minSdk = 24 minSdk = 24
targetSdk = 35 targetSdk = 36
versionCode = 1 versionCode = 2
versionName = "1.0" versionName = "1.1"
setProperty("archivesBaseName", "FunkyVoice_V" + versionName + "(${versionCode})_$timestamp") setProperty("archivesBaseName", "FunkyVoice_V" + versionName + "(${versionCode})_$timestamp")
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
} }
@ -30,12 +32,16 @@ android {
) )
} }
} }
// compileOptions {
// sourceCompatibility = JavaVersion.VERSION_11
// targetCompatibility = JavaVersion.VERSION_11
// }
compileOptions { compileOptions {
sourceCompatibility = JavaVersion.VERSION_11 sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_11 targetCompatibility = JavaVersion.VERSION_1_8
} }
kotlinOptions { kotlinOptions {
jvmTarget = "11" jvmTarget = "1.8"
} }
buildFeatures { buildFeatures {
viewBinding = true viewBinding = true
@ -63,5 +69,93 @@ dependencies {
androidTestImplementation(libs.androidx.ui.test.junit4) androidTestImplementation(libs.androidx.ui.test.junit4)
debugImplementation(libs.androidx.ui.tooling) debugImplementation(libs.androidx.ui.tooling)
debugImplementation(libs.androidx.ui.test.manifest) debugImplementation(libs.androidx.ui.test.manifest)
implementation ("com.github.bumptech.glide:glide:4.16.0") implementation ("com.github.bumptech.glide:glide:5.0.5")
implementation(files("libs/UpLoadLibrary_07_03_11_54-release.aar"))
implementation ("com.squareup.okhttp3:okhttp:4.12.0")
implementation("com.squareup.okhttp3:logging-interceptor:4.12.0")
implementation(platform("com.google.firebase:firebase-bom:33.7.0"))
// When using the BoM, you don't specify versions in Firebase library dependencies
// Add the dependency for the Firebase SDK for Google Analytics
implementation("com.google.firebase:firebase-analytics")
implementation("com.google.firebase:firebase-crashlytics")
implementation("com.google.firebase:firebase-config")
// TradPlus
implementation("com.tradplusad:tradplus:14.5.0.1")
//noinspection GradleCompatible
implementation("androidx.legacy:legacy-support-v4:1.0.0")
implementation("androidx.appcompat:appcompat:1.3.0-alpha02")
// Meta
implementation("com.facebook.android:audience-network-sdk:6.20.0")
implementation("com.tradplusad:tradplus-facebook:1.14.5.0.1")
// Applovin
implementation("com.applovin:applovin-sdk:13.3.1")
implementation("com.tradplusad:tradplus-applovin:9.14.5.0.1")
implementation("com.google.android.gms:play-services-ads-identifier:18.2.0")
// Ironsource
implementation("com.ironsource.sdk:mediationsdk:8.10.0")
implementation("com.tradplusad:tradplus-ironsource:10.14.5.0.1")
implementation("com.google.android.gms:play-services-appset:16.0.0")
implementation("com.google.android.gms:play-services-ads-identifier:17.0.0")
implementation("com.google.android.gms:play-services-basement:17.5.0")
// Adcolony
implementation("com.adcolony:sdk:4.8.0")
implementation("com.tradplusad:tradplus-adcolony:4.14.5.0.1")
implementation("com.google.android.gms:play-services-ads-identifier:17.0.0")
// Pangle
implementation("com.tradplusad:tradplus-pangle:19.14.5.0.1")
implementation("com.pangle.global:pag-sdk:7.3.0.3")
// UnityAds
implementation("com.tradplusad:tradplus-unity:5.14.5.0.1")
implementation("com.unity3d.ads:unity-ads:4.15.1")
// Chartboost
implementation("com.tradplusad:tradplus-chartboostx:15.14.5.0.1")
implementation("com.chartboost:chartboost-sdk:9.8.3")
implementation("com.google.android.gms:play-services-ads-identifier:17.0.0")
implementation("com.google.android.gms:play-services-base:17.4.0")
// Inmobi
implementation("com.tradplusad:tradplus-inmobix:23.14.5.0.1")
implementation("com.inmobi.monetization:inmobi-ads-kotlin:10.8.3")
implementation("androidx.core:core-ktx:1.5.0")
implementation("com.inmobi.omsdk:inmobi-omsdk:1.5.2.0")
// Fyber
implementation("com.fyber:marketplace-sdk:8.3.7")
implementation("com.tradplusad:tradplus-fyber:24.14.5.0.1")
implementation("com.google.android.gms:play-services-ads-identifier:17.0.0")
implementation("com.google.android.gms:play-services-base:17.4.0")
// Start.io
implementation("com.startapp:inapp-sdk:5.2.3")
implementation("com.tradplusad:tradplus-startapp:28.14.5.0.1")
// Mintegral
implementation("com.tradplusad:tradplus-mintegralx_overseas:18.14.5.0.1")
implementation("androidx.recyclerview:recyclerview:1.1.0")
implementation("com.mbridge.msdk.oversea:mbridge_android_sdk:16.9.71")
// Liftoff
implementation("com.tradplusad:tradplus-vunglex:7.14.5.0.1")
implementation("com.vungle:vungle-ads:7.5.0")
// Yandex
implementation("com.yandex.android:mobileads:7.13.0") {
exclude(group = "com.caverock", module = "androidsvg-aar")
}
implementation("com.tradplusad:tradplus-yandex:50.14.6.10.1")
// Bigo
implementation("com.bigossp:bigo-ads:5.4.0")
implementation("com.tradplusad:tradplus-bigo:57.14.5.0.1")
// Cross Promotion
implementation("com.tradplusad:tradplus-crosspromotion:27.14.5.0.1")
// TP Exchange
// 请注意保持与主包版本同步更新
implementation("com.google.code.gson:gson:2.8.6")
implementation("com.tradplusad:tp_exchange:40.14.5.0.1")
// TradPlus Tools
// implementation("com.tradplusad:tradplus-tool:1.1.4")
// Google UMP
implementation ("com.google.android.ump:user-messaging-platform:3.2.0")
} }

29
app/google-services.json Normal file
View File

@ -0,0 +1,29 @@
{
"project_info": {
"project_number": "1098450660647",
"project_id": "funky-voice",
"storage_bucket": "funky-voice.firebasestorage.app"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:1098450660647:android:ced86a0bca6189b26acd02",
"android_client_info": {
"package_name": "com.prank.funky.voice"
}
},
"oauth_client": [],
"api_key": [
{
"current_key": "AIzaSyCm8ET5NhcGvRLEmeEarGYNgwthaqPffeg"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": []
}
}
}
],
"configuration_version": "1"
}

Binary file not shown.

View File

@ -30,3 +30,6 @@
<init>(...); <init>(...);
<methods>; <methods>;
} }
-keep public class com.tradplus.** { *; }
-keep class com.tradplus.ads.** { *; }

View File

@ -10,7 +10,7 @@
<uses-permission android:name="android.permission.RECORD_AUDIO" /> <uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.AD_ID" />
<application <application
android:name="com.prank.funky.voice.App" android:name="com.prank.funky.voice.App"
android:allowBackup="true" android:allowBackup="true"
@ -20,9 +20,14 @@
android:label="@string/app_name" android:label="@string/app_name"
android:roundIcon="@mipmap/logo" android:roundIcon="@mipmap/logo"
android:supportsRtl="true" android:supportsRtl="true"
android:networkSecurityConfig="@xml/net"
tools:replace="android:networkSecurityConfig"
android:theme="@style/Theme.ThePrankApp" android:theme="@style/Theme.ThePrankApp"
tools:targetApi="31"> tools:targetApi="31">
<!-- Start.io设置COPPA-->
<meta-data
android:name="com.startapp.sdk.MIXED_AUDIENCE"
android:value="true"/>
<activity <activity
android:name="com.prank.funky.voice.recordSounds.CustomActivity" android:name="com.prank.funky.voice.recordSounds.CustomActivity"
android:exported="false" /> android:exported="false" />

View File

@ -4,6 +4,7 @@ import android.app.Application
import com.prank.funky.voice.objectBox.DbBaseFunction import com.prank.funky.voice.objectBox.DbBaseFunction
import com.prank.funky.voice.objectBox.EntitySounds import com.prank.funky.voice.objectBox.EntitySounds
import com.prank.funky.voice.utils.Util import com.prank.funky.voice.utils.Util
import com.up.uploadlibrary.UpLoadManager
import java.io.IOException import java.io.IOException
import java.util.Collections import java.util.Collections
@ -18,6 +19,9 @@ class App : Application() {
super.onCreate() super.onCreate()
mApp = this mApp = this
DbBaseFunction.init(this) DbBaseFunction.init(this)
UpLoadManager.init(this,TAG)
if (entitySoundsList != null) return if (entitySoundsList != null) return
try { try {
val open = getAssets().open("pranksounds.json") val open = getAssets().open("pranksounds.json")

View File

@ -0,0 +1,11 @@
package com.prank.funky.voice.ad
interface AdListener {
fun loadFail(){}
fun showSuccess(){}
fun showFail(){}
fun showClose(){}
}

View File

@ -0,0 +1,51 @@
package com.prank.funky.voice.ad
import android.content.Context
import android.location.Geocoder
import android.util.Log
import com.facebook.ads.AdSettings
import java.util.Locale
object MetaFacebookLDUHelper {
private const val TAG = "FacebookLDU"
/**
* 检查用户是否在加州并启用 LDU
*/
fun checkAndEnableLDU(context: Context) {
try {
val geocoder = Geocoder(context, Locale.getDefault())
val locationList = geocoder.getFromLocationName("California, USA", 1)
if (!locationList.isNullOrEmpty()) {
enableLDUForCalifornia()
} else {
disableLDU()
}
} catch (e: Exception) {
enableLDUForCalifornia()
}
}
/**
* 启用加州 LDU 模式
* country = 1 表示美国
* state = 1000 表示加州
*/
fun enableLDUForCalifornia() {
AdSettings.setDataProcessingOptions(arrayOf("LDU"), 1, 1000)
Log.d(TAG, "Facebook LDU 已启用 (加州用户)")
}
/**
* 禁用 LDU 模式恢复默认
*/
private fun disableLDU() {
AdSettings.setDataProcessingOptions(emptyArray())
Log.d(TAG, "Facebook LDU 已关闭 (非加州用户)")
}
}

View File

@ -0,0 +1,206 @@
package com.prank.funky.voice.ad
import android.app.Activity
import android.os.CountDownTimer
import android.util.Log
import com.tradplus.ads.base.bean.TPAdError
import com.tradplus.ads.base.bean.TPAdInfo
import com.tradplus.ads.open.interstitial.InterstitialAdListener
import com.tradplus.ads.open.interstitial.TPInterstitial
object TPManager {
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 = "CD5465E02C6A7D6E59F2B0F7A3872812"
const val place2Id = "995A5D9A0301959DEC2A1F0C896DE312"
const val place3Id = "AD1B17B176B83EC76EEDAD044E23BA12"
var place1LoadFail = false
var place2LoadFail = false
var place3LoadFail = false
val list = mutableListOf<TPInterstitial>()
val mTAG = "TP AD"
fun loadAllAd(activity: Activity) {
if (list.size <= 0) {
place1LoadFail = false
place2LoadFail = false
place3LoadFail = false
val mInterstitialAd1 = TPInterstitial(activity, place1Id)
val mInterstitialAd2 = TPInterstitial(activity, place2Id)
val mInterstitialAd3 = TPInterstitial(activity, place3Id)
list.add(mInterstitialAd1)
list.add(mInterstitialAd2)
list.add(mInterstitialAd3)
}
for (ad in list) {
if (!ad.isReady) {
setCallBack(ad, object : AdListener {
override fun loadFail() {
}
})
ad.loadAd()
}
}
}
fun getReadyAd(): TPInterstitial? {
list.shuffle()
for (ad in list) {
if (ad.isReady) {
Log.d(mTAG, "-cache------------")
return ad
}
}
return null
}
fun showWelcomeAd(
activity: Activity,
totalTim: Long,
countAction: (millisUntilFinished: Long) -> Unit,
goMain: () -> Unit
): CountDownTimer {
var alreadyShow = false
var timer: CountDownTimer? = null
timer = object : CountDownTimer(totalTim, 100) {
override fun onTick(millisUntilFinished: Long) {
countAction(millisUntilFinished)
Log.d(mTAG, "onTick ${Thread.currentThread().name} timer=${timer}")
if (!alreadyShow) {
showCheck(activity) {
if (it == type_has_cache) {
alreadyShow = true
}
if (it == type_show_close || it == type_show_fail) {
Log.d(
mTAG,
"goMain 111 ${Thread.currentThread().name} "
)
goMain()
}
}
}
}
override fun onFinish() {
Log.d(mTAG, "onFinish() ${Thread.currentThread().name} ")
if (!alreadyShow) {
showCheck(activity) {
if (it == type_show_close || it == type_show_fail || it == type_no_cache) {
Log.d(
mTAG,
"goMain 222 ${Thread.currentThread().name} "
)
goMain()
}
}
}
}
}
return timer
}
private fun setCallBack(ad: TPInterstitial, listener: AdListener) {
ad.setAdListener(object : InterstitialAdListener {
override fun onAdLoaded(p0: TPAdInfo?) {
Log.d(mTAG, "----onAdLoaded ${p0?.tpAdUnitId}")
}
override fun onAdFailed(p0: TPAdError?) {
listener.loadFail()
Log.d(mTAG, "----onAdFailed code=${p0?.errorCode} msg=${p0?.errorMsg}")
}
override fun onAdImpression(p0: TPAdInfo?) {
listener.showSuccess()
Log.d(mTAG, "----onAdImpression ${p0?.tpAdUnitId}")
}
override fun onAdClicked(p0: TPAdInfo?) {
}
override fun onAdClosed(p0: TPAdInfo?) {
listener.showClose()
}
override fun onAdVideoError(
p0: TPAdInfo?,
p1: TPAdError?
) {
}
override fun onAdVideoStart(p0: TPAdInfo?) {
}
override fun onAdVideoEnd(p0: TPAdInfo?) {
}
})
}
private fun showCheck(activity: Activity, action: (type: Int) -> Unit) {
val readyAd = getReadyAd()
if (readyAd != null) {
Log.d(mTAG, "readyAd ")
action(type_has_cache)
setCallBack(readyAd, object : AdListener {
override fun loadFail() {
}
override fun showSuccess() {
action(type_show_success)
}
override fun showFail() {
action(type_show_fail)
}
override fun showClose() {
action(type_show_close)
}
})
if (readyAd.isReady) {
readyAd.showAd(activity, null)
}
} else {
action(type_no_cache)
}
}
fun showTPAD(activity: Activity, listener: () -> Unit) {
showCheck(activity) { type ->
if (type == type_no_cache || type == type_show_close || type == type_show_fail) {
listener()
}
}
}
}

View File

@ -14,6 +14,7 @@ import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.prank.funky.voice.utils.RecyclerSpace import com.prank.funky.voice.utils.RecyclerSpace
import com.prank.funky.voice.R import com.prank.funky.voice.R
import com.prank.funky.voice.ad.TPManager
import com.prank.funky.voice.utils.Util import com.prank.funky.voice.utils.Util
import com.prank.funky.voice.objectBox.DbBaseFunction import com.prank.funky.voice.objectBox.DbBaseFunction
import com.prank.funky.voice.playSounds.PlaySoundsActivity import com.prank.funky.voice.playSounds.PlaySoundsActivity
@ -51,7 +52,7 @@ class CollectionActivity : AppCompatActivity() {
insets insets
} }
findViewById<FrameLayout?>(R.id.framelayout_back).setOnClickListener { finish() } findViewById<FrameLayout?>(R.id.framelayout_back).setOnClickListener { finish() }
TPManager.showTPAD(this@CollectionActivity) { }
recyclerView = findViewById(R.id.favorite_recyclerview) recyclerView = findViewById(R.id.favorite_recyclerview)
emptyLayout = findViewById(R.id.empty_favorite) emptyLayout = findViewById(R.id.empty_favorite)

View File

@ -24,6 +24,7 @@ import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat import androidx.core.view.WindowInsetsCompat
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import com.prank.funky.voice.R import com.prank.funky.voice.R
import com.prank.funky.voice.ad.TPManager
import com.prank.funky.voice.utils.Util import com.prank.funky.voice.utils.Util
import com.prank.funky.voice.objectBox.DbBaseFunction import com.prank.funky.voice.objectBox.DbBaseFunction
import com.prank.funky.voice.objectBox.EntitySoundsDetail import com.prank.funky.voice.objectBox.EntitySoundsDetail
@ -69,10 +70,14 @@ class PlaySoundsActivity : AppCompatActivity() {
insets insets
} }
onBackPressedDispatcher.addCallback(this, object : OnBackPressedCallback(true) { onBackPressedDispatcher.addCallback(this, object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() { override fun handleOnBackPressed() {
Util.showLog("-----------handleOnBackPressed") Util.showLog("-----------handleOnBackPressed")
TPManager.showTPAD(this@PlaySoundsActivity) {
backIntent() backIntent()
}
} }
@ -153,7 +158,10 @@ class PlaySoundsActivity : AppCompatActivity() {
private fun setAllClick() { private fun setAllClick() {
findViewById<FrameLayout>(R.id.framelayout_back).setOnClickListener { findViewById<FrameLayout>(R.id.framelayout_back).setOnClickListener {
Util.showLog("-----------finish") Util.showLog("-----------finish")
TPManager.showTPAD(this@PlaySoundsActivity) {
backIntent() backIntent()
}
} }
favoriteLayout.setOnClickListener { favoriteLayout.setOnClickListener {
@ -189,6 +197,8 @@ class PlaySoundsActivity : AppCompatActivity() {
clockTimer?.showDown(timerLayout) clockTimer?.showDown(timerLayout)
} }
playSoundsBtn.setOnClickListener { view -> playSoundsBtn.setOnClickListener { view ->
TPManager.showTPAD(this@PlaySoundsActivity) {
mediaPlayer?.let { mediaPlayer?.let {
if (playSoundsBtn.isSelected) { if (playSoundsBtn.isSelected) {
if (it.isPlaying) { if (it.isPlaying) {
@ -211,6 +221,7 @@ class PlaySoundsActivity : AppCompatActivity() {
playSoundsBtn.setSelected(!playSoundsBtn.isSelected) playSoundsBtn.setSelected(!playSoundsBtn.isSelected)
} }
} }
}
private fun startCountDown(time: Long) { private fun startCountDown(time: Long) {
stopCountDown() stopCountDown()

View File

@ -17,6 +17,7 @@ import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.prank.funky.voice.utils.RecyclerSpace import com.prank.funky.voice.utils.RecyclerSpace
import com.prank.funky.voice.R import com.prank.funky.voice.R
import com.prank.funky.voice.ad.TPManager
import com.prank.funky.voice.utils.Util import com.prank.funky.voice.utils.Util
import com.prank.funky.voice.objectBox.DbBaseFunction import com.prank.funky.voice.objectBox.DbBaseFunction
import com.prank.funky.voice.playSounds.PlaySoundsActivity import com.prank.funky.voice.playSounds.PlaySoundsActivity
@ -63,7 +64,7 @@ class CustomActivity : AppCompatActivity() {
recyclerViewCustom = findViewById(R.id.custom_recyclerview) recyclerViewCustom = findViewById(R.id.custom_recyclerview)
emptyLayout = findViewById(R.id.empty_custom) emptyLayout = findViewById(R.id.empty_custom)
TPManager.showTPAD(this@CustomActivity) { }
importManager = ImportManager(this) { localUri, oldName -> importManager = ImportManager(this) { localUri, oldName ->
Util.showLog("-----选择-- -$localUri") Util.showLog("-----选择-- -$localUri")
importSoundsUri = localUri importSoundsUri = localUri

View File

@ -12,6 +12,7 @@ import androidx.core.view.WindowInsetsCompat
import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.prank.funky.voice.R import com.prank.funky.voice.R
import com.prank.funky.voice.ad.TPManager
import com.prank.funky.voice.utils.RecyclerSpace import com.prank.funky.voice.utils.RecyclerSpace
import com.prank.funky.voice.utils.Util import com.prank.funky.voice.utils.Util
import com.prank.funky.voice.objectBox.EntitySounds import com.prank.funky.voice.objectBox.EntitySounds
@ -40,6 +41,7 @@ class ListActivity : AppCompatActivity() {
insets insets
} }
TPManager.showTPAD(this@ListActivity) { }
findViewById<FrameLayout>(R.id.framelayout_back).setOnClickListener { findViewById<FrameLayout>(R.id.framelayout_back).setOnClickListener {
finish() finish()
} }

View File

@ -3,19 +3,33 @@ package com.prank.funky.voice.welcome
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.os.CountDownTimer import android.os.CountDownTimer
import android.util.Log
import android.widget.ProgressBar import android.widget.ProgressBar
import android.widget.TextView import android.widget.TextView
import androidx.activity.enableEdgeToEdge import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat import androidx.core.view.WindowInsetsCompat
import com.prank.funky.voice.home.HomeActivity import com.google.android.ump.ConsentForm
import com.google.android.ump.ConsentInformation
import com.google.android.ump.ConsentRequestParameters
import com.google.android.ump.UserMessagingPlatform
import com.prank.funky.voice.R import com.prank.funky.voice.R
import com.prank.funky.voice.ad.MetaFacebookLDUHelper
import com.prank.funky.voice.ad.TPManager
import com.prank.funky.voice.home.HomeActivity
import com.tradplus.ads.base.common.TPPrivacyManager.OnPrivacyRegionListener
import com.tradplus.ads.open.TradPlusSdk
import com.tradplus.ads.open.TradPlusSdk.TradPlusInitListener
import kotlinx.coroutines.DelicateCoroutinesApi
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
class WelcomeActivity : AppCompatActivity() { class WelcomeActivity : AppCompatActivity() {
private lateinit var pb: ProgressBar private lateinit var pb: ProgressBar
private lateinit var tv_progress: TextView private lateinit var tv_progress: TextView
private val count = 2000L private val count = 12000L
private var countDownTimer:CountDownTimer? = null private var countDownTimer:CountDownTimer? = null
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
@ -30,22 +44,24 @@ class WelcomeActivity : AppCompatActivity() {
pb = findViewById(R.id.load_pb) pb = findViewById(R.id.load_pb)
tv_progress = findViewById(R.id.text_progress) tv_progress = findViewById(R.id.text_progress)
countDownTimer = object : CountDownTimer(count,100){
override fun onTick(millisUntilFinished: Long) { setPrivacyConsent()
}
private fun startCountDown(){
countDownTimer = countDownTimer?:TPManager.showWelcomeAd(this@WelcomeActivity,count,{millisUntilFinished->
val progressPercentage: Int = ((100 * millisUntilFinished) / count).toInt() val progressPercentage: Int = ((100 * millisUntilFinished) / count).toInt()
val progressInt = 100 - progressPercentage val progressInt = 100 - progressPercentage
tv_progress.text = getString(R.string.welcome_progress, progressInt) tv_progress.text = getString(R.string.welcome_progress, progressInt)
pb.progress = progressInt pb.progress = progressInt
}
override fun onFinish() { }){
tv_progress.text = getString(R.string.welcome_progress, 100) tv_progress.text = getString(R.string.welcome_progress, 100)
pb.progress = 100 pb.progress = 100
startActivity(Intent(this@WelcomeActivity, HomeActivity::class.java)) startActivity(Intent(this@WelcomeActivity, HomeActivity::class.java))
finish() finish()
} }
}
countDownTimer?.start() countDownTimer?.start()
} }
@ -53,4 +69,117 @@ class WelcomeActivity : AppCompatActivity() {
super.onDestroy() super.onDestroy()
countDownTimer?.cancel() countDownTimer?.cancel()
} }
private fun setPrivacyConsent() {
// Google UMP
val params: ConsentRequestParameters? =
ConsentRequestParameters.Builder() // 指示用户是否低于同意年龄; true 低于同意年龄
// 未满同意年龄的用户不会收到 GDPR 消息表单
.setTagForUnderAgeOfConsent(false)
.build()
val consentInformation: ConsentInformation =
UserMessagingPlatform.getConsentInformation(this)
consentInformation.requestConsentInfoUpdate(
this,
params,
ConsentInformation.OnConsentInfoUpdateSuccessListener {
UserMessagingPlatform.loadAndShowConsentFormIfRequired(
this,
ConsentForm.OnConsentFormDismissedListener { loadAndShowError ->
if (loadAndShowError != null) {
// Consent gathering failed.
}
// Consent has been gathered.
if (consentInformation.canRequestAds()) {
Log.i("TP AD", "授权完成,初始化SDK: ")
// 授权完成,初始化SDK
initTPSDK()
}
} as ConsentForm.OnConsentFormDismissedListener)
} as ConsentInformation.OnConsentInfoUpdateSuccessListener,
ConsentInformation.OnConsentInfoUpdateFailureListener { requestConsentError -> } as ConsentInformation.OnConsentInfoUpdateFailureListener)
// 用户已经进行过UMP选择
if (consentInformation.canRequestAds()) {
// 授权完成,初始化SDK
Log.i("TP AD", "用户已经进行过UMP选择,初始化SDK: ")
initTPSDK()
}
// 集成Google UMP后; 如果美国加州没有投放APP无需调用
checkAreaSetCCPA();
}
private fun checkAreaSetCCPA() {
// 判断用户是否已经选择过返回true表示已经进行过选择就不需要再次进行GDPR弹窗
val firstShowGDPR = TradPlusSdk.isFirstShowGDPR(this)
// 查询地区
TradPlusSdk.checkCurrentArea(this, object : OnPrivacyRegionListener {
override fun onSuccess(isEu: Boolean, isCn: Boolean, isCalifornia: Boolean) {
// 获取到相关地域配置后设置相关隐私API
// 集成Google UMP后无需处理欧洲地区
// 表明是欧洲地区设置GDPR弹窗
// if (isEu) {
// if (!firstShowGDPR) {
// TradPlusSdk.showUploadDataNotifyDialog(application, new TradPlusSdk.TPGDPRAuthListener() {
// @Override
// public void onAuthResult(int level) {
// // 获取设置结果并做记录true 表明用户 进行过选择
// TradPlusSdk.setIsFirstShowGDPR(application, true);
// }
// }, Const.URL.GDPR_URL); // Const.URL.GDPR_URL 为TradPlus 定义的授权页面
// }
// }
// 表明是美国加州地区设置CCPA
Log.i("TP AD", "onSuccess isCalifornia=${isCalifornia} ")
if (isCalifornia) {
// false 加州用户均不上报数据 true 接受上报数据
// 默认不上报,如果上报数据,需要让用户选择
TradPlusSdk.setCCPADoNotSell(this@WelcomeActivity, false)
MetaFacebookLDUHelper.enableLDUForCalifornia()
}
if (!isEu) {
Log.i("TP AD", "isEu= initTPSDK ")
initTPSDK()
}
}
override fun onFailed() {
// 一般为网络问题导致查询失败,开发者需要自己判断地区,然后进行隐私设置
// 然后在初始化SDK
Log.i("TP AD", "onFailed ")
MetaFacebookLDUHelper.checkAndEnableLDU(this@WelcomeActivity)
initTPSDK()
}
})
}
@OptIn(DelicateCoroutinesApi::class)
private fun initTPSDK() {
GlobalScope.launch(Dispatchers.Main) {
if (!TradPlusSdk.getIsInit()) {
TradPlusSdk.initSdk(this@WelcomeActivity, "74516D6295B6B6C71D15B49ACA505F11")
TradPlusSdk.setTradPlusInitListener(object : TradPlusInitListener {
override fun onInitSuccess() {
Log.i("TP AD", "onInitSuccess: ")
startCountDown()
// appId为TradPlus后台建的应用ID
// ImportSDKUtil.getInstance().showTestTools(this@WelcomeActivity, "74516D6295B6B6C71D15B49ACA505F11")
TPManager.loadAllAd(this@WelcomeActivity)
}
})
}
}
}
} }

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<network-security-config xmlns:tools="http://schemas.android.com/tools">
<domain-config cleartextTrafficPermitted="true">
<domain tools:ignore="NetworkSecurityConfig">mobile-server.lux-ad.com</domain>
</domain-config>
</network-security-config>

View File

@ -3,9 +3,12 @@ plugins {
alias(libs.plugins.android.application) apply false alias(libs.plugins.android.application) apply false
alias(libs.plugins.kotlin.android) apply false alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.kotlin.compose) apply false alias(libs.plugins.kotlin.compose) apply false
id("com.google.gms.google-services") version "4.4.2" apply false
id ("com.google.firebase.crashlytics") version "3.0.2" apply false
} }
buildscript{ buildscript{
dependencies{ dependencies{
classpath("io.objectbox:objectbox-gradle-plugin:4.0.3") classpath("io.objectbox:objectbox-gradle-plugin:5.0.1")
} }
} }

View File

@ -6,7 +6,7 @@
# http://www.gradle.org/docs/current/userguide/build_environment.html # http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process. # Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings. # The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 org.gradle.jvmargs=-Xmx4096m -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode. # When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. For more details, visit # This option should only be used with decoupled projects. For more details, visit
# https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects # https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects

View File

@ -16,6 +16,26 @@ dependencyResolutionManagement {
repositories { repositories {
google() google()
mavenCentral() mavenCentral()
//------------------------- TradPlus
// Ironsource
maven { url = uri("https://android-sdk.is.com/") }
// Pangle
maven {
url = uri("https://artifact.bytedance.com/repository/pangle")
}
// Chartboost
maven { url = uri("https://cboost.jfrog.io/artifactory/chartboost-ads/") }
maven {
name = "Chartboost Mediations maven repo"
url = uri("https://cboost.jfrog.io/artifactory/chartboost-mediation")
}
// Mintegral
//Launch GP market application Android X Version
//If you fail to pull the code using gradle, add the maven warehouse configuration to the project root build.gradle file
maven {
url =
uri("https://dl-maven-android.mintegral.com/repository/mbridge_android_sdk_oversea")
}
} }
} }