12 Commits

Author SHA1 Message Date
LittleTurtle2333
1af8e0605b Update StatusBarLayoutForT.kt 2023-03-06 15:44:23 +08:00
LittleTurtle2333
29fa75cca0 优化写法 2023-03-06 15:44:02 +08:00
LittleTurtle2333
84f826fc31 Update SystemUIHooker.kt 2023-03-06 15:41:21 +08:00
LittleTurtle2333
719e7dfac1 Update AGP to 7.4.2 2023-03-06 15:41:06 +08:00
LittleTurtle2333
f77f9be2af Update OldNotificationWeatherForT.kt 2023-03-05 22:27:54 +08:00
LittleTurtle2333
c81951da2a Update AndroidHooker.kt 2023-03-05 22:07:28 +08:00
LittleTurtle2333
074a0fa160 Update HideBatteryIconForT.kt 2023-03-05 22:07:18 +08:00
LittleTurtle2333
ab5abc10c9 Update HideHDIconForT.kt 2023-03-05 22:07:08 +08:00
LittleTurtle2333
8117809073 Update NotificationWeatherForT.kt 2023-03-05 22:07:00 +08:00
LittleTurtle2333
ce5312494c Update SystemUIHooker.kt 2023-03-05 22:06:42 +08:00
LittleTurtle2333
3ce5d1b1f2 修复MIUI14上控制中心的天气显示 2023-03-05 22:06:05 +08:00
LittleTurtle2333
2737cd2492 修复一处MIUI14的问题 2023-03-05 20:26:13 +08:00
16 changed files with 734 additions and 37 deletions

View File

