Commit 52753f0a authored by wanglei's avatar wanglei

方便拆包修改

parent eadc463b
......@@ -15,6 +15,7 @@ import android.os.Build
import android.provider.Settings
import android.util.Log
import android.view.View
import android.widget.Toast
import androidx.activity.addCallback
import androidx.core.view.isVisible
import androidx.fragment.app.Fragment
......@@ -28,6 +29,8 @@ import com.test.easy.easycleanerjunk.fragment.LaunchesFragment
import com.test.easy.easycleanerjunk.fragment.ScreenTimeFragment
import com.test.easy.easycleanerjunk.helps.BaseActivity
import com.test.easy.easycleanerjunk.helps.LogEx
import com.test.easy.easycleanerjunk.helps.PermissionHelp.checkUsageAccessSettings
import com.test.easy.easycleanerjunk.helps.PermissionHelp.requestUsageAccessSettings
import com.test.easy.easycleanerjunk.helps.TimeUtils.TODAY_QUERY
import com.test.easy.easycleanerjunk.helps.TimeUtils.YESTERDAY_QUERY
import com.test.easy.easycleanerjunk.helps.TimeUtils.timePair
......@@ -84,22 +87,17 @@ class RecentAppActivity : BaseActivity<ActivityRecentAppBinding>() {
}
}
binding.tvGrand.setOnClickListener {
val intent = Intent(Settings.ACTION_USAGE_ACCESS_SETTINGS)
intent.addCategory("android.intent.category.DEFAULT")
intent.data = Uri.parse("package:${context.packageName}")
launcher.launch(intent) {
LogEx.logDebug(TAG, "launcher callback")
val obj = JSONObject()
obj.put("activity", javaClass.simpleName)
if (checkUsageAccessSettings()) {
requestUsageAccessSettings(launcher, result = { flag ->
if (flag) {
binding.flPermission.visibility = View.GONE
binding.llContent.visibility = View.VISIBLE
intData()
} else {
finishToMain()
}
}
}, resolveNoAction = {
Toast.makeText(this, "no support function", Toast.LENGTH_SHORT).show()
})
}
}
......@@ -113,7 +111,7 @@ class RecentAppActivity : BaseActivity<ActivityRecentAppBinding>() {
binding.llLottie.isVisible = false
showFinish?.invoke()
}
}, Random.nextLong(3000,4000))
}, Random.nextLong(3000, 4000))
}
......@@ -141,6 +139,7 @@ class RecentAppActivity : BaseActivity<ActivityRecentAppBinding>() {
}
}
@SuppressLint("QueryPermissionsNeeded")
private fun initAppData() {
dataList.clear()
......@@ -257,25 +256,6 @@ class RecentAppActivity : BaseActivity<ActivityRecentAppBinding>() {
}
private fun checkUsageAccessSettings(): Boolean {
val appOpsManager = getSystemService(Context.APP_OPS_SERVICE) as AppOpsManager
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
appOpsManager.unsafeCheckOpNoThrow(
AppOpsManager.OPSTR_GET_USAGE_STATS,
android.os.Process.myUid(),
this.packageName
) == AppOpsManager.MODE_ALLOWED
} else {
appOpsManager.checkOpNoThrow(
AppOpsManager.OPSTR_GET_USAGE_STATS,
android.os.Process.myUid(),
this.packageName
) == AppOpsManager.MODE_ALLOWED
}
}
private fun isLaunchApp(context: Context, app: PackageInfo, filterSystem: Boolean = true): Boolean {
val flagSystem = (app.applicationInfo.flags and ApplicationInfo.FLAG_SYSTEM) < 1
......@@ -336,7 +316,7 @@ class RecentAppActivity : BaseActivity<ActivityRecentAppBinding>() {
/**
* 前台运行App+后台运行App=总的启动App
*/
fun getUsageList(context: Context, startTime: Long, endTime: Long): ArrayList<UsageStats> {
private fun getUsageList(context: Context, startTime: Long, endTime: Long): ArrayList<UsageStats> {
val list = arrayListOf<UsageStats>()
val mUsmManager = context.getSystemService(Context.USAGE_STATS_SERVICE) as UsageStatsManager
val map = mUsmManager.queryAndAggregateUsageStats(startTime, endTime)
......
......@@ -28,7 +28,8 @@ class RateStarPop(private val activity: Activity) : PopupWindow() {
}
}
fun dismiss(activity: Activity){
fun dismiss(activity: Activity) {
RateStarPop(activity).dismiss()
}
}
......@@ -47,7 +48,7 @@ class RateStarPop(private val activity: Activity) : PopupWindow() {
}
@SuppressLint("ClickableViewAccessibility")
@SuppressLint("ClickableViewAccessibility", "SetTextI18n")
fun show() {
contentView = binding.root
activity.window.decorView.post {
......@@ -56,6 +57,9 @@ class RateStarPop(private val activity: Activity) : PopupWindow() {
showAtLocation(activity.window.decorView, Gravity.CENTER, 0, 0)
}
val appName = activity.resources.getString(R.string.app_name)
binding.tvTitle.text = "Thank you for using $appName"
listOf(
binding.idStar1,
binding.idStar2,
......
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#b3000000"
......@@ -28,13 +29,13 @@
android:src="@mipmap/guanbi" />
<TextView
android:id="@+id/tv_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginHorizontal="20dp"
android:layout_marginTop="15dp"
android:gravity="center"
android:text="Thank you for using File Manager Select!"
android:textColor="#000000"
android:textSize="16sp"
android:textStyle="bold" />
......@@ -48,7 +49,8 @@
android:gravity="center"
android:text="Thank you very much for taking the time to rate us."
android:textColor="#999999"
android:textSize="14sp" />
android:textSize="14sp"
tools:ignore="HardcodedText" />
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
......
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