修复状态栏天气布局修复异常

This commit is contained in:
乌堆小透明
2022-03-05 20:18:05 +08:00
parent 4987291cb1
commit 6eda650901

View File

@@ -2,7 +2,6 @@ package com.lt2333.simplicitytools.hook.app.systemui
import android.view.ViewGroup
import android.widget.TextView
import androidx.constraintlayout.widget.ConstraintLayout
import de.robv.android.xposed.IXposedHookLoadPackage
import de.robv.android.xposed.XC_MethodHook
import de.robv.android.xposed.XposedHelpers
@@ -18,20 +17,46 @@ class NotificationWeather :IXposedHookLoadPackage {
override fun afterHookedMethod(param: MethodHookParam) {
val viewGroup = param.thisObject as ViewGroup
val layoutParams = ConstraintLayout.LayoutParams(
ConstraintLayout.LayoutParams.WRAP_CONTENT,
ConstraintLayout.LayoutParams.WRAP_CONTENT,
).also {
it.bottomToTop = viewGroup.context.resources.getIdentifier("date_time","id",viewGroup.context.packageName)
it.startToEnd = viewGroup.context.resources.getIdentifier("big_time","id",viewGroup.context.packageName)
it.marginStart = viewGroup.context.resources.getIdentifier("notification_panel_time_date_space","dimen",viewGroup.context.packageName)
}
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
)
)
val textView = TextView(viewGroup.context).also {
it.setTextAppearance(viewGroup.context.resources.getIdentifier("TextAppearance.QSControl.Date","style",viewGroup.context.packageName))
it.text = "This is a TextView"
//TODO:状态栏天气定位异常
it.layoutParams = layoutParams
it.layoutParams = layout
}
viewGroup.addView(textView)