diff --git a/app/src/main/java/com/lt2333/simplicitytools/hooks/apps/SystemUIHooker.kt b/app/src/main/java/com/lt2333/simplicitytools/hooks/apps/SystemUIHooker.kt index 47602a8c..0ca19396 100644 --- a/app/src/main/java/com/lt2333/simplicitytools/hooks/apps/SystemUIHooker.kt +++ b/app/src/main/java/com/lt2333/simplicitytools/hooks/apps/SystemUIHooker.kt @@ -13,6 +13,7 @@ import com.lt2333.simplicitytools.hooks.rules.t.systemui.HideWifiActivityIconFor 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 @@ -37,6 +38,7 @@ object SystemUIHooker : YukiBaseHooker() { loadHooker(RemoveLockScreenCameraForT) //移除锁屏相机功能 loadHooker(NotificationWeatherForT) //通知面板天气 loadHooker(NewControlCenterWeatherForT) //新控制中心天气 + loadHooker(OldNotificationWeatherForT) //经典通知天气 } Build.VERSION_CODES.S -> { diff --git a/app/src/main/java/com/lt2333/simplicitytools/hooks/rules/t/systemui/OldNotificationWeatherForT.kt b/app/src/main/java/com/lt2333/simplicitytools/hooks/rules/t/systemui/OldNotificationWeatherForT.kt new file mode 100644 index 00000000..a2d3e45b --- /dev/null +++ b/app/src/main/java/com/lt2333/simplicitytools/hooks/rules/t/systemui/OldNotificationWeatherForT.kt @@ -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() + 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 + } + } + } + } + + } +} \ No newline at end of file