修复部分版本下拉时钟变小

This commit is contained in:
LittleTurtle2333
2022-03-26 14:22:36 +08:00
parent a7947d5a2f
commit c91a46cabb

View File

@@ -38,11 +38,17 @@ class StatusBarTimeCustomization : IXposedHookLoadPackage {
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) { override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
if (isOpen) { if (isOpen) {
var c: Context? = null var c: Context? = null
val miuiClockClass = "com.android.systemui.statusbar.views.MiuiClock".findClass(lpparam.classLoader) val miuiClockClass =
miuiClockClass.hookAfterConstructor(Context::class.java, AttributeSet::class.java, Integer.TYPE) { "com.android.systemui.statusbar.views.MiuiClock".findClass(lpparam.classLoader)
miuiClockClass.hookAfterConstructor(
Context::class.java,
AttributeSet::class.java,
Integer.TYPE
) {
try { try {
c = it.args[0] as Context c = it.args[0] as Context
val textV = it.thisObject as TextView val textV = it.thisObject as TextView
if (textV.resources.getResourceEntryName(textV.id) != "clock") return@hookAfterConstructor
textV.isSingleLine = false textV.isSingleLine = false
if (isDoubleLine) { if (isDoubleLine) {
str = "\n" str = "\n"
@@ -51,7 +57,7 @@ class StatusBarTimeCustomization : IXposedHookLoadPackage {
clock_double_line_size = getClockDoubleSize.toFloat() clock_double_line_size = getClockDoubleSize.toFloat()
} }
textV.setTextSize(TypedValue.COMPLEX_UNIT_DIP, clock_double_line_size) textV.setTextSize(TypedValue.COMPLEX_UNIT_DIP, clock_double_line_size)
textV.setLineSpacing(0F,0.8F) textV.setLineSpacing(0F, 0.8F)
} else { } else {
if (getClockSize != 0) { if (getClockSize != 0) {
val clock_size = getClockSize.toFloat() val clock_size = getClockSize.toFloat()
@@ -68,7 +74,6 @@ class StatusBarTimeCustomization : IXposedHookLoadPackage {
Handler(textV.context.mainLooper).post(r) Handler(textV.context.mainLooper).post(r)
} }
} }
if (textV.resources.getResourceEntryName(textV.id) == "clock")
Timer().scheduleAtFixedRate(T(), 1000 - System.currentTimeMillis() % 1000, 1000) Timer().scheduleAtFixedRate(T(), 1000 - System.currentTimeMillis() % 1000, 1000)
} catch (e: java.lang.Exception) { } catch (e: java.lang.Exception) {
} }
@@ -77,7 +82,10 @@ class StatusBarTimeCustomization : IXposedHookLoadPackage {
try { try {
val textV = it.thisObject as TextView val textV = it.thisObject as TextView
if (textV.resources.getResourceEntryName(textV.id) == "clock") { if (textV.resources.getResourceEntryName(textV.id) == "clock") {
val t = Settings.System.getString(c!!.contentResolver, Settings.System.TIME_12_24) val t = Settings.System.getString(
c!!.contentResolver,
Settings.System.TIME_12_24
)
val is24 = t == "24" val is24 = t == "24"
now_time = Calendar.getInstance().time now_time = Calendar.getInstance().time
textV.text = getDate(c!!) + str + getTime(c!!, is24) textV.text = getDate(c!!) + str + getTime(c!!, is24)