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

Commit

Permalink
识别12/24小时制
Browse files Browse the repository at this point in the history
  • Loading branch information
YuKongA committed Feb 10, 2022
1 parent 9e226f7 commit 4e7fb30
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
24 changes: 21 additions & 3 deletions app/src/main/java/com/yuk/fuckMiuiSystemUI/XposedInit.kt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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<Class<*>>(0)); declaredMethod.isAccessible = true; textV.text = ""; declaredMethod.invoke(textV, *arrayOfNulls<Class<*>>(0)) }; h.post(r)
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)
}
}
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)
}
}
}
Expand All @@ -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
}
}
})
Expand Down

0 comments on commit 4e7fb30

Please sign in to comment.