mirror of
https://github.com/LittleTurtle2333/SimplicityTools.git
synced 2026-07-12 11:21:18 +08:00
新增控制中心天气
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -59,9 +59,10 @@ class SystemUI : IXposedHookLoadPackage {
|
|||||||
RemoveTheLeftSideOfTheLockScreen().handleLoadPackage(lpparam)
|
RemoveTheLeftSideOfTheLockScreen().handleLoadPackage(lpparam)
|
||||||
//移除锁屏相机功能
|
//移除锁屏相机功能
|
||||||
RemoveLockScreenCamera().handleLoadPackage(lpparam)
|
RemoveLockScreenCamera().handleLoadPackage(lpparam)
|
||||||
|
//通知面板天气
|
||||||
//TODO:状态栏天气
|
|
||||||
NotificationWeather().handleLoadPackage(lpparam)
|
NotificationWeather().handleLoadPackage(lpparam)
|
||||||
|
//控制中心天气
|
||||||
|
ControlCenterWeather().handleLoadPackage(lpparam)
|
||||||
//TODO:状态栏电流
|
//TODO:状态栏电流
|
||||||
//StatusBarCurrent().handleLoadPackage(lpparam)
|
//StatusBarCurrent().handleLoadPackage(lpparam)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,133 @@
|
|||||||
|
package com.lt2333.simplicitytools.hook.app.systemui
|
||||||
|
|
||||||
|
import android.database.Cursor
|
||||||
|
import android.net.Uri
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.widget.TextView
|
||||||
|
import com.lt2333.simplicitytools.util.XSPUtils
|
||||||
|
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||||
|
import de.robv.android.xposed.XC_MethodHook
|
||||||
|
import de.robv.android.xposed.XposedHelpers
|
||||||
|
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
class ControlCenterWeather : IXposedHookLoadPackage {
|
||||||
|
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||||
|
|
||||||
|
var mWeatherView: TextView? = null
|
||||||
|
|
||||||
|
if (!XSPUtils.getBoolean("control_center_weather", false)) return
|
||||||
|
|
||||||
|
var display_city = XSPUtils.getBoolean("control_center_weather_city", false)
|
||||||
|
|
||||||
|
val classIfExists = XposedHelpers.findClassIfExists(
|
||||||
|
"com.android.systemui.controlcenter.phone.widget.QSControlCenterHeaderView",
|
||||||
|
lpparam.classLoader
|
||||||
|
)
|
||||||
|
|
||||||
|
XposedHelpers.findAndHookMethod(classIfExists, "onFinishInflate", object : XC_MethodHook() {
|
||||||
|
override fun afterHookedMethod(param: MethodHookParam) {
|
||||||
|
val viewGroup = param.thisObject as ViewGroup
|
||||||
|
|
||||||
|
val layout = XposedHelpers.findClass(
|
||||||
|
"androidx.constraintlayout.widget.ConstraintLayout\$LayoutParams",
|
||||||
|
lpparam.classLoader
|
||||||
|
).getConstructor(Int::class.java, Int::class.java).newInstance(
|
||||||
|
ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||||
|
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||||
|
) as ViewGroup.MarginLayoutParams
|
||||||
|
|
||||||
|
XposedHelpers.setObjectField(
|
||||||
|
layout,
|
||||||
|
"bottomToTop",
|
||||||
|
viewGroup.context.resources.getIdentifier(
|
||||||
|
"date_time",
|
||||||
|
"id",
|
||||||
|
viewGroup.context.packageName
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
XposedHelpers.setObjectField(
|
||||||
|
layout,
|
||||||
|
"startToEnd",
|
||||||
|
viewGroup.context.resources.getIdentifier(
|
||||||
|
"big_time",
|
||||||
|
"id",
|
||||||
|
viewGroup.context.packageName
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
layout.marginStart = viewGroup.context.resources.getDimensionPixelSize(
|
||||||
|
viewGroup.context.resources.getIdentifier(
|
||||||
|
"notification_panel_time_date_space",
|
||||||
|
"dimen",
|
||||||
|
viewGroup.context.packageName
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
mWeatherView = TextView(viewGroup.context).also {
|
||||||
|
it.setTextAppearance(
|
||||||
|
viewGroup.context.resources.getIdentifier(
|
||||||
|
"TextAppearance.QSControl.Date",
|
||||||
|
"style",
|
||||||
|
viewGroup.context.packageName
|
||||||
|
)
|
||||||
|
)
|
||||||
|
it.layoutParams = layout
|
||||||
|
}
|
||||||
|
|
||||||
|
viewGroup.addView(mWeatherView)
|
||||||
|
|
||||||
|
val query: Cursor? = viewGroup.context.contentResolver
|
||||||
|
.query(Uri.parse("content://weather/weather"), null, null, null, null)
|
||||||
|
var str = "未找到天气"
|
||||||
|
|
||||||
|
class T : TimerTask() {
|
||||||
|
override fun run() {
|
||||||
|
try {
|
||||||
|
if (query != null) {
|
||||||
|
if (query.moveToFirst()) {
|
||||||
|
if (display_city) {
|
||||||
|
str =
|
||||||
|
query.getString(query.getColumnIndexOrThrow("city_name")) + " " +
|
||||||
|
query.getString(query.getColumnIndexOrThrow("description")) + " " +
|
||||||
|
query.getString(query.getColumnIndexOrThrow("temperature"))
|
||||||
|
} else {
|
||||||
|
str =
|
||||||
|
query.getString(query.getColumnIndexOrThrow("description")) + " " +
|
||||||
|
query.getString(query.getColumnIndexOrThrow("temperature"))
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
query.close()
|
||||||
|
}
|
||||||
|
mWeatherView!!.text = str
|
||||||
|
} catch (e: Exception) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//每小时刷新一次
|
||||||
|
Timer().scheduleAtFixedRate(
|
||||||
|
T(),
|
||||||
|
0,
|
||||||
|
3600000
|
||||||
|
)
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
||||||
|
//解决横屏重叠
|
||||||
|
XposedHelpers.findAndHookMethod(classIfExists, "updateLayout", object : XC_MethodHook() {
|
||||||
|
override fun afterHookedMethod(param: MethodHookParam) {
|
||||||
|
super.afterHookedMethod(param)
|
||||||
|
val mOrientation =
|
||||||
|
XposedHelpers.getObjectField(param.thisObject, "mOrientation") as Int
|
||||||
|
if (mOrientation == 1) {
|
||||||
|
mWeatherView!!.visibility = View.VISIBLE
|
||||||
|
} else {
|
||||||
|
mWeatherView!!.visibility = View.GONE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -118,9 +118,11 @@
|
|||||||
<string name="hide_wifi_activity_icon">隐藏 WIFI箭头 图标</string>
|
<string name="hide_wifi_activity_icon">隐藏 WIFI箭头 图标</string>
|
||||||
<string name="hide_mobile_activity_icon">隐藏 移动箭头 图标</string>
|
<string name="hide_mobile_activity_icon">隐藏 移动箭头 图标</string>
|
||||||
<string name="hide_mobile_type_icon">隐藏 移动类型 图标</string>
|
<string name="hide_mobile_type_icon">隐藏 移动类型 图标</string>
|
||||||
<string name="notification_weather">显示天气-总开关</string>
|
|
||||||
<string name="lock_screen">锁屏</string>
|
<string name="lock_screen">锁屏</string>
|
||||||
<string name="notification_center">通知中心</string>
|
<string name="notification_center">通知中心</string>
|
||||||
<string name="notification_weather_city">显示城市</string>
|
|
||||||
<string name="lock_max_fps_summary">支持添加下拉控制中心快速开关,实时切换</string>
|
<string name="lock_max_fps_summary">支持添加下拉控制中心快速开关,实时切换</string>
|
||||||
|
<string name="show_city">显示城市</string>
|
||||||
|
<string name="control_center">控制中心</string>
|
||||||
|
<string name="show_weather_main_switch">显示天气-总开关</string>
|
||||||
|
<string name="control_center_weather_summary">暂不支持妙想版控制中心</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -50,7 +50,7 @@
|
|||||||
<string name="hide_gps_icon">Hide GPS icon</string>
|
<string name="hide_gps_icon">Hide GPS icon</string>
|
||||||
<string name="hide_status_bar_network_speed_second">Hide network speed (/s) units</string>
|
<string name="hide_status_bar_network_speed_second">Hide network speed (/s) units</string>
|
||||||
<string name="menu">Menu</string>
|
<string name="menu">Menu</string>
|
||||||
<string name="Tips">Tips</string>
|
<string name="Tips">Tips</string>
|
||||||
<string name="skip_waiting_time">Skip 5/10 second warning time</string>
|
<string name="skip_waiting_time">Skip 5/10 second warning time</string>
|
||||||
<string name="unlock_unlimited_cropping">Unlock unlimited cropping pictures/screenshots</string>
|
<string name="unlock_unlimited_cropping">Unlock unlimited cropping pictures/screenshots</string>
|
||||||
<string name="hide_slave_wifi_icon">Hide WIFI secondary icon</string>
|
<string name="hide_slave_wifi_icon">Hide WIFI secondary icon</string>
|
||||||
@@ -64,7 +64,7 @@
|
|||||||
<string name="status_bar_time_week">Display week</string>
|
<string name="status_bar_time_week">Display week</string>
|
||||||
<string name="status_bar_time_hide_space">Hide interval</string>
|
<string name="status_bar_time_hide_space">Hide interval</string>
|
||||||
<string name="allow_screenshots">Allow screenshots</string>
|
<string name="allow_screenshots">Allow screenshots</string>
|
||||||
<string name="lock_max">Lock current limit</string>
|
<string name="lock_max">Lock current limit</string>
|
||||||
<string name="status_bar_time_double_hour">Display hour</string>
|
<string name="status_bar_time_double_hour">Display hour</string>
|
||||||
<string name="custom_clock_switch">Custom Clock Switch</string>
|
<string name="custom_clock_switch">Custom Clock Switch</string>
|
||||||
<string name="status_bar_time_period">Display period</string>
|
<string name="status_bar_time_period">Display period</string>
|
||||||
@@ -79,7 +79,7 @@
|
|||||||
<string name="thank_list">Thanks list</string>
|
<string name="thank_list">Thanks list</string>
|
||||||
<string name="third_party_open_source_statement">Third Party Open Source Statement</string>
|
<string name="third_party_open_source_statement">Third Party Open Source Statement</string>
|
||||||
<string name="corepacth">Remove restrictions</string>
|
<string name="corepacth">Remove restrictions</string>
|
||||||
<string name="corepacth_summary">Supports downgrade/Different signature/Unsigned installation</string>
|
<string name="corepacth_summary">Supports downgrade/Different signature/Unsigned installation</string>
|
||||||
<string name="prevent_recovery_of_battery_optimization_white_list">Prevent recovery of battery optimization whitelist</string>
|
<string name="prevent_recovery_of_battery_optimization_white_list">Prevent recovery of battery optimization whitelist</string>
|
||||||
<string name="failed_after_restart">It will be restored after system restart</string>
|
<string name="failed_after_restart">It will be restored after system restart</string>
|
||||||
<string name="battery_optimization">Battery optimization</string>
|
<string name="battery_optimization">Battery optimization</string>
|
||||||
@@ -96,7 +96,7 @@
|
|||||||
<string name="remove_lock_screen_camera">Remove the lock screen camera function</string>
|
<string name="remove_lock_screen_camera">Remove the lock screen camera function</string>
|
||||||
<string name="only_official_default_themes_are_supported">Only official default themes are supported</string>
|
<string name="only_official_default_themes_are_supported">Only official default themes are supported</string>
|
||||||
<string name="lock_one_hundred">SecurityCenter Lock 100 points</string>
|
<string name="lock_one_hundred">SecurityCenter Lock 100 points</string>
|
||||||
<string name="scope">scope</string>
|
<string name="scope">scope</string>
|
||||||
<string name="scope_android">System Framework</string>
|
<string name="scope_android">System Framework</string>
|
||||||
<string name="scope_systemui">SystemUI</string>
|
<string name="scope_systemui">SystemUI</string>
|
||||||
<string name="scope_miuihome">Home screen</string>
|
<string name="scope_miuihome">Home screen</string>
|
||||||
@@ -118,9 +118,11 @@
|
|||||||
<string name="hide_wifi_activity_icon">Hide WIFI activity icon</string>
|
<string name="hide_wifi_activity_icon">Hide WIFI activity icon</string>
|
||||||
<string name="hide_mobile_activity_icon">Hide mobile activity icon</string>
|
<string name="hide_mobile_activity_icon">Hide mobile activity icon</string>
|
||||||
<string name="hide_mobile_type_icon">Hide mobile type icon</string>
|
<string name="hide_mobile_type_icon">Hide mobile type icon</string>
|
||||||
<string name="notification_weather">Show Weather - Master Switch</string>
|
<string name="show_weather_main_switch">Show Weather - Main Switch</string>
|
||||||
<string name="lock_screen">Lock screen</string>
|
<string name="lock_screen">Lock screen</string>
|
||||||
<string name="notification_center">Notification Center</string>
|
<string name="notification_center">Notification Center</string>
|
||||||
<string name="notification_weather_city">Show the city</string>
|
<string name="show_city">Show the city</string>
|
||||||
<string name="lock_max_fps_summary">Support adding drop-down control center quick switch, real-time switching</string>
|
<string name="lock_max_fps_summary">Support adding drop-down control center quick switch, real-time switching</string>
|
||||||
|
<string name="control_center">Control Center</string>
|
||||||
|
<string name="control_center_weather_summary">The Mi Smart Hub version is not currently supported</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
Reference in New Issue
Block a user