mirror of
https://github.com/LittleTurtle2333/SimplicityTools.git
synced 2026-07-13 03:41:19 +08:00
新增时钟居中+图标居左(未完成)
This commit is contained in:
@@ -508,10 +508,12 @@ class SettingsActivity : MIUIActivity() {
|
||||
)
|
||||
add(LineV())
|
||||
add(TitleTextV(resId = R.string.status_bar_layout))
|
||||
val statusBarLayoutMode: HashMap<Int, String> = hashMapOf()
|
||||
statusBarLayoutMode[0] = getString(R.string.default1)
|
||||
statusBarLayoutMode[1] = getString(R.string.clock_center)
|
||||
statusBarLayoutMode[2] = getString(R.string.clock_right)
|
||||
val statusBarLayoutMode: HashMap<Int, String> = hashMapOf<Int, String>().also {
|
||||
it[0] = getString(R.string.default1)
|
||||
it[1] = getString(R.string.clock_center)
|
||||
it[2] = getString(R.string.clock_right)
|
||||
it[3] = getString(R.string.clock_center_and_icon_left)
|
||||
}
|
||||
add(
|
||||
TextWithSpinnerV(
|
||||
TextV(resId = R.string.status_bar_layout_mode),
|
||||
@@ -544,6 +546,15 @@ class SettingsActivity : MIUIActivity() {
|
||||
apply()
|
||||
}
|
||||
})
|
||||
add(MIUIPopupData(statusBarLayoutMode[3].toString()) {
|
||||
OwnSP.ownSP.edit().run {
|
||||
putInt(
|
||||
"status_bar_layout_mode",
|
||||
3
|
||||
)
|
||||
apply()
|
||||
}
|
||||
})
|
||||
}, currentValue = statusBarLayoutMode[OwnSP.ownSP.getInt(
|
||||
"status_bar_layout_mode",
|
||||
0
|
||||
|
||||
@@ -8,7 +8,6 @@ import android.os.Bundle
|
||||
import android.view.Gravity
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
@@ -18,6 +17,8 @@ import com.lt2333.simplicitytools.util.findClass
|
||||
import com.lt2333.simplicitytools.util.getObjectField
|
||||
import com.lt2333.simplicitytools.util.hookAfterMethod
|
||||
import com.lt2333.simplicitytools.util.xposed.base.HookRegister
|
||||
import de.robv.android.xposed.XposedHelpers
|
||||
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
object StatusBarLayout : HookRegister() {
|
||||
@@ -33,9 +34,7 @@ object StatusBarLayout : HookRegister() {
|
||||
private var statusBarBottom = 0
|
||||
|
||||
override fun init() {
|
||||
val mode = XSPUtils.getInt("status_bar_layout_mode", 0)
|
||||
|
||||
when (mode) {
|
||||
when (XSPUtils.getInt("status_bar_layout_mode", 0)) {
|
||||
//默认
|
||||
0 -> return
|
||||
//时钟居中
|
||||
@@ -159,19 +158,6 @@ object StatusBarLayout : HookRegister() {
|
||||
updateLayout(context)
|
||||
}
|
||||
}
|
||||
val miuiPhoneStatusBarViewClass =
|
||||
"com.android.systemui.statusbar.phone.MiuiPhoneStatusBarView".findClass(
|
||||
getDefaultClassLoader()
|
||||
)
|
||||
|
||||
miuiPhoneStatusBarViewClass.hookAfterMethod("updateNotificationIconAreaInnnerParent") {
|
||||
val viewGroup = it.thisObject as ViewGroup
|
||||
val fullscreen_notification_icon_area_lp = FrameLayout.LayoutParams(
|
||||
ConstraintLayout.LayoutParams.MATCH_PARENT,
|
||||
ConstraintLayout.LayoutParams.MATCH_PARENT
|
||||
)
|
||||
viewGroup.layoutParams = fullscreen_notification_icon_area_lp
|
||||
}
|
||||
val phoneStatusBarViewClass =
|
||||
"com.android.systemui.statusbar.phone.PhoneStatusBarView".findClass(
|
||||
getDefaultClassLoader()
|
||||
@@ -201,24 +187,39 @@ object StatusBarLayout : HookRegister() {
|
||||
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@hookAfterMethod
|
||||
val clock: TextView = MiuiPhoneStatusBarView.findViewById(clockId)
|
||||
val battery: ViewGroup = MiuiPhoneStatusBarView.findViewById(batteryId)
|
||||
|
||||
(clock.parent as ViewGroup).removeView(clock)
|
||||
battery!!.addView(clock)
|
||||
clock.setPadding(dp2px(context,5f),0,0,0)
|
||||
}
|
||||
}
|
||||
//新建布局
|
||||
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)
|
||||
}
|
||||
}
|
||||
//时钟居中+图标居左
|
||||
3 -> {}
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateLayout(context: Context) {
|
||||
//判断屏幕方向
|
||||
|
||||
@@ -197,4 +197,5 @@
|
||||
<string name="clock_center">Clock Center</string>
|
||||
<string name="clock_right">Clock Right</string>
|
||||
<string name="status_bar_layout_mode">Status bar layout mode</string>
|
||||
<string name="clock_center_and_icon_left">Clock Center and Icon Left</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user