修复A12状态栏布局兼容模式的一些BUG

This commit is contained in:
LittleTurtle2333
2023-02-19 23:03:29 +08:00
parent 7f23f07209
commit 12848808d3
2 changed files with 208 additions and 195 deletions

View File

@ -12,10 +12,9 @@ import cn.fkj233.ui.activity.view.TextSummaryV
import cn.fkj233.ui.activity.view.TextV
import cn.fkj233.ui.dialog.MIUIDialog
import com.lt2333.simplicitytools.R
import java.util.HashMap
@BMPage("scope_systemui","System UI", hideMenu = false)
@BMPage("scope_systemui", "System UI", hideMenu = false)
class SystemUIPageForS : BasePage() {
override fun onCreate() {
@ -54,11 +53,10 @@ class SystemUIPageForS : BasePage() {
}
})
val layoutCompatibilityModeBinding = GetDataBinding({
MIUIActivity.safeSP.getInt(
"screen_hole_location",
0
) == 2
val layoutCompatibilityBinding = GetDataBinding({
MIUIActivity.safeSP.getBoolean(
"layout_compatibility_mode", false
)
}) { view, flags, data ->
when (flags) {
1 -> (view as Switch).isEnabled = data as Boolean
@ -66,57 +64,23 @@ class SystemUIPageForS : BasePage() {
}
}
val screenHoleLocation: HashMap<Int, String> = hashMapOf<Int, String>().also {
it[0] = getString(R.string.off)
it[1] = getString(R.string.center)
it[2] = getString(R.string.left_or_right)
}
TextSummaryWithSpinner(
TextSummaryWithSwitch(
TextSummaryV(
textId = R.string.layout_compatibility_mode,
tipsId = R.string.screen_hole_location
),
SpinnerV(
screenHoleLocation[MIUIActivity.safeSP.getInt(
"screen_hole_location",
0
)].toString()
) {
add(screenHoleLocation[0].toString()) {
MIUIActivity.safeSP.putAny("screen_hole_location", 0)
layoutCompatibilityModeBinding.binding.Send().send(false)
}
add(screenHoleLocation[1].toString()) {
MIUIActivity.safeSP.putAny("screen_hole_location", 1)
layoutCompatibilityModeBinding.binding.Send().send(false)
}
add(screenHoleLocation[2].toString()) {
MIUIActivity.safeSP.putAny("screen_hole_location", 2)
layoutCompatibilityModeBinding.binding.Send().send(true)
}
})
textId = R.string.layout_compatibility_mode, tipsId = R.string.layout_compatibility_mode_summary
), SwitchV("layout_compatibility_mode", dataBindingSend = layoutCompatibilityBinding.bindingSend)
)
Text(
textId = R.string.left_margin,
dataBindingRecv = layoutCompatibilityModeBinding.binding.getRecv(2)
textId = R.string.left_margin, dataBindingRecv = layoutCompatibilityBinding.binding.getRecv(2)
)
SeekBarWithText(
"status_bar_left_margin",
0,
300,
0,
dataBindingRecv = layoutCompatibilityModeBinding.binding.getRecv(2)
"status_bar_left_margin", 0, 300, 0, dataBindingRecv = layoutCompatibilityBinding.binding.getRecv(2)
)
Text(
textId = R.string.right_margin,
dataBindingRecv = layoutCompatibilityModeBinding.binding.getRecv(2)
textId = R.string.right_margin, dataBindingRecv = layoutCompatibilityBinding.binding.getRecv(2)
)
SeekBarWithText(
"status_bar_right_margin",
0,
300,
0,
dataBindingRecv = layoutCompatibilityModeBinding.binding.getRecv(2)
"status_bar_right_margin", 0, 300, 0, dataBindingRecv = layoutCompatibilityBinding.binding.getRecv(2)
)
Line()
TitleText(textId = R.string.status_bar_clock_format)
@ -248,7 +212,11 @@ class SystemUIPageForS : BasePage() {
TextSummaryWithArrow(TextSummaryV(textId = R.string.custom_clock_format_geek) {
MIUIDialog(activity) {
setTitle(R.string.custom_clock_format_geek)
setEditText(MIUIActivity.safeSP.getString("custom_clock_format_geek", "HH:mm:ss"), "", isSingleLine = false)
setEditText(
MIUIActivity.safeSP.getString("custom_clock_format_geek", "HH:mm:ss"),
"",
isSingleLine = false
)
setLButton(textId = R.string.cancel) {
dismiss()
}

View File

@ -1,5 +1,6 @@
package com.lt2333.simplicitytools.hooks.rules.s.systemui
import android.app.KeyguardManager
import android.content.Context
import android.content.res.Configuration
@ -16,10 +17,11 @@ import com.lt2333.simplicitytools.utils.XSPUtils
import com.lt2333.simplicitytools.utils.hasEnable
import com.lt2333.simplicitytools.utils.xposed.base.HookRegister
object StatusBarLayoutForS : HookRegister() {
private val getMode = XSPUtils.getInt("status_bar_layout_mode", 0)
private val getHoleLocation = XSPUtils.getInt("screen_hole_location", 0)
private val isCompatibilityMode = XSPUtils.getBoolean("layout_compatibility_mode", false)
private var statusBarLeft = 0
private var statusBarTop = 0
@ -32,23 +34,31 @@ object StatusBarLayoutForS : HookRegister() {
var mCenterLayout: LinearLayout?
var statusBar: ViewGroup? = null
fun updateLayout(context: Context) {
//判断屏幕方向
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(175, 0, 0, 0)
mRightLayout!!.setPadding(0, 0, 175, 0)
statusBar!!.setPadding(0, statusBarTop, 0, statusBarBottom)
//判断屏幕状态更新布局 mode: 1正常布局 2居中布局
fun updateLayout(context: Context,mode: Int) {
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)
}
}
}
}
//判断是否开启居中挖孔兼容模式
if (getHoleLocation == 1) {
//判断是否开启挖孔兼容模式
if (isCompatibilityMode) {
findMethod("com.android.systemui.ScreenDecorations\$DisplayCutoutView") {
name == "boundsFromDirection" && parameterCount == 3 && isStatic
}.hookBefore {
@ -56,48 +66,83 @@ object StatusBarLayoutForS : HookRegister() {
}
}
//修改对应布局
when (getMode) {
//默认
0 -> return
0 -> {
findMethod("com.android.systemui.statusbar.phone.CollapsedStatusBarFragment") {
name == "onViewCreated" && parameterCount == 2
}.hookAfter { param ->
val miuiPhoneStatusBarView = param.thisObject.getObjectAs<ViewGroup>("mStatusBar")
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@hookAfter
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)
}
}
//兼容模式
findMethod("com.android.systemui.statusbar.phone.PhoneStatusBarView") {
name == "updateLayoutForCutout"
}.hookAfter {
if (isCompatibilityMode) {
val context = (it.thisObject as ViewGroup).context
updateLayout(context,1)
}
}
}
//时钟居中
1 -> {
findMethod("com.android.systemui.statusbar.phone.CollapsedStatusBarFragment") {
name == "onViewCreated" && parameterCount == 2
}.hookAfter { param ->
val miuiPhoneStatusBarView =
param.thisObject.getObjectAs<ViewGroup>("mStatusBar")
val miuiPhoneStatusBarView = param.thisObject.getObjectAs<ViewGroup>("mStatusBar")
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 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"
)
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)
val statusBarContents: ViewGroup = miuiPhoneStatusBarView.findViewById(statusBarContentsId)
if (statusBar == null) return@hookAfter
val clock: TextView = miuiPhoneStatusBarView.findViewById(clockId)
val phoneStatusBarLeftContainer: ViewGroup =
miuiPhoneStatusBarView.findViewById(phoneStatusBarLeftContainerId)
val notificationIconAreaInner: ViewGroup =
miuiPhoneStatusBarView.findViewById(notificationIconAreaInnerId)
val systemIconArea: ViewGroup =
miuiPhoneStatusBarView.findViewById(systemIconAreaId)
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(
@ -108,41 +153,39 @@ object StatusBarLayoutForS : HookRegister() {
)
(systemIconArea.parent as ViewGroup).removeView(systemIconArea)
val mConstraintLayout =
ConstraintLayout(context).also {
it.layoutParams = ConstraintLayout.LayoutParams(
ConstraintLayout.LayoutParams.MATCH_PARENT,
ConstraintLayout.LayoutParams.MATCH_PARENT
)
}
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
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)
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
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)
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)
@ -160,7 +203,7 @@ object StatusBarLayoutForS : HookRegister() {
statusBarBottom = statusBar!!.paddingBottom
if (getHoleLocation == 2) {
if (isCompatibilityMode) {
val customLeftMargin = XSPUtils.getInt("status_bar_left_margin", 0)
if (customLeftMargin != 0) {
statusBarLeft = customLeftMargin
@ -170,7 +213,7 @@ object StatusBarLayoutForS : HookRegister() {
if (customRightMargin != 0) {
statusBarRight = customRightMargin
}
updateLayout(context)
updateLayout(context,2)
}
}
@ -179,7 +222,7 @@ object StatusBarLayoutForS : HookRegister() {
}.hookAfter {
hasEnable("layout_compatibility_mode") {
val context = (it.thisObject as ViewGroup).context
updateLayout(context)
updateLayout(context,2)
}
}
}
@ -188,14 +231,12 @@ object StatusBarLayoutForS : HookRegister() {
findMethod("com.android.systemui.statusbar.phone.CollapsedStatusBarFragment") {
name == "onViewCreated" && parameterCount == 2
}.hookAfter { param ->
val miuiPhoneStatusBarView =
param.thisObject.getObjectAs<ViewGroup>("mStatusBar")
val miuiPhoneStatusBarView = param.thisObject.getObjectAs<ViewGroup>("mStatusBar")
val context: Context = miuiPhoneStatusBarView.context
val res: Resources = miuiPhoneStatusBarView.resources
//组件ID
val statusBarId: Int =
res.getIdentifier("status_bar", "id", "com.android.systemui")
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")
@ -207,8 +248,7 @@ object StatusBarLayoutForS : HookRegister() {
//新建布局
val rightLp = LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.MATCH_PARENT
LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT
).also {
it.marginStart = dp2px(context, 5f)
}
@ -220,6 +260,36 @@ object StatusBarLayoutForS : HookRegister() {
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)
}
}
//兼容模式
findMethod("com.android.systemui.statusbar.phone.PhoneStatusBarView") {
name == "updateLayoutForCutout"
}.hookAfter {
if (isCompatibilityMode) {
val context = (it.thisObject as ViewGroup).context
updateLayout(context,1)
}
}
}
//时钟居中+图标居左
@ -227,65 +297,45 @@ object StatusBarLayoutForS : HookRegister() {
findMethod("com.android.systemui.statusbar.phone.CollapsedStatusBarFragment") {
name == "onViewCreated" && parameterCount == 2
}.hookAfter { param ->
val miuiPhoneStatusBarView =
param.thisObject.getObjectAs<ViewGroup>("mStatusBar")
val miuiPhoneStatusBarView = param.thisObject.getObjectAs<ViewGroup>("mStatusBar")
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 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"
)
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)
val statusBarContents: ViewGroup = miuiPhoneStatusBarView.findViewById(statusBarContentsId)
if (statusBar == null) return@hookAfter
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)
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(
@ -299,29 +349,25 @@ object StatusBarLayoutForS : HookRegister() {
fullscreenNotificationIconArea
)
val mConstraintLayout =
ConstraintLayout(context).also {
it.layoutParams = ConstraintLayout.LayoutParams(
ConstraintLayout.LayoutParams.MATCH_PARENT,
ConstraintLayout.LayoutParams.MATCH_PARENT
)
}
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
ConstraintLayout.LayoutParams.WRAP_CONTENT, ConstraintLayout.LayoutParams.MATCH_PARENT
).also {
it.endToEnd = 0
}
fullscreenNotificationIconArea.layoutParams = ConstraintLayout.LayoutParams(
0,
ConstraintLayout.LayoutParams.MATCH_PARENT
0, ConstraintLayout.LayoutParams.MATCH_PARENT
).also {
it.startToEnd = batteryId
it.endToEnd = 0
@ -331,24 +377,25 @@ object StatusBarLayoutForS : HookRegister() {
//增加一个左对齐布局
mLeftLayout = LinearLayout(context)
val leftLp: LinearLayout.LayoutParams =
LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT, 1.0f)
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
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)
val rightLp: LinearLayout.LayoutParams = LinearLayout.LayoutParams(
0, LinearLayout.LayoutParams.MATCH_PARENT, 1.0f
)
mRightLayout!!.layoutParams = rightLp
mRightLayout!!.gravity = Gravity.END or Gravity.CENTER_VERTICAL
@ -375,7 +422,7 @@ object StatusBarLayoutForS : HookRegister() {
statusBarBottom = statusBar!!.paddingBottom
if (getHoleLocation == 2) {
if (isCompatibilityMode) {
val customLeftMargin = XSPUtils.getInt("status_bar_left_margin", 0)
if (customLeftMargin != 0) {
statusBarLeft = customLeftMargin
@ -385,16 +432,16 @@ object StatusBarLayoutForS : HookRegister() {
if (customRightMargin != 0) {
statusBarRight = customRightMargin
}
updateLayout(context)
updateLayout(context,2)
}
}
//兼容模式
findMethod("com.android.systemui.statusbar.phone.PhoneStatusBarView") {
name == "updateLayoutForCutout"
}.hookAfter {
if (getHoleLocation == 2) {
if (isCompatibilityMode) {
val context = (it.thisObject as ViewGroup).context
updateLayout(context)
updateLayout(context,2)
}
}
@ -404,12 +451,10 @@ object StatusBarLayoutForS : HookRegister() {
}.hookAfter {
val miuiPhoneStatusBarView = it.thisObject.getObjectAs<ViewGroup>("mStatusBar")
val res = miuiPhoneStatusBarView.resources
val statusBarId =
res.getIdentifier("status_bar", "id", "com.android.systemui")
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
val keyguardMgr = statusBar1.context.getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager
if (keyguardMgr.isKeyguardLocked) {
statusBar1!!.visibility = View.GONE
} else {