mirror of
https://github.com/LittleTurtle2333/SimplicityTools.git
synced 2026-07-12 19:31:17 +08:00
Update OldNotificationWeatherForT.kt
This commit is contained in:
@@ -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 -> {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user