From c91a46cabb0035a837ad8e750988db72c64c8142 Mon Sep 17 00:00:00 2001 From: LittleTurtle2333 Date: Sat, 26 Mar 2022 14:22:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=83=A8=E5=88=86=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E4=B8=8B=E6=8B=89=E6=97=B6=E9=92=9F=E5=8F=98=E5=B0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../systemui/StatusBarTimeCustomization.kt | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/lt2333/simplicitytools/hook/app/systemui/StatusBarTimeCustomization.kt b/app/src/main/java/com/lt2333/simplicitytools/hook/app/systemui/StatusBarTimeCustomization.kt index e32fe758..f3d34eb1 100644 --- a/app/src/main/java/com/lt2333/simplicitytools/hook/app/systemui/StatusBarTimeCustomization.kt +++ b/app/src/main/java/com/lt2333/simplicitytools/hook/app/systemui/StatusBarTimeCustomization.kt @@ -18,7 +18,7 @@ import java.text.SimpleDateFormat import java.util.* class StatusBarTimeCustomization : IXposedHookLoadPackage { - + private val isYear = XSPUtils.getBoolean("status_bar_time_year", false) private val isMonth = XSPUtils.getBoolean("status_bar_time_month", false) private val isDay = XSPUtils.getBoolean("status_bar_time_day", false) @@ -38,11 +38,17 @@ class StatusBarTimeCustomization : IXposedHookLoadPackage { override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) { if (isOpen) { var c: Context? = null - val miuiClockClass = "com.android.systemui.statusbar.views.MiuiClock".findClass(lpparam.classLoader) - miuiClockClass.hookAfterConstructor(Context::class.java, AttributeSet::class.java, Integer.TYPE) { + val miuiClockClass = + "com.android.systemui.statusbar.views.MiuiClock".findClass(lpparam.classLoader) + miuiClockClass.hookAfterConstructor( + Context::class.java, + AttributeSet::class.java, + Integer.TYPE + ) { try { c = it.args[0] as Context val textV = it.thisObject as TextView + if (textV.resources.getResourceEntryName(textV.id) != "clock") return@hookAfterConstructor textV.isSingleLine = false if (isDoubleLine) { str = "\n" @@ -51,7 +57,7 @@ class StatusBarTimeCustomization : IXposedHookLoadPackage { clock_double_line_size = getClockDoubleSize.toFloat() } textV.setTextSize(TypedValue.COMPLEX_UNIT_DIP, clock_double_line_size) - textV.setLineSpacing(0F,0.8F) + textV.setLineSpacing(0F, 0.8F) } else { if (getClockSize != 0) { val clock_size = getClockSize.toFloat() @@ -68,8 +74,7 @@ class StatusBarTimeCustomization : IXposedHookLoadPackage { 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) { } } @@ -77,7 +82,10 @@ class StatusBarTimeCustomization : IXposedHookLoadPackage { try { val textV = it.thisObject as TextView 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" now_time = Calendar.getInstance().time textV.text = getDate(c!!) + str + getTime(c!!, is24)