支持点击下拉天气启动APP

This commit is contained in:
乌堆小透明
2022-03-10 13:45:34 +08:00
parent a3a4a015fb
commit b636d415c4
3 changed files with 53 additions and 1 deletions

View File

@@ -1,8 +1,11 @@
package com.lt2333.simplicitytools.hook.app.systemui package com.lt2333.simplicitytools.hook.app.systemui
import android.content.ComponentName
import android.content.Intent
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.TextView import android.widget.TextView
import android.widget.Toast
import com.lt2333.simplicitytools.util.XSPUtils import com.lt2333.simplicitytools.util.XSPUtils
import com.lt2333.simplicitytools.view.WeatherView import com.lt2333.simplicitytools.view.WeatherView
import de.robv.android.xposed.IXposedHookLoadPackage import de.robv.android.xposed.IXposedHookLoadPackage
@@ -76,6 +79,19 @@ class ControlCenterWeather : IXposedHookLoadPackage {
} }
viewGroup.addView(mWeatherView) 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()
}
}
} }
}) })
//解决横屏重叠 //解决横屏重叠

View File

@@ -1,8 +1,11 @@
package com.lt2333.simplicitytools.hook.app.systemui package com.lt2333.simplicitytools.hook.app.systemui
import android.content.ComponentName
import android.content.Intent
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.TextView import android.widget.TextView
import android.widget.Toast
import com.lt2333.simplicitytools.util.XSPUtils import com.lt2333.simplicitytools.util.XSPUtils
import com.lt2333.simplicitytools.view.WeatherView import com.lt2333.simplicitytools.view.WeatherView
import de.robv.android.xposed.IXposedHookLoadPackage 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( it.setTextAppearance(
viewGroup.context.resources.getIdentifier( viewGroup.context.resources.getIdentifier(
"TextAppearance.QSControl.Date", "TextAppearance.QSControl.Date",
@@ -75,6 +78,20 @@ class NotificationWeather : IXposedHookLoadPackage {
it.layoutParams = layout it.layoutParams = layout
} }
viewGroup.addView(mWeatherView) 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 {
} }
} }
}) })
} }
} }

View File

@@ -1,8 +1,11 @@
package com.lt2333.simplicitytools.hook.app.systemui package com.lt2333.simplicitytools.hook.app.systemui
import android.content.ComponentName
import android.content.Intent
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.TextView import android.widget.TextView
import android.widget.Toast
import com.lt2333.simplicitytools.util.XSPUtils import com.lt2333.simplicitytools.util.XSPUtils
import com.lt2333.simplicitytools.view.WeatherView import com.lt2333.simplicitytools.view.WeatherView
import de.robv.android.xposed.IXposedHookLoadPackage import de.robv.android.xposed.IXposedHookLoadPackage
@@ -77,6 +80,19 @@ class OldNotificationWeather : IXposedHookLoadPackage {
it.layoutParams = layout it.layoutParams = layout
} }
viewGroup.addView(mWeatherView) 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()
}
}
} }
}) })
//解决横屏重叠 //解决横屏重叠