V1.0.4(5) 集成TopOn广告
This commit is contained in:
parent
d17993f4ce
commit
e77c72e478
@ -16,11 +16,11 @@ android {
|
||||
|
||||
defaultConfig {
|
||||
//com.pink.cute.wallpapers Pink Wallpapers
|
||||
applicationId = "com.pink.cute.wallpapers.test"
|
||||
applicationId = "com.pink.cute.wallpapers"
|
||||
minSdk = 23
|
||||
targetSdk = 34
|
||||
versionCode = 4
|
||||
versionName = "1.0.3"
|
||||
versionCode = 5
|
||||
versionName = "1.0.4"
|
||||
setProperty("archivesBaseName", "Pink Wallpapers_V" + versionName + "(${versionCode})_$timestamp")
|
||||
testInstrumentationRunner = "androidx.wallpapers.runner.AndroidJUnitRunner"
|
||||
}
|
||||
@ -69,7 +69,63 @@ dependencies {
|
||||
implementation ("androidx.room:room-runtime:$room_version")
|
||||
kapt("androidx.room:room-compiler:$room_version")
|
||||
|
||||
implementation("com.squareup.okhttp3:okhttp:4.11.0")
|
||||
|
||||
|
||||
//-----------------------------------------------TopOn(pangle、IronSource、mintegral、unityads、liftoff(vungle)、Bigo)
|
||||
//Anythink (Necessary)
|
||||
implementation("com.anythink.sdk:core-tpn:6.3.68")
|
||||
implementation("com.anythink.sdk:nativead-tpn:6.3.68")
|
||||
implementation("com.anythink.sdk:banner-tpn:6.3.68")
|
||||
implementation("com.anythink.sdk:interstitial-tpn:6.3.68")
|
||||
implementation("com.anythink.sdk:rewardedvideo-tpn:6.3.68")
|
||||
implementation("com.anythink.sdk:splash-tpn:6.3.68")
|
||||
|
||||
//Androidx (Necessary)
|
||||
implementation("androidx.appcompat:appcompat:1.1.0")
|
||||
implementation("androidx.browser:browser:1.4.0")
|
||||
|
||||
//Vungle
|
||||
implementation("com.anythink.sdk:adapter-tpn-vungle:6.3.68")
|
||||
implementation("com.vungle:vungle-ads:7.3.2")
|
||||
implementation("com.google.android.gms:play-services-basement:18.1.0")
|
||||
implementation("com.google.android.gms:play-services-ads-identifier:18.0.1")
|
||||
|
||||
//UnityAds
|
||||
implementation("com.anythink.sdk:adapter-tpn-unityads:6.3.68")
|
||||
implementation("com.unity3d.ads:unity-ads:4.9.3")
|
||||
|
||||
//Ironsource
|
||||
implementation("com.anythink.sdk:adapter-tpn-ironsource:6.3.68")
|
||||
implementation("com.ironsource.sdk:mediationsdk:8.1.0")
|
||||
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.3.68")
|
||||
implementation("com.bigossp:bigo-ads:4.7.4")
|
||||
|
||||
//Pangle
|
||||
implementation("com.anythink.sdk:adapter-tpn-pangle-nonchina:6.3.68.1")
|
||||
implementation( "com.pangle.global:ads-sdk:6.0.0.3")
|
||||
implementation( "com.google.android.gms:play-services-ads-identifier:18.0.1")
|
||||
|
||||
//Mintegral
|
||||
implementation("com.anythink.sdk:adapter-tpn-mintegral-nonchina:6.3.68")
|
||||
implementation("com.mbridge.msdk.oversea:reward:16.7.51")
|
||||
implementation("com.mbridge.msdk.oversea:newinterstitial:16.7.51")
|
||||
implementation("com.mbridge.msdk.oversea:mbnative:16.7.51")
|
||||
implementation("com.mbridge.msdk.oversea:mbnativeadvanced:16.7.51")
|
||||
implementation("com.mbridge.msdk.oversea:mbsplash:16.7.51")
|
||||
implementation("com.mbridge.msdk.oversea:mbbanner:16.7.51")
|
||||
implementation("com.mbridge.msdk.oversea:mbbid:16.7.51")
|
||||
implementation("androidx.recyclerview:recyclerview:1.1.0")
|
||||
|
||||
// Debugger UI Tools
|
||||
// implementation ("com.anythink.sdk:debugger-ui:1.0.7")
|
||||
|
||||
//----------------------------------------------TopOn
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
"client_info": {
|
||||
"mobilesdk_app_id": "1:62351382065:android:8efff2c8a82f275be32710",
|
||||
"android_client_info": {
|
||||
"package_name": "com.pink.cute.wallpapers.test"
|
||||
"package_name": "com.pink.cute.wallpapers"
|
||||
}
|
||||
},
|
||||
"oauth_client": [],
|
||||
|
||||
94
app/proguard-rules.pro
vendored
94
app/proguard-rules.pro
vendored
@ -49,3 +49,97 @@ java.lang.Object readResolve();
|
||||
-keep class com.pink.cute.wallpapers.myroom.MyDatabase { *; }
|
||||
-keep class com.pink.cute.wallpapers.myroom.CategoryDao { *; }
|
||||
-keep class com.pink.cute.wallpapers.myroom.WallpaperDao { *; }
|
||||
|
||||
|
||||
|
||||
#---------------------------------------------Topon
|
||||
# Vungle
|
||||
-dontwarn com.vungle.ads.**
|
||||
-keepclassmembers class com.vungle.ads.** {
|
||||
*;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
# Google
|
||||
-keep class com.google.android.gms.** { *; }
|
||||
-dontwarn com.google.android.gms.**
|
||||
|
||||
|
||||
|
||||
|
||||
# START OkHttp + Okio
|
||||
# JSR 305 annotations are for embedding nullability information.
|
||||
-dontwarn javax.annotation.**
|
||||
|
||||
|
||||
# A resource is loaded with a relative path so the package of this class must be preserved.
|
||||
-adaptresourcefilenames okhttp3/internal/publicsuffix/PublicSuffixDatabase.gz
|
||||
|
||||
|
||||
# Animal Sniffer compileOnly dependency to ensure APIs are compatible with older versions of Java.
|
||||
-dontwarn org.codehaus.mojo.animal_sniffer.*
|
||||
|
||||
|
||||
# OkHttp platform used only on JVM and when Conscrypt and other security providers are available.
|
||||
-dontwarn okhttp3.internal.platform.**
|
||||
-dontwarn org.conscrypt.**
|
||||
-dontwarn org.bouncycastle.**
|
||||
-dontwarn org.openjsse.**
|
||||
|
||||
|
||||
# Animal Sniffer compileOnly dependency to ensure APIs are compatible with older versions of Java.
|
||||
-dontwarn org.codehaus.mojo.animal_sniffer.*
|
||||
|
||||
|
||||
# END OkHttp + Okio
|
||||
|
||||
|
||||
# START Protobuf
|
||||
-dontwarn com.google.protobuf.**
|
||||
-keepclassmembers class com.google.protobuf.** {
|
||||
*;
|
||||
}
|
||||
-keep class * extends com.google.protobuf.GeneratedMessageLite { *; }
|
||||
|
||||
|
||||
# END Protobuf
|
||||
-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.** { *; }
|
||||
-keepattributes Signature
|
||||
-keepattributes *Annotation*
|
||||
-keep class com.mbridge.** {*; }
|
||||
-keep interface com.mbridge.** {*; }
|
||||
-keep class android.support.v4.** { *; }
|
||||
-dontwarn com.mbridge.**
|
||||
-keep class **.R$* { public static final int mbridge*; }
|
||||
-keep public class com.mbridge.* extends androidx.** { *; }
|
||||
-keep public class androidx.viewpager.widget.PagerAdapter{ *; }
|
||||
-keep public class androidx.viewpager.widget.ViewPager.OnPageChangeListener{ *; }
|
||||
-keep interface androidx.annotation.IntDef{ *; }
|
||||
-keep interface androidx.annotation.Nullable{ *; }
|
||||
-keep interface androidx.annotation.CheckResult{ *; }
|
||||
-keep interface androidx.annotation.NonNull{ *; }
|
||||
-keep public class androidx.fragment.app.Fragment{ *; }
|
||||
-keep public class androidx.core.content.FileProvider{ *; }
|
||||
-keep public class androidx.core.app.NotificationCompat{ *; }
|
||||
-keep public class androidx.appcompat.widget.AppCompatImageView { *; }
|
||||
-keep public class androidx.recyclerview.*{ *; }
|
||||
#---------------------------------------------Topon
|
||||
|
||||
@ -3,11 +3,10 @@
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.SET_WALLPAPER" />
|
||||
<uses-permission
|
||||
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
|
||||
android:maxSdkVersion="32" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
|
||||
|
||||
<application
|
||||
android:name=".PinkWallpapers"
|
||||
@ -34,7 +33,7 @@
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".activity.LaunActivity"
|
||||
android:exported="true" >
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
@ -44,7 +43,7 @@
|
||||
<activity
|
||||
android:name=".activity.MainActivity"
|
||||
android:exported="false"
|
||||
android:label="@string/app_name"/>
|
||||
android:label="@string/app_name" />
|
||||
|
||||
</application>
|
||||
|
||||
|
||||
@ -2,9 +2,13 @@ package com.pink.cute.wallpapers
|
||||
|
||||
import android.app.Application
|
||||
import android.util.Log
|
||||
import com.anythink.core.api.ATSDK
|
||||
import com.anythink.core.api.NetTrafficeCallback
|
||||
//import com.anythink.debug.api.ATDebuggerUITest
|
||||
import com.pink.cute.wallpapers.bean.Category
|
||||
import com.pink.cute.wallpapers.manager.Common
|
||||
import com.pink.cute.wallpapers.myroom.MyDatabase
|
||||
import com.pink.cute.wallpapers.topon.AdManager
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
@ -23,8 +27,15 @@ class PinkWallpapers : Application() {
|
||||
|
||||
lateinit var categoryList: List<Category>
|
||||
|
||||
const val TAG = "----------ting"
|
||||
|
||||
}
|
||||
|
||||
private val APPId = "h66b1da1782fa1"
|
||||
private val AppKey = "a075f35a10322b63a76894a4bda9ffb56"
|
||||
|
||||
private val debug_Key = "529b9d845e53ac839536d321c0b6be5f6928b24d"
|
||||
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
pinkWallpapers = this
|
||||
@ -36,7 +47,7 @@ class PinkWallpapers : Application() {
|
||||
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
val queryAllData = MyDatabase.myDatabase.CategoryDao().queryAllData()
|
||||
Log.d("ting","---------queryAllData=${queryAllData.size}")
|
||||
Log.d("ting", "---------queryAllData=${queryAllData.size}")
|
||||
if (queryAllData.size <= 0) {
|
||||
val fdInput = assets.open("wallres.json")
|
||||
val jsonStr = Common.getJsonString(fdInput)
|
||||
@ -49,6 +60,24 @@ class PinkWallpapers : Application() {
|
||||
}
|
||||
|
||||
private fun initMAX() {
|
||||
ATSDK.checkIsEuTraffic(this, object : NetTrafficeCallback {
|
||||
override fun onResultCallback(isEU: Boolean) {
|
||||
Log.e(TAG, "onResultCallback:$isEU")
|
||||
if (isEU && ATSDK.getGDPRDataLevel(this@PinkWallpapers) == ATSDK.UNKNOWN) {
|
||||
ATSDK.showGdprAuth(this@PinkWallpapers)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onErrorCallback(errorMsg: String) {
|
||||
Log.e(TAG, "onErrorCallback:$errorMsg")
|
||||
}
|
||||
})
|
||||
ATSDK.init(this, APPId, AppKey)
|
||||
AdManager.loadAllAd()
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -10,6 +10,7 @@ import android.util.Log
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.pink.cute.wallpapers.R
|
||||
import com.pink.cute.wallpapers.databinding.ActivityAboutBinding
|
||||
import com.pink.cute.wallpapers.topon.AdManager
|
||||
|
||||
|
||||
class AboutActivity : AppCompatActivity() {
|
||||
@ -18,7 +19,7 @@ class AboutActivity : AppCompatActivity() {
|
||||
super.onCreate(savedInstanceState)
|
||||
vb = ActivityAboutBinding.inflate(layoutInflater)
|
||||
setContentView(vb.root)
|
||||
// AdManager.loadAllAd()
|
||||
AdManager.loadAllAd()
|
||||
val appVersionName = getAppVersionName()
|
||||
appVersionName?.run {
|
||||
vb.tvVersion.text = String.format(getString(R.string.app_version), this.versionName)
|
||||
@ -39,8 +40,8 @@ class AboutActivity : AppCompatActivity() {
|
||||
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
})
|
||||
|
||||
}catch (ex:Exception){
|
||||
Log.d("ting","---------ex=${ex.message}")
|
||||
} catch (ex: Exception) {
|
||||
Log.d("ting", "---------ex=${ex.message}")
|
||||
}
|
||||
}
|
||||
|
||||
@ -54,7 +55,12 @@ class AboutActivity : AppCompatActivity() {
|
||||
putExtra(Intent.EXTRA_TEXT, uri)
|
||||
type = "text/plain"
|
||||
}
|
||||
startActivity(Intent.createChooser(sendIntent, resources.getString(R.string.share_title)))
|
||||
startActivity(
|
||||
Intent.createChooser(
|
||||
sendIntent,
|
||||
resources.getString(R.string.share_title)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -4,22 +4,42 @@ import android.content.Intent
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.os.Bundle
|
||||
import android.os.CountDownTimer
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import com.pink.cute.wallpapers.databinding.ActivityLaunBinding
|
||||
import com.pink.cute.wallpapers.topon.AdManager
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
|
||||
class LaunActivity : AppCompatActivity() {
|
||||
private lateinit var vb: ActivityLaunBinding
|
||||
private var countDownTimer: CountDownTimer?= null
|
||||
private var countDown = 10000L
|
||||
private var countDownTimer: CountDownTimer? = null
|
||||
private var countDown = 11000L
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
vb = ActivityLaunBinding.inflate(LayoutInflater.from(this), null, false)
|
||||
setContentView(vb.root)
|
||||
countDownTimer =
|
||||
AdManager.showWelcomeAd(this@LaunActivity, countDown, { millisUntilFinished ->
|
||||
val percentage: Float = 100 - millisUntilFinished.toFloat() / countDown * 100
|
||||
val round = percentage.roundToInt()
|
||||
vb.progressbar.progress = round
|
||||
if (AdManager.place1LoadFail && AdManager.place2LoadFail && AdManager.place3LoadFail) {
|
||||
countDownTimer?.cancel()
|
||||
welcome()
|
||||
}
|
||||
}, {
|
||||
welcome()
|
||||
})
|
||||
countDownTimer?.start()
|
||||
|
||||
|
||||
}
|
||||
|
||||
private fun welcome() {
|
||||
vb.progressbar.progress = 100
|
||||
startActivity(Intent(this@LaunActivity, MainActivity::class.java))
|
||||
finish()
|
||||
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
|
||||
@ -3,6 +3,7 @@ package com.pink.cute.wallpapers.activity
|
||||
import android.os.Bundle
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.pink.cute.wallpapers.databinding.ActivityPrivacyBinding
|
||||
import com.pink.cute.wallpapers.topon.AdManager
|
||||
|
||||
|
||||
class PrivacyActivity : AppCompatActivity() {
|
||||
@ -10,7 +11,7 @@ class PrivacyActivity : AppCompatActivity() {
|
||||
private lateinit var vb: ActivityPrivacyBinding
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
AdManager.loadAllAd()
|
||||
vb = ActivityPrivacyBinding.inflate(layoutInflater)
|
||||
setContentView(vb.root)
|
||||
vb.webView.loadUrl("file:///android_asset/Pink_Wallpapers_privacy.html")
|
||||
|
||||
@ -34,6 +34,7 @@ import com.pink.cute.wallpapers.databinding.ActivitySetWallpaperBinding
|
||||
import com.pink.cute.wallpapers.manager.Common
|
||||
import com.pink.cute.wallpapers.manager.CropTransformation
|
||||
import com.pink.cute.wallpapers.myroom.MyDatabase
|
||||
import com.pink.cute.wallpapers.topon.AdManager
|
||||
import com.pink.cute.wallpapers.ui.DialogWallpaper
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
@ -51,55 +52,62 @@ class SetWallpaperActivity : AppCompatActivity() {
|
||||
private var mBitmap: Bitmap? = null
|
||||
private var selectDialog: DialogWallpaper? = null
|
||||
|
||||
private val code = -23
|
||||
private val code = 0
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
viewbing = ActivitySetWallpaperBinding.inflate(LayoutInflater.from(this), null, false)
|
||||
setContentView(viewbing.root)
|
||||
initBar()
|
||||
AdManager.loadAllAd()
|
||||
|
||||
wallpaper = intent.getSerializableExtra(Common.KEY_WALLPAPER) as Wallpaper
|
||||
refrshLike()
|
||||
wallpaperManager = WallpaperManager.getInstance(this)
|
||||
loadSource()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
viewbing.btnBack.setOnClickListener {
|
||||
finish()
|
||||
}
|
||||
viewbing.textSetBtn.setOnClickListener {
|
||||
startShowAd {
|
||||
|
||||
AdManager.showTopOn(this@SetWallpaperActivity) {
|
||||
startSet()
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
viewbing.btnSave.setOnClickListener {
|
||||
if (requestPermission(this@SetWallpaperActivity, code)) {
|
||||
startSave()
|
||||
AdManager.showTopOn(this@SetWallpaperActivity) {
|
||||
|
||||
Log.d(PinkWallpapers.TAG,"----------${Thread.currentThread().name}")
|
||||
if (requestPermission( code)) {
|
||||
startSave()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
viewbing.btnLike.setOnClickListener {
|
||||
viewbing.imLike.isSelected = !viewbing.imLike.isSelected
|
||||
if(viewbing.imLike.isSelected){
|
||||
Toast.makeText(this, getString(R.string.add_like), Toast.LENGTH_SHORT)
|
||||
.show()
|
||||
}else{
|
||||
Toast.makeText(this, getString(R.string.cancel_like), Toast.LENGTH_SHORT)
|
||||
.show()
|
||||
AdManager.showTopOn(this@SetWallpaperActivity) {
|
||||
viewbing.imLike.isSelected = !viewbing.imLike.isSelected
|
||||
if (viewbing.imLike.isSelected) {
|
||||
Toast.makeText(this, getString(R.string.add_like), Toast.LENGTH_SHORT)
|
||||
.show()
|
||||
} else {
|
||||
Toast.makeText(this, getString(R.string.cancel_like), Toast.LENGTH_SHORT)
|
||||
.show()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private fun refrshLike(){
|
||||
private fun refrshLike() {
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
wallpaper = MyDatabase.myDatabase.WallpaperDao().queryWallpaper(wallpaper.id)
|
||||
withContext(Dispatchers.Main){
|
||||
viewbing.imLike.isSelected = wallpaper.like
|
||||
withContext(Dispatchers.Main) {
|
||||
viewbing.imLike.isSelected = wallpaper.like
|
||||
}
|
||||
}
|
||||
|
||||
@ -237,10 +245,6 @@ class SetWallpaperActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
|
||||
private fun startShowAd(action: () -> Unit) {
|
||||
action.invoke()
|
||||
}
|
||||
|
||||
private fun initBar() {
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN)
|
||||
window.decorView.systemUiVisibility =
|
||||
@ -288,56 +292,51 @@ class SetWallpaperActivity : AppCompatActivity() {
|
||||
}).preload()
|
||||
}
|
||||
|
||||
/**
|
||||
* .listener(object : RequestListener<Bitmap> {
|
||||
* override fun onLoadFailed(
|
||||
* e: GlideException?,
|
||||
* model: Any?,
|
||||
* target: Target<Bitmap>,
|
||||
* isFirstResource: Boolean
|
||||
* ): Boolean {
|
||||
*
|
||||
* viewbing.loading.isVisible = false
|
||||
* return false
|
||||
* }
|
||||
*
|
||||
* override fun onResourceReady(
|
||||
* resource: Bitmap,
|
||||
* model: Any,
|
||||
* target: Target<Bitmap>?,
|
||||
* dataSource: DataSource,
|
||||
* isFirstResource: Boolean
|
||||
* ): Boolean {
|
||||
* viewbing.loading.isVisible = false
|
||||
* mBitmap = resource
|
||||
*
|
||||
* return false
|
||||
* }
|
||||
* })
|
||||
*/
|
||||
|
||||
// override fun onRequestPermissionsResult(
|
||||
// requestCode: Int,
|
||||
// permissions: Array<out String>,
|
||||
// grantResults: IntArray
|
||||
// ) {
|
||||
// super.onRequestPermissionsResult(requestCode, permissions, grantResults)
|
||||
// if (requestCode == code) {
|
||||
// if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
// startSave()
|
||||
// } else {
|
||||
// Toast.makeText(this, getString(R.string.grant_permission), Toast.LENGTH_SHORT)
|
||||
// .show()
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
override fun onRequestPermissionsResult(
|
||||
requestCode: Int,
|
||||
permissions: Array<out String>,
|
||||
grantResults: IntArray
|
||||
) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
|
||||
if (requestCode == code) {
|
||||
if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
if(requestCode == code){
|
||||
val b =
|
||||
checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED
|
||||
Log.d(PinkWallpapers.TAG,"---------b=${b}")
|
||||
if(b){
|
||||
startSave()
|
||||
} else {
|
||||
}else{
|
||||
Toast.makeText(this, getString(R.string.grant_permission), Toast.LENGTH_SHORT)
|
||||
.show()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun requestPermission(context: Activity, requestCode: Int): Boolean {
|
||||
|
||||
private fun requestPermission(requestCode: Int): Boolean {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
return true
|
||||
}
|
||||
return if (context.checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||
return if (checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||
ActivityCompat.requestPermissions(
|
||||
context,
|
||||
this,
|
||||
arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE),
|
||||
requestCode
|
||||
)
|
||||
|
||||
@ -10,6 +10,7 @@ import com.pink.cute.wallpapers.databinding.ActivityWallpaperListBinding
|
||||
import com.pink.cute.wallpapers.manager.Common
|
||||
import com.pink.cute.wallpapers.manager.ItemDecoration
|
||||
import com.pink.cute.wallpapers.myroom.MyDatabase
|
||||
import com.pink.cute.wallpapers.topon.AdManager
|
||||
import com.pink.cute.wallpapers.viewadapter.AdapterRecommend
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
@ -25,19 +26,19 @@ class WallpaperListActivity : AppCompatActivity() {
|
||||
super.onCreate(savedInstanceState)
|
||||
viewbing = ActivityWallpaperListBinding.inflate(LayoutInflater.from(this), null, false)
|
||||
setContentView(viewbing.root)
|
||||
|
||||
AdManager.loadAllAd()
|
||||
|
||||
mCategory = intent.getSerializableExtra(Common.KEY_CATEGORY_NAME) as Category
|
||||
mAdapter = AdapterRecommend(this)
|
||||
|
||||
CoroutineScope(Dispatchers.IO).launch{
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
val queryList = MyDatabase.myDatabase.WallpaperDao().queryList(mCategory.id)
|
||||
mAdapter.updateList(queryList)
|
||||
}
|
||||
setList()
|
||||
viewbing.textName.text = mCategory.category
|
||||
viewbing.btnBack.setOnClickListener {
|
||||
startShowAd {
|
||||
AdManager.showTopOn(this@WallpaperListActivity) {
|
||||
finish()
|
||||
}
|
||||
|
||||
@ -47,7 +48,7 @@ class WallpaperListActivity : AppCompatActivity() {
|
||||
|
||||
override fun onBackPressed() {
|
||||
super.onBackPressed()
|
||||
startShowAd {
|
||||
AdManager.showTopOn(this@WallpaperListActivity) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,7 +16,7 @@ import java.io.Serializable
|
||||
onDelete = ForeignKey.CASCADE
|
||||
)
|
||||
),
|
||||
indices = [Index(value = ["id"], unique = true)]
|
||||
indices = [Index(value = ["id"], unique = true),Index(value = ["categoryId"])]
|
||||
)
|
||||
class Wallpaper(
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
|
||||
@ -0,0 +1,11 @@
|
||||
package com.pink.cute.wallpapers.topon
|
||||
|
||||
interface AdListener {
|
||||
|
||||
fun loadFail(placeId: String)
|
||||
fun showSuccess()
|
||||
|
||||
fun showFail()
|
||||
|
||||
fun showClose()
|
||||
}
|
||||
220
app/src/main/java/com/pink/cute/wallpapers/topon/AdManager.kt
Normal file
220
app/src/main/java/com/pink/cute/wallpapers/topon/AdManager.kt
Normal file
@ -0,0 +1,220 @@
|
||||
package com.pink.cute.wallpapers.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.pink.cute.wallpapers.PinkWallpapers
|
||||
|
||||
|
||||
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
|
||||
|
||||
/**
|
||||
n66b1da7a40667
|
||||
n66b1da79da269
|
||||
n66b1da796d1ae
|
||||
*/
|
||||
|
||||
const val place1Id = "n66b1da7a40667"
|
||||
const val place2Id = "n66b1da79da269"
|
||||
const val place3Id = "n66b1da796d1ae"
|
||||
|
||||
|
||||
var place1LoadFail = false
|
||||
var place2LoadFail = false
|
||||
var place3LoadFail = false
|
||||
|
||||
val list = mutableListOf<ATInterstitial>()
|
||||
|
||||
|
||||
@JvmStatic
|
||||
fun loadAllAd() {
|
||||
if (list.size <= 0) {
|
||||
val mInterstitialAd1 = ATInterstitial(PinkWallpapers.pinkWallpapers, place1Id)
|
||||
val mInterstitialAd2 = ATInterstitial(PinkWallpapers.pinkWallpapers, place2Id)
|
||||
val mInterstitialAd3 = ATInterstitial(PinkWallpapers.pinkWallpapers, 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(PinkWallpapers.TAG, "-有广告------------")
|
||||
return ad
|
||||
}
|
||||
}
|
||||
Log.d(PinkWallpapers.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(PinkWallpapers.TAG, "LoadLoaded ${ad.mPlacementId}")
|
||||
}
|
||||
|
||||
override fun onInterstitialAdLoadFail(p0: AdError?) {
|
||||
Log.d(PinkWallpapers.TAG, "LoadFail:${p0?.code} ${p0?.fullErrorInfo}")
|
||||
}
|
||||
|
||||
override fun onInterstitialAdClicked(p0: ATAdInfo?) {
|
||||
|
||||
}
|
||||
|
||||
override fun onInterstitialAdShow(p0: ATAdInfo?) {
|
||||
Log.d(PinkWallpapers.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(PinkWallpapers.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()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,6 @@
|
||||
package com.pink.cute.wallpapers.topon;
|
||||
|
||||
public interface onActionListener {
|
||||
|
||||
void onAction();
|
||||
}
|
||||
@ -11,6 +11,7 @@ import androidx.recyclerview.widget.GridLayoutManager
|
||||
import com.pink.cute.wallpapers.activity.AboutActivity
|
||||
import com.pink.cute.wallpapers.databinding.FragmentDashboardBinding
|
||||
import com.pink.cute.wallpapers.manager.ItemDecoration
|
||||
import com.pink.cute.wallpapers.topon.AdManager
|
||||
import com.pink.cute.wallpapers.viewadapter.AdapterRecommend
|
||||
|
||||
class DashboardFragment : Fragment() {
|
||||
@ -43,7 +44,10 @@ class DashboardFragment : Fragment() {
|
||||
|
||||
private fun onClick() {
|
||||
binding.set.setOnClickListener {
|
||||
startActivity(Intent(requireContext(), AboutActivity::class.java))
|
||||
AdManager.showTopOn(requireActivity()) {
|
||||
startActivity(Intent(requireContext(), AboutActivity::class.java))
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -14,6 +14,7 @@ import com.pink.cute.wallpapers.activity.WallpaperListActivity
|
||||
import com.pink.cute.wallpapers.databinding.FragmentHomeBinding
|
||||
import com.pink.cute.wallpapers.manager.Common
|
||||
import com.pink.cute.wallpapers.manager.ItemDecoration
|
||||
import com.pink.cute.wallpapers.topon.AdManager
|
||||
import com.pink.cute.wallpapers.viewadapter.AdapterCategory
|
||||
|
||||
class HomeFragment : Fragment() {
|
||||
@ -32,6 +33,8 @@ class HomeFragment : Fragment() {
|
||||
): View {
|
||||
val homeViewModel = ViewModelProvider(this)[HomeViewModel::class.java]
|
||||
|
||||
|
||||
AdManager.loadAllAd()
|
||||
_binding = FragmentHomeBinding.inflate(inflater, container, false)
|
||||
val root: View = binding.root
|
||||
adapterCategory = AdapterCategory(requireContext())
|
||||
|
||||
@ -10,6 +10,7 @@ import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import com.pink.cute.wallpapers.databinding.FragmentFavoriteBinding
|
||||
import com.pink.cute.wallpapers.manager.ItemDecoration
|
||||
import com.pink.cute.wallpapers.topon.AdManager
|
||||
import com.pink.cute.wallpapers.viewadapter.AdapterRecommend
|
||||
|
||||
class FavoriteFragment : Fragment() {
|
||||
@ -26,7 +27,7 @@ class FavoriteFragment : Fragment() {
|
||||
): View {
|
||||
val favoriteViewModel =
|
||||
ViewModelProvider(this).get(FavoriteViewModel::class.java)
|
||||
|
||||
AdManager.loadAllAd()
|
||||
_binding = FragmentFavoriteBinding.inflate(inflater, container, false)
|
||||
val root: View = binding.root
|
||||
|
||||
|
||||
28
app/src/main/res/drawable/progressbar.xml
Normal file
28
app/src/main/res/drawable/progressbar.xml
Normal file
@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:id="@android:id/background">
|
||||
<shape>
|
||||
<corners android:radius="10dp" />
|
||||
<solid android:color="@color/pb_bg" />
|
||||
</shape>
|
||||
</item>
|
||||
|
||||
|
||||
<item android:id="@android:id/progress">
|
||||
<clip>
|
||||
<shape>
|
||||
<corners android:radius="10dp" />
|
||||
<gradient
|
||||
android:angle="0"
|
||||
android:endColor="@color/pb_end_color"
|
||||
android:startColor="@color/pb_start_color" />
|
||||
</shape>
|
||||
</clip>
|
||||
</item>
|
||||
</layer-list>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -36,13 +36,19 @@
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/logo" />
|
||||
|
||||
|
||||
<ProgressBar
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="84dp"
|
||||
android:indeterminateTint="@color/set_btn_color"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/logo" />
|
||||
android:id="@+id/progressbar"
|
||||
style="?android:attr/progressBarStyleHorizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="10dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginStart="33dp"
|
||||
android:layout_marginEnd="33dp"
|
||||
android:layout_marginBottom="40dp"
|
||||
android:progress="10"
|
||||
android:progressDrawable="@drawable/progressbar"
|
||||
app:layout_constraintBottom_toBottomOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@ -28,10 +28,25 @@
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/set" />
|
||||
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/title_recommend"
|
||||
android:id="@+id/tv_recommend"
|
||||
android:layout_marginStart="12dp"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/set"
|
||||
android:textColor="@color/purple_500"
|
||||
android:textSize="21sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recomoned_recycler"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
android:layout_marginTop="5dp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/set" />
|
||||
app:layout_constraintTop_toBottomOf="@id/tv_recommend" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@ -17,4 +17,7 @@
|
||||
<color name="like_gray">#737373</color>
|
||||
<color name="like_red">#D13434</color>
|
||||
<color name="ss">#1a73e8</color>
|
||||
<color name="pb_bg">#737373</color>
|
||||
<color name="pb_start_color">#F1C9C9</color>
|
||||
<color name="pb_end_color">#FFF78FA7</color>
|
||||
</resources>
|
||||
@ -1,7 +1,7 @@
|
||||
<resources>
|
||||
<string name="app_name">Pink Wallpapers</string>
|
||||
<string name="title_category">Category</string>
|
||||
<string name="title_recommend">Recommend</string>
|
||||
<string name="title_recommend">Recommendation</string>
|
||||
<string name="title_favorite">Favorite</string>
|
||||
<string name="set_wallpaper">Set Wallpaper</string>
|
||||
|
||||
|
||||
@ -12,6 +12,17 @@ dependencyResolutionManagement {
|
||||
google()
|
||||
mavenCentral()
|
||||
|
||||
//Anythink(Core)
|
||||
maven("https://jfrog.anythinktech.com/artifactory/overseas_sdk")
|
||||
//Ironsource
|
||||
maven("https://android-sdk.is.com/")
|
||||
//Mintegral
|
||||
maven("https://dl-maven-android.mintegral.com/repository/mbridge_android_sdk_oversea")
|
||||
//Pangle
|
||||
maven ( "https://artifact.bytedance.com/repository/pangle")
|
||||
|
||||
//TopOn集成测试工具
|
||||
// maven ( "https://jfrog.anythinktech.com/artifactory/debugger")
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user