Skip to content

Commit

Permalink
Fix injectRes in Wechat
Browse files Browse the repository at this point in the history
  • Loading branch information
keta1 committed May 2, 2021
1 parent 2bfe19d commit 9f26c5f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
12 changes: 1 addition & 11 deletions app/src/main/java/me/kyuubiran/qqcleaner/WeChatHookLoader.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ package me.kyuubiran.qqcleaner
import android.annotation.SuppressLint
import android.app.Application
import android.content.Context
import android.content.res.Resources
import com.github.kyuubiran.ezxhelper.init.EzXHelperInit
import com.github.kyuubiran.ezxhelper.utils.Log
import com.github.kyuubiran.ezxhelper.utils.showToast
import de.robv.android.xposed.callbacks.XC_LoadPackage
import me.kyuubiran.qqcleaner.data.hostApp
import me.kyuubiran.qqcleaner.data.hostInfo
import me.kyuubiran.qqcleaner.data.init
import me.kyuubiran.qqcleaner.hook.ModuleEntryHook
Expand All @@ -28,15 +27,6 @@ class WeChatHookLoader(lpparam: XC_LoadPackage.LoadPackageParam) {
private fun initItem() {
ModuleEntryHook()
ResInjector.initSubActivity()
var res = hostInfo.application.resources
if (hostApp == HostApp.WE_CHAT) {
for (f in res.javaClass.declaredFields) {
f.isAccessible = true
if (f.type.isAssignableFrom(Resources::class.java))
res = f.get(res) as Resources
}
}
ResInjector.injectRes(res)
ConfigManager.checkConfigIsExists()
CleanManager.AutoClean.init()
}
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/java/me/kyuubiran/qqcleaner/utils/ToastX.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import android.content.Context
import android.view.Gravity
import android.widget.Toast
import com.github.kyuubiran.ezxhelper.utils.runOnMainThread
import com.github.kyuubiran.ezxhelper.utils.showToast
import me.kyuubiran.qqcleaner.data.hostApp
import me.kyuubiran.qqcleaner.ui.view.ToastView
import java.lang.ref.WeakReference

Expand Down Expand Up @@ -36,6 +38,10 @@ object ToastX {

fun Context.showToastX(msg: String, duration: Int = Toast.LENGTH_SHORT) {
runOnMainThread {
if (hostApp == HostApp.WE_CHAT) {
this.showToast(msg, duration)
return@runOnMainThread
}
ToastX.showToastX(this, msg, duration)
}
}

0 comments on commit 9f26c5f

Please sign in to comment.