显示电池温度适配新版手机管家&新增隐藏NFC图标 (#163)

This commit is contained in:
GSWXXN
2022-05-12 18:48:31 +08:00
committed by GitHub
parent 94beae5f45
commit 2a94e1da69
17 changed files with 70 additions and 30 deletions

View File

@@ -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")

View File

@@ -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)
}

View File

@@ -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
}
}
}
}

View File

@@ -216,4 +216,5 @@
<string name="take_effect_after_reboot">Se activa después de reiniciar</string>
<string name="media_volume_steps_summary">Activar esta opción puede hacer que el desplazamiento de la barra de volumen se congele o que el volumen Bluetooth sea anormal</string>
<string name="can_notification_slide_summary">Es posible que algunas notificaciones a través de Mi Push no sean soportadas.</string>
<string name="hide_nfc_icon">Ocultar icono NFC</string>
</resources>

View File

@@ -172,4 +172,5 @@
<string name="status_bar_network_speed_dual_row_gravity">Alignement double ligne</string>
<string name="left">Gauche</string>
<string name="right">Droite</string>
<string name="hide_nfc_icon">Masquer l\'icône NFC</string>
</resources>

View File

@@ -163,4 +163,5 @@
<string name="qs_custom_rows">Baris</string>
<string name="qs_custom_columns">Kolom</string>
<string name="qs_custom_rows_horizontal">Baris (Horizontal)</string>
<string name="hide_nfc_icon">Sembunyikan ikon NFC</string>
</resources>

View File

@@ -216,4 +216,5 @@
<string name="take_effect_after_reboot">機能は再起動後に有効になります</string>
<string name="media_volume_steps_summary">オンにすると、ボリュームバーのスクロールがフリーズしたり、Bluetoothの音量が異常になる場合があります</string>
<string name="can_notification_slide_summary">一部のMi Pushによる通知では機能しない場合があります。</string>
<string name="hide_nfc_icon">NFC アイコンを隠す</string>
</resources>

View File

@@ -55,4 +55,5 @@
<string name="scope_android_summary">Na het inschakelen van de module voor de eerste keer of de module is bijgewerkt, zal de functie hier van kracht worden na het herstarten van het systeem</string>
<string name="scope_other_summary">Beveiligingsapp, Gallerij aanpasser, Batterij en prestatie, enz.</string>
<string name="scope_powerkeeper">Batterij en prestatie</string>
<string name="hide_nfc_icon">Verberg NFC icoon</string>
</resources>

View File

@@ -213,4 +213,5 @@
<string name="sound">Dźwięk</string>
<string name="media_volume_steps_switch">Kroki głośności multimediów</string>
<string name="can_notification_slide_summary">Niektóre powiadomienia Mi Push mogą nie być obsługiwane.</string>
<string name="hide_nfc_icon">Ukryj ikonę NFC</string>
</resources>

View File

@@ -216,4 +216,5 @@
<string name="take_effect_after_reboot">Intră în vigoare după repornire</string>
<string name="media_volume_steps_summary">Activarea poate provoca înghețarea derulării barei de volum sau volumul Bluetooth să fie anormal</string>
<string name="can_notification_slide_summary">Este posibil ca unele notificări prin Mi Push să nu fie acceptate.</string>
<string name="hide_nfc_icon">Ascunde pictograma NFC</string>
</resources>

View File

@@ -220,4 +220,5 @@
<string name="take_effect_after_reboot">Вступит в силу после перезагрузки</string>
<string name="media_volume_steps_summary">Включение может привести к ненормальной прокрутке строки громкости</string>
<string name="can_notification_slide_summary">Некоторые уведомления через Mi Push могут не поддерживаться.</string>
<string name="hide_nfc_icon">Скрыть NFC</string>
</resources>

View File

@@ -217,4 +217,5 @@
<string name="take_effect_after_reboot">Yeniden başlattıktan sonra etkili ol</string>
<string name="media_volume_steps_summary">Açmak, ses seviyesi çubuğunun kaymasının donmasına veya Bluetooth ses seviyesinin anormal olmasına neden olabilir.</string>
<string name="can_notification_slide_summary">Mi Push aracılığıyla yapılan bazı bildirimler desteklenmeyebilir.</string>
<string name="hide_nfc_icon">NFC simgesini gizle</string>
</resources>

View File

@@ -181,4 +181,5 @@
<string name="range">Phạm vi: </string>
<string name="big_mobile_type_icon_left_and_right_margins">Căn lề biểu tượng mạng dữ liệu lớn</string>
<string name="cast">Truyền</string>
<string name="hide_nfc_icon">Ẩn biểu tượng NFC</string>
</resources>

View File

@@ -21,6 +21,7 @@
<string name="hide_airplane_icon">隐藏 飞行模式 图标</string>
<string name="hide_wifi_icon">隐藏 WIFI 图标</string>
<string name="hide_bluetooth_icon">隐藏 蓝牙 图标</string>
<string name="hide_nfc_icon">隐藏 NFC 图标</string>
<string name="hide_volume_zen_icon">隐藏 声音、勿扰 图标</string>
<string name="hide_alarm_icon">隐藏 闹钟 图标</string>
<string name="hide_hotspot_icon">隐藏 WIFI热点 图标</string>

View File

@@ -156,4 +156,5 @@
<string name="hide_zen_icon">隱藏 勿擾 圖標</string>
<string name="hide_icon">隱藏圖標</string>
<string name="double_tap_to_sleep">雙擊鎖定螢幕</string>
<string name="hide_nfc_icon">隱藏 NFC 圖標</string>
</resources>

View File

@@ -216,4 +216,5 @@
<string name="take_effect_after_reboot">重新開機後生效</string>
<string name="media_volume_steps_summary">開啟後可能會導致音量條的滾動卡頓或藍牙音量異常</string>
<string name="can_notification_slide_summary">可能無法支援一些使用小米推送(Mi Push)推播的通知</string>
<string name="hide_nfc_icon">隱藏 NFC 圖示</string>
</resources>

View File

@@ -28,6 +28,7 @@
<string name="hide_hotspot_icon">Hide Portable hotspot icon</string>
<string name="hide_headset_icon">Hide Headset icon</string>
<string name="hide_bluetooth_battery_icon">Hide Bluetooth battery icon</string>
<string name="hide_nfc_icon">Hide NFC icon</string>
<string name="hide_big_hd_icon">Hide big HD icon</string>
<string name="hide_small_hd_icon">Hide small HD icon</string>
<string name="hide_hd_no_service_icon">Hide HD No Service icon</string>