Commit 294472a7 authored by 周文华's avatar 周文华

【修复】1.修复循环获取通知栏事件id导致的崩溃。2.修复空数据导致的崩溃。3.修复部分机型跳转页缺失导致的崩溃。

parent 0145597a
...@@ -116,6 +116,7 @@ class ColorProgress : View { ...@@ -116,6 +116,7 @@ class ColorProgress : View {
fun animateProgress(list: List<ProgressBean>) { fun animateProgress(list: List<ProgressBean>) {
listProgressBean = list listProgressBean = list
if(list.isEmpty())return
val totalAngle = list.maxOf { it.sweepAngle } val totalAngle = list.maxOf { it.sweepAngle }
val progressAnimator = ValueAnimator.ofFloat(0f, totalAngle) val progressAnimator = ValueAnimator.ofFloat(0f, totalAngle)
progressAnimator.interpolator = LinearInterpolator() // 平滑插值器 progressAnimator.interpolator = LinearInterpolator() // 平滑插值器
......
...@@ -2,6 +2,7 @@ package com.base.pdfviewerscannerwhite.utils ...@@ -2,6 +2,7 @@ package com.base.pdfviewerscannerwhite.utils
import android.Manifest import android.Manifest
import android.app.Activity import android.app.Activity
import android.content.ActivityNotFoundException
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.content.pm.PackageManager import android.content.pm.PackageManager
...@@ -18,15 +19,20 @@ object PermissionUtils { ...@@ -18,15 +19,20 @@ object PermissionUtils {
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
Environment.isExternalStorageManager() Environment.isExternalStorageManager()
} else { } else {
val readPermission = ActivityCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) val readPermission =
val writePermission = ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) ActivityCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE)
val writePermission =
ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)
return readPermission == PackageManager.PERMISSION_GRANTED && writePermission == PackageManager.PERMISSION_GRANTED; return readPermission == PackageManager.PERMISSION_GRANTED && writePermission == PackageManager.PERMISSION_GRANTED;
} }
} }
fun Context.checkNotificationPermission(): Boolean { fun Context.checkNotificationPermission(): Boolean {
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
ActivityCompat.checkSelfPermission(this, Manifest.permission.POST_NOTIFICATIONS) == PackageManager.PERMISSION_GRANTED ActivityCompat.checkSelfPermission(
this,
Manifest.permission.POST_NOTIFICATIONS
) == PackageManager.PERMISSION_GRANTED
} else { } else {
return true return true
} }
...@@ -38,7 +44,10 @@ object PermissionUtils { ...@@ -38,7 +44,10 @@ object PermissionUtils {
fun Activity.userDenyNotificationPermission(): Boolean { fun Activity.userDenyNotificationPermission(): Boolean {
val shouldShowRationale = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { val shouldShowRationale = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.POST_NOTIFICATIONS) ActivityCompat.shouldShowRequestPermissionRationale(
this,
Manifest.permission.POST_NOTIFICATIONS
)
} else { } else {
true true
} }
...@@ -55,20 +64,28 @@ object PermissionUtils { ...@@ -55,20 +64,28 @@ object PermissionUtils {
jumpAction: (() -> Unit)? = null, jumpAction: (() -> Unit)? = null,
result: (flag: Boolean) -> Unit result: (flag: Boolean) -> Unit
) { ) {
try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
val intent = val intent =
Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION) Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION)
intent.addCategory("android.intent.category.DEFAULT") intent.addCategory("android.intent.category.DEFAULT")
intent.data = Uri.parse("package:${packageName}") intent.data = Uri.parse("package:${packageName}")
jumpAction?.invoke() jumpAction?.invoke()
launcher.launch(intent) { launcher.launch(intent) {
result.invoke(checkStorePermission()) result.invoke(checkStorePermission())
} }
} else { } else {
launcher.launch(arrayOf(Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE)) { map -> launcher.launch(
result(map.values.all { it }) arrayOf(
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE
)
) { map ->
result(map.values.all { it })
}
} }
} catch (_: ActivityNotFoundException) {
} }
} }
......
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