Compare commits

7 Commits

Author SHA1 Message Date
LittleTurtle2333
f77f9be2af Update OldNotificationWeatherForT.kt 2023-03-05 22:27:54 +08:00
LittleTurtle2333
c81951da2a Update AndroidHooker.kt 2023-03-05 22:07:28 +08:00
LittleTurtle2333
074a0fa160 Update HideBatteryIconForT.kt 2023-03-05 22:07:18 +08:00
LittleTurtle2333
ab5abc10c9 Update HideHDIconForT.kt 2023-03-05 22:07:08 +08:00
LittleTurtle2333
8117809073 Update NotificationWeatherForT.kt 2023-03-05 22:07:00 +08:00
LittleTurtle2333
ce5312494c Update SystemUIHooker.kt 2023-03-05 22:06:42 +08:00
LittleTurtle2333
3ce5d1b1f2 修复MIUI14上控制中心的天气显示 2023-03-05 22:06:05 +08:00
7 changed files with 192 additions and 15 deletions

View File

@@ -8,14 +8,15 @@ import com.lt2333.simplicitytools.hooks.rules.all.android.DisableFlagSecureForAl
object AndroidHooker: YukiBaseHooker() {
override fun onHook() {
//判断Android版本号加载不同的Hooker
when (Build.VERSION.SDK_INT) {
Build.VERSION_CODES.TIRAMISU -> {
Build.VERSION_CODES.TIRAMISU -> { //Android13
loadHooker(DisableFlagSecureForAll) //允许截图
loadHooker(AllowUntrustedTouchesForAll) //允许不受信任触摸
loadHooker(DeleteOnPostNotificationForAll) //上层显示
}
Build.VERSION_CODES.S -> {
Build.VERSION_CODES.S -> { //Android12
loadHooker(DisableFlagSecureForAll) //允许截图
loadHooker(AllowUntrustedTouchesForAll) //允许不受信任触摸
loadHooker(DeleteOnPostNotificationForAll) //上层显示

View File

@@ -2,7 +2,22 @@ package com.lt2333.simplicitytools.hooks.apps
import android.os.Build
import com.highcapable.yukihookapi.hook.entity.YukiBaseHooker
import com.lt2333.simplicitytools.hooks.rules.t.systemui.*
import com.lt2333.simplicitytools.hooks.rules.t.systemui.HideBatteryIconForT
import com.lt2333.simplicitytools.hooks.rules.t.systemui.HideHDIconForT
import com.lt2333.simplicitytools.hooks.rules.t.systemui.HideMobileActivityIconForT
import com.lt2333.simplicitytools.hooks.rules.t.systemui.HideMobileTypeIconForT
import com.lt2333.simplicitytools.hooks.rules.t.systemui.HideSimIconForT
import com.lt2333.simplicitytools.hooks.rules.t.systemui.HideStatusBarIconForT
import com.lt2333.simplicitytools.hooks.rules.t.systemui.HideStatusBarNetworkSpeedSecondForT
import com.lt2333.simplicitytools.hooks.rules.t.systemui.HideWifiActivityIconForT
import com.lt2333.simplicitytools.hooks.rules.t.systemui.MaximumNumberOfNotificationIconsForT
import com.lt2333.simplicitytools.hooks.rules.t.systemui.NewControlCenterWeatherForT
import com.lt2333.simplicitytools.hooks.rules.t.systemui.NotificationWeatherForT
import com.lt2333.simplicitytools.hooks.rules.t.systemui.OldNotificationWeatherForT
import com.lt2333.simplicitytools.hooks.rules.t.systemui.RemoveLockScreenCameraForT
import com.lt2333.simplicitytools.hooks.rules.t.systemui.RemoveTheLeftSideOfTheLockScreenForT
import com.lt2333.simplicitytools.hooks.rules.t.systemui.StatusBarNetworkSpeedRefreshSpeedForT
import com.lt2333.simplicitytools.hooks.rules.t.systemui.StatusBarTimeCustomizationForT
object SystemUIHooker : YukiBaseHooker() {
override fun onHook() {
@@ -22,6 +37,8 @@ object SystemUIHooker : YukiBaseHooker() {
loadHooker(RemoveTheLeftSideOfTheLockScreenForT) //移除锁屏负一屏功能
loadHooker(RemoveLockScreenCameraForT) //移除锁屏相机功能
loadHooker(NotificationWeatherForT) //通知面板天气
loadHooker(NewControlCenterWeatherForT) //新控制中心天气
loadHooker(OldNotificationWeatherForT) //经典通知天气
}
Build.VERSION_CODES.S -> {

View File

@@ -1,7 +1,6 @@
package com.lt2333.simplicitytools.hooks.rules.t.systemui
import android.view.View
import android.view.ViewGroup
import android.widget.FrameLayout
import android.widget.ImageView
import android.widget.TextView
@@ -18,6 +17,7 @@ object HideBatteryIconForT : YukiBaseHooker() {
afterHook {
//隐藏电池图标
hasEnable("hide_battery_icon") {
//从当前实例中获取名为mBatteryStyle的Field并转换成ImageView类型操作可见度
instance.current().field { name = "mBatteryStyle" }.cast<ImageView>()?.visibility = View.GONE
if (instance.current().field { name = "mBatteryStyle" }.int() == 1) {
instance.current().field { name = "mBatteryDigitalView" }.cast<FrameLayout>()?.visibility = View.GONE

View File

@@ -42,6 +42,7 @@ object HideHDIconForT : YukiBaseHooker() {
}
private fun hide(it: HookParam) {
hasEnable("hide_big_hd_icon") {
//从当前实例中获取名为mVolte的Field并转换成ImageView类型操作可见度
it.instance.current().field {name = "mVolte" }.cast<ImageView>()?.visibility = View.GONE
}
hasEnable("hide_small_hd_icon") {

View File

@@ -0,0 +1,84 @@
package com.lt2333.simplicitytools.hooks.rules.t.systemui
import android.content.pm.ApplicationInfo
import android.widget.TextView
import com.highcapable.yukihookapi.hook.entity.YukiBaseHooker
import com.highcapable.yukihookapi.hook.factory.current
import com.lt2333.simplicitytools.utils.XSPUtils
import com.lt2333.simplicitytools.utils.hasEnable
import com.lt2333.simplicitytools.views.WeatherData
object NewControlCenterWeatherForT : YukiBaseHooker() {
override fun onHook() = hasEnable("control_center_weather") {
lateinit var weather: WeatherData
var clockId: Int = -2
val isDisplayCity = XSPUtils.getBoolean("notification_weather_city", false)
"com.android.systemui.controlcenter.phone.widget.ControlCenterDateView".hook {
injectMember {
method {
name = "onDetachedFromWindow"
superClass(true)
}
beforeHook {
if (instance<TextView>().id == clockId) {
weather.onDetachedFromWindow()
}
}
}
}
"com.android.systemui.controlcenter.phone.widget.ControlCenterDateView".hook {
injectMember {
method {
name = "setText"
superClass(true)
}
beforeHook {
val time = this.args[0]?.toString()
val view = instance<TextView>()
if (view.id == clockId && time != null) {
this.args[0] = "${weather.weatherData}$time"
}
}
}
}
"com.android.systemui.shared.plugins.PluginInstance\$Factory".hook {
injectMember {
method {
name = "getClassLoader"
}
afterHook {
val appInfo = this.args[0] as ApplicationInfo
val classLoader = this.result as ClassLoader
if (appInfo.packageName == "miui.systemui.plugin") {
"miui.systemui.controlcenter.windowview.MainPanelHeaderController".hook {
injectMember {
appClassLoader = classLoader
method {
name = "addClockViews"
}
afterHook {
val dateView = instance.current().field { name = "dateView" }.cast<TextView>()
if (dateView != null) {
clockId = dateView.id
}
weather = WeatherData(dateView?.context, isDisplayCity)
weather.callBacks = {
dateView?.current {
method {
name = "updateTime"
superClass(true)
}.call()
}
}
}
}
}.onHookClassNotFoundFailure { }
}
}
}
}
}
}

View File

@@ -10,9 +10,8 @@ import android.widget.Toast
import androidx.constraintlayout.widget.ConstraintLayout
import cn.fkj233.ui.activity.dp2px
import com.highcapable.yukihookapi.hook.entity.YukiBaseHooker
import com.highcapable.yukihookapi.hook.factory.constructor
import com.highcapable.yukihookapi.hook.factory.buildOf
import com.highcapable.yukihookapi.hook.factory.current
import com.highcapable.yukihookapi.hook.factory.toClass
import com.lt2333.simplicitytools.utils.SystemProperties
import com.lt2333.simplicitytools.utils.XSPUtils
import com.lt2333.simplicitytools.utils.hasEnable
@@ -123,18 +122,20 @@ object NotificationWeatherForT : YukiBaseHooker() {
(mWeatherView as WeatherView).layoutParams = mweatherviewLp
} else {
// 通过YukiHook的构造方法创建新实例指定类型 ViewGroup.MarginLayoutParams
val layoutParam = "androidx.constraintlayout.widget.ConstraintLayout\$LayoutParams".toClass()
.constructor {
paramCount = 2
}.get().newInstance<ViewGroup.MarginLayoutParams>(
.buildOf<ViewGroup.MarginLayoutParams>(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT
)
) {
paramCount = 2
}
layoutParam?.current()?.field { name = "bottomToTop" }?.set(context.resources.getIdentifier("date_time", "id", context.packageName))
layoutParam?.current()?.field { name = "startToEnd" }?.set(context.resources.getIdentifier("big_time", "id", context.packageName))
layoutParam?.current()?.field { name = "bottomToTop" }
?.set(context.resources.getIdentifier("date_time", "id", context.packageName))
layoutParam?.current()?.field { name = "startToEnd" }
?.set(context.resources.getIdentifier("big_time", "id", context.packageName))
layoutParam?.marginStart = context.resources.getDimensionPixelSize(
context.resources.getIdentifier(

View File

@@ -0,0 +1,73 @@
package com.lt2333.simplicitytools.hooks.rules.t.systemui
import android.content.ComponentName
import android.content.Intent
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import android.widget.Toast
import com.highcapable.yukihookapi.hook.entity.YukiBaseHooker
import com.highcapable.yukihookapi.hook.factory.current
import com.lt2333.simplicitytools.utils.XSPUtils
import com.lt2333.simplicitytools.utils.hasEnable
import com.lt2333.simplicitytools.views.WeatherView
object OldNotificationWeatherForT : YukiBaseHooker() {
override fun onHook() = hasEnable("notification_weather") {
var mWeatherView: TextView? = null
val isDisplayCity = XSPUtils.getBoolean("notification_weather_city", false)
"com.android.systemui.qs.MiuiQSHeaderView".hook {
injectMember {
method {
name = "onFinishInflate"
}
afterHook {
val viewGroup = instance<ViewGroup>()
val context = viewGroup.context
mWeatherView = WeatherView(context, isDisplayCity).apply {
setTextAppearance(
context.resources.getIdentifier(
"TextAppearance.StatusBar.Expanded.Clock.QuickSettingDate",
"style",
context.packageName
)
)
}
viewGroup.addView(mWeatherView)
(mWeatherView as WeatherView).setOnClickListener {
try {
val intent = Intent().apply {
flags = Intent.FLAG_ACTIVITY_NEW_TASK
component = ComponentName(
"com.miui.weather2",
"com.miui.weather2.ActivityWeatherMain"
)
}
context.startActivity(intent)
} catch (e: Exception) {
Toast.makeText(context, "启动失败,可能是不支持", Toast.LENGTH_LONG).show()
}
}
}
}
}
"com.android.systemui.qs.MiuiQSHeaderView".hook {
injectMember {
method { name = "updateLayout" }
afterHook {
val mOrientation = instance.current().field { name = "mOrientation" }.int()
if (mOrientation == 1) {
mWeatherView!!.visibility = View.VISIBLE
} else {
mWeatherView!!.visibility = View.GONE
}
}
}
}
}
}