mirror of
https://github.com/LittleTurtle2333/SimplicityTools.git
synced 2026-07-13 11:51:22 +08:00
显示电池温度适配新版手机管家&新增隐藏NFC图标 (#163)
This commit is contained in:
@@ -1103,6 +1103,11 @@ class SettingsActivity : MIUIActivity() {
|
||||
TextV(resId = R.string.hide_bluetooth_icon),
|
||||
SwitchV("hide_bluetooth_icon")
|
||||
)
|
||||
|
||||
TextWithSwitch(
|
||||
TextV(resId = R.string.hide_nfc_icon),
|
||||
SwitchV("hide_nfc_icon")
|
||||
)
|
||||
TextWithSwitch(
|
||||
TextV(resId = R.string.hide_bluetooth_battery_icon),
|
||||
SwitchV("hide_bluetooth_battery_icon")
|
||||
|
||||
@@ -14,12 +14,11 @@ import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import cn.fkj233.ui.activity.dp2px
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.getObjectAs
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookAfter
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookBefore
|
||||
import com.github.kyuubiran.ezxhelper.utils.loadClass
|
||||
import com.lt2333.simplicitytools.util.*
|
||||
import com.lt2333.simplicitytools.util.xposed.base.HookRegister
|
||||
import java.lang.reflect.Field
|
||||
|
||||
object ShowBatteryTemperature : HookRegister() {
|
||||
|
||||
@@ -31,15 +30,26 @@ object ShowBatteryTemperature : HookRegister() {
|
||||
}
|
||||
|
||||
override fun init() = hasEnable("battery_life_function") {
|
||||
findMethod("com.miui.powercenter.a") {
|
||||
name == "b" && parameterTypes[0] == Context::class.java
|
||||
try {
|
||||
findMethod("com.miui.powercenter.a") {
|
||||
name == "b" && parameterTypes[0] == Context::class.java
|
||||
}
|
||||
} catch (e : Exception) {
|
||||
findMethod("com.miui.powercenter.BatteryFragment") {
|
||||
name == "b" && parameterTypes[0] == Context::class.java
|
||||
}
|
||||
}.hookBefore {
|
||||
it.result = getBatteryTemperature(it.args[0] as Context).toString()
|
||||
|
||||
}
|
||||
|
||||
findMethod("com.miui.powercenter.a\$a") {
|
||||
name == "run"
|
||||
try {
|
||||
findMethod("com.miui.powercenter.a\$a") {
|
||||
name == "run"
|
||||
}
|
||||
} catch (e : Exception) {
|
||||
findMethod("com.miui.powercenter.BatteryFragment\$a") {
|
||||
name == "run"
|
||||
}
|
||||
}.hookAfter {
|
||||
val context = AndroidAppHelper.currentApplication().applicationContext
|
||||
val isDarkMode =
|
||||
@@ -49,36 +59,43 @@ object ShowBatteryTemperature : HookRegister() {
|
||||
"id",
|
||||
"com.miui.securitycenter"
|
||||
)
|
||||
val field = loadClass("com.miui.powercenter.a\$a").getDeclaredField("a") as Field
|
||||
field.isAccessible = true
|
||||
val view = field.get(it.thisObject) as View
|
||||
|
||||
val view = it.thisObject.getObjectAs<View>("a")
|
||||
|
||||
val textView = view.findViewById<TextView>(currentTemperatureValue)
|
||||
(textView.layoutParams as LinearLayout.LayoutParams).marginStart = dp2px(context, 25f)
|
||||
(textView.layoutParams as LinearLayout.LayoutParams).topMargin = 0
|
||||
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 36.399998f)
|
||||
textView.setPadding(0, 0, 0, 0)
|
||||
textView.gravity = Gravity.NO_GRAVITY
|
||||
textView.typeface = Typeface.defaultFromStyle(Typeface.NORMAL)
|
||||
textView.height = dp2px(context, 49.099983f)
|
||||
textView.textAlignment = View.TEXT_ALIGNMENT_VIEW_START
|
||||
textView.apply {
|
||||
(layoutParams as LinearLayout.LayoutParams).marginStart = dp2px(context, 25f)
|
||||
(layoutParams as LinearLayout.LayoutParams).topMargin = 0
|
||||
setTextSize(TypedValue.COMPLEX_UNIT_DIP, 36.399998f)
|
||||
setPadding(0, 0, 0, 0)
|
||||
gravity = Gravity.NO_GRAVITY
|
||||
typeface = Typeface.defaultFromStyle(Typeface.NORMAL)
|
||||
height = dp2px(context, 49.099983f)
|
||||
textAlignment = View.TEXT_ALIGNMENT_VIEW_START
|
||||
}
|
||||
|
||||
val tempView = TextView(context)
|
||||
tempView.layoutParams = LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
dp2px(context, 49.099983f)
|
||||
)
|
||||
(tempView.layoutParams as LinearLayout.LayoutParams).marginStart =
|
||||
dp2px(context, 3.599976f)
|
||||
tempView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13.099977f)
|
||||
tempView.setTextColor(Color.parseColor(if (isDarkMode) "#e6e6e6" else "#333333"))
|
||||
tempView.setPadding(0, dp2px(context, 25f), 0, 0)
|
||||
tempView.text = "℃"
|
||||
tempView.typeface = Typeface.create(null, 500, false)
|
||||
tempView.textAlignment = View.TEXT_ALIGNMENT_VIEW_START
|
||||
tempView.apply {
|
||||
layoutParams = LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
dp2px(context, 49.099983f)
|
||||
)
|
||||
(layoutParams as LinearLayout.LayoutParams).marginStart =
|
||||
dp2px(context, 3.599976f)
|
||||
setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13.099977f)
|
||||
setTextColor(Color.parseColor(if (isDarkMode) "#e6e6e6" else "#333333"))
|
||||
setPadding(0, dp2px(context, 25f), 0, 0)
|
||||
text = "℃"
|
||||
typeface = Typeface.create(null, 500, false)
|
||||
textAlignment = View.TEXT_ALIGNMENT_VIEW_START
|
||||
}
|
||||
|
||||
val tempeValueContainer = context.resources.getIdentifier(
|
||||
"tempe_value_container",
|
||||
"id",
|
||||
"com.miui.securitycenter"
|
||||
)
|
||||
|
||||
val linearLayout = view.findViewById<LinearLayout>(tempeValueContainer)
|
||||
linearLayout.addView(tempView)
|
||||
}
|
||||
|
||||
@@ -76,6 +76,10 @@ object HideStatusBarIcon : HookRegister() {
|
||||
"no_sim" -> hasEnable("hide_no_sim_icon") {
|
||||
it.args[1] = false
|
||||
}
|
||||
//隐藏NFC图标
|
||||
"nfc" -> hasEnable("hide_nfc_icon") {
|
||||
it.args[1] = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user