Commit 5c5b6aaf authored by wanglei's avatar wanglei

...

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