mirror of
https://github.com/LittleTurtle2333/SimplicityTools.git
synced 2026-07-14 12:21:18 +08:00
统一A13状态栏兼容模式
This commit is contained in:
@@ -51,10 +51,10 @@ import com.lt2333.simplicitytools.R
|
||||
}
|
||||
})
|
||||
|
||||
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
|
||||
@@ -62,43 +62,23 @@ import com.lt2333.simplicitytools.R
|
||||
}
|
||||
}
|
||||
|
||||
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(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)
|
||||
}
|
||||
})
|
||||
TextSummaryWithSwitch(
|
||||
TextSummaryV(
|
||||
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)
|
||||
|
||||
@@ -19,7 +19,8 @@ import com.lt2333.simplicitytools.utils.xposed.base.HookRegister
|
||||
object StatusBarLayoutForT : 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
|
||||
@@ -51,7 +52,7 @@ object StatusBarLayoutForT : HookRegister() {
|
||||
}
|
||||
|
||||
//判断是否开启居中挖孔兼容模式
|
||||
if (getHoleLocation == 1) {
|
||||
if (isCompatibilityMode) {
|
||||
findMethod("com.android.systemui.ScreenDecorations") {
|
||||
name == "boundsFromDirection" && parameterCount == 3 && isStatic
|
||||
}.hookBefore {
|
||||
@@ -163,7 +164,7 @@ object StatusBarLayoutForT : HookRegister() {
|
||||
statusBarBottom = statusBar!!.paddingBottom
|
||||
|
||||
|
||||
if (getHoleLocation == 2) {
|
||||
if (isCompatibilityMode) {
|
||||
val customLeftMargin = XSPUtils.getInt("status_bar_left_margin", 0)
|
||||
if (customLeftMargin != 0) {
|
||||
statusBarLeft = customLeftMargin
|
||||
@@ -378,7 +379,7 @@ object StatusBarLayoutForT : HookRegister() {
|
||||
statusBarBottom = statusBar!!.paddingBottom
|
||||
|
||||
|
||||
if (getHoleLocation == 2) {
|
||||
if (isCompatibilityMode) {
|
||||
val customLeftMargin = XSPUtils.getInt("status_bar_left_margin", 0)
|
||||
if (customLeftMargin != 0) {
|
||||
statusBarLeft = customLeftMargin
|
||||
@@ -395,7 +396,7 @@ object StatusBarLayoutForT : HookRegister() {
|
||||
findMethod("com.android.systemui.statusbar.phone.PhoneStatusBarView") {
|
||||
name == "updateLayoutForCutout"
|
||||
}.hookAfter {
|
||||
if (getHoleLocation == 2) {
|
||||
if (isCompatibilityMode) {
|
||||
val context = (it.thisObject as ViewGroup).context
|
||||
updateLayout(context)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user