diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 6e2c4a9..f822be9 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -5,18 +5,20 @@ plugins { alias(libs.plugins.kotlin.android) alias(libs.plugins.kotlin.compose) id("io.objectbox") + id("com.google.gms.google-services") + id("com.google.firebase.crashlytics") } val timestamp = SimpleDateFormat("MM_dd_HH_mm").format(Date()) android { namespace = "com.prank.funky.voice" - compileSdk = 35 + compileSdk = 36 defaultConfig { applicationId = "com.prank.funky.voice" minSdk = 24 - targetSdk = 35 - versionCode = 1 - versionName = "1.0" + targetSdk = 36 + versionCode = 2 + versionName = "1.1" setProperty("archivesBaseName", "FunkyVoice_V" + versionName + "(${versionCode})_$timestamp") testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } @@ -30,12 +32,16 @@ android { ) } } +// compileOptions { +// sourceCompatibility = JavaVersion.VERSION_11 +// targetCompatibility = JavaVersion.VERSION_11 +// } compileOptions { - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 } kotlinOptions { - jvmTarget = "11" + jvmTarget = "1.8" } buildFeatures { viewBinding = true @@ -63,5 +69,93 @@ dependencies { androidTestImplementation(libs.androidx.ui.test.junit4) debugImplementation(libs.androidx.ui.tooling) 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") } \ No newline at end of file diff --git a/app/google-services.json b/app/google-services.json new file mode 100644 index 0000000..73ef4d2 --- /dev/null +++ b/app/google-services.json @@ -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" +} \ No newline at end of file diff --git a/app/libs/UpLoadLibrary_07_03_11_54-release.aar b/app/libs/UpLoadLibrary_07_03_11_54-release.aar new file mode 100644 index 0000000..5a50672 Binary files /dev/null and b/app/libs/UpLoadLibrary_07_03_11_54-release.aar differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 0cf19be..3cbe229 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -29,4 +29,7 @@ -keepclassmembers class * extends io.objectbox.Box { (...); ; -} \ No newline at end of file +} + +-keep public class com.tradplus.** { *; } +-keep class com.tradplus.ads.** { *; } \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 39397c0..fe509fa 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -10,7 +10,7 @@ - + - + + diff --git a/app/src/main/java/com/prank/funky/voice/App.kt b/app/src/main/java/com/prank/funky/voice/App.kt index 3d11e01..9fc5a17 100644 --- a/app/src/main/java/com/prank/funky/voice/App.kt +++ b/app/src/main/java/com/prank/funky/voice/App.kt @@ -4,6 +4,7 @@ import android.app.Application import com.prank.funky.voice.objectBox.DbBaseFunction import com.prank.funky.voice.objectBox.EntitySounds import com.prank.funky.voice.utils.Util +import com.up.uploadlibrary.UpLoadManager import java.io.IOException import java.util.Collections @@ -18,6 +19,9 @@ class App : Application() { super.onCreate() mApp = this DbBaseFunction.init(this) + + UpLoadManager.init(this,TAG) + if (entitySoundsList != null) return try { val open = getAssets().open("pranksounds.json") diff --git a/app/src/main/java/com/prank/funky/voice/ad/AdListener.kt b/app/src/main/java/com/prank/funky/voice/ad/AdListener.kt new file mode 100644 index 0000000..7a89941 --- /dev/null +++ b/app/src/main/java/com/prank/funky/voice/ad/AdListener.kt @@ -0,0 +1,11 @@ +package com.prank.funky.voice.ad + +interface AdListener { + + fun loadFail(){} + fun showSuccess(){} + + fun showFail(){} + + fun showClose(){} +} \ No newline at end of file diff --git a/app/src/main/java/com/prank/funky/voice/ad/MetaFacebookLDUHelper.kt b/app/src/main/java/com/prank/funky/voice/ad/MetaFacebookLDUHelper.kt new file mode 100644 index 0000000..bde3cf5 --- /dev/null +++ b/app/src/main/java/com/prank/funky/voice/ad/MetaFacebookLDUHelper.kt @@ -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 已关闭 (非加州用户)") + } +} diff --git a/app/src/main/java/com/prank/funky/voice/ad/TPManager.kt b/app/src/main/java/com/prank/funky/voice/ad/TPManager.kt new file mode 100644 index 0000000..2ed927c --- /dev/null +++ b/app/src/main/java/com/prank/funky/voice/ad/TPManager.kt @@ -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() + + 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() + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/prank/funky/voice/collection/CollectionActivity.kt b/app/src/main/java/com/prank/funky/voice/collection/CollectionActivity.kt index a0485c1..f5c687f 100644 --- a/app/src/main/java/com/prank/funky/voice/collection/CollectionActivity.kt +++ b/app/src/main/java/com/prank/funky/voice/collection/CollectionActivity.kt @@ -14,6 +14,7 @@ import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.RecyclerView import com.prank.funky.voice.utils.RecyclerSpace 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.objectBox.DbBaseFunction import com.prank.funky.voice.playSounds.PlaySoundsActivity @@ -51,7 +52,7 @@ class CollectionActivity : AppCompatActivity() { insets } findViewById(R.id.framelayout_back).setOnClickListener { finish() } - + TPManager.showTPAD(this@CollectionActivity) { } recyclerView = findViewById(R.id.favorite_recyclerview) emptyLayout = findViewById(R.id.empty_favorite) diff --git a/app/src/main/java/com/prank/funky/voice/playSounds/PlaySoundsActivity.kt b/app/src/main/java/com/prank/funky/voice/playSounds/PlaySoundsActivity.kt index 3041127..627d1bc 100644 --- a/app/src/main/java/com/prank/funky/voice/playSounds/PlaySoundsActivity.kt +++ b/app/src/main/java/com/prank/funky/voice/playSounds/PlaySoundsActivity.kt @@ -24,6 +24,7 @@ import androidx.core.view.ViewCompat import androidx.core.view.WindowInsetsCompat import com.bumptech.glide.Glide 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.objectBox.DbBaseFunction import com.prank.funky.voice.objectBox.EntitySoundsDetail @@ -69,10 +70,14 @@ class PlaySoundsActivity : AppCompatActivity() { insets } + onBackPressedDispatcher.addCallback(this, object : OnBackPressedCallback(true) { override fun handleOnBackPressed() { Util.showLog("-----------handleOnBackPressed") - backIntent() + TPManager.showTPAD(this@PlaySoundsActivity) { + backIntent() + } + } @@ -153,7 +158,10 @@ class PlaySoundsActivity : AppCompatActivity() { private fun setAllClick() { findViewById(R.id.framelayout_back).setOnClickListener { Util.showLog("-----------finish") - backIntent() + TPManager.showTPAD(this@PlaySoundsActivity) { + backIntent() + } + } favoriteLayout.setOnClickListener { @@ -189,26 +197,29 @@ class PlaySoundsActivity : AppCompatActivity() { clockTimer?.showDown(timerLayout) } playSoundsBtn.setOnClickListener { view -> - mediaPlayer?.let { - if (playSoundsBtn.isSelected) { - if (it.isPlaying) { - it.pause() - isPause = true - playAnime.pauseRipple() - } - } else { - if (!it.isPlaying) { - it.start() - if (isPause) { - playAnime.resumeRipple() - } else { - playAnime.startRipple() + + TPManager.showTPAD(this@PlaySoundsActivity) { + mediaPlayer?.let { + if (playSoundsBtn.isSelected) { + if (it.isPlaying) { + it.pause() + isPause = true + playAnime.pauseRipple() + } + } else { + if (!it.isPlaying) { + it.start() + if (isPause) { + playAnime.resumeRipple() + } else { + playAnime.startRipple() + } + isPause = false } - isPause = false } } + playSoundsBtn.setSelected(!playSoundsBtn.isSelected) } - playSoundsBtn.setSelected(!playSoundsBtn.isSelected) } } diff --git a/app/src/main/java/com/prank/funky/voice/recordSounds/CustomActivity.kt b/app/src/main/java/com/prank/funky/voice/recordSounds/CustomActivity.kt index c10d6f9..ad958f6 100644 --- a/app/src/main/java/com/prank/funky/voice/recordSounds/CustomActivity.kt +++ b/app/src/main/java/com/prank/funky/voice/recordSounds/CustomActivity.kt @@ -17,6 +17,7 @@ import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.RecyclerView import com.prank.funky.voice.utils.RecyclerSpace 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.objectBox.DbBaseFunction import com.prank.funky.voice.playSounds.PlaySoundsActivity @@ -63,7 +64,7 @@ class CustomActivity : AppCompatActivity() { recyclerViewCustom = findViewById(R.id.custom_recyclerview) emptyLayout = findViewById(R.id.empty_custom) - + TPManager.showTPAD(this@CustomActivity) { } importManager = ImportManager(this) { localUri, oldName -> Util.showLog("-----选择-- -$localUri") importSoundsUri = localUri diff --git a/app/src/main/java/com/prank/funky/voice/soundsList/ListActivity.kt b/app/src/main/java/com/prank/funky/voice/soundsList/ListActivity.kt index fd499e2..50864f5 100644 --- a/app/src/main/java/com/prank/funky/voice/soundsList/ListActivity.kt +++ b/app/src/main/java/com/prank/funky/voice/soundsList/ListActivity.kt @@ -12,6 +12,7 @@ import androidx.core.view.WindowInsetsCompat import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.RecyclerView 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.Util import com.prank.funky.voice.objectBox.EntitySounds @@ -40,6 +41,7 @@ class ListActivity : AppCompatActivity() { insets } + TPManager.showTPAD(this@ListActivity) { } findViewById(R.id.framelayout_back).setOnClickListener { finish() } diff --git a/app/src/main/java/com/prank/funky/voice/welcome/WelcomeActivity.kt b/app/src/main/java/com/prank/funky/voice/welcome/WelcomeActivity.kt index abdbffe..f70828f 100644 --- a/app/src/main/java/com/prank/funky/voice/welcome/WelcomeActivity.kt +++ b/app/src/main/java/com/prank/funky/voice/welcome/WelcomeActivity.kt @@ -3,19 +3,33 @@ package com.prank.funky.voice.welcome import android.content.Intent import android.os.Bundle import android.os.CountDownTimer +import android.util.Log import android.widget.ProgressBar import android.widget.TextView import androidx.activity.enableEdgeToEdge import androidx.appcompat.app.AppCompatActivity import androidx.core.view.ViewCompat 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.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() { private lateinit var pb: ProgressBar private lateinit var tv_progress: TextView - private val count = 2000L + private val count = 12000L private var countDownTimer:CountDownTimer? = null override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -30,21 +44,23 @@ class WelcomeActivity : AppCompatActivity() { pb = findViewById(R.id.load_pb) tv_progress = findViewById(R.id.text_progress) - countDownTimer = object : CountDownTimer(count,100){ - override fun onTick(millisUntilFinished: Long) { - val progressPercentage: Int = ((100 * millisUntilFinished) / count).toInt() - val progressInt = 100 - progressPercentage - tv_progress.text = getString(R.string.welcome_progress, progressInt) - pb.progress = progressInt - } - override fun onFinish() { - tv_progress.text = getString(R.string.welcome_progress, 100) - pb.progress = 100 - startActivity(Intent(this@WelcomeActivity, HomeActivity::class.java)) - finish() - } + setPrivacyConsent() + } + + private fun startCountDown(){ + countDownTimer = countDownTimer?:TPManager.showWelcomeAd(this@WelcomeActivity,count,{millisUntilFinished-> + val progressPercentage: Int = ((100 * millisUntilFinished) / count).toInt() + val progressInt = 100 - progressPercentage + tv_progress.text = getString(R.string.welcome_progress, progressInt) + pb.progress = progressInt + + }){ + tv_progress.text = getString(R.string.welcome_progress, 100) + pb.progress = 100 + startActivity(Intent(this@WelcomeActivity, HomeActivity::class.java)) + finish() } countDownTimer?.start() } @@ -53,4 +69,117 @@ class WelcomeActivity : AppCompatActivity() { super.onDestroy() 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) + } + }) + + + } + } + + } } \ No newline at end of file diff --git a/app/src/main/res/xml/net.xml b/app/src/main/res/xml/net.xml new file mode 100644 index 0000000..0ac6102 --- /dev/null +++ b/app/src/main/res/xml/net.xml @@ -0,0 +1,6 @@ + + + + mobile-server.lux-ad.com + + diff --git a/build.gradle.kts b/build.gradle.kts index 9681706..3cb7e75 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -3,9 +3,12 @@ plugins { alias(libs.plugins.android.application) apply false alias(libs.plugins.kotlin.android) 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{ dependencies{ - classpath("io.objectbox:objectbox-gradle-plugin:4.0.3") + classpath("io.objectbox:objectbox-gradle-plugin:5.0.1") } + } \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 20e2a01..97a23a8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ # http://www.gradle.org/docs/current/userguide/build_environment.html # Specifies the JVM arguments used for the daemon process. # 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. # This option should only be used with decoupled projects. For more details, visit # https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects diff --git a/settings.gradle.kts b/settings.gradle.kts index efa6ae8..0f2aa20 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -16,6 +16,26 @@ dependencyResolutionManagement { repositories { google() 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 Mediation’s 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") + } } }