diff --git a/app/src/main/java/com/yuk/fuckMiuiSystemUI/XposedInit.kt b/app/src/main/java/com/yuk/fuckMiuiSystemUI/XposedInit.kt index 892b549..ae28dec 100644 --- a/app/src/main/java/com/yuk/fuckMiuiSystemUI/XposedInit.kt +++ b/app/src/main/java/com/yuk/fuckMiuiSystemUI/XposedInit.kt @@ -1,7 +1,6 @@ package com.yuk.fuckMiuiSystemUI import android.annotation.SuppressLint -import android.content.ContentResolver import android.content.Context import android.os.Handler import android.provider.Settings @@ -12,7 +11,6 @@ import de.robv.android.xposed.XC_MethodHook import de.robv.android.xposed.XposedHelpers import de.robv.android.xposed.callbacks.XC_LoadPackage import java.lang.reflect.Method -import java.text.DateFormat import java.text.SimpleDateFormat import java.util.* @@ -28,22 +26,18 @@ class XposedInit : IXposedHookLoadPackage { override fun afterHookedMethod(param: MethodHookParam) { c = param.args[0] as Context val textV = param.thisObject as TextView - val h = Handler(textV.context.mainLooper) + val d: Method = textV.javaClass.getDeclaredMethod("updateTime") + val r = Runnable { + d.isAccessible = true + d.invoke(textV) + } class T : TimerTask() { override fun run() { - 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) + Handler(textV.context.mainLooper).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) - } + if (textV.resources.getResourceEntryName(textV.id) == "clock") + Timer().scheduleAtFixedRate(T(), 1000 - System.currentTimeMillis() % 1000, 1000) } } ) @@ -53,14 +47,11 @@ class XposedInit : IXposedHookLoadPackage { override fun afterHookedMethod(param: MethodHookParam) { val textV = param.thisObject as TextView if (textV.resources.getResourceEntryName(textV.id) == "clock") { - 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 + val t = Settings.System.getString(c!!.contentResolver, Settings.System.TIME_12_24) + if (t == "24") + textV.text = SimpleDateFormat("HH:mm:ss").format(Calendar.getInstance().time) + else + textV.text = textV.text.toString() + SimpleDateFormat(":ss").format(Calendar.getInstance().time) } } }) @@ -68,4 +59,4 @@ class XposedInit : IXposedHookLoadPackage { else -> return } } -} \ No newline at end of file +}