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