fix plugin bug

pull/21/head
fengyuecanzhu 3 years ago
parent 1d5df732aa
commit a6e1ce2a21
  1. 4
      app/src/main/java/xyz/fycz/myreader/util/utils/PluginUtils.kt
  2. 18
      dynamic/src/main/java/xyz/fycz/dynamic/AppLoadImpl.kt

@ -72,7 +72,7 @@ object PluginUtils {
} else { } else {
config = oldConfig config = oldConfig
} }
if (!App.isDebug() && config!!.md5.lowercase(Locale.getDefault()) if (config!!.md5.lowercase(Locale.getDefault())
!= getPluginMD5(config!!)?.lowercase(Locale.getDefault()) != getPluginMD5(config!!)?.lowercase(Locale.getDefault())
) { ) {
downloadPlugin(config!!) downloadPlugin(config!!)
@ -115,8 +115,8 @@ object PluginUtils {
appParam.packageName = context.packageName appParam.packageName = context.packageName
appParam.appInfo = context.applicationInfo appParam.appInfo = context.applicationInfo
onLoad(appParam) onLoad(appParam)
hasLoad = true
} }
hasLoad = true
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printStackTrace()
} }

@ -22,7 +22,6 @@ import android.app.AlertDialog
import android.content.Context import android.content.Context
import android.content.SharedPreferences import android.content.SharedPreferences
import android.os.Bundle import android.os.Bundle
import android.util.Log
import me.fycz.maple.MapleBridge import me.fycz.maple.MapleBridge
import me.fycz.maple.MapleUtils import me.fycz.maple.MapleUtils
import me.fycz.maple.MethodHook import me.fycz.maple.MethodHook
@ -31,7 +30,6 @@ import xyz.fycz.dynamic.fix.App244Fix
import xyz.fycz.dynamic.fix.AppFix import xyz.fycz.dynamic.fix.AppFix
import xyz.fycz.myreader.application.App import xyz.fycz.myreader.application.App
import xyz.fycz.myreader.ui.activity.MainActivity import xyz.fycz.myreader.ui.activity.MainActivity
import xyz.fycz.myreader.util.utils.AdUtils
/** /**
* @author fengyue * @author fengyue
@ -78,7 +76,7 @@ class AppLoadImpl : IAppLoader {
val key = "fix244" val key = "fix244"
val hasRead = spu.getBoolean(key, false) val hasRead = spu.getBoolean(key, false)
if (!hasRead) { if (!hasRead) {
announce("插件更新", "更新内容:\n$sb", "fix244") announce("插件更新", "更新内容:\n$sb")
spu.edit().run { spu.edit().run {
putBoolean(key, true) putBoolean(key, true)
apply() apply()
@ -87,7 +85,7 @@ class AppLoadImpl : IAppLoader {
} }
} }
private fun announce(title: String, msg: String, key: String) { private fun announce(title: String, msg: String) {
try { try {
MapleUtils.findAndHookMethod( MapleUtils.findAndHookMethod(
MainActivity::class.java, MainActivity::class.java,
@ -96,11 +94,13 @@ 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
AlertDialog.Builder(context) App.getHandler().postDelayed({
.setTitle(title) AlertDialog.Builder(context)
.setMessage(msg) .setTitle(title)
.setPositiveButton("我知道了", null) .setMessage(msg)
.create().show() .setPositiveButton("我知道了", null)
.create().show()
}, 1000)
} }
} }
) )

Loading…
Cancel
Save