Skip to content

Commit

Permalink
[add] 手机管家-全局侧边栏背景自定义-图标反色(不开启时可以避免游戏工具箱爆炸)
Browse files Browse the repository at this point in the history
  • Loading branch information
lingqiqi5211 committed Dec 2, 2023
1 parent 6a2c1ef commit f7b2883
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import de.robv.android.xposed.XposedHelpers
object BlurSecurity : BaseHook() {
val blurRadius = mPrefsMap.getInt("security_center_blurradius", 60)
val backgroundColor = mPrefsMap.getInt("security_center_color", -1)
val isInvertColor = mPrefsMap.getBoolean("security_center_invert_color")
val shouldInvertColor = !ColorUtils.isDarkColor(backgroundColor)

private var appVersionCode = 40000727
Expand Down Expand Up @@ -79,7 +80,6 @@ object BlurSecurity : BaseHook() {
view.addOnAttachStateChangeListener(
object :
View.OnAttachStateChangeListener {
@RequiresApi(Build.VERSION_CODES.S)
override fun onViewAttachedToWindow(view: View) {
// 已有背景 避免重复添加

Expand Down Expand Up @@ -119,7 +119,7 @@ object BlurSecurity : BaseHook() {
HookUtils.createBlurDrawable(gameContentLayout, blurRadius, 40, backgroundColor)

if (shouldInvertColor) {
invertViewColor(gameContentLayout)
if (isInvertColor) invertViewColor(gameContentLayout)

// 设置 RenderEffect 后会导致文字动画出现问题,故去除动画
val performanceTextView = XposedHelpers.callMethod(
Expand Down Expand Up @@ -181,7 +181,7 @@ object BlurSecurity : BaseHook() {
view.background =
HookUtils.createBlurDrawable(view, blurRadius, 40, backgroundColor)

if (shouldInvertColor) invertViewColor(mainContent)
if (shouldInvertColor && isInvertColor) invertViewColor(mainContent)
}

override fun onViewDetachedFromWindow(view: View) {
Expand Down Expand Up @@ -233,17 +233,19 @@ object BlurSecurity : BaseHook() {
"seekbar_text_speed"
)

val gameManagerMethod = dexKitBridge.findMethod {
searchPackages = listOf("com.miui.gamebooster.windowmanager.newbox")
matcher {
usingStrings = listOf("addView error")
}
}.firstOrNull()?.getMethodInstance(safeClassLoader)
if (isInvertColor) {
val gameManagerMethod = dexKitBridge.findMethod {
searchPackages = listOf("com.miui.gamebooster.windowmanager.newbox")
matcher {
usingStrings = listOf("addView error")
}
}.firstOrNull()?.getMethodInstance(safeClassLoader)

gameManagerMethod!!.createHook {
after {
val view = it.args[0] as View
invertViewColor(view, gameBoxWhiteList, gameBoxKeepList)
gameManagerMethod!!.createHook {
after {
val view = it.args[0] as View
invertViewColor(view, gameBoxWhiteList, gameBoxKeepList)
}
}
}

Expand Down Expand Up @@ -296,11 +298,13 @@ object BlurSecurity : BaseHook() {
}
}
if (currentObject is View) {
invertViewColor(
currentObject,
videoBoxWhiteList,
videoBoxKeepList
)
if (isInvertColor) {
invertViewColor(
currentObject,
videoBoxWhiteList,
videoBoxKeepList
)
}
}
}
}
Expand Down Expand Up @@ -379,7 +383,7 @@ object BlurSecurity : BaseHook() {
lastChild.setImageDrawable(newDrawable)
}
}
invertViewColor(view, gameBoxWhiteList, gameBoxKeepList)
if (isInvertColor) invertViewColor(view, gameBoxWhiteList, gameBoxKeepList)
}
})
}
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1211,6 +1211,8 @@
<string name="security_center_unlock_smart_charge_title">解锁 “智能断充保护” 和 “低电疾充” 功能</string>
<string name="security_center_super_wireless_charge">解锁极速无线充电模式</string>
<string name="security_center_blur_model">全局侧边栏背景自定义</string>
<string name="security_center_invert_color">图标反色</string>
<string name="security_center_invert_color_summary">对某些背景下的图标选中颜色进行反色,以达到更好的可视效果\n该功能可能会有反色异常的情况,请酌情开启</string>
<string name="security_center_blurradius">全局侧边栏背景模糊程度</string>
<string name="security_center_color">全局侧边栏背景叠加层颜色</string>
<string name="security_center_other_title">其他</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-zh-rHK/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1089,6 +1089,8 @@
<string name="security_center_unlock_smart_charge_title">解鎖「智能斷充保護」和「低電疾充」功能</string>
<string name="security_center_super_wireless_charge">解鎖極速無線充電模式</string>
<string name="security_center_blur_model">全域側邊欄背景設定</string>
<string name="security_center_invert_color">圖示反色</string>
<string name="security_center_invert_color_summary">對某些背景下的圖示選中顏色進行反色,以達到更好的可視效果\n該功能可能會有反色異常的情況,請酌情開啟</string>
<string name="security_center_blurradius">全域側邊欄背景模糊程度</string>
<string name="security_center_color">全域側邊欄背景疊加層顏色</string>
<string name="security_center_other_title">其他</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-zh-rTW/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1107,6 +1107,8 @@
<string name="security_center_unlock_smart_charge_title">解鎖「智能斷充保護」和「低電疾充」功能</string>
<string name="security_center_super_wireless_charge">解鎖極速無線充電模式</string>
<string name="security_center_blur_model">全域側邊欄背景設定</string>
<string name="security_center_invert_color">圖示反色</string>
<string name="security_center_invert_color_summary">對某些背景下的圖示選中顏色進行反色,以達到更好的可視效果\n該功能可能會有反色異常的情況,請酌情開啟</string>
<string name="security_center_blurradius">全域側邊欄背景模糊程度</string>
<string name="security_center_color">全域側邊欄背景疊加層顏色</string>
<string name="security_center_other_title">其他</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1181,6 +1181,8 @@
<string name="security_center_unlock_smart_charge_title">Unlock the “Smart Charge Off Protection” and “Low Battery Quick Charge” functions</string>
<string name="security_center_super_wireless_charge">Unlock Super wireless charge</string>
<string name="security_center_blur_model">Sidebar blur model</string>
<string name="security_center_invert_color">Icon inverted</string>
<string name="security_center_invert_color_summary">Invert the selected colors of icons in some backgrounds for better visibility\nThis function may have abnormal color inversions, please enable it as appropriate</string>
<string name="security_center_blurradius">Sidebar blur value</string>
<string name="security_center_color">Sidebar color</string>
<string name="security_center_other_title">Other</string>
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/res/xml/security_center.xml
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,13 @@
android:key="prefs_key_se_enable"
android:title="@string/security_center_blur_model" />

<SwitchPreference
android:defaultValue="false"
android:dependency="prefs_key_se_enable"
android:key="prefs_key_security_center_invert_color"
android:summary="@string/security_center_invert_color_summary"
android:title="@string/security_center_invert_color" />

<SeekBarPreferenceEx
android:defaultValue="60"
android:dependency="prefs_key_se_enable"
Expand Down

0 comments on commit f7b2883

Please sign in to comment.