Commit 5c5b6aaf authored by wanglei's avatar wanglei

...

parent b3f775b5
......@@ -38,6 +38,18 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".activity.junkclean.ScanJunkActivity"
android:exported="false"
android:launchMode="singleTop"
android:screenOrientation="portrait"
tools:ignore="DiscouragedApi,LockedOrientationActivity" >
<!-- <intent-filter>-->
<!-- <action android:name="android.intent.action.MAIN" />-->
<!-- <category android:name="android.intent.category.LAUNCHER" />-->
<!-- </intent-filter>-->
</activity>
<activity
android:name=".activity.guide.GuideActivity"
android:exported="true"
......@@ -75,12 +87,7 @@
android:launchMode="singleTop"
android:screenOrientation="portrait"
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
<activity
android:name=".activity.junkclean.ScanJunkActivity"
android:exported="false"
android:launchMode="singleTop"
android:screenOrientation="portrait"
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
<activity
android:name=".activity.junkclean.CleanJunkActivity"
android:exported="false"
......
......@@ -10,7 +10,6 @@ import android.widget.Toast
import androidx.activity.addCallback
import androidx.core.view.updatePadding
import androidx.lifecycle.lifecycleScope
import com.base.datarecovery.ads.AdmobMaxHelper
import com.base.datarecovery.ads.AdmobMaxHelper.admobMaxShowInterstitialAd
import com.base.datarecovery.databinding.ActivityLayoutScanJunkBinding
import com.base.datarecovery.help.BaseActivity
......@@ -19,6 +18,7 @@ import com.base.datarecovery.help.PermissionHelp.requestStorePermission
import com.base.datarecovery.utils.BarUtils
import com.base.datarecovery.view.DialogViews.showGerPermission
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
......@@ -27,31 +27,28 @@ import kotlinx.coroutines.launch
*/
class ScanJunkActivity : BaseActivity<ActivityLayoutScanJunkBinding>() {
private val TAG = "ScanJunkActivity"
override val binding: ActivityLayoutScanJunkBinding by lazy {
ActivityLayoutScanJunkBinding.inflate(layoutInflater)
}
private var onResumePlay: Boolean = false
private var job: Job? = null
override fun initView() {
BarUtils.setStatusBarColor(this, Color.TRANSPARENT)
binding.root.updatePadding(top = BarUtils.getStatusBarHeight())
if (checkStorePermission()) {
playLottie()
} else {
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) {
onResumePlay = true
} else {
finishToMain()
}
})
})
}
}
......@@ -63,16 +60,13 @@ class ScanJunkActivity : BaseActivity<ActivityLayoutScanJunkBinding>() {
}
}
private var isPause = false
override fun onResume() {
super.onResume()
if (onResumePlay) {
playLottie()
}
if (isPause) {
binding.lottie.resumeAnimation()
if (checkStorePermission()) {
resumeLottie()
job = waitJob()
}
isPause = false
}
override fun onDestroy() {
......@@ -85,17 +79,18 @@ class ScanJunkActivity : BaseActivity<ActivityLayoutScanJunkBinding>() {
override fun onPause() {
super.onPause()
isPause = true
animator1?.pause()
animator2?.pause()
animator3?.pause()
binding.lottie.pauseAnimation()
job?.cancel()
}
@SuppressLint("SetTextI18n")
private fun playLottie() {
val a1 = ValueAnimator.ofFloat(0f, 360f)
a1.run {
private fun resumeLottie() {
if (animator1 == null) {
animator1 = ValueAnimator.ofFloat(0f, 360f)
animator1?.run {
duration = 1000
repeatMode = ValueAnimator.RESTART
repeatCount = ValueAnimator.INFINITE
......@@ -103,10 +98,12 @@ class ScanJunkActivity : BaseActivity<ActivityLayoutScanJunkBinding>() {
addUpdateListener {
binding.idView1.rotation = it.animatedValue as Float
}
start()
}
val a2 = ValueAnimator.ofFloat(0f, 360f)
a2.run {
}
animator1?.start()
if (animator2 == null) {
animator1 = ValueAnimator.ofFloat(0f, 360f)
animator2?.run {
duration = 1000
repeatMode = ValueAnimator.RESTART
repeatCount = ValueAnimator.INFINITE
......@@ -114,10 +111,12 @@ class ScanJunkActivity : BaseActivity<ActivityLayoutScanJunkBinding>() {
addUpdateListener {
binding.idView2.rotation = it.animatedValue as Float
}
start()
}
val a3 = ValueAnimator.ofFloat(0f, 360f)
a3.run {
}
animator2?.start()
if (animator3 == null) {
animator3 = ValueAnimator.ofFloat(0f, 360f)
animator3?.run {
duration = 1000
repeatMode = ValueAnimator.RESTART
repeatCount = ValueAnimator.INFINITE
......@@ -125,29 +124,30 @@ class ScanJunkActivity : BaseActivity<ActivityLayoutScanJunkBinding>() {
addUpdateListener {
binding.idView3.rotation = it.animatedValue as Float
}
start()
}
}
animator3?.start()
binding.lottie.imageAssetsFolder = "junk_scan/images/"
binding.lottie.setAnimation("junk_scan/data.json")
binding.lottie.playAnimation()
}
lifecycleScope.launch(Dispatchers.Main) {
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!"
a1.cancel()
a2.cancel()
a3.cancel()
animator1?.cancel()
animator2?.cancel()
animator3?.cancel()
delay(1000)
admobMaxShowInterstitialAd(this@ScanJunkActivity) {
startActivity(Intent(this@ScanJunkActivity, CleanJunkActivity::class.java))
finish()
}
}
}
private var animator1: ValueAnimator? = null
private var animator2: ValueAnimator? = null
......
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