修复挖孔屏居中,向顺时针旋转90°,横屏显示溢出的问题

This commit is contained in:
乌堆小透明
2022-03-10 13:50:21 +08:00
parent e2adf4e934
commit b64f670798

View File

@@ -1,6 +1,7 @@
package com.lt2333.simplicitytools.hook.app.systemui package com.lt2333.simplicitytools.hook.app.systemui
import android.content.Context import android.content.Context
import android.content.res.Configuration
import android.content.res.Resources import android.content.res.Resources
import android.os.Bundle import android.os.Bundle
import android.view.Gravity import android.view.Gravity
@@ -165,7 +166,7 @@ class StatusBarLayout : IXposedHookLoadPackage {
if (custom_right_margin != 0) { if (custom_right_margin != 0) {
status_bar_right = custom_right_margin status_bar_right = custom_right_margin
} }
updateLayout() updateLayout(context)
} }
} }
@@ -182,7 +183,8 @@ class StatusBarLayout : IXposedHookLoadPackage {
object : XC_MethodHook() { object : XC_MethodHook() {
override fun afterHookedMethod(param: MethodHookParam) { override fun afterHookedMethod(param: MethodHookParam) {
if (XSPUtils.getBoolean("layout_compatibility_mode", false)) { if (XSPUtils.getBoolean("layout_compatibility_mode", false)) {
updateLayout() val context = (param.thisObject as ViewGroup).context
updateLayout(context)
} }
} }
} }
@@ -190,10 +192,19 @@ class StatusBarLayout : IXposedHookLoadPackage {
} }
fun updateLayout() { fun updateLayout(context: Context) {
mLeftLayout!!.setPadding(status_bar_left, 0, 0, 0) //判断屏幕方向
mRightLayout!!.setPadding(0, 0, status_bar_right, 0) val mConfiguration: Configuration = context.resources.configuration
status_bar!!.setPadding(0, status_bar_top, 0, status_bar_bottom) if (mConfiguration.orientation == Configuration.ORIENTATION_PORTRAIT) {
mLeftLayout!!.setPadding(status_bar_left, 0, 0, 0)
mRightLayout!!.setPadding(0, 0, status_bar_right, 0)
status_bar!!.setPadding(0, status_bar_top, 0, status_bar_bottom)
} else {
//横屏状态
mLeftLayout!!.setPadding(175, 0, 0, 0)
mRightLayout!!.setPadding(0, 0, 175, 0)
status_bar!!.setPadding(0, status_bar_top, 0, status_bar_bottom)
}
} }
} }