Skip to content
This repository has been archived by the owner on Mar 20, 2023. It is now read-only.

Commit

Permalink
12小时制时正确显示“半夜”等词汇
Browse files Browse the repository at this point in the history
  • Loading branch information
YuKongA committed Feb 10, 2022
1 parent 4e7fb30 commit 6b0cd8b
Showing 1 changed file with 14 additions and 23 deletions.
37 changes: 14 additions & 23 deletions app/src/main/java/com/yuk/fuckMiuiSystemUI/XposedInit.kt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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.*

Expand All @@ -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<Class<*>>(0))
d.isAccessible = true; textV.text = ""
d.invoke(textV, *arrayOfNulls<Class<*>>(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)
}
}
)
Expand All @@ -53,19 +47,16 @@ 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)
}
}
})
}
else -> return
}
}
}
}

0 comments on commit 6b0cd8b

Please sign in to comment.