mirror of
https://github.com/fankes/MIUINativeNotifyIcon.git
synced 2025-09-08 03:24:17 +08:00
更新通知图标优化名单功能并优化代码和相关功能
This commit is contained in:
@@ -175,17 +175,18 @@ class HookMain : IXposedHookLoadPackage {
|
|||||||
(param.args?.get(0) as? StatusBarNotification?)?.also { notifyInstance ->
|
(param.args?.get(0) as? StatusBarNotification?)?.also { notifyInstance ->
|
||||||
/** 目标彩色通知 APP 图标 */
|
/** 目标彩色通知 APP 图标 */
|
||||||
var customIcon: Icon? = null
|
var customIcon: Icon? = null
|
||||||
run {
|
if (HookMedium.getBoolean(HookMedium.ENABLE_COLOR_ICON_HOOK, default = true))
|
||||||
IconPackParams.iconDatas.forEach {
|
run {
|
||||||
if ((notifyInstance.opPkgName == it.packageName ||
|
IconPackParams.iconDatas.forEach {
|
||||||
findAppName(notifyInstance) == it.appName) &&
|
if ((notifyInstance.opPkgName == it.packageName ||
|
||||||
HookMedium.isAppNotifyHookOf(it.packageName)
|
findAppName(notifyInstance) == it.appName) &&
|
||||||
) {
|
HookMedium.isAppNotifyHookOf(it.packageName)
|
||||||
customIcon = Icon.createWithBitmap(it.iconBitmap)
|
) {
|
||||||
return@run
|
customIcon = Icon.createWithBitmap(it.iconBitmap)
|
||||||
|
return@run
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
when {
|
when {
|
||||||
/** 如果开启了修复 APP 的彩色图标 */
|
/** 如果开启了修复 APP 的彩色图标 */
|
||||||
customIcon != null && HookMedium.getBoolean(HookMedium.ENABLE_NOTIFY_ICON_HOOK, default = true) ->
|
customIcon != null && HookMedium.getBoolean(HookMedium.ENABLE_NOTIFY_ICON_HOOK, default = true) ->
|
||||||
@@ -226,17 +227,18 @@ class HookMain : IXposedHookLoadPackage {
|
|||||||
|
|
||||||
/** 自定义默认小图标 */
|
/** 自定义默认小图标 */
|
||||||
var customIcon: Bitmap? = null
|
var customIcon: Bitmap? = null
|
||||||
run {
|
if (HookMedium.getBoolean(HookMedium.ENABLE_COLOR_ICON_HOOK, default = true))
|
||||||
IconPackParams.iconDatas.forEach {
|
run {
|
||||||
if ((notifyInstance.opPkgName == it.packageName ||
|
IconPackParams.iconDatas.forEach {
|
||||||
findAppName(notifyInstance) == it.appName) &&
|
if ((notifyInstance.opPkgName == it.packageName ||
|
||||||
HookMedium.isAppNotifyHookOf(it.packageName)
|
findAppName(notifyInstance) == it.appName) &&
|
||||||
) {
|
HookMedium.isAppNotifyHookOf(it.packageName)
|
||||||
customIcon = it.iconBitmap
|
) {
|
||||||
return@run
|
customIcon = it.iconBitmap
|
||||||
|
return@run
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
/** 如果开启了修复 APP 的彩色图标 */
|
/** 如果开启了修复 APP 的彩色图标 */
|
||||||
if (customIcon != null && HookMedium.getBoolean(HookMedium.ENABLE_NOTIFY_ICON_HOOK, default = true))
|
if (customIcon != null && HookMedium.getBoolean(HookMedium.ENABLE_NOTIFY_ICON_HOOK, default = true))
|
||||||
iconImageView.apply {
|
iconImageView.apply {
|
||||||
|
@@ -33,6 +33,7 @@ import android.widget.TextView
|
|||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.appcompat.widget.SwitchCompat
|
import androidx.appcompat.widget.SwitchCompat
|
||||||
import androidx.constraintlayout.utils.widget.ImageFilterView
|
import androidx.constraintlayout.utils.widget.ImageFilterView
|
||||||
|
import androidx.core.view.isVisible
|
||||||
import com.fankes.miui.notify.BuildConfig
|
import com.fankes.miui.notify.BuildConfig
|
||||||
import com.fankes.miui.notify.R
|
import com.fankes.miui.notify.R
|
||||||
import com.fankes.miui.notify.hook.HookMedium
|
import com.fankes.miui.notify.hook.HookMedium
|
||||||
@@ -90,11 +91,13 @@ class MainActivity : BaseActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/** 初始化 View */
|
/** 初始化 View */
|
||||||
|
val notifyIconConfigItem = findViewById<View>(R.id.config_item_notify)
|
||||||
val moduleEnableSwitch = findViewById<SwitchCompat>(R.id.module_enable_switch)
|
val moduleEnableSwitch = findViewById<SwitchCompat>(R.id.module_enable_switch)
|
||||||
val hideIconInLauncherSwitch = findViewById<SwitchCompat>(R.id.hide_icon_in_launcher_switch)
|
val hideIconInLauncherSwitch = findViewById<SwitchCompat>(R.id.hide_icon_in_launcher_switch)
|
||||||
val colorIconHookSwitch = findViewById<SwitchCompat>(R.id.color_icon_fix_switch)
|
val colorIconHookSwitch = findViewById<SwitchCompat>(R.id.color_icon_fix_switch)
|
||||||
val notifyIconHookSwitch = findViewById<SwitchCompat>(R.id.notify_icon_fix_switch)
|
val notifyIconHookSwitch = findViewById<SwitchCompat>(R.id.notify_icon_fix_switch)
|
||||||
/** 获取 Sp 存储的信息 */
|
/** 获取 Sp 存储的信息 */
|
||||||
|
notifyIconConfigItem.isVisible = getBoolean(HookMedium.ENABLE_COLOR_ICON_HOOK, default = true)
|
||||||
moduleEnableSwitch.isChecked = getBoolean(HookMedium.ENABLE_MODULE, default = true)
|
moduleEnableSwitch.isChecked = getBoolean(HookMedium.ENABLE_MODULE, default = true)
|
||||||
hideIconInLauncherSwitch.isChecked = getBoolean(HookMedium.ENABLE_HIDE_ICON)
|
hideIconInLauncherSwitch.isChecked = getBoolean(HookMedium.ENABLE_HIDE_ICON)
|
||||||
colorIconHookSwitch.isChecked = getBoolean(HookMedium.ENABLE_COLOR_ICON_HOOK, default = true)
|
colorIconHookSwitch.isChecked = getBoolean(HookMedium.ENABLE_COLOR_ICON_HOOK, default = true)
|
||||||
@@ -115,6 +118,7 @@ class MainActivity : BaseActivity() {
|
|||||||
colorIconHookSwitch.setOnCheckedChangeListener { btn, b ->
|
colorIconHookSwitch.setOnCheckedChangeListener { btn, b ->
|
||||||
if (!btn.isPressed) return@setOnCheckedChangeListener
|
if (!btn.isPressed) return@setOnCheckedChangeListener
|
||||||
putBoolean(HookMedium.ENABLE_COLOR_ICON_HOOK, b)
|
putBoolean(HookMedium.ENABLE_COLOR_ICON_HOOK, b)
|
||||||
|
notifyIconConfigItem.isVisible = b
|
||||||
}
|
}
|
||||||
notifyIconHookSwitch.setOnCheckedChangeListener { btn, b ->
|
notifyIconHookSwitch.setOnCheckedChangeListener { btn, b ->
|
||||||
if (!btn.isPressed) return@setOnCheckedChangeListener
|
if (!btn.isPressed) return@setOnCheckedChangeListener
|
||||||
|
@@ -110,6 +110,7 @@
|
|||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:animateLayoutChanges="true"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
@@ -208,6 +209,7 @@
|
|||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
android:id="@+id/config_item_notify"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="10dp"
|
android:layout_marginLeft="10dp"
|
||||||
|
Reference in New Issue
Block a user