From 4e7fb3019e871ba09917adf6983838fed5b4d967 Mon Sep 17 00:00:00 2001 From: YuKongA <1348547200@qq.com> Date: Thu, 10 Feb 2022 16:38:21 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=86=E5=88=AB12/24=E5=B0=8F=E6=97=B6?= =?UTF-8?q?=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle.kts | 4 ++-- .../com/yuk/fuckMiuiSystemUI/XposedInit.kt | 24 ++++++++++++++++--- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 8e74d6f..5c8bf34 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -11,8 +11,8 @@ android { applicationId = "com.yuk.fuckMiuiSystemUI" minSdk = 28 targetSdk = 32 - versionCode = 10 - versionName = "1.0" + versionCode = 11 + versionName = "1.1" } buildTypes { release { diff --git a/app/src/main/java/com/yuk/fuckMiuiSystemUI/XposedInit.kt b/app/src/main/java/com/yuk/fuckMiuiSystemUI/XposedInit.kt index 7d67455..892b549 100644 --- a/app/src/main/java/com/yuk/fuckMiuiSystemUI/XposedInit.kt +++ b/app/src/main/java/com/yuk/fuckMiuiSystemUI/XposedInit.kt @@ -1,8 +1,10 @@ package com.yuk.fuckMiuiSystemUI import android.annotation.SuppressLint +import android.content.ContentResolver import android.content.Context import android.os.Handler +import android.provider.Settings import android.util.AttributeSet import android.widget.TextView import de.robv.android.xposed.IXposedHookLoadPackage @@ -19,19 +21,28 @@ class XposedInit : IXposedHookLoadPackage { override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) { when (lpparam.packageName) { "com.android.systemui" -> { + var c :Context? = null val classIfExists = XposedHelpers.findClassIfExists("com.android.systemui.statusbar.views.MiuiClock", lpparam.classLoader) XposedHelpers.findAndHookConstructor(classIfExists, Context::class.java, AttributeSet::class.java, Integer.TYPE, object : XC_MethodHook() { override fun afterHookedMethod(param: MethodHookParam) { + c = param.args[0] as Context val textV = param.thisObject as TextView val h = Handler(textV.context.mainLooper) class T : TimerTask() { override fun run() { - val r = Runnable { val declaredMethod: Method = textV.javaClass.getDeclaredMethod("updateTime", *arrayOfNulls>(0)); declaredMethod.isAccessible = true; textV.text = ""; declaredMethod.invoke(textV, *arrayOfNulls>(0)) }; h.post(r) + val r = Runnable { + val d: Method = textV.javaClass.getDeclaredMethod("updateTime", *arrayOfNulls>(0)) + d.isAccessible = true; textV.text = "" + d.invoke(textV, *arrayOfNulls>(0)) + } + h.post(r) } } if (textV.resources.getResourceEntryName(textV.id) == "clock") { - var t: Timer? = null; if (t == null) t = Timer(); t.scheduleAtFixedRate(T(), 1050 - System.currentTimeMillis() % 1000, 1000) + var t: Timer? = null + if (t == null) t = Timer() + t.scheduleAtFixedRate(T(), 1050 - System.currentTimeMillis() % 1000, 1000) } } } @@ -42,7 +53,14 @@ class XposedInit : IXposedHookLoadPackage { override fun afterHookedMethod(param: MethodHookParam) { val textV = param.thisObject as TextView if (textV.resources.getResourceEntryName(textV.id) == "clock") { - TimeZone.setDefault(TimeZone.getDefault()); val c = Calendar.getInstance(); val f: DateFormat = SimpleDateFormat("hh:mm:ss"); val d = c.time; val t : String = f.format(d); textV.text = t + val cv: ContentResolver = c!!.contentResolver + val strTimeFormat = Settings.System.getString(cv, Settings.System.TIME_12_24) + TimeZone.setDefault(TimeZone.getDefault()) + val f : DateFormat = if (strTimeFormat == "24") SimpleDateFormat("HH:mm:ss") else SimpleDateFormat("ah:mm:ss") + val ca = Calendar.getInstance() + val d = ca.time + val t : String = f.format(d) + textV.text = t } } })