diff --git a/app/build.gradle.kts b/app/build.gradle.kts index b687124..346604c 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -6,6 +6,8 @@ plugins { alias(libs.plugins.kotlin.android) id("kotlin-kapt") id ("kotlin-parcelize") + id("com.google.gms.google-services") + id("com.google.firebase.crashlytics") } val timestamp: String = SimpleDateFormat("MM_dd_HH_mm").format(Date()) android { @@ -16,8 +18,8 @@ android { applicationId = "com.wallpaper.wallpapergallery" minSdk = 23 targetSdk = 35 - versionCode = 1 - versionName = "1.0.0" + versionCode = 2 + versionName = "1.0.1" setProperty("archivesBaseName", "Wallpaper Gallery_V" + versionName + "(${versionCode})_$timestamp") testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } @@ -63,4 +65,104 @@ dependencies { implementation("androidx.room:room-ktx:2.6.1") implementation ("androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.7") + + implementation(platform("com.google.firebase:firebase-bom:33.7.0")) + + // Add the dependencies for the Crashlytics and Analytics libraries + // When using the BoM, you don't specify versions in Firebase library dependencies + implementation("com.google.firebase:firebase-crashlytics") + implementation("com.google.firebase:firebase-analytics") + implementation("com.google.firebase:firebase-config") + + + + //-----------------------------------------------TopOn(Mintegral、Pangle、UnitAds、Digital Turbine(Fyber)、Chartboost&Helium、Ironsource、Liftoff(Vungle)、Inmobi、Start.io、Appnext、Bigo) + + //Anythink (Necessary) + implementation("com.anythink.sdk:core-tpn:6.4.07") + implementation("com.anythink.sdk:nativead-tpn:6.4.07") + implementation("com.anythink.sdk:banner-tpn:6.4.07") + implementation("com.anythink.sdk:interstitial-tpn:6.4.07") + implementation("com.anythink.sdk:rewardedvideo-tpn:6.4.07") + implementation("com.anythink.sdk:splash-tpn:6.4.07") + + //Androidx (Necessary) + implementation("androidx.appcompat:appcompat:1.1.0") + implementation("androidx.browser:browser:1.4.0") + + //StartApp + implementation("com.anythink.sdk:adapter-tpn-startapp:6.4.07") + implementation("com.startapp:inapp-sdk:5.0.2") + + //Appnext + implementation("com.anythink.sdk:adapter-tpn-appnext:6.4.07") + implementation("com.appnext.sdk:ads:2.7.1.473") + implementation("com.appnext.sdk:banners:2.7.1.473") + implementation("com.appnext.sdk:native-ads2:2.7.1.473") + implementation("com.appnext.sdk:actions:2.4.6.472") + implementation("androidx.constraintlayout:constraintlayout:2.0.4") + + //Vungle + implementation("com.anythink.sdk:adapter-tpn-vungle:6.4.07") + implementation("com.vungle:vungle-ads:7.4.0") + 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.4.07") + implementation("com.unity3d.ads:unity-ads:4.12.2") + + //Ironsource + implementation("com.anythink.sdk:adapter-tpn-ironsource:6.4.07") + implementation("com.ironsource.sdk:mediationsdk:8.2.1") + implementation("com.google.android.gms:play-services-appset:16.0.2") + implementation("com.google.android.gms:play-services-ads-identifier:18.0.1") + implementation("com.google.android.gms:play-services-basement:18.1.0") + + //Bigo + implementation("com.anythink.sdk:adapter-tpn-bigo:6.4.07") + implementation("com.bigossp:bigo-ads:4.9.0") + + //Pangle + implementation("com.anythink.sdk:adapter-tpn-pangle-nonchina:6.4.07") + implementation("com.pangle.global:ads-sdk:6.1.0.9") + implementation("com.google.android.gms:play-services-ads-identifier:18.0.1") + + //Inmobi + implementation("com.anythink.sdk:adapter-tpn-inmobi:6.4.07") + implementation("com.inmobi.monetization:inmobi-ads-kotlin:10.7.5") + + //Mintegral + implementation("com.anythink.sdk:adapter-tpn-mintegral-nonchina:6.4.07") + implementation("com.mbridge.msdk.oversea:reward:16.8.11") + implementation("com.mbridge.msdk.oversea:newinterstitial:16.8.11") + implementation("com.mbridge.msdk.oversea:mbnative:16.8.11") + implementation("com.mbridge.msdk.oversea:mbnativeadvanced:16.8.11") + implementation("com.mbridge.msdk.oversea:mbsplash:16.8.11") + implementation("com.mbridge.msdk.oversea:mbbanner:16.8.11") + implementation("com.mbridge.msdk.oversea:mbbid:16.8.11") + implementation("androidx.recyclerview:recyclerview:1.1.0") + + //Chartboost + implementation("com.anythink.sdk:adapter-tpn-chartboost:6.4.07") + implementation("com.chartboost:chartboost-sdk:9.7.0") + implementation("com.chartboost:chartboost-mediation-sdk:4.9.1") + implementation("com.chartboost:chartboost-mediation-adapter-chartboost:4.9.7.0.0") + implementation("com.jakewharton.retrofit:retrofit2-kotlinx-serialization-converter:1.0.0") + implementation("com.squareup.okhttp3:logging-interceptor:4.10.0") + implementation("com.squareup.okhttp3:okhttp:4.10.0") + implementation("com.squareup.retrofit2:converter-scalars:2.9.0") + implementation("com.squareup.retrofit2:retrofit:2.9.0") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.1") + implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.1") + + //Fyber + implementation("com.anythink.sdk:adapter-tpn-fyber:6.4.07") + implementation("com.fyber:marketplace-sdk:8.3.0") + implementation("com.google.android.gms:play-services-ads-identifier:18.0.1") + + // Debugger UI Tools + //implementation ("com.anythink.sdk:debugger-ui:1.0.7") + + //----------------------------------------------TopOn } \ No newline at end of file diff --git a/app/google-services.json b/app/google-services.json new file mode 100644 index 0000000..ad5cb5d --- /dev/null +++ b/app/google-services.json @@ -0,0 +1,29 @@ +{ + "project_info": { + "project_number": "15626745342", + "project_id": "wallpaper-gallery-c5252", + "storage_bucket": "wallpaper-gallery-c5252.firebasestorage.app" + }, + "client": [ + { + "client_info": { + "mobilesdk_app_id": "1:15626745342:android:a1d28533bf2bfd4ea8bcaf", + "android_client_info": { + "package_name": "com.wallpaper.wallpapergallery" + } + }, + "oauth_client": [], + "api_key": [ + { + "current_key": "AIzaSyAUyH03zbXdqDrKJmctkYoIUGbXGM09TVA" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [] + } + } + } + ], + "configuration_version": "1" +} \ No newline at end of file diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index d60ab1a..155479a 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -31,4 +31,135 @@ -keep class com.wallpaper.wallpapergallery.data.local.database.AppDatabase { *; } -keep class com.wallpaper.wallpapergallery.data.local.dao.WallpapersDao { *; } --keep class com.wallpaper.wallpapergallery.data.local.entity.Wallpapers { *; } \ No newline at end of file +-keep class com.wallpaper.wallpapergallery.data.local.entity.Wallpapers { *; } + + + +#---------------------------------------------Topon + -keep class com.startapp.** { + *; + } + + -keep class com.truenet.** { + *; + } + + -keepattributes Exceptions, InnerClasses, Signature, Deprecated, SourceFile, + LineNumberTable, *Annotation*, EnclosingMethod + -dontwarn android.webkit.JavascriptInterface + -dontwarn com.startapp.** + + -dontwarn org.jetbrains.annotations.** + -keep class com.appnext.** { *; } + -dontwarn com.appnext.** + # Vungle + -dontwarn com.vungle.ads.** + -keepclassmembers class com.vungle.ads.** { + *; + } + -keep 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 + -keepclassmembers class com.ironsource.sdk.controller.IronSourceWebView$JSInterface { + public *; + } + -keepclassmembers class * implements android.os.Parcelable { + public static final android.os.Parcelable$Creator *; + } + -keep public class com.google.android.gms.ads.** { + public *; + } + -keep class com.ironsource.adapters.** { *; + } + -dontwarn com.ironsource.mediationsdk.** + -dontwarn com.ironsource.adapters.** + -keepattributes JavascriptInterface + -keepclassmembers class * { + @android.webkit.JavascriptInterface ; + } + -keep class com.bytedance.sdk.** { *; } + -keep class com.inmobi.** { *; } + -keep public class com.google.android.gms.** + -dontwarn com.google.android.gms.** + -dontwarn com.squareup.picasso.** + -keep class com.google.android.gms.ads.identifier.AdvertisingIdClient{ + public *; + } + -keep class com.google.android.gms.ads.identifier.AdvertisingIdClient$Info{ + public *; + } + # skip the Picasso library classes + -keep class com.squareup.picasso.** {*;} + -dontwarn com.squareup.okhttp.** + # skip Moat classes + -keep class com.moat.** {*;} + -dontwarn com.moat.** + # skip IAB classes + -keep class com.iab.** {*;} + -dontwarn com.iab.** + -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.*{ *; } + -keep class com.chartboost.** { *; } + + #---------------------------------------------Topon \ No newline at end of file diff --git a/app/src/main/java/com/wallpaper/wallpapergallery/App.kt b/app/src/main/java/com/wallpaper/wallpapergallery/App.kt index 5cafe4b..b8ca547 100644 --- a/app/src/main/java/com/wallpaper/wallpapergallery/App.kt +++ b/app/src/main/java/com/wallpaper/wallpapergallery/App.kt @@ -3,8 +3,12 @@ package com.wallpaper.wallpapergallery import android.app.Application import android.content.Context import android.content.SharedPreferences +import android.util.Log +import com.anythink.core.api.ATSDK +import com.anythink.core.api.NetTrafficeCallback import com.wallpaper.wallpapergallery.data.local.database.AppDatabase import com.wallpaper.wallpapergallery.data.repository.NetworkWallpaperRepository +import com.wallpaper.wallpapergallery.topon.AdManager import com.wallpaper.wallpapergallery.util.JsonUtils import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers @@ -19,7 +23,7 @@ class App : Application() { const val DB_NAME = "wallpaper_database" private const val PREF_NAME = "wallpaper_preferences" private const val INIT_DATABASE = "InitDatabase" - + const val TAG = "----------Test----" @JvmStatic fun getContext(): Context { return instance.applicationContext @@ -29,7 +33,7 @@ class App : Application() { override fun onCreate() { super.onCreate() instance = this - + initTopOn() val preferences: SharedPreferences = getSharedPreferences(PREF_NAME, MODE_PRIVATE) val init = preferences.getBoolean(INIT_DATABASE, false) @@ -48,5 +52,23 @@ class App : Application() { networkWallpaperRepository.insertWallpaperList(wallpaperInfoList) } } + + private fun initTopOn(){ + Log.d(TAG,"--------initTopOn") + ATSDK.checkIsEuTraffic(this, object : NetTrafficeCallback { + override fun onResultCallback(isEU: Boolean) { + if (isEU && ATSDK.getGDPRDataLevel(this@App) == ATSDK.UNKNOWN) { + ATSDK.showGdprAuth(this@App) + } + } + + override fun onErrorCallback(errorMsg: String) { + + } + }) + ATSDK.init( this, "h67a9a3b3cf58a", "af381af63adb9aa7ed68e798a0c445cb7") + AdManager.loadAllAd() + } + } diff --git a/app/src/main/java/com/wallpaper/wallpapergallery/topon/AdListener.kt b/app/src/main/java/com/wallpaper/wallpapergallery/topon/AdListener.kt new file mode 100644 index 0000000..f736d3f --- /dev/null +++ b/app/src/main/java/com/wallpaper/wallpapergallery/topon/AdListener.kt @@ -0,0 +1,11 @@ +package com.wallpaper.wallpapergallery.topon + +interface AdListener { + + fun loadFail(placeId: String) + fun showSuccess() + + fun showFail() + + fun showClose() +} \ No newline at end of file diff --git a/app/src/main/java/com/wallpaper/wallpapergallery/topon/AdManager.kt b/app/src/main/java/com/wallpaper/wallpapergallery/topon/AdManager.kt new file mode 100644 index 0000000..f0f78f0 --- /dev/null +++ b/app/src/main/java/com/wallpaper/wallpapergallery/topon/AdManager.kt @@ -0,0 +1,223 @@ +package com.wallpaper.wallpapergallery.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.wallpaper.wallpapergallery.App + + +object AdManager { + + //上次广告展示时刻 + var LAST_AD_SHOW = 0L + + 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 + + /** + INST_3 + n67a9a3d0eee98 + INST_2 + n67a9a3d0af0b8 + INST_1 + n67a9a3d05f53b + */ + + const val place1Id = "n67a9a3d0eee98" + const val place2Id = "n67a9a3d0af0b8" + const val place3Id = "n67a9a3d05f53b" + + + var place1LoadFail = false + var place2LoadFail = false + var place3LoadFail = false + + val list = mutableListOf() + + + @JvmStatic + fun loadAllAd() { + if (list.size <= 0) { + val mInterstitialAd1 = ATInterstitial(App.getContext(), place1Id) + val mInterstitialAd2 = ATInterstitial(App.getContext(), place2Id) + val mInterstitialAd3 = ATInterstitial(App.getContext(), place3Id) + list.add(mInterstitialAd1) + list.add(mInterstitialAd2) + list.add(mInterstitialAd3) + } + for (ad in list) { + if (!ad.isAdReady) { + setCallBack(ad, object : AdListener { + override fun loadFail(placeId: String) { + if (placeId == place1Id) { + place1LoadFail = true + } + if (placeId == place2Id) { + place2LoadFail = true + } + if (placeId == place3Id) { + place3LoadFail = true + } + } + + override fun showSuccess() { + + } + + override fun showFail() { + + } + + override fun showClose() { + + } + + }) + ad.load() + } + } + + + } + + @JvmStatic + fun getReadyAd(): ATInterstitial? { + list.shuffle() + for (ad in list) { + if (ad.isAdReady) { + Log.d(App.TAG, "-有广告------------") + return ad + } + } + Log.d(App.TAG, "-没有广告------------") + return null + } + + + @JvmStatic + fun showWelcomeAd( + activity: Activity, + totalTim: Long, + countAction: (millisUntilFinished: Long) -> Unit, + goMain: () -> Unit + ): CountDownTimer { + var alreadyShow = false + var timer = object : CountDownTimer(totalTim, 100) { + override fun onTick(millisUntilFinished: Long) { + countAction.invoke(millisUntilFinished) + 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(App.TAG, "LoadLoaded ${ad.mPlacementId}") + } + + override fun onInterstitialAdLoadFail(p0: AdError?) { + Log.d(App.TAG, "LoadFail:${p0?.code} ${p0?.desc}") + } + + override fun onInterstitialAdClicked(p0: ATAdInfo?) { + + } + + override fun onInterstitialAdShow(p0: ATAdInfo?) { + Log.d(App.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 + private fun showAD(activity: Activity, action: (type: Int) -> Unit) { + val readyAd = getReadyAd() + if (readyAd != null) { + Log.d(App.TAG, "readyAd ${readyAd.mPlacementId} ") + action.invoke(type_has_cache) + setCallBack(readyAd, object : AdListener { + override fun loadFail(placeId: String) { + + } + + override fun showSuccess() { + action.invoke(type_show_success) + LAST_AD_SHOW = System.currentTimeMillis() + } + + 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) + + } + } + + @JvmStatic + fun showTopOn(activity: Activity, listener: onActionListener) { + showAD(activity) { type -> + if (type == type_no_cache || type == type_show_close || type == type_show_fail) { + listener.onAction() + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/wallpaper/wallpapergallery/topon/onActionListener.java b/app/src/main/java/com/wallpaper/wallpapergallery/topon/onActionListener.java new file mode 100644 index 0000000..dfcba80 --- /dev/null +++ b/app/src/main/java/com/wallpaper/wallpapergallery/topon/onActionListener.java @@ -0,0 +1,6 @@ +package com.wallpaper.wallpapergallery.topon; + +public interface onActionListener { + + void onAction(); +} diff --git a/app/src/main/java/com/wallpaper/wallpapergallery/ui/activity/CategoryActivity.kt b/app/src/main/java/com/wallpaper/wallpapergallery/ui/activity/CategoryActivity.kt index 72ec585..90cb746 100644 --- a/app/src/main/java/com/wallpaper/wallpapergallery/ui/activity/CategoryActivity.kt +++ b/app/src/main/java/com/wallpaper/wallpapergallery/ui/activity/CategoryActivity.kt @@ -9,6 +9,7 @@ import androidx.lifecycle.ViewModelProvider import androidx.recyclerview.widget.GridLayoutManager import com.wallpaper.wallpapergallery.R import com.wallpaper.wallpapergallery.databinding.ActivityCategoryBinding +import com.wallpaper.wallpapergallery.topon.AdManager import com.wallpaper.wallpapergallery.ui.adapter.WallpaperAdapter import com.wallpaper.wallpapergallery.ui.viewmodel.NetworkWallpaperViewModel import com.wallpaper.wallpapergallery.util.ItemDecoration @@ -23,7 +24,7 @@ class CategoryActivity : AppCompatActivity() { super.onCreate(savedInstanceState) binding = ActivityCategoryBinding.inflate(layoutInflater) setContentView(binding.root) - + AdManager.loadAllAd() enableEdgeToEdge() ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets -> val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars()) @@ -36,6 +37,7 @@ class CategoryActivity : AppCompatActivity() { } private fun initData() { + AdManager.showTopOn(this@CategoryActivity) {} name = intent.getStringExtra("name").toString() viewModel = ViewModelProvider(this)[NetworkWallpaperViewModel::class.java] @@ -50,7 +52,9 @@ class CategoryActivity : AppCompatActivity() { private fun initEvent() { binding.back.setOnClickListener { - finish() + AdManager.showTopOn(this@CategoryActivity) { + finish() + } } binding.title.text = name diff --git a/app/src/main/java/com/wallpaper/wallpapergallery/ui/activity/MainActivity.kt b/app/src/main/java/com/wallpaper/wallpapergallery/ui/activity/MainActivity.kt index c6c6642..90f62e5 100644 --- a/app/src/main/java/com/wallpaper/wallpapergallery/ui/activity/MainActivity.kt +++ b/app/src/main/java/com/wallpaper/wallpapergallery/ui/activity/MainActivity.kt @@ -14,6 +14,7 @@ import com.google.android.material.tabs.TabLayoutMediator import com.wallpaper.wallpapergallery.R import com.wallpaper.wallpapergallery.databinding.ActivityMainBinding import com.wallpaper.wallpapergallery.databinding.MainCustomBinding +import com.wallpaper.wallpapergallery.topon.AdManager import com.wallpaper.wallpapergallery.ui.adapter.MainViewPager2Adapter import com.wallpaper.wallpapergallery.ui.fragment.CategoryFragment import com.wallpaper.wallpapergallery.ui.fragment.LikeFragment @@ -34,6 +35,7 @@ class MainActivity : AppCompatActivity() { v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom) insets } + AdManager.loadAllAd() initData() initEvent() diff --git a/app/src/main/java/com/wallpaper/wallpapergallery/ui/activity/SplashActivity.kt b/app/src/main/java/com/wallpaper/wallpapergallery/ui/activity/SplashActivity.kt index f4f34e1..8361801 100644 --- a/app/src/main/java/com/wallpaper/wallpapergallery/ui/activity/SplashActivity.kt +++ b/app/src/main/java/com/wallpaper/wallpapergallery/ui/activity/SplashActivity.kt @@ -3,6 +3,7 @@ package com.wallpaper.wallpapergallery.ui.activity import android.content.Intent import android.os.Bundle import android.os.CountDownTimer +import android.util.Log import android.view.View import androidx.activity.enableEdgeToEdge import androidx.appcompat.app.AppCompatActivity @@ -10,21 +11,24 @@ import androidx.core.view.ViewCompat import androidx.core.view.WindowInsetsCompat import com.bumptech.glide.Glide import com.bumptech.glide.load.resource.bitmap.RoundedCorners +import com.wallpaper.wallpapergallery.App import com.wallpaper.wallpapergallery.R import com.wallpaper.wallpapergallery.databinding.ActivitySplashBinding +import com.wallpaper.wallpapergallery.topon.AdManager class SplashActivity : AppCompatActivity() { private lateinit var binding: ActivitySplashBinding private lateinit var countDownTimer: CountDownTimer companion object { - private const val TOTAL_TIME: Long = 3000 + private const val TOTAL_TIME: Long = 11000 } override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) this.enableEdgeToEdge() - + Log.d(App.TAG,"--------SplashActivity") + AdManager.loadAllAd() binding = ActivitySplashBinding.inflate(layoutInflater) setContentView(binding.getRoot()) @@ -41,17 +45,22 @@ class SplashActivity : AppCompatActivity() { .transform(RoundedCorners(16)) .into(binding.image) - countDownTimer = object : CountDownTimer(TOTAL_TIME, 100) { - override fun onTick(millisUntilFinished: Long) { - val percentage = (100 - millisUntilFinished.toFloat() / TOTAL_TIME * 100).toInt() - binding.progressBar.progress = percentage - } - - override fun onFinish() { - startMain() - } +// countDownTimer = object : CountDownTimer(TOTAL_TIME, 100) { +// override fun onTick(millisUntilFinished: Long) { +// val percentage = (100 - millisUntilFinished.toFloat() / TOTAL_TIME * 100).toInt() +// binding.progressBar.progress = percentage +// } +// +// override fun onFinish() { +// startMain() +// } +// } + countDownTimer = AdManager.showWelcomeAd(this@SplashActivity, TOTAL_TIME,{millisUntilFinished-> + val percentage = (100 - millisUntilFinished.toFloat() / TOTAL_TIME * 100).toInt() + binding.progressBar.progress = percentage + }){ + startMain() } - countDownTimer.start() } diff --git a/app/src/main/java/com/wallpaper/wallpapergallery/ui/activity/WallpaperActivity.kt b/app/src/main/java/com/wallpaper/wallpapergallery/ui/activity/WallpaperActivity.kt index 399e79b..1c0da1c 100644 --- a/app/src/main/java/com/wallpaper/wallpapergallery/ui/activity/WallpaperActivity.kt +++ b/app/src/main/java/com/wallpaper/wallpapergallery/ui/activity/WallpaperActivity.kt @@ -24,6 +24,7 @@ import com.google.android.material.bottomsheet.BottomSheetDialog import com.wallpaper.wallpapergallery.R import com.wallpaper.wallpapergallery.data.local.entity.Wallpapers import com.wallpaper.wallpapergallery.databinding.ActivityWallpaperaBinding +import com.wallpaper.wallpapergallery.topon.AdManager import com.wallpaper.wallpapergallery.ui.viewmodel.NetworkWallpaperViewModel import com.wallpaper.wallpapergallery.util.WallpaperUtils import com.wallpaper.wallpapergallery.util.WallpaperUtils.REQUEST_CODE_WRITE_EXTERNAL_STORAGE @@ -44,7 +45,7 @@ class WallpaperActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - + AdManager.loadAllAd() this.enableEdgeToEdge() binding = ActivityWallpaperaBinding.inflate(layoutInflater) setContentView(binding.getRoot()) @@ -61,6 +62,8 @@ class WallpaperActivity : AppCompatActivity() { } private fun initData() { + AdManager.showTopOn(this@WallpaperActivity){} + val receivedWallpaper: Wallpapers? = intent.getParcelableExtra("wallpaper") if (receivedWallpaper != null) { wallpapers = receivedWallpaper @@ -95,12 +98,18 @@ class WallpaperActivity : AppCompatActivity() { } binding.set.setOnClickListener { - showCustomBottomSheetDialog() + AdManager.showTopOn(this@WallpaperActivity){ + showCustomBottomSheetDialog() + } + } binding.downPicture.setOnClickListener { - showProgress() - wallpaperUtils.saveToGallery(this@WallpaperActivity, imagePath) + AdManager.showTopOn(this@WallpaperActivity){ + showProgress() + wallpaperUtils.saveToGallery(this@WallpaperActivity, imagePath) + } + } loadImage() diff --git a/build.gradle.kts b/build.gradle.kts index 922f551..935d953 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,4 +2,6 @@ plugins { alias(libs.plugins.android.application) apply false alias(libs.plugins.kotlin.android) 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 } \ 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/gradle/libs.versions.toml b/gradle/libs.versions.toml deleted file mode 100644 index 2683a5b..0000000 --- a/gradle/libs.versions.toml +++ /dev/null @@ -1,26 +0,0 @@ -[versions] -agp = "8.8.0" -kotlin = "1.9.24" -coreKtx = "1.15.0" -junit = "4.13.2" -junitVersion = "1.2.1" -espressoCore = "3.6.1" -appcompat = "1.7.0" -material = "1.12.0" -activity = "1.10.0" -constraintlayout = "2.2.0" - -[libraries] -androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" } -junit = { group = "junit", name = "junit", version.ref = "junit" } -androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" } -androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" } -androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" } -material = { group = "com.google.android.material", name = "material", version.ref = "material" } -androidx-activity = { group = "androidx.activity", name = "activity", version.ref = "activity" } -androidx-constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" } - -[plugins] -android-application = { id = "com.android.application", version.ref = "agp" } -kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } - diff --git a/settings.gradle.kts b/settings.gradle.kts index 0fe4a8f..301619a 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -16,6 +16,29 @@ dependencyResolutionManagement { repositories { google() mavenCentral() + + + //Anythink(Core) + maven ("https://jfrog.anythinktech.com/artifactory/overseas_sdk") + + //Appnext + maven ("https://dl.appnext.com") + + //Ironsource + maven ("https://android-sdk.is.com/") + + //Pangle + maven ("https://artifact.bytedance.com/repository/pangle") + + //Mintegral + maven ("https://dl-maven-android.mintegral.com/repository/mbridge_android_sdk_oversea") + + //Chartboost + maven ("https://cboost.jfrog.io/artifactory/chartboost-ads") + maven ("https://cboost.jfrog.io/artifactory/chartboost-mediation") + + //TopOn集成测试工具 +// maven ( "https://jfrog.anythinktech.com/artifactory/debugger") } }