V1.0.1(1)接入topon和firebase

This commit is contained in:
lihongwei 2025-05-13 11:53:30 +08:00
parent 4ba4b8b0f2
commit 8da601c4be
26 changed files with 616 additions and 27 deletions

BIN
app/WallpaperMagic.jks Normal file

Binary file not shown.

View File

@ -6,6 +6,8 @@ plugins {
alias(libs.plugins.kotlin.android) alias(libs.plugins.kotlin.android)
id("com.google.devtools.ksp") id("com.google.devtools.ksp")
id("kotlin-parcelize") id("kotlin-parcelize")
id("com.google.gms.google-services")
id("com.google.firebase.crashlytics")
} }
val timestamp: String = SimpleDateFormat("MM_dd_HH_mm").format(Date()) val timestamp: String = SimpleDateFormat("MM_dd_HH_mm").format(Date())
android { android {
@ -16,8 +18,8 @@ android {
applicationId = "com.wallpaper.wallpapermagic" applicationId = "com.wallpaper.wallpapermagic"
minSdk = 23 minSdk = 23
targetSdk = 35 targetSdk = 35
versionCode = 1 versionCode = 2
versionName = "1.0.0" versionName = "1.0.1"
setProperty( setProperty(
"archivesBaseName", "archivesBaseName",
"Wallpaper Magic_V" + versionName + "(${versionCode})_$timestamp" "Wallpaper Magic_V" + versionName + "(${versionCode})_$timestamp"
@ -72,4 +74,104 @@ dependencies {
implementation ("androidx.activity:activity-ktx:1.10.1") implementation ("androidx.activity:activity-ktx:1.10.1")
implementation ("androidx.lifecycle:lifecycle-runtime-ktx:2.8.7") implementation ("androidx.lifecycle:lifecycle-runtime-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
} }

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

@ -0,0 +1,29 @@
{
"project_info": {
"project_number": "647920341695",
"project_id": "wallpaper-magic-c84fe",
"storage_bucket": "wallpaper-magic-c84fe.firebasestorage.app"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:647920341695:android:c6fb1d8a53bb643c6d2c0a",
"android_client_info": {
"package_name": "com.wallpaper.wallpapermagic"
}
},
"oauth_client": [],
"api_key": [
{
"current_key": "AIzaSyCAztcie2imOFVrgpFeniHUUu6EXtpRqK8"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": []
}
}
}
],
"configuration_version": "1"
}

142
app/proguard-rules.pro vendored
View File

@ -19,3 +19,145 @@
# If you keep the line number information, uncomment this to # If you keep the line number information, uncomment this to
# hide the original source file name. # hide the original source file name.
#-renamesourcefileattribute SourceFile #-renamesourcefileattribute SourceFile
-keepclassmembers class com.wallpaper.wallpapermagic.App {
public static final java.lang.String DB_NAME;
public static final int DB_VERSION;
}
-keepclassmembers class * {
@androidx.room.Query <methods>;
}
-keep class com.wallpaper.wallpapermagic.room.AppDatabase { *; }
-keep class com.wallpaper.wallpapermagic.room.MagicEntity { *; }
-keep class com.wallpaper.wallpapermagic.room.MagicDao { *; }
#---------------------------------------------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 <methods>;
}
-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

View File

@ -3,8 +3,12 @@ package com.wallpaper.wallpapermagic
import android.app.Application import android.app.Application
import android.content.Context import android.content.Context
import android.content.SharedPreferences import android.content.SharedPreferences
import android.util.Log
import androidx.core.content.edit import androidx.core.content.edit
import com.anythink.core.api.ATSDK
import com.anythink.core.api.NetTrafficeCallback
import com.wallpaper.wallpapermagic.room.AppDatabase import com.wallpaper.wallpapermagic.room.AppDatabase
import com.wallpaper.wallpapermagic.topon.AdManager
import com.wallpaper.wallpapermagic.utils.JsonUtils import com.wallpaper.wallpapermagic.utils.JsonUtils
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
@ -19,6 +23,7 @@ class App : Application() {
const val DB_NAME = "magic_database" const val DB_NAME = "magic_database"
private const val PREF_NAME = "magic_preferences" private const val PREF_NAME = "magic_preferences"
private const val INIT_DATABASE = "InitDatabase" private const val INIT_DATABASE = "InitDatabase"
const val TAG = "----------Test----"
@JvmStatic @JvmStatic
fun getContext(): Context { fun getContext(): Context {
@ -29,6 +34,7 @@ class App : Application() {
override fun onCreate() { override fun onCreate() {
super.onCreate() super.onCreate()
instance = this instance = this
initTopOn()
val preferences: SharedPreferences = getSharedPreferences(PREF_NAME, MODE_PRIVATE) val preferences: SharedPreferences = getSharedPreferences(PREF_NAME, MODE_PRIVATE)
val init = preferences.getBoolean(INIT_DATABASE, false) val init = preferences.getBoolean(INIT_DATABASE, false)
@ -48,5 +54,22 @@ class App : Application() {
} }
} }
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, "h67d933408d3fc", "a3d2ffafdcdfe47b9a129164309345cce")
AdManager.loadAllAd()
}
} }

View File

@ -24,6 +24,7 @@ import com.google.android.material.bottomsheet.BottomSheetDialog
import com.wallpaper.wallpapermagic.R import com.wallpaper.wallpapermagic.R
import com.wallpaper.wallpapermagic.databinding.ActivityMagicBinding import com.wallpaper.wallpapermagic.databinding.ActivityMagicBinding
import com.wallpaper.wallpapermagic.room.MagicEntity import com.wallpaper.wallpapermagic.room.MagicEntity
import com.wallpaper.wallpapermagic.topon.AdManager
import com.wallpaper.wallpapermagic.utils.RoomViewModel import com.wallpaper.wallpapermagic.utils.RoomViewModel
import com.wallpaper.wallpapermagic.utils.WallpaperImageHelper import com.wallpaper.wallpapermagic.utils.WallpaperImageHelper
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
@ -68,6 +69,9 @@ class MagicActivity : AppCompatActivity() {
finish() finish()
return return
} }
AdManager.showTopOn(this@MagicActivity) {}
wallpaperPath = wallpaperData.source wallpaperPath = wallpaperData.source
wallpaperName = wallpaperData.name wallpaperName = wallpaperData.name
@ -88,11 +92,17 @@ class MagicActivity : AppCompatActivity() {
updateLikeIcon() updateLikeIcon()
} }
uiBinding.set.setOnClickListener { openWallpaperOptions() } uiBinding.set.setOnClickListener {
AdManager.showTopOn(this@MagicActivity) {
openWallpaperOptions()
}
}
uiBinding.downPicture.setOnClickListener { uiBinding.downPicture.setOnClickListener {
displayLoading() AdManager.showTopOn(this@MagicActivity) {
imageHelper.downloadImage(this, wallpaperPath) displayLoading()
imageHelper.downloadImage(this, wallpaperPath)
}
} }
fetchAndDisplayImage() fetchAndDisplayImage()
@ -119,7 +129,10 @@ class MagicActivity : AppCompatActivity() {
val dialogLayout = LayoutInflater.from(this).inflate(R.layout.set_dialog, null) val dialogLayout = LayoutInflater.from(this).inflate(R.layout.set_dialog, null)
dialogLayout.findViewById<View>(R.id.both).setOnClickListener { dialogLayout.findViewById<View>(R.id.both).setOnClickListener {
setWallpaperWithFlags(imageBitmap, WallpaperManager.FLAG_SYSTEM or WallpaperManager.FLAG_LOCK) setWallpaperWithFlags(
imageBitmap,
WallpaperManager.FLAG_SYSTEM or WallpaperManager.FLAG_LOCK
)
dialog.dismiss() dialog.dismiss()
} }
dialogLayout.findViewById<View>(R.id.lock).setOnClickListener { dialogLayout.findViewById<View>(R.id.lock).setOnClickListener {
@ -143,12 +156,20 @@ class MagicActivity : AppCompatActivity() {
applyWallpaper(bitmap, flags) applyWallpaper(bitmap, flags)
withContext(Dispatchers.Main) { withContext(Dispatchers.Main) {
hideLoading() hideLoading()
Toast.makeText(this@MagicActivity, "Wallpaper set successfully", Toast.LENGTH_SHORT).show() Toast.makeText(
this@MagicActivity,
"Wallpaper set successfully",
Toast.LENGTH_SHORT
).show()
} }
} catch (e: Exception) { } catch (e: Exception) {
withContext(Dispatchers.Main) { withContext(Dispatchers.Main) {
hideLoading() hideLoading()
Toast.makeText(this@MagicActivity, "Wallpaper setting failed", Toast.LENGTH_SHORT).show() Toast.makeText(
this@MagicActivity,
"Wallpaper setting failed",
Toast.LENGTH_SHORT
).show()
} }
} }
} }
@ -174,9 +195,11 @@ class MagicActivity : AppCompatActivity() {
imageBitmap = resource imageBitmap = resource
hideLoading() hideLoading()
} }
override fun onLoadCleared(placeholder: Drawable?) { override fun onLoadCleared(placeholder: Drawable?) {
uiBinding.imageView.setImageDrawable(placeholder) uiBinding.imageView.setImageDrawable(placeholder)
} }
override fun onLoadFailed(errorDrawable: Drawable?) { override fun onLoadFailed(errorDrawable: Drawable?) {
uiBinding.imageView.setImageDrawable(errorDrawable) uiBinding.imageView.setImageDrawable(errorDrawable)
hideLoading() hideLoading()
@ -186,7 +209,8 @@ class MagicActivity : AppCompatActivity() {
private fun observeFavoriteStatus() { private fun observeFavoriteStatus() {
lifecycleScope.launch { lifecycleScope.launch {
roomViewModel.getFavoriteStatus(wallpaperPath, wallpaperName).collect { updateLikeIcon() } roomViewModel.getFavoriteStatus(wallpaperPath, wallpaperName)
.collect { updateLikeIcon() }
} }
} }

View File

@ -15,6 +15,7 @@ import com.bumptech.glide.load.resource.bitmap.RoundedCorners
import com.wallpaper.wallpapermagic.App import com.wallpaper.wallpapermagic.App
import com.wallpaper.wallpapermagic.R import com.wallpaper.wallpapermagic.R
import com.wallpaper.wallpapermagic.databinding.ActivitySplashBinding import com.wallpaper.wallpapermagic.databinding.ActivitySplashBinding
import com.wallpaper.wallpapermagic.topon.AdManager
@SuppressLint("CustomSplashScreen") @SuppressLint("CustomSplashScreen")
class SplashActivity : AppCompatActivity() { class SplashActivity : AppCompatActivity() {
@ -22,7 +23,7 @@ class SplashActivity : AppCompatActivity() {
private lateinit var countDownTimer: CountDownTimer private lateinit var countDownTimer: CountDownTimer
companion object { companion object {
private const val TOTAL_TIME: Long = 3000 private const val TOTAL_TIME: Long = 11000
} }
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
@ -39,20 +40,18 @@ class SplashActivity : AppCompatActivity() {
insets insets
} }
AdManager.loadAllAd()
Glide.with(this) Glide.with(this)
.load(R.mipmap.placeholder) .load(R.mipmap.placeholder)
.transform(RoundedCorners(16)) .transform(RoundedCorners(16))
.into(binding.image) .into(binding.image)
countDownTimer = object : CountDownTimer(TOTAL_TIME, 100) { countDownTimer = AdManager.showWelcomeAd(this@SplashActivity, TOTAL_TIME,{millisUntilFinished->
override fun onTick(millisUntilFinished: Long) { val percentage = (100 - millisUntilFinished.toFloat() / TOTAL_TIME * 100).toInt()
val percentage = (100 - millisUntilFinished.toFloat() / TOTAL_TIME * 100).toInt() binding.progressBar.progress = percentage
binding.progressBar.progress = percentage }){
} startMain()
override fun onFinish() {
startMain()
}
} }
countDownTimer.start() countDownTimer.start()

View File

@ -11,6 +11,7 @@ import androidx.recyclerview.widget.GridLayoutManager
import com.wallpaper.wallpapermagic.R import com.wallpaper.wallpapermagic.R
import com.wallpaper.wallpapermagic.adapter.MagicAdapter import com.wallpaper.wallpapermagic.adapter.MagicAdapter
import com.wallpaper.wallpapermagic.databinding.ActivitySubListBinding import com.wallpaper.wallpapermagic.databinding.ActivitySubListBinding
import com.wallpaper.wallpapermagic.topon.AdManager
import com.wallpaper.wallpapermagic.utils.ItemDecoration import com.wallpaper.wallpapermagic.utils.ItemDecoration
import com.wallpaper.wallpapermagic.utils.RoomViewModel import com.wallpaper.wallpapermagic.utils.RoomViewModel
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
@ -38,6 +39,8 @@ class SubListActivity : AppCompatActivity() {
private fun initData() { private fun initData() {
name = intent.getStringExtra("name").toString() name = intent.getStringExtra("name").toString()
AdManager.showTopOn(this@SubListActivity) {}
roomViewModel = ViewModelProvider(this)[RoomViewModel::class.java] roomViewModel = ViewModelProvider(this)[RoomViewModel::class.java]
binding.recyclerView.setLayoutManager(GridLayoutManager(this, 2)) binding.recyclerView.setLayoutManager(GridLayoutManager(this, 2))
@ -57,7 +60,9 @@ class SubListActivity : AppCompatActivity() {
private fun initEvent() { private fun initEvent() {
binding.back.setOnClickListener { binding.back.setOnClickListener {
finish() AdManager.showTopOn(this@SubListActivity) {
finish()
}
} }
loadList() loadList()

View File

@ -0,0 +1,11 @@
package com.wallpaper.wallpapermagic.topon
interface AdListener {
fun loadFail(placeId: String)
fun showSuccess()
fun showFail()
fun showClose()
}

View File

@ -0,0 +1,223 @@
package com.wallpaper.wallpapermagic.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.wallpapermagic.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
/**
Magic_inter_3
n67d9338f6d7e5
Magic_inter_2
n67d9337e0b5b9
Magic_inter_1
n67d933693f34b
*/
const val place1Id = "n67d933693f34b"
const val place2Id = "n67d9337e0b5b9"
const val place3Id = "n67d9338f6d7e5"
var place1LoadFail = false
var place2LoadFail = false
var place3LoadFail = false
val list = mutableListOf<ATInterstitial>()
@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()
}
}
}
}

View File

@ -0,0 +1,6 @@
package com.wallpaper.wallpapermagic.topon;
public interface onActionListener {
void onAction();
}

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 982 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 169 KiB

After

Width:  |  Height:  |  Size: 195 KiB

View File

@ -4,4 +4,7 @@ plugins {
alias(libs.plugins.kotlin.android) apply false alias(libs.plugins.kotlin.android) apply false
id("com.google.devtools.ksp") version "2.0.21-1.0.27" apply false id("com.google.devtools.ksp") version "2.0.21-1.0.27" 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
} }

6
keystore.properties Normal file
View File

@ -0,0 +1,6 @@
app_name=Wallpaper Magic
package_name=com.wallpaper.wallpapermagic
keystoreFile=app/WallpaperMagic.jks
key_alias=WallpaperMagickey0
key_store_password=WallpaperMagic
key_password=WallpaperMagic

View File

@ -16,6 +16,28 @@ dependencyResolutionManagement {
repositories { repositories {
google() google()
mavenCentral() 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")
} }
} }