pull/783/head
gedoor 4 years ago
parent f07a291a96
commit 98fc831706
  1. 3
      app/src/main/java/io/legado/app/data/entities/ReplaceRule.kt
  2. 8
      app/src/main/java/io/legado/app/help/IntentHelp.kt
  3. 6
      app/src/main/java/io/legado/app/help/ThemeConfig.kt

@ -49,8 +49,7 @@ data class ReplaceRule(
if (isRegex){ if (isRegex){
try { try {
Pattern.compile(pattern) Pattern.compile(pattern)
} } catch (ex: PatternSyntaxException) {
catch (ex: PatternSyntaxException){
return false return false
} }
} }

@ -13,23 +13,23 @@ object IntentHelp {
fun toTTSSetting(context: Context) { fun toTTSSetting(context: Context) {
//跳转到文字转语音设置界面 //跳转到文字转语音设置界面
try { kotlin.runCatching {
val intent = Intent() val intent = Intent()
intent.action = "com.android.settings.TTS_SETTINGS" intent.action = "com.android.settings.TTS_SETTINGS"
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
context.startActivity(intent) context.startActivity(intent)
} catch (ignored: Exception) { }.onFailure {
context.toast(R.string.tip_cannot_jump_setting_page) context.toast(R.string.tip_cannot_jump_setting_page)
} }
} }
fun toInstallUnknown(context: Context) { fun toInstallUnknown(context: Context) {
try { kotlin.runCatching {
val intent = Intent() val intent = Intent()
intent.action = "android.settings.MANAGE_UNKNOWN_APP_SOURCES" intent.action = "android.settings.MANAGE_UNKNOWN_APP_SOURCES"
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
context.startActivity(intent) context.startActivity(intent)
} catch (ignored: Exception) { }.onFailure {
context.toast("无法打开设置") context.toast("无法打开设置")
} }
} }

@ -61,11 +61,11 @@ object ThemeConfig {
private fun getConfigs(): List<Config>? { private fun getConfigs(): List<Config>? {
val configFile = File(configFilePath) val configFile = File(configFilePath)
if (configFile.exists()) { if (configFile.exists()) {
try { kotlin.runCatching {
val json = configFile.readText() val json = configFile.readText()
return GSON.fromJsonArray(json) return GSON.fromJsonArray(json)
} catch (e: Exception) { }.onFailure {
e.printStackTrace() it.printStackTrace()
} }
} }
return null return null

Loading…
Cancel
Save