优化写法

This commit is contained in:
LittleTurtle2333
2023-03-06 15:44:02 +08:00
parent 84f826fc31
commit 29fa75cca0
8 changed files with 18 additions and 21 deletions

View File

@@ -24,7 +24,7 @@ object DisableFlagSecureForAll : YukiBaseHooker() {
method { name = "setSecure" }
beforeHook {
hasEnable("disable_flag_secure") {
this.args[0] = false
args[0] = false
}
}
}
@@ -32,10 +32,10 @@ object DisableFlagSecureForAll : YukiBaseHooker() {
allMembers(MembersType.CONSTRUCTOR)
beforeHook {
hasEnable("disable_flag_secure") {
var flags = this.args[2] as Int
var flags = args[2] as Int
val secureFlag = 128
flags = flags and secureFlag.inv()
this.args[2] = flags
args[2] = flags
}
}
}

View File

@@ -9,10 +9,8 @@ import android.view.View
import com.highcapable.yukihookapi.hook.entity.YukiBaseHooker
import com.highcapable.yukihookapi.hook.factory.current
import com.highcapable.yukihookapi.hook.factory.field
import com.highcapable.yukihookapi.hook.factory.toClass
import com.lt2333.simplicitytools.R
import com.lt2333.simplicitytools.utils.hasEnable
import de.robv.android.xposed.XposedHelpers
object ShortcutAddSmallWindowForAll : YukiBaseHooker() {
override fun onHook() = hasEnable("miuihome_shortcut_add_small_window") {
@@ -51,8 +49,8 @@ object ShortcutAddSmallWindowForAll : YukiBaseHooker() {
paramCount = 2
}
beforeHook {
val obj = this.args[0]
val view: View = this.args[1] as View
val obj = args[0]
val view: View = args[1] as View
val mShortTitle = obj?.current {
method { name = "getShortTitle" }.invoke<CharSequence>()
}

View File

@@ -12,7 +12,7 @@ object HideSimIconForT:YukiBaseHooker() {
param(MutableList::class.java)
}
beforeHook {
val list = this.args[0] as MutableList<*>
val list = args[0] as MutableList<*>
val size = list.size
hasEnable("hide_sim_two_icon", extraCondition = { size == 2 }) {
list.removeAt(1)

View File

@@ -13,13 +13,13 @@ object HideStatusBarNetworkSpeedSecondForT : YukiBaseHooker() {
}
beforeHook {
hasEnable("hide_status_bar_network_speed_second") {
if (this.args[0] != null) {
val mText = (this.args[0] as String)
if (args[0] != null) {
val mText = (args[0] as String)
.replace("/", "")
.replace("s", "")
.replace("\'", "")
.replace("วิ", "")
this.args[0] = mText
args[0] = mText
}
}
}

View File

@@ -3,7 +3,6 @@ package com.lt2333.simplicitytools.hooks.rules.t.systemui
import com.highcapable.yukihookapi.hook.entity.YukiBaseHooker
import com.highcapable.yukihookapi.hook.factory.current
import com.lt2333.simplicitytools.utils.XSPUtils
import java.lang.reflect.Method
object MaximumNumberOfNotificationIconsForT: YukiBaseHooker() {
override fun onHook() {
@@ -16,7 +15,7 @@ object MaximumNumberOfNotificationIconsForT: YukiBaseHooker() {
paramCount = 1
}
replaceUnit {
if (this.args[0] as Boolean) {
if (args[0] as Boolean) {
instance.current().field { name = "MAX_DOTS" }.set(dots)
instance.current().field { name = "MAX_STATIC_ICONS" }.set(icons)
instance.current().field { name = "MAX_ICONS_ON_LOCKSCREEN" }.set(icons)

View File

@@ -35,10 +35,10 @@ object NewControlCenterWeatherForT : YukiBaseHooker() {
superClass(true)
}
beforeHook {
val time = this.args[0]?.toString()
val time = args[0]?.toString()
val view = instance<TextView>()
if (view.id == clockId && time != null) {
this.args[0] = "${weather.weatherData}$time"
args[0] = "${weather.weatherData}$time"
}
}
}
@@ -50,7 +50,7 @@ object NewControlCenterWeatherForT : YukiBaseHooker() {
name = "getClassLoader"
}
afterHook {
val appInfo = this.args[0] as ApplicationInfo
val appInfo = args[0] as ApplicationInfo
val classLoader = this.result as ClassLoader
if (appInfo.packageName == "miui.systemui.plugin") {
"miui.systemui.controlcenter.windowview.MainPanelHeaderController".hook {

View File

@@ -13,7 +13,7 @@ object StatusBarNetworkSpeedRefreshSpeedForT : YukiBaseHooker() {
}
beforeHook {
hasEnable("status_bar_network_speed_refresh_speed") {
this.args[0] = 1000L
args[0] = 1000L
}
}
}

View File

@@ -55,7 +55,7 @@ object StatusBarTimeCustomizationForT : YukiBaseHooker() {
}
afterHook {
try {
c = this.args[0] as Context
c = args[0] as Context
val textV = instance<TextView>()
if (textV.resources.getResourceEntryName(textV.id) != "clock") return@afterHook
textV.isSingleLine = false
@@ -94,7 +94,7 @@ object StatusBarTimeCustomizationForT : YukiBaseHooker() {
if (isCenterAlign) {
try {
if (textV.resources.getResourceEntryName(textV.id) == "clock") {
c = this.args[0] as Context
c = args[0] as Context
textV.gravity = Gravity.CENTER
}
} catch (_: Exception) {
@@ -131,7 +131,7 @@ object StatusBarTimeCustomizationForT : YukiBaseHooker() {
constructor { paramCount = 3 }
afterHook {
try {
c = this.args[0] as Context
c = args[0] as Context
val textV = instance<TextView>()
if (textV.resources.getResourceEntryName(textV.id) != "clock") return@afterHook
textV.isSingleLine = false
@@ -159,7 +159,7 @@ object StatusBarTimeCustomizationForT : YukiBaseHooker() {
if (isGeekCenterAlign) {
try {
if (textV.resources.getResourceEntryName(textV.id) == "clock") {
c = this.args[0] as Context
c = args[0] as Context
textV.gravity = Gravity.CENTER
}
} catch (_: Exception) {