新增旧版快速开关排列

This commit is contained in:
乌堆小透明
2022-03-18 17:45:55 +08:00
parent dfa47653f0
commit 9bd6aee5e9
4 changed files with 151 additions and 0 deletions

View File

@@ -853,6 +853,97 @@ class SettingsActivity : MIUIActivity() {
), SwitchV("lock_screen_double_tap_to_sleep")
)
)
add(LineV())
add(TitleTextV(resId = R.string.old_quick_settings_panel))
val old_qs_custom_switch_binding = getDataBinding(
SPUtils.getBoolean(
activity,
"old_qs_custom_switch",
false
)
) { view, flags, data ->
when (flags) {
1 -> (view as Switch).isEnabled = data as Boolean
2 -> view.visibility = if (data as Boolean) View.VISIBLE else View.GONE
}
}
add(
TextSummaryWithSwitchV(
TextSummaryV(
textId = R.string.old_qs_custom_switch,
colorId = R.color.purple_700
),
SwitchV(
"old_qs_custom_switch",
dataBindingSend = old_qs_custom_switch_binding.bindingSend
)
)
)
add(
TextV(
resId = R.string.qs_custom_rows,
dataBindingRecv = old_qs_custom_switch_binding.binding.getRecv(2)
)
)
add(
SeekBarWithTextV(
"qs_custom_rows",
1,
6,
3,
dataBindingRecv = old_qs_custom_switch_binding.binding.getRecv(2)
)
)
add(
TextV(
resId = R.string.qs_custom_rows_horizontal,
dataBindingRecv = old_qs_custom_switch_binding.binding.getRecv(2)
)
)
add(
SeekBarWithTextV(
"qs_custom_rows_horizontal",
1,
3,
2,
dataBindingRecv = old_qs_custom_switch_binding.binding.getRecv(2)
)
)
add(
TextV(
resId = R.string.qs_custom_columns,
dataBindingRecv = old_qs_custom_switch_binding.binding.getRecv(2)
)
)
add(
SeekBarWithTextV(
"qs_custom_columns",
1,
7,
4,
dataBindingRecv = old_qs_custom_switch_binding.binding.getRecv(2)
)
)
add(
TextV(
resId = R.string.qs_custom_columns_unexpanded,
dataBindingRecv = old_qs_custom_switch_binding.binding.getRecv(2)
)
)
add(
SeekBarWithTextV(
"qs_custom_columns_unexpanded",
1,
7,
5,
dataBindingRecv = old_qs_custom_switch_binding.binding.getRecv(2)
)
)
}
}

View File

@@ -54,6 +54,8 @@ class SystemUI : IXposedHookLoadPackage {
LockScreenDoubleTapToSleep().handleLoadPackage(lpparam)
//双击状态栏锁屏
StatusBarDoubleTapToSleep().handleLoadPackage(lpparam)
Test().handleLoadPackage(lpparam)
}
}

View File

@@ -0,0 +1,52 @@
package com.lt2333.simplicitytools.hook.app.systemui
import android.content.res.Configuration
import android.view.ViewGroup
import com.lt2333.simplicitytools.util.XSPUtils
import com.lt2333.simplicitytools.util.hasEnable
import com.lt2333.simplicitytools.util.hookAfterMethod
import com.lt2333.simplicitytools.util.hookBeforeMethod
import de.robv.android.xposed.IXposedHookLoadPackage
import de.robv.android.xposed.XposedHelpers
import de.robv.android.xposed.callbacks.XC_LoadPackage
class Test : IXposedHookLoadPackage {
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
hasEnable("old_qs_custom_switch") {
val mRows = XSPUtils.getInt("qs_custom_rows", 3)
val mRowsHorizontal = XSPUtils.getInt("qs_custom_rows_horizontal", 2)
val mColumns = XSPUtils.getInt("qs_custom_columns", 4)
val mColumnsUnexpanded = XSPUtils.getInt("qs_custom_columns_unexpanded", 5)
"com.android.systemui.qs.MiuiQuickQSPanel".hookBeforeMethod(
lpparam.classLoader,
"setMaxTiles", Int::class.java
) {
//未展开时的列数
it.args[0] = mColumnsUnexpanded
}
"com.android.systemui.qs.MiuiTileLayout".hookAfterMethod(
lpparam.classLoader,
"updateColumns"
) {
//展开时的列数
XposedHelpers.setObjectField(it.thisObject, "mColumns", mColumns)
}
"com.android.systemui.qs.MiuiTileLayout".hookAfterMethod(
lpparam.classLoader,
"updateResources"
) {
//展开时的行数
val viewGroup = it.thisObject as ViewGroup
val mConfiguration: Configuration = viewGroup.context.resources.configuration
if (mConfiguration.orientation == Configuration.ORIENTATION_PORTRAIT) {
XposedHelpers.setObjectField(viewGroup, "mMaxAllowedRows", mRows)
} else {
XposedHelpers.setObjectField(viewGroup, "mMaxAllowedRows", mRowsHorizontal)
}
viewGroup.requestLayout()
}
}
}
}

View File

@@ -165,4 +165,10 @@
<string name="hide_icon">Hide Icon</string>
<string name="double_tap_to_sleep">Double tap to sleep</string>
<string name="home_double_tap_to_sleep_summary">Double-tap the blank space to sleep</string>
<string name="old_quick_settings_panel">Old quick settings panel</string>
<string name="old_qs_custom_switch">Customize rows and columns</string>
<string name="qs_custom_columns_unexpanded">Columns (Unexpanded)</string>
<string name="qs_custom_rows">Rows</string>
<string name="qs_custom_columns">Columns</string>
<string name="qs_custom_rows_horizontal">Rows (horizontal)</string>
</resources>