mirror of
https://github.com/LittleTurtle2333/SimplicityTools.git
synced 2026-07-13 03:41:19 +08:00
修复旧版通知面板天气不显示
This commit is contained in:
@@ -17,19 +17,53 @@ class OldNotificationWeather : IXposedHookLoadPackage {
|
|||||||
hasEnable("notification_weather") {
|
hasEnable("notification_weather") {
|
||||||
var mWeatherView: TextView? = null
|
var mWeatherView: TextView? = null
|
||||||
val isDisplayCity = XSPUtils.getBoolean("notification_weather_city", false)
|
val isDisplayCity = XSPUtils.getBoolean("notification_weather_city", false)
|
||||||
"com.android.systemui.qs.MiuiQSHeaderView".hookAfterMethod(lpparam.classLoader, "onFinishInflate") {
|
"com.android.systemui.qs.MiuiQSHeaderView".hookAfterMethod(
|
||||||
|
lpparam.classLoader,
|
||||||
|
"onFinishInflate"
|
||||||
|
) {
|
||||||
val viewGroup = it.thisObject as ViewGroup
|
val viewGroup = it.thisObject as ViewGroup
|
||||||
val context = viewGroup.context
|
val context = viewGroup.context
|
||||||
val layoutParam = loadClass("androidx.constraintlayout.widget.ConstraintLayout\$LayoutParams")
|
val layoutParam =
|
||||||
.getConstructor(Int::class.java, Int::class.java)
|
loadClass("androidx.constraintlayout.widget.ConstraintLayout\$LayoutParams")
|
||||||
.newInstance(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT) as ViewGroup.MarginLayoutParams
|
.getConstructor(Int::class.java, Int::class.java)
|
||||||
|
.newInstance(
|
||||||
|
ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||||
|
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||||
|
) as ViewGroup.MarginLayoutParams
|
||||||
|
|
||||||
layoutParam.setObjectField("engToStart", context.resources.getIdentifier("notification_shade_shortcut", "id", context.packageName))
|
layoutParam.setObjectField(
|
||||||
layoutParam.setObjectField("topToTop", context.resources.getIdentifier("notification_shade_shortcut", "id", context.packageName))
|
"endToStart",
|
||||||
layoutParam.setObjectField("bottomToBottom", context.resources.getIdentifier("notification_shade_shortcut", "id", context.packageName))
|
context.resources.getIdentifier(
|
||||||
|
"notification_shade_shortcut",
|
||||||
|
"id",
|
||||||
|
context.packageName
|
||||||
|
)
|
||||||
|
)
|
||||||
|
layoutParam.setObjectField(
|
||||||
|
"topToTop",
|
||||||
|
context.resources.getIdentifier(
|
||||||
|
"notification_shade_shortcut",
|
||||||
|
"id",
|
||||||
|
context.packageName
|
||||||
|
)
|
||||||
|
)
|
||||||
|
layoutParam.setObjectField(
|
||||||
|
"bottomToBottom",
|
||||||
|
context.resources.getIdentifier(
|
||||||
|
"notification_shade_shortcut",
|
||||||
|
"id",
|
||||||
|
context.packageName
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
mWeatherView = WeatherView(context, isDisplayCity).apply {
|
mWeatherView = WeatherView(context, isDisplayCity).apply {
|
||||||
setTextAppearance(context.resources.getIdentifier("TextAppearance.StatusBar.Expanded.Clock.QuickSettingDate", "style", context.packageName))
|
setTextAppearance(
|
||||||
|
context.resources.getIdentifier(
|
||||||
|
"TextAppearance.StatusBar.Expanded.Clock.QuickSettingDate",
|
||||||
|
"style",
|
||||||
|
context.packageName
|
||||||
|
)
|
||||||
|
)
|
||||||
layoutParams = layoutParam
|
layoutParams = layoutParam
|
||||||
}
|
}
|
||||||
viewGroup.addView(mWeatherView)
|
viewGroup.addView(mWeatherView)
|
||||||
@@ -37,7 +71,10 @@ class OldNotificationWeather : IXposedHookLoadPackage {
|
|||||||
try {
|
try {
|
||||||
val intent = Intent().apply {
|
val intent = Intent().apply {
|
||||||
flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
||||||
component = ComponentName("com.miui.weather2", "com.miui.weather2.ActivityWeatherMain")
|
component = ComponentName(
|
||||||
|
"com.miui.weather2",
|
||||||
|
"com.miui.weather2.ActivityWeatherMain"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
context.startActivity(intent)
|
context.startActivity(intent)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
@@ -46,7 +83,10 @@ class OldNotificationWeather : IXposedHookLoadPackage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//解决横屏重叠
|
//解决横屏重叠
|
||||||
"com.android.systemui.qs.MiuiQSHeaderView".hookAfterMethod(lpparam.classLoader, "updateLayout") {
|
"com.android.systemui.qs.MiuiQSHeaderView".hookAfterMethod(
|
||||||
|
lpparam.classLoader,
|
||||||
|
"updateLayout"
|
||||||
|
) {
|
||||||
val mOritation = it.thisObject.getObjectField("mOrientation") as Int
|
val mOritation = it.thisObject.getObjectField("mOrientation") as Int
|
||||||
if (mOritation == 1) {
|
if (mOritation == 1) {
|
||||||
mWeatherView!!.visibility = View.VISIBLE
|
mWeatherView!!.visibility = View.VISIBLE
|
||||||
|
|||||||
Reference in New Issue
Block a user