mirror of
https://github.com/fankes/ColorOSNotifyIcon.git
synced 2025-09-04 09:45:34 +08:00
Added notify icon in notify panel used app icon function
This commit is contained in:
@@ -33,6 +33,7 @@ object DataConst {
|
|||||||
val ENABLE_HIDE_ICON = PrefsData("_hide_icon", false)
|
val ENABLE_HIDE_ICON = PrefsData("_hide_icon", false)
|
||||||
val ENABLE_ANDROID12_STYLE = PrefsData("_notify_android12_style", isUpperOfAndroidS)
|
val ENABLE_ANDROID12_STYLE = PrefsData("_notify_android12_style", isUpperOfAndroidS)
|
||||||
val ENABLE_NOTIFY_ICON_FIX = PrefsData("_notify_icon_fix", true)
|
val ENABLE_NOTIFY_ICON_FIX = PrefsData("_notify_icon_fix", true)
|
||||||
|
val ENABLE_NOTIFY_ICON_FORCE_APP_ICON = PrefsData("_notify_icon_force_app_icon", false)
|
||||||
val ENABLE_NOTIFY_ICON_FIX_NOTIFY = PrefsData("_notify_icon_fix_notify", true)
|
val ENABLE_NOTIFY_ICON_FIX_NOTIFY = PrefsData("_notify_icon_fix_notify", true)
|
||||||
val REMOVE_DEV_NOTIFY = PrefsData("_remove_dev_notify", true)
|
val REMOVE_DEV_NOTIFY = PrefsData("_remove_dev_notify", true)
|
||||||
val REMOVE_CHANGECP_NOTIFY = PrefsData("_remove_charge_complete_notify", false)
|
val REMOVE_CHANGECP_NOTIFY = PrefsData("_remove_charge_complete_notify", false)
|
||||||
|
@@ -428,6 +428,13 @@ object SystemUIHooker : YukiBaseHooker() {
|
|||||||
) = runInSafe {
|
) = runInSafe {
|
||||||
compatCustomIcon(isGrayscaleIcon, packageName).also { customPair ->
|
compatCustomIcon(isGrayscaleIcon, packageName).also { customPair ->
|
||||||
when {
|
when {
|
||||||
|
prefs.get(DataConst.ENABLE_NOTIFY_ICON_FORCE_APP_ICON) && isEnableHookColorNotifyIcon(isHooking = false) ->
|
||||||
|
iconView.apply {
|
||||||
|
/** 重新设置图标 */
|
||||||
|
setImageDrawable(appIcons[packageName] ?: context.findAppIcon(packageName))
|
||||||
|
/** 设置默认样式 */
|
||||||
|
setDefaultNotifyIconViewStyle()
|
||||||
|
}
|
||||||
customPair.first != null || isGrayscaleIcon -> iconView.apply {
|
customPair.first != null || isGrayscaleIcon -> iconView.apply {
|
||||||
/** 设置不要裁切到边界 */
|
/** 设置不要裁切到边界 */
|
||||||
clipToOutline = false
|
clipToOutline = false
|
||||||
@@ -467,23 +474,8 @@ object SystemUIHooker : YukiBaseHooker() {
|
|||||||
else -> iconView.apply {
|
else -> iconView.apply {
|
||||||
/** 重新设置图标 */
|
/** 重新设置图标 */
|
||||||
setImageDrawable(nf.compatPushingIcon(drawable))
|
setImageDrawable(nf.compatPushingIcon(drawable))
|
||||||
/** 设置裁切到边界 */
|
/** 设置默认样式 */
|
||||||
clipToOutline = true
|
setDefaultNotifyIconViewStyle()
|
||||||
/** 设置一个圆角轮廓裁切 */
|
|
||||||
outlineProvider = object : ViewOutlineProvider() {
|
|
||||||
override fun getOutline(view: View, out: Outline) {
|
|
||||||
out.setRoundRect(
|
|
||||||
0, 0,
|
|
||||||
view.width, view.height, 3.dpFloat(context)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/** 清除图标间距 */
|
|
||||||
setPadding(0, 0, 0, 0)
|
|
||||||
/** 清除背景 */
|
|
||||||
background = null
|
|
||||||
/** 清除着色 */
|
|
||||||
colorFilter = null
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/** 打印日志 */
|
/** 打印日志 */
|
||||||
@@ -520,6 +512,27 @@ object SystemUIHooker : YukiBaseHooker() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 设置默认通知栏通知图标样式 */
|
||||||
|
private fun ImageView.setDefaultNotifyIconViewStyle() {
|
||||||
|
/** 设置裁切到边界 */
|
||||||
|
clipToOutline = true
|
||||||
|
/** 设置一个圆角轮廓裁切 */
|
||||||
|
outlineProvider = object : ViewOutlineProvider() {
|
||||||
|
override fun getOutline(view: View, out: Outline) {
|
||||||
|
out.setRoundRect(
|
||||||
|
0, 0,
|
||||||
|
view.width, view.height, 3.dpFloat(context)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/** 清除图标间距 */
|
||||||
|
setPadding(0, 0, 0, 0)
|
||||||
|
/** 清除背景 */
|
||||||
|
background = null
|
||||||
|
/** 清除着色 */
|
||||||
|
colorFilter = null
|
||||||
|
}
|
||||||
|
|
||||||
/** 注册 */
|
/** 注册 */
|
||||||
private fun register() {
|
private fun register() {
|
||||||
/** 解锁后重新刷新状态栏图标防止系统重新设置它 */
|
/** 解锁后重新刷新状态栏图标防止系统重新设置它 */
|
||||||
|
@@ -124,6 +124,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||||||
binding.a12StyleConfigItem.isVisible = modulePrefs.get(DataConst.ENABLE_MODULE)
|
binding.a12StyleConfigItem.isVisible = modulePrefs.get(DataConst.ENABLE_MODULE)
|
||||||
binding.notifyIconConfigItem.isVisible = modulePrefs.get(DataConst.ENABLE_MODULE)
|
binding.notifyIconConfigItem.isVisible = modulePrefs.get(DataConst.ENABLE_MODULE)
|
||||||
binding.notifyIconFixButton.isVisible = modulePrefs.get(DataConst.ENABLE_NOTIFY_ICON_FIX)
|
binding.notifyIconFixButton.isVisible = modulePrefs.get(DataConst.ENABLE_NOTIFY_ICON_FIX)
|
||||||
|
binding.notifyIconForceAppIconItem.isVisible = modulePrefs.get(DataConst.ENABLE_NOTIFY_ICON_FIX)
|
||||||
binding.notifyIconFixNotifyItem.isVisible = modulePrefs.get(DataConst.ENABLE_NOTIFY_ICON_FIX)
|
binding.notifyIconFixNotifyItem.isVisible = modulePrefs.get(DataConst.ENABLE_NOTIFY_ICON_FIX)
|
||||||
binding.notifyIconAutoSyncItem.isVisible = modulePrefs.get(DataConst.ENABLE_NOTIFY_ICON_FIX)
|
binding.notifyIconAutoSyncItem.isVisible = modulePrefs.get(DataConst.ENABLE_NOTIFY_ICON_FIX)
|
||||||
binding.notifyIconAutoSyncChildItem.isVisible = modulePrefs.get(DataConst.ENABLE_NOTIFY_ICON_FIX_AUTO)
|
binding.notifyIconAutoSyncChildItem.isVisible = modulePrefs.get(DataConst.ENABLE_NOTIFY_ICON_FIX_AUTO)
|
||||||
@@ -139,6 +140,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||||||
binding.moduleEnableLogSwitch.isChecked = modulePrefs.get(DataConst.ENABLE_MODULE_LOG)
|
binding.moduleEnableLogSwitch.isChecked = modulePrefs.get(DataConst.ENABLE_MODULE_LOG)
|
||||||
binding.hideIconInLauncherSwitch.isChecked = modulePrefs.get(DataConst.ENABLE_HIDE_ICON)
|
binding.hideIconInLauncherSwitch.isChecked = modulePrefs.get(DataConst.ENABLE_HIDE_ICON)
|
||||||
binding.notifyIconFixSwitch.isChecked = modulePrefs.get(DataConst.ENABLE_NOTIFY_ICON_FIX)
|
binding.notifyIconFixSwitch.isChecked = modulePrefs.get(DataConst.ENABLE_NOTIFY_ICON_FIX)
|
||||||
|
binding.notifyIconForceAppIconSwitch.isChecked = modulePrefs.get(DataConst.ENABLE_NOTIFY_ICON_FORCE_APP_ICON)
|
||||||
binding.notifyIconFixNotifySwitch.isChecked = modulePrefs.get(DataConst.ENABLE_NOTIFY_ICON_FIX_NOTIFY)
|
binding.notifyIconFixNotifySwitch.isChecked = modulePrefs.get(DataConst.ENABLE_NOTIFY_ICON_FIX_NOTIFY)
|
||||||
binding.notifyIconAutoSyncSwitch.isChecked = modulePrefs.get(DataConst.ENABLE_NOTIFY_ICON_FIX_AUTO)
|
binding.notifyIconAutoSyncSwitch.isChecked = modulePrefs.get(DataConst.ENABLE_NOTIFY_ICON_FIX_AUTO)
|
||||||
binding.notifyPanelConfigSwitch.isChecked = modulePrefs.get(DataConst.ENABLE_NOTIFY_PANEL_ALPHA)
|
binding.notifyPanelConfigSwitch.isChecked = modulePrefs.get(DataConst.ENABLE_NOTIFY_PANEL_ALPHA)
|
||||||
@@ -177,10 +179,27 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||||||
if (btn.isPressed.not()) return@setOnCheckedChangeListener
|
if (btn.isPressed.not()) return@setOnCheckedChangeListener
|
||||||
modulePrefs.put(DataConst.ENABLE_NOTIFY_ICON_FIX, b)
|
modulePrefs.put(DataConst.ENABLE_NOTIFY_ICON_FIX, b)
|
||||||
binding.notifyIconFixButton.isVisible = b
|
binding.notifyIconFixButton.isVisible = b
|
||||||
|
binding.notifyIconForceAppIconItem.isVisible = b
|
||||||
binding.notifyIconFixNotifyItem.isVisible = b
|
binding.notifyIconFixNotifyItem.isVisible = b
|
||||||
binding.notifyIconAutoSyncItem.isVisible = b
|
binding.notifyIconAutoSyncItem.isVisible = b
|
||||||
SystemUITool.refreshSystemUI(context = this)
|
SystemUITool.refreshSystemUI(context = this)
|
||||||
}
|
}
|
||||||
|
binding.notifyIconForceAppIconSwitch.setOnCheckedChangeListener { btn, b ->
|
||||||
|
if (btn.isPressed.not()) return@setOnCheckedChangeListener
|
||||||
|
fun saveState() {
|
||||||
|
modulePrefs.put(DataConst.ENABLE_NOTIFY_ICON_FORCE_APP_ICON, b)
|
||||||
|
SystemUITool.refreshSystemUI(context = this)
|
||||||
|
}
|
||||||
|
if (b) showDialog {
|
||||||
|
title = "破坏性功能警告"
|
||||||
|
msg = "开启这个功能后,任何通知栏中的通知图标都会被强制替换为当前推送通知的 APP 的图标," +
|
||||||
|
"某些系统级别的 APP 通知图标可能会显示异常或发生图标丢失。\n\n" +
|
||||||
|
"此功能仅面向一些追求图标美观度的用户,我们不推荐开启这个功能,且发生任何 BUG 都不会去修复,仍然继续开启吗?"
|
||||||
|
confirmButton { saveState() }
|
||||||
|
cancelButton { btn.isChecked = btn.isChecked.not() }
|
||||||
|
noCancelable()
|
||||||
|
} else saveState()
|
||||||
|
}
|
||||||
binding.notifyIconFixNotifySwitch.setOnCheckedChangeListener { btn, b ->
|
binding.notifyIconFixNotifySwitch.setOnCheckedChangeListener { btn, b ->
|
||||||
if (btn.isPressed.not()) return@setOnCheckedChangeListener
|
if (btn.isPressed.not()) return@setOnCheckedChangeListener
|
||||||
modulePrefs.put(DataConst.ENABLE_NOTIFY_ICON_FIX_NOTIFY, b)
|
modulePrefs.put(DataConst.ENABLE_NOTIFY_ICON_FIX_NOTIFY, b)
|
||||||
|
@@ -639,6 +639,34 @@
|
|||||||
android:textColor="@color/colorTextDark"
|
android:textColor="@color/colorTextDark"
|
||||||
android:textSize="12sp" />
|
android:textSize="12sp" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/notify_icon_force_app_icon_item"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="5dp"
|
||||||
|
android:layout_marginRight="5dp"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<com.fankes.coloros.notify.ui.view.MaterialSwitch
|
||||||
|
android:id="@+id/notify_icon_force_app_icon_switch"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="30dp"
|
||||||
|
android:layout_marginBottom="5dp"
|
||||||
|
android:text="通知栏中的图标强制为 APP 图标"
|
||||||
|
android:textColor="@color/colorTextGray"
|
||||||
|
android:textSize="15sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="10dp"
|
||||||
|
android:alpha="0.6"
|
||||||
|
android:lineSpacingExtra="6dp"
|
||||||
|
android:text="此选项默认关闭,开启后下拉通知栏中的通知图标将会被替换为 APP 自身图标,但是不会更改状态栏中的通知图标,这是一个破坏原生通知图标的行为,仅针对部分有需要的用户而添加,我们不推荐开启这个功能,请根据个人偏好进行选择是否需要开启。"
|
||||||
|
android:textColor="@color/colorTextDark"
|
||||||
|
android:textSize="12sp" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/notify_icon_fix_notify_item"
|
android:id="@+id/notify_icon_fix_notify_item"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
Reference in New Issue
Block a user