@@ -8,14 +8,15 @@ import com.lt2333.simplicitytools.hooks.rules.all.android.DisableFlagSecureForAl
object AndroidHooker: YukiBaseHooker() { object AndroidHooker: YukiBaseHooker() {
override fun onHook() { override fun onHook() {
//判断Android版本号加载不同的Hooker
when (Build.VERSION.SDK_INT) { when (Build.VERSION.SDK_INT) {
Build.VERSION_CODES.TIRAMISU -> { Build.VERSION_CODES.TIRAMISU -> { //Android13
loadHooker(DisableFlagSecureForAll) //允许截图 loadHooker(DisableFlagSecureForAll) //允许截图
loadHooker(AllowUntrustedTouchesForAll) //允许不受信任触摸 loadHooker(AllowUntrustedTouchesForAll) //允许不受信任触摸
loadHooker(DeleteOnPostNotificationForAll) //上层显示 loadHooker(DeleteOnPostNotificationForAll) //上层显示
} }
Build.VERSION_CODES.S -> { Build.VERSION_CODES.S -> { //Android12
loadHooker(DisableFlagSecureForAll) //允许截图 loadHooker(DisableFlagSecureForAll) //允许截图
loadHooker(AllowUntrustedTouchesForAll) //允许不受信任触摸 loadHooker(AllowUntrustedTouchesForAll) //允许不受信任触摸
loadHooker(DeleteOnPostNotificationForAll) //上层显示 loadHooker(DeleteOnPostNotificationForAll) //上层显示

View File

@@ -2,7 +2,23 @@ package com.lt2333.simplicitytools.hooks.apps
import android.os.Build import android.os.Build
import com.highcapable.yukihookapi.hook.entity.YukiBaseHooker import com.highcapable.yukihookapi.hook.entity.YukiBaseHooker
import com.lt2333.simplicitytools.hooks.rules.t.systemui.* import com.lt2333.simplicitytools.hooks.rules.t.systemui.HideBatteryIconForT
import com.lt2333.simplicitytools.hooks.rules.t.systemui.HideHDIconForT
import com.lt2333.simplicitytools.hooks.rules.t.systemui.HideMobileActivityIconForT
import com.lt2333.simplicitytools.hooks.rules.t.systemui.HideMobileTypeIconForT
import com.lt2333.simplicitytools.hooks.rules.t.systemui.HideSimIconForT
import com.lt2333.simplicitytools.hooks.rules.t.systemui.HideStatusBarIconForT
import com.lt2333.simplicitytools.hooks.rules.t.systemui.HideStatusBarNetworkSpeedSecondForT
import com.lt2333.simplicitytools.hooks.rules.t.systemui.HideWifiActivityIconForT
import com.lt2333.simplicitytools.hooks.rules.t.systemui.MaximumNumberOfNotificationIconsForT
import com.lt2333.simplicitytools.hooks.rules.t.systemui.NewControlCenterWeatherForT
import com.lt2333.simplicitytools.hooks.rules.t.systemui.NotificationWeatherForT
import com.lt2333.simplicitytools.hooks.rules.t.systemui.OldNotificationWeatherForT
import com.lt2333.simplicitytools.hooks.rules.t.systemui.RemoveLockScreenCameraForT
import com.lt2333.simplicitytools.hooks.rules.t.systemui.RemoveTheLeftSideOfTheLockScreenForT
import com.lt2333.simplicitytools.hooks.rules.t.systemui.StatusBarLayoutForT
import com.lt2333.simplicitytools.hooks.rules.t.systemui.StatusBarNetworkSpeedRefreshSpeedForT
import com.lt2333.simplicitytools.hooks.rules.t.systemui.StatusBarTimeCustomizationForT
object SystemUIHooker : YukiBaseHooker() { object SystemUIHooker : YukiBaseHooker() {
override fun onHook() { override fun onHook() {
@@ -22,6 +38,9 @@ object SystemUIHooker : YukiBaseHooker() {
loadHooker(RemoveTheLeftSideOfTheLockScreenForT) //移除锁屏负一屏功能 loadHooker(RemoveTheLeftSideOfTheLockScreenForT) //移除锁屏负一屏功能
loadHooker(RemoveLockScreenCameraForT) //移除锁屏相机功能 loadHooker(RemoveLockScreenCameraForT) //移除锁屏相机功能
loadHooker(NotificationWeatherForT) //通知面板天气 loadHooker(NotificationWeatherForT) //通知面板天气
loadHooker(NewControlCenterWeatherForT) //新控制中心天气
loadHooker(OldNotificationWeatherForT) //经典通知天气
loadHooker(StatusBarLayoutForT) //状态栏布局
} }
Build.VERSION_CODES.S -> { Build.VERSION_CODES.S -> {

View File

@@ -24,7 +24,7 @@ object DisableFlagSecureForAll : YukiBaseHooker() {
method { name = "setSecure" } method { name = "setSecure" }
beforeHook { beforeHook {
hasEnable("disable_flag_secure") { hasEnable("disable_flag_secure") {
this.args[0] = false args[0] = false
} }
} }
} }
@@ -32,10 +32,10 @@ object DisableFlagSecureForAll : YukiBaseHooker() {
allMembers(MembersType.CONSTRUCTOR) allMembers(MembersType.CONSTRUCTOR)
beforeHook { beforeHook {
hasEnable("disable_flag_secure") { hasEnable("disable_flag_secure") {
var flags = this.args[2] as Int var flags = args[2] as Int
val secureFlag = 128 val secureFlag = 128
flags = flags and secureFlag.inv() flags = flags and secureFlag.inv()
this.args[2] = flags args[2] = flags
} }
} }
} }

View File

@@ -9,10 +9,8 @@ import android.view.View
import com.highcapable.yukihookapi.hook.entity.YukiBaseHooker import com.highcapable.yukihookapi.hook.entity.YukiBaseHooker
import com.highcapable.yukihookapi.hook.factory.current import com.highcapable.yukihookapi.hook.factory.current
import com.highcapable.yukihookapi.hook.factory.field import com.highcapable.yukihookapi.hook.factory.field
import com.highcapable.yukihookapi.hook.factory.toClass
import com.lt2333.simplicitytools.R import com.lt2333.simplicitytools.R
import com.lt2333.simplicitytools.utils.hasEnable import com.lt2333.simplicitytools.utils.hasEnable
import de.robv.android.xposed.XposedHelpers
object ShortcutAddSmallWindowForAll : YukiBaseHooker() { object ShortcutAddSmallWindowForAll : YukiBaseHooker() {
override fun onHook() = hasEnable("miuihome_shortcut_add_small_window") { override fun onHook() = hasEnable("miuihome_shortcut_add_small_window") {
@@ -51,8 +49,8 @@ object ShortcutAddSmallWindowForAll : YukiBaseHooker() {
paramCount = 2 paramCount = 2
} }
beforeHook { beforeHook {
val obj = this.args[0] val obj = args[0]
val view: View = this.args[1] as View val view: View = args[1] as View
val mShortTitle = obj?.current { val mShortTitle = obj?.current {
method { name = "getShortTitle" }.invoke<CharSequence>() method { name = "getShortTitle" }.invoke<CharSequence>()
} }

View File

@@ -1,7 +1,6 @@
package com.lt2333.simplicitytools.hooks.rules.t.systemui package com.lt2333.simplicitytools.hooks.rules.t.systemui
import android.view.View import android.view.View
import android.view.ViewGroup
import android.widget.FrameLayout import android.widget.FrameLayout
import android.widget.ImageView import android.widget.ImageView
import android.widget.TextView import android.widget.TextView
@@ -18,6 +17,7 @@ object HideBatteryIconForT : YukiBaseHooker() {
afterHook { afterHook {
//隐藏电池图标 //隐藏电池图标
hasEnable("hide_battery_icon") { hasEnable("hide_battery_icon") {
//从当前实例中获取名为mBatteryStyle的Field并转换成ImageView类型操作可见度
instance.current().field { name = "mBatteryStyle" }.cast<ImageView>()?.visibility = View.GONE instance.current().field { name = "mBatteryStyle" }.cast<ImageView>()?.visibility = View.GONE
if (instance.current().field { name = "mBatteryStyle" }.int() == 1) { if (instance.current().field { name = "mBatteryStyle" }.int() == 1) {
instance.current().field { name = "mBatteryDigitalView" }.cast<FrameLayout>()?.visibility = View.GONE instance.current().field { name = "mBatteryDigitalView" }.cast<FrameLayout>()?.visibility = View.GONE

View File

@@ -42,6 +42,7 @@ object HideHDIconForT : YukiBaseHooker() {
} }
private fun hide(it: HookParam) { private fun hide(it: HookParam) {
hasEnable("hide_big_hd_icon") { hasEnable("hide_big_hd_icon") {
//从当前实例中获取名为mVolte的Field并转换成ImageView类型操作可见度
it.instance.current().field {name = "mVolte" }.cast<ImageView>()?.visibility = View.GONE it.instance.current().field {name = "mVolte" }.cast<ImageView>()?.visibility = View.GONE
} }
hasEnable("hide_small_hd_icon") { hasEnable("hide_small_hd_icon") {

View File

@@ -12,7 +12,7 @@ object HideSimIconForT:YukiBaseHooker() {
param(MutableList::class.java) param(MutableList::class.java)
} }
beforeHook { beforeHook {
val list = this.args[0] as MutableList<*> val list = args[0] as MutableList<*>
val size = list.size val size = list.size
hasEnable("hide_sim_two_icon", extraCondition = { size == 2 }) { hasEnable("hide_sim_two_icon", extraCondition = { size == 2 }) {
list.removeAt(1) list.removeAt(1)

View File

@@ -13,13 +13,13 @@ object HideStatusBarNetworkSpeedSecondForT : YukiBaseHooker() {
} }
beforeHook { beforeHook {
hasEnable("hide_status_bar_network_speed_second") { hasEnable("hide_status_bar_network_speed_second") {
if (this.args[0] != null) { if (args[0] != null) {
val mText = (this.args[0] as String) val mText = (args[0] as String)
.replace("/", "") .replace("/", "")
.replace("s", "") .replace("s", "")
.replace("\'", "") .replace("\'", "")
.replace("วิ", "") .replace("วิ", "")
this.args[0] = mText args[0] = mText
} }
} }
} }

View File

@@ -3,7 +3,6 @@ package com.lt2333.simplicitytools.hooks.rules.t.systemui
import com.highcapable.yukihookapi.hook.entity.YukiBaseHooker import com.highcapable.yukihookapi.hook.entity.YukiBaseHooker
import com.highcapable.yukihookapi.hook.factory.current import com.highcapable.yukihookapi.hook.factory.current
import com.lt2333.simplicitytools.utils.XSPUtils import com.lt2333.simplicitytools.utils.XSPUtils
import java.lang.reflect.Method
object MaximumNumberOfNotificationIconsForT: YukiBaseHooker() { object MaximumNumberOfNotificationIconsForT: YukiBaseHooker() {
override fun onHook() { override fun onHook() {
@@ -16,14 +15,14 @@ object MaximumNumberOfNotificationIconsForT: YukiBaseHooker() {
paramCount = 1 paramCount = 1
} }
replaceUnit { replaceUnit {
if (this.args[0] as Boolean) { if (args[0] as Boolean) {
instance.current().field { name = "MAX_DOTS" }.set(dots) instance.current().field { name = "MAX_DOTS" }.set(dots)
instance.current().field { name = "MAX_STATIC_ICONS" }.set(icons) instance.current().field { name = "MAX_STATIC_ICONS" }.set(icons)
instance.current().field { name = "MAX_VISIBLE_ICONS_ON_LOCK" }.set(icons) instance.current().field { name = "MAX_ICONS_ON_LOCKSCREEN" }.set(icons)
} else { } else {
instance.current().field { name = "MAX_DOTS" }.set(0) instance.current().field { name = "MAX_DOTS" }.set(0)
instance.current().field { name = "MAX_STATIC_ICONS" }.set(0) instance.current().field { name = "MAX_STATIC_ICONS" }.set(0)
instance.current().field { name = "MAX_VISIBLE_ICONS_ON_LOCK" }.set(0) instance.current().field { name = "MAX_ICONS_ON_LOCKSCREEN" }.set(0)
} }
instance.current().method { name = "updateState" }.call() instance.current().method { name = "updateState" }.call()
} }

View File

@@ -0,0 +1,84 @@
package com.lt2333.simplicitytools.hooks.rules.t.systemui
import android.content.pm.ApplicationInfo
import android.widget.TextView
import com.highcapable.yukihookapi.hook.entity.YukiBaseHooker
import com.highcapable.yukihookapi.hook.factory.current
import com.lt2333.simplicitytools.utils.XSPUtils
import com.lt2333.simplicitytools.utils.hasEnable
import com.lt2333.simplicitytools.views.WeatherData
object NewControlCenterWeatherForT : YukiBaseHooker() {
override fun onHook() = hasEnable("control_center_weather") {
lateinit var weather: WeatherData
var clockId: Int = -2
val isDisplayCity = XSPUtils.getBoolean("notification_weather_city", false)
"com.android.systemui.controlcenter.phone.widget.ControlCenterDateView".hook {
injectMember {
method {
name = "onDetachedFromWindow"
superClass(true)
}
beforeHook {
if (instance<TextView>().id == clockId) {
weather.onDetachedFromWindow()
}
}
}
}
"com.android.systemui.controlcenter.phone.widget.ControlCenterDateView".hook {
injectMember {
method {
name = "setText"
superClass(true)
}
beforeHook {
val time = args[0]?.toString()
val view = instance<TextView>()
if (view.id == clockId && time != null) {
args[0] = "${weather.weatherData}$time"
}
}
}
}
"com.android.systemui.shared.plugins.PluginInstance\$Factory".hook {
injectMember {
method {
name = "getClassLoader"
}
afterHook {
val appInfo = args[0] as ApplicationInfo
val classLoader = this.result as ClassLoader
if (appInfo.packageName == "miui.systemui.plugin") {
"miui.systemui.controlcenter.windowview.MainPanelHeaderController".hook {
injectMember {
appClassLoader = classLoader
method {
name = "addClockViews"
}
afterHook {
val dateView = instance.current().field { name = "dateView" }.cast<TextView>()
if (dateView != null) {
clockId = dateView.id
}
weather = WeatherData(dateView?.context, isDisplayCity)
weather.callBacks = {
dateView?.current {
method {
name = "updateTime"
superClass(true)
}.call()
}
}
}
}
}.onHookClassNotFoundFailure { }
}
}
}
}
}
}

View File

@@ -10,9 +10,8 @@ import android.widget.Toast
import androidx.constraintlayout.widget.ConstraintLayout import androidx.constraintlayout.widget.ConstraintLayout
import cn.fkj233.ui.activity.dp2px import cn.fkj233.ui.activity.dp2px
import com.highcapable.yukihookapi.hook.entity.YukiBaseHooker import com.highcapable.yukihookapi.hook.entity.YukiBaseHooker
import com.highcapable.yukihookapi.hook.factory.constructor import com.highcapable.yukihookapi.hook.factory.buildOf
import com.highcapable.yukihookapi.hook.factory.current import com.highcapable.yukihookapi.hook.factory.current
import com.highcapable.yukihookapi.hook.factory.toClass
import com.lt2333.simplicitytools.utils.SystemProperties import com.lt2333.simplicitytools.utils.SystemProperties
import com.lt2333.simplicitytools.utils.XSPUtils import com.lt2333.simplicitytools.utils.XSPUtils
import com.lt2333.simplicitytools.utils.hasEnable import com.lt2333.simplicitytools.utils.hasEnable
@@ -123,18 +122,20 @@ object NotificationWeatherForT : YukiBaseHooker() {
(mWeatherView as WeatherView).layoutParams = mweatherviewLp (mWeatherView as WeatherView).layoutParams = mweatherviewLp
} else { } else {
// 通过YukiHook的构造方法创建新实例指定类型 ViewGroup.MarginLayoutParams
val layoutParam = "androidx.constraintlayout.widget.ConstraintLayout\$LayoutParams".toClass() val layoutParam = "androidx.constraintlayout.widget.ConstraintLayout\$LayoutParams".toClass()
.constructor { .buildOf<ViewGroup.MarginLayoutParams>(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT
) {
paramCount = 2 paramCount = 2
}.get().newInstance<ViewGroup.MarginLayoutParams>( }
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT
)
layoutParam?.current()?.field { name = "bottomToTop" }?.set(context.resources.getIdentifier("date_time", "id", context.packageName)) layoutParam?.current()?.field { name = "bottomToTop" }
layoutParam?.current()?.field { name = "startToEnd" }?.set(context.resources.getIdentifier("big_time", "id", context.packageName)) ?.set(context.resources.getIdentifier("date_time", "id", context.packageName))
layoutParam?.current()?.field { name = "startToEnd" }
?.set(context.resources.getIdentifier("big_time", "id", context.packageName))
layoutParam?.marginStart = context.resources.getDimensionPixelSize( layoutParam?.marginStart = context.resources.getDimensionPixelSize(
context.resources.getIdentifier( context.resources.getIdentifier(

View File

@@ -0,0 +1,73 @@
package com.lt2333.simplicitytools.hooks.rules.t.systemui
import android.content.ComponentName
import android.content.Intent
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import android.widget.Toast
import com.highcapable.yukihookapi.hook.entity.YukiBaseHooker
import com.highcapable.yukihookapi.hook.factory.current
import com.lt2333.simplicitytools.utils.XSPUtils
import com.lt2333.simplicitytools.utils.hasEnable
import com.lt2333.simplicitytools.views.WeatherView
object OldNotificationWeatherForT : YukiBaseHooker() {
override fun onHook() = hasEnable("notification_weather") {
var mWeatherView: TextView? = null
val isDisplayCity = XSPUtils.getBoolean("notification_weather_city", false)
"com.android.systemui.qs.MiuiQSHeaderView".hook {
injectMember {
method {
name = "onFinishInflate"
}
afterHook {
val viewGroup = instance<ViewGroup>()
val context = viewGroup.context
mWeatherView = WeatherView(context, isDisplayCity).apply {
setTextAppearance(
context.resources.getIdentifier(
"TextAppearance.StatusBar.Expanded.Clock.QuickSettingDate",
"style",
context.packageName
)
)
}
viewGroup.addView(mWeatherView)
(mWeatherView as WeatherView).setOnClickListener {
try {
val intent = Intent().apply {
flags = Intent.FLAG_ACTIVITY_NEW_TASK
component = ComponentName(
"com.miui.weather2",
"com.miui.weather2.ActivityWeatherMain"
)
}
context.startActivity(intent)
} catch (e: Exception) {
Toast.makeText(context, "启动失败,可能是不支持", Toast.LENGTH_LONG).show()
}
}
}
}
}
"com.android.systemui.qs.MiuiQSHeaderView".hook {
injectMember {
method { name = "updateLayout" }
afterHook {
val mOrientation = instance.current().field { name = "mOrientation" }.int()
if (mOrientation == 1) {
mWeatherView!!.visibility = View.VISIBLE
} else {
mWeatherView!!.visibility = View.GONE
}
}
}
}
}
}

View File

@@ -0,0 +1,521 @@
package com.lt2333.simplicitytools.hooks.rules.t.systemui
import android.app.KeyguardManager
import android.content.Context
import android.content.res.Configuration
import android.content.res.Resources
import android.view.Gravity
import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
import android.widget.TextView
import androidx.constraintlayout.widget.ConstraintLayout
import cn.fkj233.ui.activity.dp2px
import com.highcapable.yukihookapi.hook.entity.YukiBaseHooker
import com.highcapable.yukihookapi.hook.factory.current
import com.lt2333.simplicitytools.utils.XSPUtils
import com.lt2333.simplicitytools.utils.hasEnable
object StatusBarLayoutForT : YukiBaseHooker() {
private val getMode = XSPUtils.getInt("status_bar_layout_mode", 0)
private val isCompatibilityMode = XSPUtils.getBoolean("layout_compatibility_mode", false)
private var statusBarLeft = 0
private var statusBarTop = 0
private var statusBarRight = 0
private var statusBarBottom = 0
override fun onHook() {
var mLeftLayout: LinearLayout? = null
var mRightLayout: LinearLayout? = null
var mCenterLayout: LinearLayout?
var statusBar: ViewGroup? = null
//判断屏幕状态更新布局 mode: 1正常布局 2居中布局
fun updateLayout(context: Context, mode: Int) {
runCatching {
when (mode) {
1 -> {
val mConfiguration: Configuration = context.resources.configuration
if (mConfiguration.orientation == Configuration.ORIENTATION_PORTRAIT) { //横屏
statusBar!!.setPadding(statusBarLeft, statusBarTop, statusBarRight, statusBarBottom)
}
}
2 -> {
val mConfiguration: Configuration = context.resources.configuration
if (mConfiguration.orientation == Configuration.ORIENTATION_PORTRAIT) { //横屏
mLeftLayout!!.setPadding(statusBarLeft, 0, 0, 0)
mRightLayout!!.setPadding(0, 0, statusBarRight, 0)
statusBar!!.setPadding(0, statusBarTop, 0, statusBarBottom)
} else { //竖屏
mLeftLayout!!.setPadding(0, 0, 0, 0)
mRightLayout!!.setPadding(0, 0, 0, 0)
}
}
}
}.getOrNull()
}
//判断是否开启挖孔兼容模式
if (isCompatibilityMode) {
"com.android.systemui.ScreenDecorations".hook {
injectMember {
method {
name = "boundsFromDirection"
paramCount = 3
}
beforeHook {
args[1] = 0
}
}
}
}
//修改对应布局
when (getMode) {
//默认
0 -> {
"com.android.systemui.statusbar.phone.fragment.CollapsedStatusBarFragment".hook {
injectMember {
method {
name = "onViewCreated"
paramCount = 2
}
afterHook {
val miuiPhoneStatusBarView =args(0).cast<ViewGroup>()!!
val context: Context = miuiPhoneStatusBarView.context
val res: Resources = miuiPhoneStatusBarView.resources
val statusBarId: Int = res.getIdentifier("status_bar", "id", "com.android.systemui")
statusBar = miuiPhoneStatusBarView.findViewById(statusBarId)
if (statusBar == null) return@afterHook
statusBarLeft = statusBar!!.paddingLeft
statusBarTop = statusBar!!.paddingTop
statusBarRight = statusBar!!.paddingRight
statusBarBottom = statusBar!!.paddingBottom
if (isCompatibilityMode) {
val customLeftMargin = XSPUtils.getInt("status_bar_left_margin", 0)
if (customLeftMargin != 0) {
statusBarLeft = customLeftMargin
}
val customRightMargin = XSPUtils.getInt("status_bar_right_margin", 0)
if (customRightMargin != 0) {
statusBarRight = customRightMargin
}
updateLayout(context, 1)
}
}
}
}
//兼容模式
"com.android.systemui.statusbar.phone.PhoneStatusBarView".hook {
injectMember {
method {
name = "updateLayoutForCutout"
}
afterHook {
if (isCompatibilityMode) {
val context = instance<ViewGroup>().context
updateLayout(context, 1)
}
}
}
}
}
//时钟居中
1 -> {
"com.android.systemui.statusbar.phone.fragment.CollapsedStatusBarFragment".hook {
injectMember {
method {
name = "onViewCreated"
paramCount = 2
}
afterHook {
val miuiPhoneStatusBarView = args(0).cast<ViewGroup>()!!
val context: Context = miuiPhoneStatusBarView.context
val res: Resources = miuiPhoneStatusBarView.resources
val statusBarId: Int = res.getIdentifier("status_bar", "id", "com.android.systemui")
val statusBarContentsId: Int = res.getIdentifier(
"status_bar_contents", "id", "com.android.systemui"
)
val systemIconAreaId: Int = res.getIdentifier("system_icon_area", "id", "com.android.systemui")
val clockId: Int = res.getIdentifier("clock", "id", "com.android.systemui")
val phoneStatusBarLeftContainerId: Int = res.getIdentifier(
"phone_status_bar_left_container", "id", "com.android.systemui"
)
val notificationIconAreaInnerId: Int = res.getIdentifier(
"notification_icon_area_inner", "id", "com.android.systemui"
)
statusBar = miuiPhoneStatusBarView.findViewById(statusBarId)
val statusBarContents: ViewGroup = miuiPhoneStatusBarView.findViewById(statusBarContentsId)
if (statusBar == null) return@afterHook
val clock: TextView = miuiPhoneStatusBarView.findViewById(clockId)
val phoneStatusBarLeftContainer: ViewGroup = miuiPhoneStatusBarView.findViewById(
phoneStatusBarLeftContainerId
)
val notificationIconAreaInner: ViewGroup = miuiPhoneStatusBarView.findViewById(
notificationIconAreaInnerId
)
val systemIconArea: ViewGroup = miuiPhoneStatusBarView.findViewById(systemIconAreaId)
(clock.parent as ViewGroup).removeView(clock)
(phoneStatusBarLeftContainer.parent as ViewGroup).removeView(
phoneStatusBarLeftContainer
)
(notificationIconAreaInner.parent as ViewGroup).removeView(
notificationIconAreaInner
)
(systemIconArea.parent as ViewGroup).removeView(systemIconArea)
val mConstraintLayout = ConstraintLayout(context).also {
it.layoutParams = ConstraintLayout.LayoutParams(
ConstraintLayout.LayoutParams.MATCH_PARENT, ConstraintLayout.LayoutParams.MATCH_PARENT
)
}
mConstraintLayout.addView(notificationIconAreaInner)
val fullscreenNotificationIconAreaLp = LinearLayout.LayoutParams(
ConstraintLayout.LayoutParams.MATCH_PARENT, ConstraintLayout.LayoutParams.MATCH_PARENT
)
notificationIconAreaInner.layoutParams = fullscreenNotificationIconAreaLp
//增加一个左对齐布局
mLeftLayout = LinearLayout(context)
val leftLp: LinearLayout.LayoutParams = LinearLayout.LayoutParams(
0, LinearLayout.LayoutParams.MATCH_PARENT, 1.0f
)
mLeftLayout!!.layoutParams = leftLp
mLeftLayout!!.gravity = Gravity.START or Gravity.CENTER_VERTICAL
//增加一个居中布局
mCenterLayout = LinearLayout(context)
val centerLp: LinearLayout.LayoutParams = LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT
)
mCenterLayout!!.layoutParams = centerLp
mCenterLayout!!.gravity = Gravity.CENTER or Gravity.CENTER_VERTICAL
mRightLayout = LinearLayout(context)
val rightLp: LinearLayout.LayoutParams = LinearLayout.LayoutParams(
0, LinearLayout.LayoutParams.MATCH_PARENT, 1.0f
)
mRightLayout!!.layoutParams = rightLp
mRightLayout!!.gravity = Gravity.END or Gravity.CENTER_VERTICAL
mLeftLayout!!.addView(phoneStatusBarLeftContainer)
mLeftLayout!!.addView(mConstraintLayout)
mCenterLayout!!.addView(clock)
mRightLayout!!.addView(systemIconArea)
statusBarContents.addView(mLeftLayout, 0)
statusBarContents.addView(mCenterLayout)
statusBarContents.addView(mRightLayout)
statusBarLeft = statusBar!!.paddingLeft
statusBarTop = statusBar!!.paddingTop
statusBarRight = statusBar!!.paddingRight
statusBarBottom = statusBar!!.paddingBottom
if (isCompatibilityMode) {
val customLeftMargin = XSPUtils.getInt("status_bar_left_margin", 0)
if (customLeftMargin != 0) {
statusBarLeft = customLeftMargin
}
val customRightMargin = XSPUtils.getInt("status_bar_right_margin", 0)
if (customRightMargin != 0) {
statusBarRight = customRightMargin
}
updateLayout(context, 2)
}
}
}
}
//兼容模式
"com.android.systemui.statusbar.phone.PhoneStatusBarView".hook {
injectMember {
method {
name = "updateLayoutForCutout"
}
afterHook {
hasEnable("layout_compatibility_mode") {
val context = instance<ViewGroup>().context
updateLayout(context, 2)
}
}
}
}
}
//时钟居右
2 -> {
"com.android.systemui.statusbar.phone.fragment.CollapsedStatusBarFragment".hook {
injectMember {
method {
name = "onViewCreated"
paramCount = 2
}
afterHook {
val miuiPhoneStatusBarView = args(0).cast<ViewGroup>()!!
val context: Context = miuiPhoneStatusBarView.context
val res: Resources = miuiPhoneStatusBarView.resources
//组件ID
val statusBarId: Int = res.getIdentifier("status_bar", "id", "com.android.systemui")
val clockId: Int = res.getIdentifier("clock", "id", "com.android.systemui")
val batteryId: Int = res.getIdentifier("battery", "id", "com.android.systemui")
//查找组件
statusBar = miuiPhoneStatusBarView.findViewById(statusBarId)
if (statusBar == null) return@afterHook
val clock: TextView = miuiPhoneStatusBarView.findViewById(clockId)
val battery: ViewGroup = miuiPhoneStatusBarView.findViewById(batteryId)
//新建布局
val rightLp = LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT
).also {
it.marginStart = dp2px(context, 5f)
}
mRightLayout = LinearLayout(context).also {
it.layoutParams = rightLp
}
//添加布局与组件
battery.addView(mRightLayout)
(clock.parent as ViewGroup).removeView(clock)
mRightLayout!!.addView(clock)
statusBarLeft = statusBar!!.paddingLeft
statusBarTop = statusBar!!.paddingTop
statusBarRight = statusBar!!.paddingRight
statusBarBottom = statusBar!!.paddingBottom
if (isCompatibilityMode) {
val customLeftMargin = XSPUtils.getInt("status_bar_left_margin", 0)
if (customLeftMargin != 0) {
statusBarLeft = customLeftMargin
}
val customRightMargin = XSPUtils.getInt("status_bar_right_margin", 0)
if (customRightMargin != 0) {
statusBarRight = customRightMargin
}
updateLayout(context, 1)
}
}
}
}
//兼容模式
"com.android.systemui.statusbar.phone.PhoneStatusBarView".hook {
injectMember {
method {
name = "updateLayoutForCutout"
}
afterHook {
if (isCompatibilityMode) {
val context = instance<ViewGroup>().context
updateLayout(context, 1)
}
}
}
}
}
//时钟居中+图标居左
3 -> {
"com.android.systemui.statusbar.phone.fragment.CollapsedStatusBarFragment".hook {
injectMember {
method {
name = "onViewCreated"
paramCount = 2
}
afterHook {
val miuiPhoneStatusBarView = args(0).cast<ViewGroup>()!!
val context: Context = miuiPhoneStatusBarView.context
val res: Resources = miuiPhoneStatusBarView.resources
val statusBarId: Int = res.getIdentifier("status_bar", "id", "com.android.systemui")
val statusBarContentsId: Int = res.getIdentifier(
"status_bar_contents", "id", "com.android.systemui"
)
val systemIconAreaId: Int = res.getIdentifier("system_icon_area", "id", "com.android.systemui")
val clockId: Int = res.getIdentifier("clock", "id", "com.android.systemui")
val phoneStatusBarLeftContainerId: Int = res.getIdentifier(
"phone_status_bar_left_container", "id", "com.android.systemui"
)
val fullscreenNotificationIconAreaId: Int = res.getIdentifier(
"fullscreen_notification_icon_area", "id", "com.android.systemui"
)
val statusIconsId: Int = res.getIdentifier(
"statusIcons", "id", "com.android.systemui"
)
val systemIconsId: Int = res.getIdentifier(
"system_icons", "id", "com.android.systemui"
)
val batteryId: Int = res.getIdentifier(
"battery", "id", "com.android.systemui"
)
statusBar = miuiPhoneStatusBarView.findViewById(statusBarId)
val statusBarContents: ViewGroup = miuiPhoneStatusBarView.findViewById(statusBarContentsId)
if (statusBar == null) return@afterHook
val clock: TextView = miuiPhoneStatusBarView.findViewById(clockId)
val phoneStatusBarLeftContainer: ViewGroup = miuiPhoneStatusBarView.findViewById(
phoneStatusBarLeftContainerId
)
val fullscreenNotificationIconArea: ViewGroup = miuiPhoneStatusBarView.findViewById(
fullscreenNotificationIconAreaId
)
val systemIconArea: ViewGroup = miuiPhoneStatusBarView.findViewById(systemIconAreaId)
val statusIcons: ViewGroup = miuiPhoneStatusBarView.findViewById(statusIconsId)
val systemIcons: ViewGroup = miuiPhoneStatusBarView.findViewById(systemIconsId)
val battery: ViewGroup = miuiPhoneStatusBarView.findViewById(batteryId)
(clock.parent as ViewGroup).removeView(clock)
(phoneStatusBarLeftContainer.parent as ViewGroup).removeView(
phoneStatusBarLeftContainer
)
(systemIconArea.parent as ViewGroup).removeView(systemIconArea)
(statusIcons.parent as ViewGroup).removeView(statusIcons)
(systemIcons.parent as ViewGroup).removeView(systemIcons)
(battery.parent as ViewGroup).removeView(battery)
(fullscreenNotificationIconArea.parent as ViewGroup).removeView(
fullscreenNotificationIconArea
)
val mConstraintLayout = ConstraintLayout(context).also {
it.layoutParams = ConstraintLayout.LayoutParams(
ConstraintLayout.LayoutParams.MATCH_PARENT, ConstraintLayout.LayoutParams.MATCH_PARENT
)
}
mConstraintLayout.addView(fullscreenNotificationIconArea)
mConstraintLayout.addView(battery)
battery.layoutParams = ConstraintLayout.LayoutParams(
ConstraintLayout.LayoutParams.WRAP_CONTENT, ConstraintLayout.LayoutParams.MATCH_PARENT
).also {
it.endToEnd = 0
}
fullscreenNotificationIconArea.layoutParams = ConstraintLayout.LayoutParams(
0, ConstraintLayout.LayoutParams.MATCH_PARENT
).also {
it.startToEnd = batteryId
it.endToEnd = 0
}
fullscreenNotificationIconArea.layoutDirection = View.LAYOUT_DIRECTION_RTL
//增加一个左对齐布局
mLeftLayout = LinearLayout(context)
val leftLp: LinearLayout.LayoutParams = LinearLayout.LayoutParams(
0, LinearLayout.LayoutParams.MATCH_PARENT, 1.0f
)
mLeftLayout!!.layoutParams = leftLp
mLeftLayout!!.gravity = Gravity.START or Gravity.CENTER_VERTICAL
//增加一个居中布局
mCenterLayout = LinearLayout(context)
val centerLp: LinearLayout.LayoutParams = LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT
)
mCenterLayout!!.layoutParams = centerLp
mCenterLayout!!.gravity = Gravity.CENTER or Gravity.CENTER_VERTICAL
//增加一个右布局
mRightLayout = LinearLayout(context)
val rightLp: LinearLayout.LayoutParams = LinearLayout.LayoutParams(
0, LinearLayout.LayoutParams.MATCH_PARENT, 1.0f
)
mRightLayout!!.layoutParams = rightLp
mRightLayout!!.gravity = Gravity.END or Gravity.CENTER_VERTICAL
mLeftLayout!!.addView(phoneStatusBarLeftContainer)
mLeftLayout!!.addView(statusIcons)
statusIcons.layoutDirection = View.LAYOUT_DIRECTION_RTL
mCenterLayout!!.addView(clock)
mRightLayout!!.addView(mConstraintLayout)
fullscreenNotificationIconArea.layoutDirection = View.LAYOUT_DIRECTION_RTL
statusBarContents.addView(mLeftLayout, 0)
statusBarContents.addView(mCenterLayout)
statusBarContents.addView(mRightLayout)
statusBarLeft = statusBar!!.paddingLeft
statusBarTop = statusBar!!.paddingTop
statusBarRight = statusBar!!.paddingRight
statusBarBottom = statusBar!!.paddingBottom
if (isCompatibilityMode) {
val customLeftMargin = XSPUtils.getInt("status_bar_left_margin", 0)
if (customLeftMargin != 0) {
statusBarLeft = customLeftMargin
}
val customRightMargin = XSPUtils.getInt("status_bar_right_margin", 0)
if (customRightMargin != 0) {
statusBarRight = customRightMargin
}
updateLayout(context, 2)
}
}
}
}
//兼容模式
"com.android.systemui.statusbar.phone.PhoneStatusBarView".hook {
injectMember {
method {
name = "updateLayoutForCutout"
}
afterHook {
if (isCompatibilityMode) {
val context = instance<ViewGroup>().context
updateLayout(context, 2)
}
}
}
}
//解决重叠
"com.android.systemui.statusbar.phone.MiuiCollapsedStatusBarFragment".hook {
injectMember {
method {
name = "showClock"
param { it[0] == Boolean::class.java }
}
afterHook {
val miuiPhoneStatusBarView = instance.current().field {
name = "mStatusBar"
superClass(true)
}.cast<ViewGroup>()!!
val res = miuiPhoneStatusBarView.resources
val statusBarId = res.getIdentifier("status_bar", "id", "com.android.systemui")
val statusBar1 = miuiPhoneStatusBarView.findViewById<ViewGroup>(statusBarId)
//非锁屏下整个状态栏布局
val keyguardMgr = statusBar1.context.getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager
if (keyguardMgr.isKeyguardLocked) {
statusBar1!!.visibility = View.GONE
} else {
statusBar1!!.visibility = View.VISIBLE
}
}
}
}
}
}
}
}

View File

@@ -13,7 +13,7 @@ object StatusBarNetworkSpeedRefreshSpeedForT : YukiBaseHooker() {
} }
beforeHook { beforeHook {
hasEnable("status_bar_network_speed_refresh_speed") { hasEnable("status_bar_network_speed_refresh_speed") {
this.args[0] = 1000L args[0] = 1000L
} }
} }
} }

View File

@@ -55,7 +55,7 @@ object StatusBarTimeCustomizationForT : YukiBaseHooker() {
} }
afterHook { afterHook {
try { try {
c = this.args[0] as Context c = args[0] as Context
val textV = instance<TextView>() val textV = instance<TextView>()
if (textV.resources.getResourceEntryName(textV.id) != "clock") return@afterHook if (textV.resources.getResourceEntryName(textV.id) != "clock") return@afterHook
textV.isSingleLine = false textV.isSingleLine = false
@@ -94,7 +94,7 @@ object StatusBarTimeCustomizationForT : YukiBaseHooker() {
if (isCenterAlign) { if (isCenterAlign) {
try { try {
if (textV.resources.getResourceEntryName(textV.id) == "clock") { if (textV.resources.getResourceEntryName(textV.id) == "clock") {
c = this.args[0] as Context c = args[0] as Context
textV.gravity = Gravity.CENTER textV.gravity = Gravity.CENTER
} }
} catch (_: Exception) { } catch (_: Exception) {
@@ -131,7 +131,7 @@ object StatusBarTimeCustomizationForT : YukiBaseHooker() {
constructor { paramCount = 3 } constructor { paramCount = 3 }
afterHook { afterHook {
try { try {
c = this.args[0] as Context c = args[0] as Context
val textV = instance<TextView>() val textV = instance<TextView>()
if (textV.resources.getResourceEntryName(textV.id) != "clock") return@afterHook if (textV.resources.getResourceEntryName(textV.id) != "clock") return@afterHook
textV.isSingleLine = false textV.isSingleLine = false
@@ -159,7 +159,7 @@ object StatusBarTimeCustomizationForT : YukiBaseHooker() {
if (isGeekCenterAlign) { if (isGeekCenterAlign) {
try { try {
if (textV.resources.getResourceEntryName(textV.id) == "clock") { if (textV.resources.getResourceEntryName(textV.id) == "clock") {
c = this.args[0] as Context c = args[0] as Context
textV.gravity = Gravity.CENTER textV.gravity = Gravity.CENTER
} }
} catch (_: Exception) { } catch (_: Exception) {

View File

@@ -1,6 +1,6 @@
plugins { plugins {
id 'com.android.application' version '7.4.1' apply false id 'com.android.application' version '7.4.2' apply false
id 'com.android.library' version '7.4.1' apply false id 'com.android.library' version '7.4.2' apply false
id 'org.jetbrains.kotlin.android' version '1.8.10' apply false id 'org.jetbrains.kotlin.android' version '1.8.10' apply false
} }