mirror of
https://github.com/LittleTurtle2333/SimplicityTools.git
synced 2026-07-12 19:31:17 +08:00
更新时钟自定义极客模式
This commit is contained in:
@@ -18,6 +18,9 @@ import java.util.*
|
|||||||
|
|
||||||
object StatusBarTimeCustomization : HookRegister() {
|
object StatusBarTimeCustomization : HookRegister() {
|
||||||
|
|
||||||
|
private val getMode = XSPUtils.getInt("custom_clock_mode", 0)
|
||||||
|
private val getClockSize = XSPUtils.getInt("status_bar_clock_size", 0)
|
||||||
|
private val getClockDoubleSize = XSPUtils.getInt("status_bar_clock_double_line_size", 0)
|
||||||
private val isYear = XSPUtils.getBoolean("status_bar_time_year", false)
|
private val isYear = XSPUtils.getBoolean("status_bar_time_year", false)
|
||||||
private val isMonth = XSPUtils.getBoolean("status_bar_time_month", false)
|
private val isMonth = XSPUtils.getBoolean("status_bar_time_month", false)
|
||||||
private val isDay = XSPUtils.getBoolean("status_bar_time_day", false)
|
private val isDay = XSPUtils.getBoolean("status_bar_time_day", false)
|
||||||
@@ -27,17 +30,23 @@ object StatusBarTimeCustomization : HookRegister() {
|
|||||||
private val isSecond = XSPUtils.getBoolean("status_bar_time_seconds", false)
|
private val isSecond = XSPUtils.getBoolean("status_bar_time_seconds", false)
|
||||||
private val isDoubleHour = XSPUtils.getBoolean("status_bar_time_double_hour", false)
|
private val isDoubleHour = XSPUtils.getBoolean("status_bar_time_double_hour", false)
|
||||||
private val isPeriod = XSPUtils.getBoolean("status_bar_time_period", true)
|
private val isPeriod = XSPUtils.getBoolean("status_bar_time_period", true)
|
||||||
private val getClockSize = XSPUtils.getInt("status_bar_clock_size", 0)
|
|
||||||
private val isOpen = XSPUtils.getBoolean("custom_clock_switch", false)
|
|
||||||
private val isCenterAlign =
|
private val isCenterAlign =
|
||||||
XSPUtils.getBoolean("status_bar_time_double_line_center_align", false)
|
XSPUtils.getBoolean("status_bar_time_double_line_center_align", false)
|
||||||
private val getClockDoubleSize = XSPUtils.getInt("status_bar_clock_double_line_size", 0)
|
|
||||||
|
//极客模式
|
||||||
|
private val getGeekClockSize = XSPUtils.getInt("status_bar_clock_size_geek", 0)
|
||||||
|
private val getGeekFormat = XSPUtils.getString("custom_clock_format_geek", "HH:mm:ss")
|
||||||
|
private val isGeekCenterAlign =
|
||||||
|
XSPUtils.getBoolean("status_bar_time_center_align_geek", false)
|
||||||
|
|
||||||
private lateinit var nowTime: Date
|
private lateinit var nowTime: Date
|
||||||
private var str = ""
|
private var str = ""
|
||||||
|
|
||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
override fun init() {
|
override fun init() {
|
||||||
if (isOpen) {
|
when (getMode) {
|
||||||
|
//预设模式
|
||||||
|
1 -> {
|
||||||
var c: Context? = null
|
var c: Context? = null
|
||||||
|
|
||||||
findConstructor("com.android.systemui.statusbar.views.MiuiClock") {
|
findConstructor("com.android.systemui.statusbar.views.MiuiClock") {
|
||||||
@@ -73,7 +82,11 @@ object StatusBarTimeCustomization : HookRegister() {
|
|||||||
Handler(textV.context.mainLooper).post(r)
|
Handler(textV.context.mainLooper).post(r)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Timer().scheduleAtFixedRate(T(), 1000 - System.currentTimeMillis() % 1000, 1000)
|
Timer().scheduleAtFixedRate(
|
||||||
|
T(),
|
||||||
|
1000 - System.currentTimeMillis() % 1000,
|
||||||
|
1000
|
||||||
|
)
|
||||||
} catch (_: Exception) {
|
} catch (_: Exception) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -109,6 +122,71 @@ object StatusBarTimeCustomization : HookRegister() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//极客模式
|
||||||
|
2 -> {
|
||||||
|
var c: Context? = null
|
||||||
|
|
||||||
|
findConstructor("com.android.systemui.statusbar.views.MiuiClock") {
|
||||||
|
paramCount == 3
|
||||||
|
}.hookAfter {
|
||||||
|
try {
|
||||||
|
c = it.args[0] as Context
|
||||||
|
val textV = it.thisObject as TextView
|
||||||
|
if (textV.resources.getResourceEntryName(textV.id) != "clock") return@hookAfter
|
||||||
|
textV.isSingleLine = false
|
||||||
|
textV.setLineSpacing(0F, 0.8F)
|
||||||
|
if (getGeekClockSize != 0) {
|
||||||
|
val clockSize = getGeekClockSize.toFloat()
|
||||||
|
textV.setTextSize(TypedValue.COMPLEX_UNIT_DIP, clockSize)
|
||||||
|
}
|
||||||
|
|
||||||
|
val d: Method = textV.javaClass.getDeclaredMethod("updateTime")
|
||||||
|
val r = Runnable {
|
||||||
|
d.isAccessible = true
|
||||||
|
d.invoke(textV)
|
||||||
|
}
|
||||||
|
|
||||||
|
class T : TimerTask() {
|
||||||
|
override fun run() {
|
||||||
|
Handler(textV.context.mainLooper).post(r)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Timer().scheduleAtFixedRate(
|
||||||
|
T(),
|
||||||
|
1000 - System.currentTimeMillis() % 1000,
|
||||||
|
1000
|
||||||
|
)
|
||||||
|
} catch (_: Exception) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
findMethod("com.android.systemui.statusbar.views.MiuiClock") {
|
||||||
|
name == "updateTime"
|
||||||
|
}.hookAfter {
|
||||||
|
try {
|
||||||
|
val textV = it.thisObject as TextView
|
||||||
|
if (textV.resources.getResourceEntryName(textV.id) == "clock") {
|
||||||
|
nowTime = Calendar.getInstance().time
|
||||||
|
textV.text = SimpleDateFormat(getGeekFormat).format(nowTime)
|
||||||
|
}
|
||||||
|
} catch (_: Exception) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isGeekCenterAlign) {
|
||||||
|
findMethod("com.android.systemui.statusbar.phone.CollapsedStatusBarFragment") {
|
||||||
|
name == "onViewCreated" && parameterCount == 2
|
||||||
|
}.hookAfter {
|
||||||
|
val miuiPhoneStatusBarView =
|
||||||
|
it.thisObject.getObject("mStatusBar") as ViewGroup
|
||||||
|
val res: Resources = miuiPhoneStatusBarView.resources
|
||||||
|
val clockId: Int = res.getIdentifier("clock", "id", "com.android.systemui")
|
||||||
|
val clock: TextView = miuiPhoneStatusBarView.findViewById(clockId)
|
||||||
|
clock.gravity = Gravity.CENTER
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("SimpleDateFormat")
|
@SuppressLint("SimpleDateFormat")
|
||||||
|
|||||||
Reference in New Issue
Block a user