V1.0.4(5) 集成TopOn
This commit is contained in:
parent
00e10020c0
commit
fe19a59e5d
@ -19,8 +19,8 @@ android {
|
||||
applicationId = "com.wallart.art.wallpapers.hd"
|
||||
minSdk = 23
|
||||
targetSdk = 34
|
||||
versionCode = 4
|
||||
versionName = "1.0.3"
|
||||
versionCode = 5
|
||||
versionName = "1.0.4"
|
||||
setProperty("archivesBaseName", "Art Wallpaper_V" + versionName + "(${versionCode})_$timestamp")
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
@ -83,4 +83,50 @@ dependencies {
|
||||
implementation ("com.google.firebase:firebase-crashlytics-ktx")
|
||||
|
||||
|
||||
|
||||
//-----------------------------TopOn 聚合(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")
|
||||
|
||||
//Bigo
|
||||
implementation("com.anythink.sdk:adapter-tpn-bigo:6.3.68")
|
||||
implementation("com.bigossp:bigo-ads:4.7.4")
|
||||
|
||||
//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")
|
||||
|
||||
//Tramini
|
||||
implementation("com.anythink.sdk:tramini-plugin-tpn:6.3.68")
|
||||
//-----------------------------TopOn 聚合
|
||||
|
||||
|
||||
// Debugger UI Tools
|
||||
// implementation ("com.anythink.sdk:debugger-ui:1.0.7")
|
||||
}
|
||||
93
app/proguard-rules.pro
vendored
93
app/proguard-rules.pro
vendored
@ -33,38 +33,77 @@
|
||||
-dontwarn org.openjsse.javax.net.ssl.SSLSocket
|
||||
-dontwarn org.openjsse.net.ssl.OpenJSSE
|
||||
|
||||
|
||||
#=======================================UNity SDK
|
||||
# Keep filenames and line numbers for stack traces
|
||||
-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# Keep JavascriptInterface for WebView bridge
|
||||
-keepattributes JavascriptInterface
|
||||
#---------------------------------TopOn 聚合
|
||||
# Vungle
|
||||
-dontwarn com.vungle.ads.**
|
||||
-keepclassmembers class com.vungle.ads.** {
|
||||
*;
|
||||
}
|
||||
|
||||
|
||||
-keep class android.webkit.JavascriptInterface {
|
||||
*;
|
||||
}
|
||||
|
||||
# Keep all classes in Unity Ads package
|
||||
|
||||
-keep class com.unity3d.ads.** {
|
||||
*;
|
||||
}
|
||||
# Google
|
||||
-keep class com.google.android.gms.** { *; }
|
||||
-dontwarn com.google.android.gms.**
|
||||
|
||||
# Keep all classes in Unity Services package
|
||||
-keep class com.unity3d.services.** {
|
||||
*;
|
||||
}
|
||||
|
||||
-keep class com.google.android.gms.ads.initialization.** {
|
||||
*;
|
||||
}
|
||||
|
||||
-keep class com.google.android.gms.ads.MobileAds {
|
||||
*;
|
||||
}
|
||||
|
||||
-dontwarn com.google.ads.mediation.admob.*
|
||||
-dontwarn com.google.android.gms.ads.**
|
||||
#==================================UNity SDK
|
||||
# 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
|
||||
-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 聚合
|
||||
@ -40,11 +40,7 @@
|
||||
android:screenOrientation="fullSensor"
|
||||
tools:ignore="DiscouragedApi" />
|
||||
|
||||
<activity
|
||||
android:name=".page.CategoryPreviewAbility"
|
||||
android:exported="false"
|
||||
android:screenOrientation="fullSensor"
|
||||
tools:ignore="DiscouragedApi" />
|
||||
|
||||
|
||||
<activity
|
||||
android:name=".page.MainAbility"
|
||||
|
||||
@ -2,8 +2,12 @@ package com.cute.girl.hd.pink.img.wallpaper
|
||||
|
||||
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.cute.girl.hd.pink.img.wallpaper.entity.CategoryData
|
||||
import com.cute.girl.hd.pink.img.wallpaper.entity.Data
|
||||
import com.cute.girl.hd.pink.img.wallpaper.topon.AdManager
|
||||
import com.liulishuo.filedownloader.FileDownloader
|
||||
import org.json.JSONArray
|
||||
import java.io.BufferedReader
|
||||
@ -20,10 +24,14 @@ class MyApp : Application() {
|
||||
companion object {
|
||||
lateinit var app: MyApp
|
||||
lateinit var myData: List<CategoryData>
|
||||
const val TAG = "=============="
|
||||
const val AD_INIT_ACTION = "on_success_action"
|
||||
var initSDK = false
|
||||
}
|
||||
|
||||
}
|
||||
private val APPId="h66978895679a9"
|
||||
private val APPKey="00c254f2caba04948f14c41014ac5f33"
|
||||
private val debug_key="fe06c76b794f95216f98e5982ae8f335fc558956"
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
app = this
|
||||
@ -106,23 +114,25 @@ class MyApp : Application() {
|
||||
|
||||
|
||||
private fun initSDK() {
|
||||
// UnityAds.initialize(this, UnityAdManager.unityGameID, UnityAdManager.testMode, object :
|
||||
// IUnityAdsInitializationListener {
|
||||
// override fun onInitializationComplete() {
|
||||
// LocalBroadcastManager.getInstance(this@MyApp).sendBroadcast(Intent(AD_INIT_ACTION))
|
||||
// initSDK = true
|
||||
// UnityAdManager.loadAllAdNew()
|
||||
//
|
||||
// }
|
||||
//
|
||||
// override fun onInitializationFailed(
|
||||
// error: UnityAds.UnityAdsInitializationError?,
|
||||
// message: String?
|
||||
// ) {
|
||||
// initSDK = false
|
||||
// }
|
||||
//
|
||||
// });
|
||||
ATSDK.checkIsEuTraffic(this, object : NetTrafficeCallback {
|
||||
override fun onResultCallback(isEU: Boolean) {
|
||||
Log.e(TAG, "onResultCallback:$isEU")
|
||||
if (isEU && ATSDK.getGDPRDataLevel(this@MyApp) == ATSDK.UNKNOWN) {
|
||||
ATSDK.showGdprAuth(this@MyApp)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onErrorCallback(p0: String?) {
|
||||
Log.e(TAG, "onErrorCallback:${p0}")
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
|
||||
ATSDK.init( this, APPId, APPKey)
|
||||
AdManager.loadAllAd()
|
||||
//测试工具
|
||||
// ATDebuggerUITest.showDebuggerUI(this,debug_key)
|
||||
}
|
||||
|
||||
}
|
||||
@ -205,12 +205,9 @@ class CategoryAbility : AppCompatActivity() {
|
||||
|
||||
|
||||
fun toPreview(pos: Data) {
|
||||
// if (pos < 0 || pos >= mList.size) {
|
||||
// return
|
||||
// }
|
||||
val listBean = CategoryPreviewBean()
|
||||
listBean.list = mList
|
||||
CategoryPreviewAbility.start(this, pos)
|
||||
PreviewAbility.start(this, pos)
|
||||
}
|
||||
|
||||
}
|
||||
@ -11,6 +11,7 @@ import com.cute.girl.hd.pink.img.wallpaper.adapter.CategoryAdapter
|
||||
import com.cute.girl.hd.pink.img.wallpaper.databinding.PageRecentBinding
|
||||
import com.cute.girl.hd.pink.img.wallpaper.entity.CategoryData
|
||||
import com.cute.girl.hd.pink.img.wallpaper.entity.GCategory
|
||||
import com.cute.girl.hd.pink.img.wallpaper.topon.AdManager
|
||||
//import com.cute.girl.hd.pink.img.wallpaper.net.base.BaseListener
|
||||
//import com.cute.girl.hd.pink.img.wallpaper.net.base.ServiceImage
|
||||
//import com.cute.girl.hd.pink.img.wallpaper.net.response.ResponseCategory
|
||||
@ -126,11 +127,20 @@ class CategoryPage : Fragment() {
|
||||
|
||||
|
||||
fun toDetail(pos: CategoryData) {
|
||||
// if (pos < 0 || pos >= mList.size) {
|
||||
// return
|
||||
// }
|
||||
if (activity != null) {
|
||||
CategoryAbility.start(requireActivity(), pos)
|
||||
showTopOn{
|
||||
CategoryAbility.start(requireActivity(), pos)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private fun showTopOn(action: () -> Unit) {
|
||||
AdManager.showAD(requireActivity()) { integer: Int ->
|
||||
if (integer == AdManager.type_show_close || integer == AdManager.type_no_cache || integer == AdManager.type_show_fail) {
|
||||
action.invoke()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,352 +0,0 @@
|
||||
package com.cute.girl.hd.pink.img.wallpaper.page
|
||||
|
||||
import android.app.WallpaperManager
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.view.WindowManager
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.viewpager2.widget.ViewPager2
|
||||
import com.cute.girl.hd.pink.img.wallpaper.R
|
||||
import com.cute.girl.hd.pink.img.wallpaper.adapter.CategoryPagerAdapter
|
||||
import com.cute.girl.hd.pink.img.wallpaper.databinding.AbilityPreviewBinding
|
||||
import com.cute.girl.hd.pink.img.wallpaper.entity.CategoryPreviewBean
|
||||
import com.cute.girl.hd.pink.img.wallpaper.entity.Data
|
||||
import com.cute.girl.hd.pink.img.wallpaper.entity.GCategoryDetail
|
||||
import com.cute.girl.hd.pink.img.wallpaper.entity.IntentConstants
|
||||
import com.cute.girl.hd.pink.img.wallpaper.utils.DownloadUtil
|
||||
import com.cute.girl.hd.pink.img.wallpaper.utils.GlobalExt.getString
|
||||
import com.cute.girl.hd.pink.img.wallpaper.utils.GlobalExt.hide
|
||||
import com.cute.girl.hd.pink.img.wallpaper.utils.GlobalExt.onMain
|
||||
import com.cute.girl.hd.pink.img.wallpaper.utils.GlobalExt.show
|
||||
import com.cute.girl.hd.pink.img.wallpaper.utils.MediaUtil
|
||||
import com.cute.girl.hd.pink.img.wallpaper.utils.PermissionUtil
|
||||
import com.cute.girl.hd.pink.img.wallpaper.view.SetAsDialog
|
||||
import com.liulishuo.filedownloader.BaseDownloadTask
|
||||
import com.liulishuo.filedownloader.FileDownloadListener
|
||||
import com.liulishuo.filedownloader.FileDownloader
|
||||
import kotlinx.coroutines.launch
|
||||
import pub.devrel.easypermissions.EasyPermissions
|
||||
import java.io.File
|
||||
|
||||
class CategoryPreviewAbility : AppCompatActivity(), EasyPermissions.PermissionCallbacks {
|
||||
private lateinit var binding: AbilityPreviewBinding
|
||||
private var mList: MutableList<Data> = mutableListOf()
|
||||
private var mCurPos: Int = 0
|
||||
private var mImagePagerAdapter: CategoryPagerAdapter? = null
|
||||
private var mSetAsDialog: SetAsDialog? = null
|
||||
private var mAction = 0//0设置壁纸 1下载壁纸
|
||||
|
||||
companion object {
|
||||
fun start(context: Context,bean: Data) {
|
||||
val intent = Intent(context, CategoryPreviewAbility::class.java)
|
||||
intent.putExtra(IntentConstants.KEY_LIST, bean)
|
||||
// intent.putExtra(IntentConstants.KEY_POS, pos)
|
||||
context.startActivity(intent)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
binding = AbilityPreviewBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
setupViews()
|
||||
}
|
||||
|
||||
private fun setupViews() {
|
||||
//隐藏状态栏和底部导航栏
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN)
|
||||
window.decorView.systemUiVisibility =
|
||||
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_FULLSCREEN
|
||||
|
||||
initData()
|
||||
setUpView()
|
||||
}
|
||||
|
||||
private fun initData() {
|
||||
var listBean: Data? = null
|
||||
if (intent.hasExtra(IntentConstants.KEY_LIST)) {
|
||||
listBean = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
intent.getSerializableExtra(IntentConstants.KEY_LIST, Data::class.java)
|
||||
} else {
|
||||
intent.getSerializableExtra(IntentConstants.KEY_LIST) as Data?
|
||||
}
|
||||
}
|
||||
if (listBean == null) {
|
||||
finish()
|
||||
return
|
||||
}
|
||||
mList.clear()
|
||||
mList.add(listBean)
|
||||
|
||||
if (mList.size == 0) {
|
||||
finish()
|
||||
return
|
||||
}
|
||||
|
||||
mCurPos = intent.getIntExtra(IntentConstants.KEY_POS, 0)
|
||||
|
||||
if (mCurPos < 0 || mCurPos >= mList.size) {
|
||||
finish()
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
private fun setUpView() {
|
||||
mImagePagerAdapter = CategoryPagerAdapter(this, mList)
|
||||
mImagePagerAdapter?.setOnItemClickListener(object :
|
||||
CategoryPagerAdapter.OnItemClickListener {
|
||||
override fun onItemClick(pos: Int) {
|
||||
|
||||
}
|
||||
})
|
||||
binding.viewPager.adapter = mImagePagerAdapter!!
|
||||
binding.viewPager.setCurrentItem(mCurPos, false)
|
||||
binding.viewPager.registerOnPageChangeCallback(object :
|
||||
ViewPager2.OnPageChangeCallback() {
|
||||
override fun onPageSelected(position: Int) {
|
||||
mCurPos = position
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
binding.ivBack.setOnClickListener {
|
||||
onBackPressed()
|
||||
}
|
||||
|
||||
binding.tvSet.setOnClickListener {
|
||||
mAction = 0
|
||||
if (isExist()) {
|
||||
set4KWallpaper()
|
||||
} else {
|
||||
startDownload()
|
||||
}
|
||||
}
|
||||
|
||||
binding.tvDownload.setOnClickListener {
|
||||
doSave()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
mSetAsDialog?.dismiss()
|
||||
}
|
||||
|
||||
private fun isExist(): Boolean {
|
||||
return DownloadUtil.isExist(
|
||||
mList[mCurPos].sourceURl,
|
||||
mList[mCurPos].getTag()
|
||||
)
|
||||
}
|
||||
|
||||
private fun set4KWallpaper() {
|
||||
val image = mList[mCurPos]
|
||||
val path =
|
||||
DownloadUtil.getFilePath(
|
||||
image.getTag()
|
||||
)
|
||||
val file = File(path)
|
||||
if (!file.exists()) {
|
||||
return
|
||||
}
|
||||
val wallpaperManager = WallpaperManager.getInstance(this)
|
||||
if (mSetAsDialog == null) {
|
||||
mSetAsDialog = SetAsDialog(this) {
|
||||
onClickHomeScreen = {
|
||||
lifecycleScope.launch {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
wallpaperManager.setStream(
|
||||
file.inputStream(),
|
||||
null,
|
||||
true,
|
||||
WallpaperManager.FLAG_SYSTEM
|
||||
)
|
||||
}else{
|
||||
wallpaperManager.setStream(file.inputStream())
|
||||
}
|
||||
onMain {
|
||||
Toast.makeText(
|
||||
this@CategoryPreviewAbility,
|
||||
R.string.set_success.getString(),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onClickLockScreen = {
|
||||
lifecycleScope.launch {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
wallpaperManager.setStream(
|
||||
file.inputStream(),
|
||||
null,
|
||||
true,
|
||||
WallpaperManager.FLAG_LOCK
|
||||
)
|
||||
}else{
|
||||
wallpaperManager.setStream(file.inputStream())
|
||||
}
|
||||
onMain {
|
||||
Toast.makeText(
|
||||
this@CategoryPreviewAbility,
|
||||
R.string.set_success.getString(),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onClickBoth = {
|
||||
lifecycleScope.launch {
|
||||
wallpaperManager.setStream(file.inputStream())//FLAG_SYSTEM | FLAG_LOCK)
|
||||
onMain {
|
||||
Toast.makeText(
|
||||
this@CategoryPreviewAbility,
|
||||
R.string.set_success.getString(),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
mSetAsDialog?.show()
|
||||
}
|
||||
|
||||
private fun doSave() {
|
||||
if (!PermissionUtil.hasStoragePermission(this)) {
|
||||
PermissionUtil.requestStoragePermission(this)
|
||||
return
|
||||
}
|
||||
clickSave()
|
||||
}
|
||||
|
||||
private fun clickSave() {
|
||||
mAction = 1
|
||||
if (isExist()) {
|
||||
saveWallpaper()
|
||||
} else {
|
||||
startDownload()
|
||||
}
|
||||
}
|
||||
|
||||
private fun startDownload() {
|
||||
if (isFinishing) {
|
||||
return
|
||||
}
|
||||
binding.flDownload.show()
|
||||
FileDownloader.getImpl().create(mList[mCurPos].sourceURl)
|
||||
.setPath(DownloadUtil.getFilePath( mList[mCurPos].getTag()))
|
||||
.setCallbackProgressTimes(300)
|
||||
.setMinIntervalUpdateSpeed(400)
|
||||
.setListener(object : FileDownloadListener() {
|
||||
override fun pending(task: BaseDownloadTask?, soFarBytes: Int, totalBytes: Int) {
|
||||
|
||||
}
|
||||
|
||||
override fun progress(task: BaseDownloadTask?, soFarBytes: Int, totalBytes: Int) {
|
||||
if (!isFinishing) {
|
||||
binding.pbb.show()
|
||||
}
|
||||
}
|
||||
|
||||
override fun completed(task: BaseDownloadTask?) {
|
||||
if (!isFinishing) {
|
||||
binding.flDownload.hide()
|
||||
mImagePagerAdapter?.notifyItemChanged(mCurPos)
|
||||
if (mAction == 0) {
|
||||
set4KWallpaper()
|
||||
} else {
|
||||
saveWallpaper()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun paused(task: BaseDownloadTask?, soFarBytes: Int, totalBytes: Int) {
|
||||
if (!isFinishing) {
|
||||
binding.flDownload.hide()
|
||||
Toast.makeText(
|
||||
this@CategoryPreviewAbility,
|
||||
R.string.download_failed,
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
}
|
||||
|
||||
override fun error(task: BaseDownloadTask?, e: Throwable?) {
|
||||
if (!isFinishing) {
|
||||
binding.flDownload.hide()
|
||||
Toast.makeText(
|
||||
this@CategoryPreviewAbility,
|
||||
R.string.download_failed,
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
}
|
||||
|
||||
override fun warn(task: BaseDownloadTask?) {
|
||||
if (!isFinishing) {
|
||||
binding.flDownload.hide()
|
||||
Toast.makeText(
|
||||
this@CategoryPreviewAbility,
|
||||
R.string.download_failed,
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
}
|
||||
|
||||
}).start()
|
||||
}
|
||||
|
||||
private fun saveWallpaper() {
|
||||
val image = mList[mCurPos]
|
||||
val path =
|
||||
DownloadUtil.getFilePath(
|
||||
image.getTag()
|
||||
)
|
||||
val saved = MediaUtil.saveImageToSystemAlbum(path, this@CategoryPreviewAbility)
|
||||
if (!isFinishing) {
|
||||
if (saved) {
|
||||
Toast.makeText(
|
||||
this@CategoryPreviewAbility,
|
||||
R.string.saved_to_album,
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
} else {
|
||||
Toast.makeText(
|
||||
this@CategoryPreviewAbility,
|
||||
R.string.save_failed,
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
override fun onRequestPermissionsResult(
|
||||
requestCode: Int,
|
||||
permissions: Array<out String>,
|
||||
grantResults: IntArray
|
||||
) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
|
||||
EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this)
|
||||
}
|
||||
|
||||
override fun onPermissionsGranted(requestCode: Int, perms: MutableList<String>) {
|
||||
if (requestCode == PermissionUtil.REQUEST_CODE_PERMISSION_STORAGE) {
|
||||
doSave()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onPermissionsDenied(requestCode: Int, perms: MutableList<String>) {
|
||||
if (requestCode == PermissionUtil.REQUEST_CODE_PERMISSION_STORAGE) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -12,11 +12,13 @@ import android.widget.Toast
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.viewpager2.widget.ViewPager2
|
||||
import com.cute.girl.hd.pink.img.wallpaper.MyApp
|
||||
import com.cute.girl.hd.pink.img.wallpaper.R
|
||||
import com.cute.girl.hd.pink.img.wallpaper.adapter.ImagePagerAdapter
|
||||
import com.cute.girl.hd.pink.img.wallpaper.databinding.AbilityPreviewBinding
|
||||
import com.cute.girl.hd.pink.img.wallpaper.entity.Data
|
||||
import com.cute.girl.hd.pink.img.wallpaper.entity.IntentConstants
|
||||
import com.cute.girl.hd.pink.img.wallpaper.topon.AdManager
|
||||
import com.cute.girl.hd.pink.img.wallpaper.utils.DownloadUtil
|
||||
import com.cute.girl.hd.pink.img.wallpaper.utils.GlobalExt.getString
|
||||
import com.cute.girl.hd.pink.img.wallpaper.utils.GlobalExt.hide
|
||||
@ -55,9 +57,13 @@ class PreviewAbility : AppCompatActivity(), EasyPermissions.PermissionCallbacks
|
||||
setupViews()
|
||||
}
|
||||
|
||||
private fun showMyMAx(action: () -> Unit) {
|
||||
// TODO:
|
||||
action.invoke()
|
||||
private fun showTopOn(action: () -> Unit) {
|
||||
AdManager.showAD(this@PreviewAbility) { integer: Int ->
|
||||
if (integer == AdManager.type_show_close || integer == AdManager.type_no_cache || integer == AdManager.type_show_fail) {
|
||||
action.invoke()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupViews() {
|
||||
@ -131,10 +137,7 @@ class PreviewAbility : AppCompatActivity(), EasyPermissions.PermissionCallbacks
|
||||
}
|
||||
|
||||
binding.tvDownload.setOnClickListener {
|
||||
showMyMAx {
|
||||
doSave()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -167,7 +170,7 @@ class PreviewAbility : AppCompatActivity(), EasyPermissions.PermissionCallbacks
|
||||
mSetAsDialog = SetAsDialog(this) {
|
||||
onClickHomeScreen = {
|
||||
|
||||
showMyMAx {
|
||||
showTopOn {
|
||||
lifecycleScope.launch {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
|
||||
wallpaperManager.setStream(file.inputStream())
|
||||
@ -193,7 +196,7 @@ class PreviewAbility : AppCompatActivity(), EasyPermissions.PermissionCallbacks
|
||||
|
||||
onClickLockScreen = {
|
||||
|
||||
showMyMAx {
|
||||
showTopOn {
|
||||
lifecycleScope.launch {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
|
||||
wallpaperManager.setStream(file.inputStream())
|
||||
@ -218,7 +221,7 @@ class PreviewAbility : AppCompatActivity(), EasyPermissions.PermissionCallbacks
|
||||
}
|
||||
|
||||
onClickBoth = {
|
||||
showMyMAx {
|
||||
showTopOn {
|
||||
lifecycleScope.launch {
|
||||
wallpaperManager.setStream(file.inputStream())//FLAG_SYSTEM | FLAG_LOCK)
|
||||
onMain {
|
||||
@ -258,16 +261,16 @@ class PreviewAbility : AppCompatActivity(), EasyPermissions.PermissionCallbacks
|
||||
if (isFinishing) {
|
||||
return
|
||||
}
|
||||
val filePath = DownloadUtil.getFilePath( mList[mCurPos].getTag())
|
||||
val filePath = DownloadUtil.getFilePath(mList[mCurPos].getTag())
|
||||
Log.d(
|
||||
"-----------",
|
||||
"---------startDownload-${mList[mCurPos].sourceURl} filePath=${filePath}"
|
||||
)
|
||||
binding.flDownload.show()
|
||||
DownloadUtil.downloadFile(mList[mCurPos].sourceURl,filePath){
|
||||
DownloadUtil.downloadFile(mList[mCurPos].sourceURl, filePath) {
|
||||
runOnUiThread {
|
||||
binding.flDownload.hide()
|
||||
if(it){
|
||||
if (it) {
|
||||
if (!isFinishing) {
|
||||
binding.flDownload.hide()
|
||||
mImagePagerAdapter?.notifyItemChanged(mCurPos)
|
||||
@ -277,7 +280,7 @@ class PreviewAbility : AppCompatActivity(), EasyPermissions.PermissionCallbacks
|
||||
saveWallpaper()
|
||||
}
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
if (!isFinishing) {
|
||||
binding.flDownload.hide()
|
||||
Toast.makeText(
|
||||
@ -288,70 +291,8 @@ class PreviewAbility : AppCompatActivity(), EasyPermissions.PermissionCallbacks
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// FileDownloader.getImpl().create(mList[mCurPos].sourceURl)
|
||||
// .setPath(filePath)
|
||||
// .setCallbackProgressTimes(300)
|
||||
// .setMinIntervalUpdateSpeed(400)
|
||||
// .setListener(object : FileDownloadListener() {
|
||||
// override fun pending(task: BaseDownloadTask?, soFarBytes: Int, totalBytes: Int) {
|
||||
//
|
||||
// }
|
||||
//
|
||||
// override fun progress(task: BaseDownloadTask?, soFarBytes: Int, totalBytes: Int) {
|
||||
// if (!isFinishing) {
|
||||
// binding.pbb.show()
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// override fun completed(task: BaseDownloadTask?) {
|
||||
// Log.d("-----------", "---------completed")
|
||||
// if (!isFinishing) {
|
||||
// binding.flDownload.hide()
|
||||
// mImagePagerAdapter?.notifyItemChanged(mCurPos)
|
||||
// if (mAction == 0) {
|
||||
// set4KWallpaper()
|
||||
// } else {
|
||||
// saveWallpaper()
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// override fun paused(task: BaseDownloadTask?, soFarBytes: Int, totalBytes: Int) {
|
||||
// if (!isFinishing) {
|
||||
// binding.flDownload.hide()
|
||||
// Toast.makeText(
|
||||
// this@PreviewAbility,
|
||||
// R.string.download_failed,
|
||||
// Toast.LENGTH_SHORT
|
||||
// ).show()
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// override fun error(task: BaseDownloadTask?, e: Throwable?) {
|
||||
// if (!isFinishing) {
|
||||
// binding.flDownload.hide()
|
||||
// Toast.makeText(
|
||||
// this@PreviewAbility,
|
||||
// R.string.download_failed,
|
||||
// Toast.LENGTH_SHORT
|
||||
// ).show()
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// override fun warn(task: BaseDownloadTask?) {
|
||||
// if (!isFinishing) {
|
||||
// binding.flDownload.hide()
|
||||
// Toast.makeText(
|
||||
// this@PreviewAbility,
|
||||
// R.string.download_failed,
|
||||
// Toast.LENGTH_SHORT
|
||||
// ).show()
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }).start()
|
||||
}
|
||||
|
||||
private fun saveWallpaper() {
|
||||
|
||||
@ -5,23 +5,31 @@ import android.os.Bundle
|
||||
import android.os.CountDownTimer
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.cute.girl.hd.pink.img.wallpaper.databinding.AbilityStartBinding
|
||||
import com.cute.girl.hd.pink.img.wallpaper.topon.AdManager
|
||||
|
||||
class StartAbility : AppCompatActivity() {
|
||||
private lateinit var binding: AbilityStartBinding
|
||||
|
||||
private var time = 13000L
|
||||
private var needShow = true
|
||||
private var time = 11000L
|
||||
|
||||
private lateinit var countDownTimer: CountDownTimer
|
||||
|
||||
private var countDownTimer: CountDownTimer? = null
|
||||
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
binding = AbilityStartBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
countDownTimer = AdManager.showWelcomeAd(this@StartAbility, time) {
|
||||
setupViews()
|
||||
}
|
||||
|
||||
setupViews()
|
||||
countDownTimer?.start()
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
countDownTimer?.cancel()
|
||||
}
|
||||
|
||||
private fun setupViews() {
|
||||
@ -30,5 +38,4 @@ class StartAbility : AppCompatActivity() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
package com.cute.girl.hd.pink.img.wallpaper.topon
|
||||
|
||||
interface AdListener {
|
||||
fun showSuccess()
|
||||
|
||||
fun showFail()
|
||||
|
||||
fun showClose()
|
||||
}
|
||||
@ -0,0 +1,181 @@
|
||||
package com.cute.girl.hd.pink.img.wallpaper.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.cute.girl.hd.pink.img.wallpaper.MyApp
|
||||
|
||||
|
||||
object AdManager {
|
||||
|
||||
|
||||
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
|
||||
|
||||
/***
|
||||
* n66978a7938950
|
||||
* n66978a6a2a132
|
||||
* n66978a40971a3
|
||||
*/
|
||||
const val place1Id = "n66978a7938950"
|
||||
const val place2Id = "n66978a6a2a132"
|
||||
const val place3Id = "n66978a40971a3"
|
||||
|
||||
val list = mutableListOf<ATInterstitial>()
|
||||
|
||||
|
||||
@JvmStatic
|
||||
fun loadAllAd() {
|
||||
if (list.size <= 0) {
|
||||
val mInterstitialAd1 = ATInterstitial(MyApp.app, place1Id)
|
||||
val mInterstitialAd2 = ATInterstitial(MyApp.app, place2Id)
|
||||
val mInterstitialAd3 = ATInterstitial(MyApp.app, place3Id)
|
||||
list.add(mInterstitialAd1)
|
||||
list.add(mInterstitialAd2)
|
||||
list.add(mInterstitialAd3)
|
||||
}
|
||||
for (ad in list) {
|
||||
if (!ad.isAdReady) {
|
||||
setCallBack(ad,object : AdListener {
|
||||
override fun showSuccess() {
|
||||
|
||||
}
|
||||
|
||||
override fun showFail() {
|
||||
|
||||
}
|
||||
|
||||
override fun showClose() {
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
ad.load()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@JvmStatic
|
||||
fun getReadyAd(): ATInterstitial? {
|
||||
list.shuffle()
|
||||
for (ad in list) {
|
||||
if (ad.isAdReady) {
|
||||
return ad
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
|
||||
@JvmStatic
|
||||
fun showWelcomeAd(activity: Activity,totalTim: Long, goMain: () -> Unit): CountDownTimer {
|
||||
var alreadyShow = false
|
||||
var timer = object : CountDownTimer(totalTim, 100) {
|
||||
override fun onTick(millisUntilFinished: Long) {
|
||||
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(MyApp.TAG, "LoadLoaded ${ad.mPlacementId}")
|
||||
}
|
||||
|
||||
override fun onInterstitialAdLoadFail(p0: AdError?) {
|
||||
Log.d(MyApp.TAG, "LoadFail:${p0?.code} ${p0?.desc}")
|
||||
}
|
||||
|
||||
override fun onInterstitialAdClicked(p0: ATAdInfo?) {
|
||||
|
||||
}
|
||||
|
||||
override fun onInterstitialAdShow(p0: ATAdInfo?) {
|
||||
Log.d(MyApp.TAG, "AdShow ${p0?.showId} ")
|
||||
listener.showSuccess()
|
||||
ad.load()
|
||||
}
|
||||
|
||||
override fun onInterstitialAdClose(p0: ATAdInfo?) {
|
||||
Log.d(MyApp.TAG, "AdClose ${p0?.showId} ")
|
||||
listener.showClose()
|
||||
}
|
||||
|
||||
override fun onInterstitialAdVideoStart(p0: ATAdInfo?) {
|
||||
|
||||
}
|
||||
|
||||
override fun onInterstitialAdVideoEnd(p0: ATAdInfo?) {
|
||||
|
||||
}
|
||||
|
||||
override fun onInterstitialAdVideoError(p0: AdError?) {
|
||||
listener.showFail()
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@JvmStatic
|
||||
fun showAD(activity: Activity, action: (type: Int) -> Unit) {
|
||||
val readyAd = getReadyAd()
|
||||
if (readyAd!= null) {
|
||||
Log.d(MyApp.TAG, "readyAd ${readyAd.mPlacementId} ")
|
||||
action.invoke(type_has_cache)
|
||||
setCallBack(readyAd,object : AdListener {
|
||||
override fun showSuccess() {
|
||||
action.invoke(type_show_success)
|
||||
}
|
||||
|
||||
override fun showFail() {
|
||||
action.invoke(type_show_fail)
|
||||
}
|
||||
|
||||
override fun showClose() {
|
||||
action.invoke(type_show_close)
|
||||
}
|
||||
|
||||
})
|
||||
readyAd.show(activity)
|
||||
} else {
|
||||
Log.d(MyApp.TAG, "showAD type_no_cache ")
|
||||
action.invoke(type_no_cache)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -20,6 +20,14 @@ dependencyResolutionManagement {
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
|
||||
//Anythink(Core)
|
||||
maven ("https://jfrog.anythinktech.com/artifactory/overseas_sdk")
|
||||
//Mintegral
|
||||
maven ("https://dl-maven-android.mintegral.com/repository/mbridge_android_sdk_oversea")
|
||||
|
||||
//TopOn集成测试工具
|
||||
// maven ( "https://jfrog.anythinktech.com/artifactory/debugger")
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user