优化
This commit is contained in:
@@ -146,30 +146,31 @@ class ContentProcessor private constructor(
|
|||||||
effectiveReplaceRules = arrayListOf()
|
effectiveReplaceRules = arrayListOf()
|
||||||
mContent = mContent.lines().joinToString("\n") { it.trim() }
|
mContent = mContent.lines().joinToString("\n") { it.trim() }
|
||||||
getContentReplaceRules().forEach { item ->
|
getContentReplaceRules().forEach { item ->
|
||||||
if (item.pattern.isNotEmpty()) {
|
if (item.pattern.isEmpty()) {
|
||||||
try {
|
return@forEach
|
||||||
val tmp = if (item.isRegex) {
|
}
|
||||||
mContent.replace(
|
try {
|
||||||
item.pattern.toRegex(),
|
val tmp = if (item.isRegex) {
|
||||||
item.replacement,
|
mContent.replace(
|
||||||
item.getValidTimeoutMillisecond()
|
item.pattern.toRegex(),
|
||||||
)
|
item.replacement,
|
||||||
} else {
|
item.getValidTimeoutMillisecond()
|
||||||
mContent.replace(item.pattern, item.replacement)
|
)
|
||||||
}
|
} else {
|
||||||
if (mContent != tmp) {
|
mContent.replace(item.pattern, item.replacement)
|
||||||
effectiveReplaceRules.add(item)
|
|
||||||
mContent = tmp
|
|
||||||
}
|
|
||||||
} catch (e: RegexTimeoutException) {
|
|
||||||
item.isEnabled = false
|
|
||||||
appDb.replaceRuleDao.update(item)
|
|
||||||
mContent = item.name + e.stackTraceStr
|
|
||||||
} catch (_: CancellationException) {
|
|
||||||
} catch (e: Exception) {
|
|
||||||
AppLog.put("替换净化: 规则 ${item.name}替换出错.\n${mContent}", e)
|
|
||||||
appCtx.toastOnUi("替换净化: 规则 ${item.name}替换出错")
|
|
||||||
}
|
}
|
||||||
|
if (mContent != tmp) {
|
||||||
|
effectiveReplaceRules.add(item)
|
||||||
|
mContent = tmp
|
||||||
|
}
|
||||||
|
} catch (e: RegexTimeoutException) {
|
||||||
|
item.isEnabled = false
|
||||||
|
appDb.replaceRuleDao.update(item)
|
||||||
|
mContent = item.name + e.stackTraceStr
|
||||||
|
} catch (_: CancellationException) {
|
||||||
|
} catch (e: Exception) {
|
||||||
|
AppLog.put("替换净化: 规则 ${item.name}替换出错.\n${mContent}", e)
|
||||||
|
appCtx.toastOnUi("替换净化: 规则 ${item.name}替换出错")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -258,6 +258,7 @@ object Restore {
|
|||||||
if (!BuildConfig.DEBUG) {
|
if (!BuildConfig.DEBUG) {
|
||||||
LauncherIconHelp.changeIcon(appCtx.getPrefString(PreferKey.launcherIcon))
|
LauncherIconHelp.changeIcon(appCtx.getPrefString(PreferKey.launcherIcon))
|
||||||
}
|
}
|
||||||
|
ThemeConfig.applyDayNight(appCtx)
|
||||||
postEvent(EventBus.RECREATE, "")
|
postEvent(EventBus.RECREATE, "")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,7 +42,8 @@ class PermissionActivity : AppCompatActivity() {
|
|||||||
Request.TYPE_MANAGE_ALL_FILES_ACCESS -> showSettingDialog(permissions, rationale) {
|
Request.TYPE_MANAGE_ALL_FILES_ACCESS -> showSettingDialog(permissions, rationale) {
|
||||||
try {
|
try {
|
||||||
if (Permissions.isManageExternalStorage()) {
|
if (Permissions.isManageExternalStorage()) {
|
||||||
val settingIntent = Intent(Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION)
|
val settingIntent =
|
||||||
|
Intent(Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION)
|
||||||
settingActivityResult.launch(settingIntent)
|
settingActivityResult.launch(settingIntent)
|
||||||
} else {
|
} else {
|
||||||
throw NoStackTraceException("no MANAGE_ALL_FILES_ACCESS_PERMISSION")
|
throw NoStackTraceException("no MANAGE_ALL_FILES_ACCESS_PERMISSION")
|
||||||
@@ -53,6 +54,7 @@ class PermissionActivity : AppCompatActivity() {
|
|||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Request.TYPE_REQUEST_NOTIFICATIONS -> showSettingDialog(permissions, rationale) {
|
Request.TYPE_REQUEST_NOTIFICATIONS -> showSettingDialog(permissions, rationale) {
|
||||||
kotlin.runCatching {
|
kotlin.runCatching {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
@@ -135,6 +137,10 @@ class PermissionActivity : AppCompatActivity() {
|
|||||||
)
|
)
|
||||||
finish()
|
finish()
|
||||||
}.setOnCancelListener {
|
}.setOnCancelListener {
|
||||||
|
RequestPlugins.sRequestCallback?.onRequestPermissionsResult(
|
||||||
|
permissions,
|
||||||
|
IntArray(0)
|
||||||
|
)
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
.show()
|
.show()
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package io.legado.app.lib.permission
|
package io.legado.app.lib.permission
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Environment
|
import android.os.Environment
|
||||||
@@ -49,6 +50,7 @@ internal class Request : OnRequestPermissionsResultCallback {
|
|||||||
this.rationale = rationale
|
this.rationale = rationale
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("ObsoleteSdkInt")
|
||||||
fun start() {
|
fun start() {
|
||||||
RequestPlugins.setOnRequestPermissionsCallback(this)
|
RequestPlugins.setOnRequestPermissionsCallback(this)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user