From 5e812da44a56d5f8964bddd40aacc4d717668d3a Mon Sep 17 00:00:00 2001 From: hosizoraru Date: Mon, 22 May 2023 07:48:35 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E4=B8=BB=E9=A2=98=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../voyager/activity/pages/SystemUIPage.kt | 69 +++++++++++++++++++ .../star/sky/voyager/hook/apps/SystemUI.kt | 2 + .../hooks/systemui/BlurLockScreenButton.kt | 60 ++++++++-------- .../voyager/hook/hooks/systemui/MonetTheme.kt | 29 ++++++++ app/src/main/res/values-zh-rCN/strings.xml | 4 ++ app/src/main/res/values/strings.xml | 3 + 6 files changed, 138 insertions(+), 29 deletions(-) create mode 100644 app/src/main/kotlin/star/sky/voyager/hook/hooks/systemui/MonetTheme.kt diff --git a/app/src/main/kotlin/star/sky/voyager/activity/pages/SystemUIPage.kt b/app/src/main/kotlin/star/sky/voyager/activity/pages/SystemUIPage.kt index 11bb4a94..94063879 100644 --- a/app/src/main/kotlin/star/sky/voyager/activity/pages/SystemUIPage.kt +++ b/app/src/main/kotlin/star/sky/voyager/activity/pages/SystemUIPage.kt @@ -16,6 +16,74 @@ import star.sky.voyager.R @BMPage("scope_system_ui", "System UI", hideMenu = false) class SystemUIPage : BasePage() { override fun onCreate() { + val monetBinding = GetDataBinding({ + MIUIActivity.safeSP.getBoolean( + "monet_theme", + false + ) + }) { view, flags, data -> + if (flags == 1) view.visibility = if (data as Boolean) View.VISIBLE else View.GONE + } + TextSummaryWithSwitch( + TextSummaryV( + textId = R.string.monet_theme, + ), SwitchV("monet_theme", false, dataBindingSend = monetBinding.bindingSend) + ) + TextSummaryWithArrow( + TextSummaryV( + textId = R.string.your_theme_accent_color, + onClickListener = { + MIUIDialog(activity) { + setTitle(R.string.your_theme_accent_color) + setEditText( + "", + "${activity.getString(R.string.current)}${ + MIUIActivity.safeSP.getString("your_theme_accent_color", "#0d84ff") + }" + ) + setLButton(textId = R.string.cancel) { + dismiss() + } + setRButton(textId = R.string.done) { + if (getEditText() != "") { + MIUIActivity.safeSP.putAny( + "your_theme_accent_color", + getEditText() + ) + } + dismiss() + } + }.show() + }), dataBindingRecv = monetBinding.binding.getRecv(1) + ) + TextSummaryWithArrow( + TextSummaryV( + textId = R.string.your_theme_neutral_color, + onClickListener = { + MIUIDialog(activity) { + setTitle(R.string.your_theme_neutral_color) + setEditText( + "", + "${activity.getString(R.string.current)}${ + MIUIActivity.safeSP.getString("your_theme_neutral_color", "#A6CDE7") + }" + ) + setLButton(textId = R.string.cancel) { + dismiss() + } + setRButton(textId = R.string.done) { + if (getEditText() != "") { + MIUIActivity.safeSP.putAny( + "your_theme_neutral_color", + getEditText() + ) + } + dismiss() + } + }.show() + }), dataBindingRecv = monetBinding.binding.getRecv(1) + ) + Line() TitleText(textId = R.string.status_bar) TextSummaryWithSwitch( TextSummaryV(textId = R.string.double_tap_to_sleep), @@ -712,6 +780,7 @@ class SystemUIPage : BasePage() { TextSummaryWithSwitch( TextSummaryV( textId = R.string.blur_lock_screen_button, + tipsId = R.string.only_official_default_themes_are_supported ), SwitchV("blur_lock_screen_button") ) TextSummaryWithSwitch( diff --git a/app/src/main/kotlin/star/sky/voyager/hook/apps/SystemUI.kt b/app/src/main/kotlin/star/sky/voyager/hook/apps/SystemUI.kt index 8170e9ff..e9c470f5 100644 --- a/app/src/main/kotlin/star/sky/voyager/hook/apps/SystemUI.kt +++ b/app/src/main/kotlin/star/sky/voyager/hook/apps/SystemUI.kt @@ -20,6 +20,7 @@ import star.sky.voyager.hook.hooks.systemui.LockScreenClockDisplaySeconds import star.sky.voyager.hook.hooks.systemui.LockScreenCurrent import star.sky.voyager.hook.hooks.systemui.LockScreenDoubleTapToSleep import star.sky.voyager.hook.hooks.systemui.MaximumNumberOfNotificationIcons +import star.sky.voyager.hook.hooks.systemui.MonetTheme import star.sky.voyager.hook.hooks.systemui.NoPasswordHook import star.sky.voyager.hook.hooks.systemui.NotificationSettingsNoWhiteList import star.sky.voyager.hook.hooks.systemui.NotificationWeather @@ -45,6 +46,7 @@ object SystemUI : AppRegister() { override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) { autoInitHooks( lpparam, + MonetTheme, // 自定义系统主题色 StatusBarDoubleTapToSleep, // 状态栏-双击锁定屏幕 StatusBarBattery, // 状态栏显示关于电池 StatusBarLayout, // 状态栏布局 diff --git a/app/src/main/kotlin/star/sky/voyager/hook/hooks/systemui/BlurLockScreenButton.kt b/app/src/main/kotlin/star/sky/voyager/hook/hooks/systemui/BlurLockScreenButton.kt index 2b747e5c..b7f216e1 100644 --- a/app/src/main/kotlin/star/sky/voyager/hook/hooks/systemui/BlurLockScreenButton.kt +++ b/app/src/main/kotlin/star/sky/voyager/hook/hooks/systemui/BlurLockScreenButton.kt @@ -17,36 +17,38 @@ object BlurLockScreenButton : HookRegister() { loadClassOrNull( "com.android.systemui.statusbar.phone.KeyguardBottomAreaView" )?.methodFinder()?.forEach { method -> - method.createHook { - after { param -> - val mLeftAffordanceView = getValueByField( - param.thisObject, - "mLeftAffordanceView" - ) as ImageView - val mRightAffordanceView = getValueByField( - param.thisObject, - "mRightAffordanceView" - ) as ImageView + if (method.name != "onAttachedToWindow") { + method.createHook { + after { param -> + val mLeftAffordanceView = getValueByField( + param.thisObject, + "mLeftAffordanceView" + ) as ImageView + val mRightAffordanceView = getValueByField( + param.thisObject, + "mRightAffordanceView" + ) as ImageView - val keyguardBottomAreaView = param.thisObject as View - val leftBlurDrawable = createBlurDrawable( - keyguardBottomAreaView, - 40, - 100, - Color.argb(60, 255, 255, 255) - ) - val leftLayerDrawable = LayerDrawable(arrayOf(leftBlurDrawable)) - val rightBlurDrawable = createBlurDrawable( - keyguardBottomAreaView, - 40, - 100, - Color.argb(60, 255, 255, 255) - ) - val rightLayerDrawable = LayerDrawable(arrayOf(rightBlurDrawable)) - leftLayerDrawable.setLayerInset(0, 40, 40, 40, 40) - rightLayerDrawable.setLayerInset(0, 40, 40, 40, 40) - mLeftAffordanceView.background = leftLayerDrawable - mRightAffordanceView.background = rightLayerDrawable + val keyguardBottomAreaView = param.thisObject as View + val leftBlurDrawable = createBlurDrawable( + keyguardBottomAreaView, + 40, + 100, + Color.argb(60, 255, 255, 255) + ) + val leftLayerDrawable = LayerDrawable(arrayOf(leftBlurDrawable)) + val rightBlurDrawable = createBlurDrawable( + keyguardBottomAreaView, + 40, + 100, + Color.argb(60, 255, 255, 255) + ) + val rightLayerDrawable = LayerDrawable(arrayOf(rightBlurDrawable)) + leftLayerDrawable.setLayerInset(0, 40, 40, 40, 40) + rightLayerDrawable.setLayerInset(0, 40, 40, 40, 40) + mLeftAffordanceView.background = leftLayerDrawable + mRightAffordanceView.background = rightLayerDrawable + } } } } diff --git a/app/src/main/kotlin/star/sky/voyager/hook/hooks/systemui/MonetTheme.kt b/app/src/main/kotlin/star/sky/voyager/hook/hooks/systemui/MonetTheme.kt new file mode 100644 index 00000000..343bcb82 --- /dev/null +++ b/app/src/main/kotlin/star/sky/voyager/hook/hooks/systemui/MonetTheme.kt @@ -0,0 +1,29 @@ +package star.sky.voyager.hook.hooks.systemui + +import android.graphics.Color +import com.github.kyuubiran.ezxhelper.ClassUtils.loadClassOrNull +import com.github.kyuubiran.ezxhelper.HookFactory.`-Static`.createHook +import com.github.kyuubiran.ezxhelper.Log +import com.github.kyuubiran.ezxhelper.finders.MethodFinder.`-Static`.methodFinder +import star.sky.voyager.utils.init.HookRegister +import star.sky.voyager.utils.key.XSPUtils +import star.sky.voyager.utils.key.hasEnable + +object MonetTheme : HookRegister() { + override fun init() = hasEnable("monet_theme") { + loadClassOrNull("com.android.systemui.theme.ThemeOverlayController")?.methodFinder() + ?.first { + name == "getOverlay" && parameterCount == 3 && parameterTypes[0] == Int::class.java && parameterTypes[1] == Int::class.java + }?.createHook { + before { param -> + param.args[0] = + Color.parseColor(XSPUtils.getString("your_theme_accent_color", "#0d84ff")) + param.args[1] = + Color.parseColor(XSPUtils.getString("your_theme_neutral_color", "#0d84ff")) + Log.i("Your monet theme color1:" + param.args[0]) + Log.i("Your monet theme color2:" + param.args[1]) + Log.i("Your monet theme style:" + param.args[2]) + } + } + } +} diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 1b910455..b5cb98c2 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -400,10 +400,14 @@ 打开快慢(越大越慢) 文件夹关闭回弹(越小越明显) 关闭快慢(越大越慢) + 图标背景色 默认颜色 -> 莫奈取色 修改成你喜欢的颜色 你喜欢的颜色 + 自定义系统主题色 + 你喜欢的系统强调色 + 你喜欢的系统中性色 状态栏显示关于电池 仅充电显示,刷新率由系统决定 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 3cf693a5..a294cea5 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -414,6 +414,9 @@ Default color -> monet color Edit it into your favorite color Your favorite color + Edit system monet theme color into your favorite color + Your favorite accent color + Your favorite neutral color StatusBar Show about Battery Charging display only, refresh rate is determined by the system