diff --git a/app/src/main/java/com/lt2333/simplicitytools/hook/app/systemui/ControlCenterWeather.kt b/app/src/main/java/com/lt2333/simplicitytools/hook/app/systemui/ControlCenterWeather.kt index d7a80999..987bdf88 100644 --- a/app/src/main/java/com/lt2333/simplicitytools/hook/app/systemui/ControlCenterWeather.kt +++ b/app/src/main/java/com/lt2333/simplicitytools/hook/app/systemui/ControlCenterWeather.kt @@ -1,8 +1,11 @@ package com.lt2333.simplicitytools.hook.app.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.lt2333.simplicitytools.util.XSPUtils import com.lt2333.simplicitytools.view.WeatherView import de.robv.android.xposed.IXposedHookLoadPackage @@ -76,6 +79,19 @@ class ControlCenterWeather : IXposedHookLoadPackage { } viewGroup.addView(mWeatherView) + (mWeatherView as WeatherView).setOnClickListener { + try { + val intent = Intent() + intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK + intent.component = ComponentName( + "com.miui.weather2", + "com.miui.weather2.ActivityWeatherMain" + ) + viewGroup.context.startActivity(intent) + } catch (e: Exception) { + Toast.makeText(viewGroup.context, "启动失败,可能是不支持", Toast.LENGTH_LONG).show() + } + } } }) //解决横屏重叠 diff --git a/app/src/main/java/com/lt2333/simplicitytools/hook/app/systemui/NotificationWeather.kt b/app/src/main/java/com/lt2333/simplicitytools/hook/app/systemui/NotificationWeather.kt index 4d63b52e..44b80bdf 100644 --- a/app/src/main/java/com/lt2333/simplicitytools/hook/app/systemui/NotificationWeather.kt +++ b/app/src/main/java/com/lt2333/simplicitytools/hook/app/systemui/NotificationWeather.kt @@ -1,8 +1,11 @@ package com.lt2333.simplicitytools.hook.app.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.lt2333.simplicitytools.util.XSPUtils import com.lt2333.simplicitytools.view.WeatherView import de.robv.android.xposed.IXposedHookLoadPackage @@ -64,7 +67,7 @@ class NotificationWeather : IXposedHookLoadPackage { ) ) - mWeatherView = WeatherView(viewGroup.context,isDisplayCity).also { + mWeatherView = WeatherView(viewGroup.context, isDisplayCity).also { it.setTextAppearance( viewGroup.context.resources.getIdentifier( "TextAppearance.QSControl.Date", @@ -75,6 +78,20 @@ class NotificationWeather : IXposedHookLoadPackage { it.layoutParams = layout } viewGroup.addView(mWeatherView) + + (mWeatherView as WeatherView).setOnClickListener { + try { + val intent = Intent() + intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK + intent.component = ComponentName( + "com.miui.weather2", + "com.miui.weather2.ActivityWeatherMain" + ) + viewGroup.context.startActivity(intent) + } catch (e: Exception) { + Toast.makeText(viewGroup.context, "启动失败", Toast.LENGTH_LONG).show() + } + } } }) //解决横屏重叠 @@ -90,6 +107,9 @@ class NotificationWeather : IXposedHookLoadPackage { } } }) + + } + } 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 f982311b..ab0d49af 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 @@ -1,8 +1,11 @@ package com.lt2333.simplicitytools.hook.app.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.lt2333.simplicitytools.util.XSPUtils import com.lt2333.simplicitytools.view.WeatherView import de.robv.android.xposed.IXposedHookLoadPackage @@ -77,6 +80,19 @@ class OldNotificationWeather : IXposedHookLoadPackage { it.layoutParams = layout } viewGroup.addView(mWeatherView) + (mWeatherView as WeatherView).setOnClickListener { + try { + val intent = Intent() + intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK + intent.component = ComponentName( + "com.miui.weather2", + "com.miui.weather2.ActivityWeatherMain" + ) + viewGroup.context.startActivity(intent) + } catch (e: Exception) { + Toast.makeText(viewGroup.context, "启动失败,可能是不支持", Toast.LENGTH_LONG).show() + } + } } }) //解决横屏重叠