Commit 52753f0a authored by wanglei's avatar wanglei

方便拆包修改

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