fix plugin bug

pull/21/head
fengyuecanzhu 3 years ago
parent 179c4ffcc5
commit 1d5df732aa
  1. 24
      dynamic/src/main/java/xyz/fycz/dynamic/AppLoadImpl.kt

@ -54,7 +54,7 @@ class AppLoadImpl : IAppLoader {
val sb = StringBuilder() val sb = StringBuilder()
fixList.forEach { fixList.forEach {
val annotation = it.getAnnotation(AppFix::class.java)!! val annotation = it.getAnnotation(AppFix::class.java)!!
for (version in annotation.versions){ for (version in annotation.versions) {
if (App.getVersionCode() == version) { if (App.getVersionCode() == version) {
val fix = it.newInstance() val fix = it.newInstance()
val fixResult = fix.onFix(annotation.date) val fixResult = fix.onFix(annotation.date)
@ -62,7 +62,7 @@ class AppLoadImpl : IAppLoader {
if (sb.isNotEmpty()) sb.append("\n") if (sb.isNotEmpty()) sb.append("\n")
sb.append("${annotation.date}\n") sb.append("${annotation.date}\n")
fixResult.forEachIndexed { i, b -> fixResult.forEachIndexed { i, b ->
sb.append("${i+1}${annotation.fixLog[i]}${if (b) "成功" else "失败"}\n") sb.append("${i + 1}${annotation.fixLog[i]}${if (b) "成功" else "失败"}\n")
} }
spu.edit().run { spu.edit().run {
putBoolean(annotation.date, true) putBoolean(annotation.date, true)
@ -73,9 +73,18 @@ class AppLoadImpl : IAppLoader {
} }
} }
} }
if (sb.isNotEmpty()) sb.substring(0, sb.length - 1) if (sb.isNotEmpty()) {
Log.i(spuName, "更新内容:$sb") if (sb.endsWith("\n")) sb.substring(0, sb.length - 1)
val key = "fix244"
val hasRead = spu.getBoolean(key, false)
if (!hasRead) {
announce("插件更新", "更新内容:\n$sb", "fix244") announce("插件更新", "更新内容:\n$sb", "fix244")
spu.edit().run {
putBoolean(key, true)
apply()
}
}
}
} }
private fun announce(title: String, msg: String, key: String) { private fun announce(title: String, msg: String, key: String) {
@ -87,18 +96,11 @@ class AppLoadImpl : IAppLoader {
object : MethodHook() { object : MethodHook() {
override fun afterHookedMethod(param: MapleBridge.MethodHookParam) { override fun afterHookedMethod(param: MapleBridge.MethodHookParam) {
val context = param.thisObject as Context val context = param.thisObject as Context
val hasRead = spu.getBoolean(key, false)
if (!hasRead) {
AlertDialog.Builder(context) AlertDialog.Builder(context)
.setTitle(title) .setTitle(title)
.setMessage(msg) .setMessage(msg)
.setPositiveButton("我知道了", null) .setPositiveButton("我知道了", null)
.create().show() .create().show()
spu.edit().run {
putBoolean(key, true)
apply()
}
}
} }
} }
) )

Loading…
Cancel
Save