mirror of
https://github.com/LittleTurtle2333/SimplicityTools.git
synced 2026-07-13 03:41:19 +08:00
新增背屏天气
This commit is contained in:
@@ -195,7 +195,8 @@ class SettingsActivity : MIUIActivity() {
|
|||||||
"killall com.android.updater",
|
"killall com.android.updater",
|
||||||
"killall com.miui.mediaeditor",
|
"killall com.miui.mediaeditor",
|
||||||
"killall com.miui.screenshot",
|
"killall com.miui.screenshot",
|
||||||
"killall com.milink.service"
|
"killall com.milink.service",
|
||||||
|
"killall com.xiaomi.misubscreenui",
|
||||||
)
|
)
|
||||||
ShellUtils.execCommand(command, true)
|
ShellUtils.execCommand(command, true)
|
||||||
dismiss()
|
dismiss()
|
||||||
@@ -1605,6 +1606,16 @@ class SettingsActivity : MIUIActivity() {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
add(LineV())
|
add(LineV())
|
||||||
|
add(TitleTextV(resId = R.string.rear_display))
|
||||||
|
add(
|
||||||
|
TextSummaryWithSwitchV(
|
||||||
|
TextSummaryV(
|
||||||
|
textId = R.string.show_weather_main_switch,
|
||||||
|
),
|
||||||
|
SwitchV("rear_show_weather")
|
||||||
|
)
|
||||||
|
)
|
||||||
|
add(LineV())
|
||||||
add(TitleTextV(resId = R.string.remove_ad))
|
add(TitleTextV(resId = R.string.remove_ad))
|
||||||
add(
|
add(
|
||||||
TextSummaryWithSwitchV(
|
TextSummaryWithSwitchV(
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ class XposedEntry : EasyXposedInit() {
|
|||||||
ThemeManager, // 主题壁纸
|
ThemeManager, // 主题壁纸
|
||||||
ScreenShot, // 截屏
|
ScreenShot, // 截屏
|
||||||
Cast, //投屏
|
Cast, //投屏
|
||||||
|
RearDisplay, //背屏
|
||||||
)
|
)
|
||||||
|
|
||||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam?) {
|
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam?) {
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package com.lt2333.simplicitytools.hook.app
|
||||||
|
|
||||||
|
import com.lt2333.simplicitytools.hook.app.cast.RearDisplayWeather
|
||||||
|
import com.lt2333.simplicitytools.util.xposed.base.AppRegister
|
||||||
|
import de.robv.android.xposed.XposedBridge
|
||||||
|
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||||
|
|
||||||
|
object RearDisplay: AppRegister() {
|
||||||
|
override val packageName: String = "com.xiaomi.misubscreenui"
|
||||||
|
override val processName: List<String> = emptyList()
|
||||||
|
override val logTag: String = "Simplicitytools"
|
||||||
|
|
||||||
|
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||||
|
XposedBridge.log("Simplicitytools: 成功 Hook "+javaClass.simpleName)
|
||||||
|
autoInitHooks(lpparam,
|
||||||
|
RearDisplayWeather, //背屏显示天气
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,131 @@
|
|||||||
|
package com.lt2333.simplicitytools.hook.app.cast
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
|
import android.graphics.Typeface
|
||||||
|
import android.util.TypedValue
|
||||||
|
import android.view.Gravity
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.widget.RelativeLayout
|
||||||
|
import android.widget.TextView
|
||||||
|
import cn.fkj233.ui.activity.dp2px
|
||||||
|
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||||
|
import com.github.kyuubiran.ezxhelper.utils.hookMethod
|
||||||
|
import com.lt2333.simplicitytools.util.hasEnable
|
||||||
|
import com.lt2333.simplicitytools.util.xposed.base.HookRegister
|
||||||
|
import com.lt2333.simplicitytools.view.WeatherView
|
||||||
|
|
||||||
|
object RearDisplayWeather : HookRegister() {
|
||||||
|
@SuppressLint("ResourceType")
|
||||||
|
override fun init() {
|
||||||
|
hasEnable("rear_show_weather") {
|
||||||
|
findMethod("com.xiaomi.misubscreenui.light.aod.view.VerticalClockView") {
|
||||||
|
name == "onFinishInflate"
|
||||||
|
}.hookMethod {
|
||||||
|
before {
|
||||||
|
val viewGroup = it.thisObject as ViewGroup
|
||||||
|
val context = viewGroup.context
|
||||||
|
|
||||||
|
//获取原组件
|
||||||
|
val gradientLayoutID =
|
||||||
|
context.resources.getIdentifier(
|
||||||
|
"gradient_layout",
|
||||||
|
"id",
|
||||||
|
context.packageName
|
||||||
|
)
|
||||||
|
val gradientLayout: ViewGroup = viewGroup.findViewById(gradientLayoutID)
|
||||||
|
|
||||||
|
val dateID =
|
||||||
|
context.resources.getIdentifier("date", "id", context.packageName)
|
||||||
|
val date: TextView = viewGroup.findViewById(dateID)
|
||||||
|
|
||||||
|
|
||||||
|
//创建天气组件
|
||||||
|
val mWeatherView = WeatherView(context, false).apply {
|
||||||
|
gravity = Gravity.END
|
||||||
|
setTextAppearance(
|
||||||
|
context.resources.getIdentifier(
|
||||||
|
"Sub_Screen_Aod_date_s",
|
||||||
|
"style",
|
||||||
|
context.packageName
|
||||||
|
)
|
||||||
|
)
|
||||||
|
typeface = Typeface.create("mipro-medium", Typeface.NORMAL)
|
||||||
|
setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14f)
|
||||||
|
|
||||||
|
}
|
||||||
|
gradientLayout.addView(mWeatherView, (gradientLayout.indexOfChild(date) + 1))
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
findMethod("com.xiaomi.misubscreenui.light.aod.view.HorizontalClockView") {
|
||||||
|
name == "onFinishInflate"
|
||||||
|
}.hookMethod {
|
||||||
|
before {
|
||||||
|
val viewGroup = it.thisObject as ViewGroup
|
||||||
|
val context = viewGroup.context
|
||||||
|
|
||||||
|
//获取原组件
|
||||||
|
val gradientLayoutID =
|
||||||
|
context.resources.getIdentifier(
|
||||||
|
"gradient_layout",
|
||||||
|
"id",
|
||||||
|
context.packageName
|
||||||
|
)
|
||||||
|
val gradientLayout: RelativeLayout = viewGroup.findViewById(gradientLayoutID)
|
||||||
|
|
||||||
|
val dateID =
|
||||||
|
context.resources.getIdentifier("date", "id", context.packageName)
|
||||||
|
val date: TextView = viewGroup.findViewById(dateID)
|
||||||
|
|
||||||
|
val dateParentLayout: ViewGroup = date.parent as ViewGroup
|
||||||
|
|
||||||
|
|
||||||
|
//创建天气组件
|
||||||
|
val mWeatherView = WeatherView(context, false).apply {
|
||||||
|
id = View.generateViewId()
|
||||||
|
gravity = Gravity.CENTER
|
||||||
|
maxLines = 1
|
||||||
|
setTextAppearance(
|
||||||
|
context.resources.getIdentifier(
|
||||||
|
"Sub_Screen_Aod_date_s_horizontal",
|
||||||
|
"style",
|
||||||
|
context.packageName
|
||||||
|
)
|
||||||
|
)
|
||||||
|
typeface = Typeface.create("mipro-medium", 0)
|
||||||
|
|
||||||
|
layoutParams = RelativeLayout.LayoutParams(
|
||||||
|
RelativeLayout.LayoutParams.WRAP_CONTENT, dp2px(context, 30f)
|
||||||
|
).also {
|
||||||
|
it.addRule(RelativeLayout.END_OF, dateID)
|
||||||
|
it.marginStart = dp2px(context, 2f)
|
||||||
|
it.marginEnd = dp2px(context, 2f)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dateParentLayout.addView(
|
||||||
|
mWeatherView,
|
||||||
|
(dateParentLayout.indexOfChild(date) + 1)
|
||||||
|
)
|
||||||
|
|
||||||
|
//电池位置
|
||||||
|
val batteryID =
|
||||||
|
context.resources.getIdentifier(
|
||||||
|
"battery_container",
|
||||||
|
"id",
|
||||||
|
context.packageName
|
||||||
|
)
|
||||||
|
val battery: ViewGroup = viewGroup.findViewById(batteryID)
|
||||||
|
|
||||||
|
battery.layoutParams = RelativeLayout.LayoutParams(
|
||||||
|
RelativeLayout.LayoutParams.WRAP_CONTENT, dp2px(context, 30f)
|
||||||
|
).also {
|
||||||
|
it.addRule(RelativeLayout.END_OF, mWeatherView.id)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,5 +12,6 @@
|
|||||||
<item>com.android.thememanager</item>
|
<item>com.android.thememanager</item>
|
||||||
<item>com.miui.screenshot</item>
|
<item>com.miui.screenshot</item>
|
||||||
<item>com.milink.service</item>
|
<item>com.milink.service</item>
|
||||||
|
<item>com.xiaomi.misubscreenui</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -212,4 +212,5 @@
|
|||||||
<string name="UsePreSig_summary">Always use signatures from already installed apps when installing.\nThis is extremely <b>dangerous</b>.\nOnly enable when really needed!</string>
|
<string name="UsePreSig_summary">Always use signatures from already installed apps when installing.\nThis is extremely <b>dangerous</b>.\nOnly enable when really needed!</string>
|
||||||
<string name="enhancedMode">Enhanced Mode</string>
|
<string name="enhancedMode">Enhanced Mode</string>
|
||||||
<string name="enhancedMode_summary">Pass some validation in the application</string>
|
<string name="enhancedMode_summary">Pass some validation in the application</string>
|
||||||
|
<string name="rear_display">Rear Display (11Ultra)</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
Reference in New Issue
Block a user