From eaaa80205423a707563d29aeb40c20f1580bf85a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=8C=E5=A0=86=E5=B0=8F=E9=80=8F=E6=98=8E?= Date: Sun, 13 Mar 2022 17:41:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=97=A7=E7=89=88=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=E9=9D=A2=E6=9D=BF=E5=A4=A9=E6=B0=94=E4=B8=8D=E6=98=BE?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/systemui/OldNotificationWeather.kt | 60 +++++++++++++++---- 1 file changed, 50 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/com/lt2333/simplicitytools/hook/app/systemui/OldNotificationWeather.kt b/app/src/main/java/com/lt2333/simplicitytools/hook/app/systemui/OldNotificationWeather.kt index 22c7f0f5..cfcd7259 100644 --- a/app/src/main/java/com/lt2333/simplicitytools/hook/app/systemui/OldNotificationWeather.kt +++ b/app/src/main/java/com/lt2333/simplicitytools/hook/app/systemui/OldNotificationWeather.kt @@ -17,19 +17,53 @@ class OldNotificationWeather : IXposedHookLoadPackage { hasEnable("notification_weather") { var mWeatherView: TextView? = null 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 context = viewGroup.context - val layoutParam = loadClass("androidx.constraintlayout.widget.ConstraintLayout\$LayoutParams") - .getConstructor(Int::class.java, Int::class.java) - .newInstance(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT) as ViewGroup.MarginLayoutParams + val layoutParam = + loadClass("androidx.constraintlayout.widget.ConstraintLayout\$LayoutParams") + .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("topToTop", context.resources.getIdentifier("notification_shade_shortcut", "id", context.packageName)) - layoutParam.setObjectField("bottomToBottom", context.resources.getIdentifier("notification_shade_shortcut", "id", context.packageName)) + layoutParam.setObjectField( + "endToStart", + 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 { - 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 } viewGroup.addView(mWeatherView) @@ -37,7 +71,10 @@ class OldNotificationWeather : IXposedHookLoadPackage { try { val intent = Intent().apply { 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) } 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 if (mOritation == 1) { mWeatherView!!.visibility = View.VISIBLE