Commit f160fd89 authored by maxiaoliang's avatar maxiaoliang

增加配置,垃圾清理页面时先播放广告,后询问权限

parent 03875a69
...@@ -238,7 +238,8 @@ ...@@ -238,7 +238,8 @@
android:launchMode="singleTop" android:launchMode="singleTop"
android:screenOrientation="portrait" android:screenOrientation="portrait"
tools:ignore="DiscouragedApi,LockedOrientationActivity" /> tools:ignore="DiscouragedApi,LockedOrientationActivity" />
<activity android:name=".activity.junkclean.ScanJunk2Activity"
android:screenOrientation="portrait"/>
<meta-data <meta-data
android:name="com.google.android.gms.ads.flag.OPTIMIZE_INITIALIZATION" android:name="com.google.android.gms.ads.flag.OPTIMIZE_INITIALIZATION"
android:value="true" /> android:value="true" />
......
package com.base.filerecoveryrecyclebin.activity.junkclean
import android.animation.ValueAnimator
import android.annotation.SuppressLint
import android.content.Intent
import android.graphics.Color
import android.view.View
import android.view.animation.LinearInterpolator
import android.widget.Toast
import androidx.activity.addCallback
import androidx.core.view.updatePadding
import androidx.lifecycle.lifecycleScope
import com.base.filerecoveryrecyclebin.ads.AdmobMaxHelper
import com.base.filerecoveryrecyclebin.databinding.ActivityLayoutScanJunkBinding
import com.base.filerecoveryrecyclebin.help.BaseActivity
import com.base.filerecoveryrecyclebin.utils.BarUtils
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
class ScanJunk2Activity : BaseActivity<ActivityLayoutScanJunkBinding>() {
private val TAG = "ScanJunkActivity"
override val binding: ActivityLayoutScanJunkBinding by lazy {
ActivityLayoutScanJunkBinding.inflate(layoutInflater)
}
private var job: Job? = null
override fun initView() {
BarUtils.setStatusBarColor(this, Color.TRANSPARENT)
binding.root.updatePadding(top = BarUtils.getStatusBarHeight())
// if (!checkStorePermission()) {
// showGerPermission(tittle = "Storage Permission Required",
// desc = "This feature requires access to your storage to scan your files and clean up junk files and unused APK files. We will not transmit your data to any third-party service. Please grant permission so that we can provide you with better service.",
// deny = { finishToMain() },
// allow = {
// requestStorePermission(launcher, result = {
// if (it) {
// } else {
// finishToMain()
// }
// })
// })
// }
}
override fun initListener() {
onBackPressedDispatcher.addCallback {
Toast.makeText(this@ScanJunk2Activity, "wait a moment", Toast.LENGTH_SHORT).show()
}
}
override fun onResume() {
super.onResume()
resumeLottie()
job = waitJob()
}
override fun onDestroy() {
super.onDestroy()
animator1?.cancel()
animator2?.cancel()
animator3?.cancel()
binding.lottie.cancelAnimation()
}
override fun onPause() {
super.onPause()
animator1?.pause()
animator2?.pause()
animator3?.pause()
binding.lottie.pauseAnimation()
job?.cancel()
}
@SuppressLint("SetTextI18n")
private fun resumeLottie() {
if (animator1 == null) {
animator1 = ValueAnimator.ofFloat(0f, 360f)
animator1?.run {
duration = 1000
repeatMode = ValueAnimator.RESTART
repeatCount = ValueAnimator.INFINITE
interpolator = LinearInterpolator()
addUpdateListener {
binding.idView1.rotation = it.animatedValue as Float
}
}
}
animator1?.start()
if (animator2 == null) {
animator2 = ValueAnimator.ofFloat(0f, 360f)
animator2?.run {
duration = 1000
repeatMode = ValueAnimator.RESTART
repeatCount = ValueAnimator.INFINITE
interpolator = LinearInterpolator()
addUpdateListener {
binding.idView2.rotation = it.animatedValue as Float
}
}
}
animator2?.start()
if (animator3 == null) {
animator3 = ValueAnimator.ofFloat(0f, 360f)
animator3?.run {
duration = 1000
repeatMode = ValueAnimator.RESTART
repeatCount = ValueAnimator.INFINITE
interpolator = LinearInterpolator()
addUpdateListener {
binding.idView3.rotation = it.animatedValue as Float
}
}
}
animator3?.start()
binding.lottie.imageAssetsFolder = "junk_scan/images/"
binding.lottie.setAnimation("junk_scan/data.json")
binding.lottie.playAnimation()
}
@SuppressLint("SetTextI18n")
private fun waitJob() = lifecycleScope.launch(Dispatchers.Main) {
delay(5000)
binding.lottie.visibility = View.GONE
binding.lottieCompleted.visibility = View.VISIBLE
binding.lottieCompleted.playAnimation()
binding.tv.text = "Completed!"
animator1?.cancel()
animator2?.cancel()
animator3?.cancel()
delay(1000)
AdmobMaxHelper.admobMaxShowInterstitialAd(this@ScanJunk2Activity) {
startActivity(Intent(this@ScanJunk2Activity, CleanJunkActivity::class.java))
finish()
}
}
private var animator1: ValueAnimator? = null
private var animator2: ValueAnimator? = null
private var animator3: ValueAnimator? = null
}
\ No newline at end of file
...@@ -16,6 +16,7 @@ import com.base.filerecoveryrecyclebin.activity.SettingActivity ...@@ -16,6 +16,7 @@ import com.base.filerecoveryrecyclebin.activity.SettingActivity
import com.base.filerecoveryrecyclebin.activity.appmanager.AppManagerAnimationActivity import com.base.filerecoveryrecyclebin.activity.appmanager.AppManagerAnimationActivity
import com.base.filerecoveryrecyclebin.activity.appprocess.AppProcessAnimationActivity import com.base.filerecoveryrecyclebin.activity.appprocess.AppProcessAnimationActivity
import com.base.filerecoveryrecyclebin.activity.battery.BatteryInfoAnimationActivity import com.base.filerecoveryrecyclebin.activity.battery.BatteryInfoAnimationActivity
import com.base.filerecoveryrecyclebin.activity.junkclean.ScanJunk2Activity
import com.base.filerecoveryrecyclebin.activity.junkclean.ScanJunkActivity import com.base.filerecoveryrecyclebin.activity.junkclean.ScanJunkActivity
import com.base.filerecoveryrecyclebin.activity.largefile.LargeFileAnimationActivity import com.base.filerecoveryrecyclebin.activity.largefile.LargeFileAnimationActivity
import com.base.filerecoveryrecyclebin.activity.repeat.RepeatAnimationActivity import com.base.filerecoveryrecyclebin.activity.repeat.RepeatAnimationActivity
...@@ -25,6 +26,7 @@ import com.base.filerecoveryrecyclebin.databinding.FragmentHome3Binding ...@@ -25,6 +26,7 @@ import com.base.filerecoveryrecyclebin.databinding.FragmentHome3Binding
import com.base.filerecoveryrecyclebin.help.BaseFragment import com.base.filerecoveryrecyclebin.help.BaseFragment
import com.base.filerecoveryrecyclebin.help.KotlinExt.toFormatSize import com.base.filerecoveryrecyclebin.help.KotlinExt.toFormatSize
import com.base.filerecoveryrecyclebin.help.PermissionHelp.checkStorePermission import com.base.filerecoveryrecyclebin.help.PermissionHelp.checkStorePermission
import com.base.filerecoveryrecyclebin.utils.AppPreferences
import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import java.io.File import java.io.File
...@@ -63,7 +65,13 @@ class HomeFragment : BaseFragment<FragmentHome3Binding>() { ...@@ -63,7 +65,13 @@ class HomeFragment : BaseFragment<FragmentHome3Binding>() {
override fun setListener() { override fun setListener() {
binding.flScan.setOnClickListener { binding.flScan.setOnClickListener {
startActivity(Intent(requireContext(), ScanJunkActivity::class.java)) val jumpJunkFirstAd = AppPreferences.getInstance().getString("jumpJunkFirstAd", "0").toInt()
if(jumpJunkFirstAd==1){
startActivity(Intent(requireContext(), ScanJunk2Activity::class.java))
}else{
startActivity(Intent(requireContext(), ScanJunkActivity::class.java))
}
// sendNotification(requireContext(), ConstObject.ID_JUNK_CLEAN_PUSH) // sendNotification(requireContext(), ConstObject.ID_JUNK_CLEAN_PUSH)
// AppLovinSdk.getInstance( requireContext() ).showMediationDebugger() // AppLovinSdk.getInstance( requireContext() ).showMediationDebugger()
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment