mirror of
https://github.com/fankes/MIUINativeNotifyIcon.git
synced 2025-09-06 10:45:20 +08:00
Merge code
This commit is contained in:
4
.github/ISSUE_TEMPLATE/----------.md
vendored
4
.github/ISSUE_TEMPLATE/----------.md
vendored
@@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
name: 通知优化图标适配反馈
|
name: 通知图标优化适配反馈
|
||||||
about: 提交通知图标优化适配必须使用此模板提交
|
about: 提交通知图标优化适配必须使用此模板提交
|
||||||
title: "[通知优化图标适配反馈]"
|
title: "[通知图标优化适配反馈]"
|
||||||
labels: To be adapted
|
labels: To be adapted
|
||||||
assignees: ''
|
assignees: ''
|
||||||
|
|
||||||
|
@@ -37,8 +37,8 @@ object HookConst {
|
|||||||
const val NOTIFY_ICON_DATAS = "_notify_icon_datas"
|
const val NOTIFY_ICON_DATAS = "_notify_icon_datas"
|
||||||
const val HOOK_STATUS_ICON_COUNT = "_hook_status_icon_count"
|
const val HOOK_STATUS_ICON_COUNT = "_hook_status_icon_count"
|
||||||
|
|
||||||
const val SOURCE_SYNC_WAY = "_source_sync_way"
|
const val SOURCE_SYNC_WAY = "_rule_source_sync_way"
|
||||||
const val SOURCE_SYNC_WAY_CUSTOM_URL = "_source_sync_way_custom_url"
|
const val SOURCE_SYNC_WAY_CUSTOM_URL = "_rule_source_sync_way_custom_url"
|
||||||
|
|
||||||
const val TYPE_SOURCE_SYNC_WAY_1 = 1000
|
const val TYPE_SOURCE_SYNC_WAY_1 = 1000
|
||||||
const val TYPE_SOURCE_SYNC_WAY_2 = 2000
|
const val TYPE_SOURCE_SYNC_WAY_2 = 2000
|
||||||
|
@@ -128,12 +128,22 @@ class HookEntry : YukiHookXposedInitProxy {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 缓存的通知优化图标数组 */
|
/** 缓存的通知图标优化数组 */
|
||||||
private var iconDatas = ArrayList<IconDataBean>()
|
private var iconDatas = ArrayList<IconDataBean>()
|
||||||
|
|
||||||
/** 是否显示通知图标 - 跟随 Hook 保存 */
|
/** 是否显示通知图标 - 跟随 Hook 保存 */
|
||||||
private var isShowNotificationIcons = true
|
private var isShowNotificationIcons = true
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否启用忽略彩色图标和启用通知图标优化功能
|
||||||
|
* @param isHooking 是否判断启用通知功能 - 默认:是
|
||||||
|
* @return [Boolean]
|
||||||
|
*/
|
||||||
|
private fun PackageParam.isEnableHookColorNotifyIcon(isHooking: Boolean = true) =
|
||||||
|
prefs.getBoolean(ENABLE_COLOR_ICON_HOOK, default = true) &&
|
||||||
|
prefs.getBoolean(ENABLE_NOTIFY_ICON_FIX, default = true) &&
|
||||||
|
(if (isHooking) prefs.getBoolean(ENABLE_NOTIFY_ICON_FIX_NOTIFY, default = true) else true)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* - 这个是修复彩色图标的关键核心代码判断
|
* - 这个是修复彩色图标的关键核心代码判断
|
||||||
*
|
*
|
||||||
@@ -477,7 +487,13 @@ class HookEntry : YukiHookXposedInitProxy {
|
|||||||
|
|
||||||
/** 缓存图标数据 */
|
/** 缓存图标数据 */
|
||||||
private fun PackageParam.cachingIconDatas() {
|
private fun PackageParam.cachingIconDatas() {
|
||||||
iconDatas = IconPackParams(param = this).iconDatas
|
iconDatas.clear()
|
||||||
|
IconPackParams(param = this).iconDatas.apply {
|
||||||
|
when {
|
||||||
|
isNotEmpty() -> forEach { iconDatas.add(it) }
|
||||||
|
isEmpty() && isEnableHookColorNotifyIcon(isHooking = false) -> loggerW(msg = "NotifyIconSupportData is empty!")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onInit() = configs {
|
override fun onInit() = configs {
|
||||||
@@ -696,9 +712,7 @@ class HookEntry : YukiHookXposedInitProxy {
|
|||||||
param(ContextClass, IntentClass)
|
param(ContextClass, IntentClass)
|
||||||
}
|
}
|
||||||
afterHook {
|
afterHook {
|
||||||
if (prefs.getBoolean(ENABLE_NOTIFY_ICON_FIX, default = true) &&
|
if (isEnableHookColorNotifyIcon()) (lastArgs as? Intent)?.also {
|
||||||
prefs.getBoolean(ENABLE_NOTIFY_ICON_FIX_NOTIFY, default = true)
|
|
||||||
) (lastArgs as? Intent)?.also {
|
|
||||||
if (!it.action.equals(Intent.ACTION_PACKAGE_REPLACED) &&
|
if (!it.action.equals(Intent.ACTION_PACKAGE_REPLACED) &&
|
||||||
it.getBooleanExtra(Intent.EXTRA_REPLACING, false)
|
it.getBooleanExtra(Intent.EXTRA_REPLACING, false)
|
||||||
) return@also
|
) return@also
|
||||||
@@ -720,7 +734,7 @@ class HookEntry : YukiHookXposedInitProxy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/** 自动检查通知优化图标更新的注入监听 */
|
/** 自动检查通知图标优化更新的注入监听 */
|
||||||
MiuiClockClass.hook {
|
MiuiClockClass.hook {
|
||||||
injectMember {
|
injectMember {
|
||||||
method { name = "updateTime" }
|
method { name = "updateTime" }
|
||||||
|
@@ -56,7 +56,7 @@ class ConfigureActivity : BaseActivity<ActivityConfigBinding>() {
|
|||||||
/** 回调滚动事件改变 */
|
/** 回调滚动事件改变 */
|
||||||
private var onScrollEvent: ((Boolean) -> Unit)? = null
|
private var onScrollEvent: ((Boolean) -> Unit)? = null
|
||||||
|
|
||||||
/** 全部的通知优化图标数据 */
|
/** 全部的通知图标优化数据 */
|
||||||
private var iconAllDatas = ArrayList<IconDataBean>()
|
private var iconAllDatas = ArrayList<IconDataBean>()
|
||||||
|
|
||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
|
@@ -121,7 +121,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||||||
if (isNotNoificationEnabled && modulePrefs.getBoolean(ENABLE_NOTIFY_ICON_FIX, default = true))
|
if (isNotNoificationEnabled && modulePrefs.getBoolean(ENABLE_NOTIFY_ICON_FIX, default = true))
|
||||||
showDialog {
|
showDialog {
|
||||||
title = "模块的通知权限已关闭"
|
title = "模块的通知权限已关闭"
|
||||||
msg = "请开启通知权限,以确保你能收到通知优化图标在线规则的更新。"
|
msg = "请开启通知权限,以确保你能收到通知图标优化在线规则的更新。"
|
||||||
confirmButton {
|
confirmButton {
|
||||||
runCatching {
|
runCatching {
|
||||||
Intent().also { intent ->
|
Intent().also { intent ->
|
||||||
|
@@ -83,11 +83,11 @@ object IconAdaptationTool {
|
|||||||
context.getSystemService(NotificationManager::class.java)?.apply {
|
context.getSystemService(NotificationManager::class.java)?.apply {
|
||||||
createNotificationChannel(
|
createNotificationChannel(
|
||||||
NotificationChannel(
|
NotificationChannel(
|
||||||
"notifyRuleAdaptId", "通知图标优化适配",
|
IconRuleManagerTool.NOTIFY_CHANNEL, "通知图标优化适配",
|
||||||
NotificationManager.IMPORTANCE_DEFAULT
|
NotificationManager.IMPORTANCE_DEFAULT
|
||||||
).apply { enableLights(false) }
|
).apply { enableLights(false) }
|
||||||
)
|
)
|
||||||
notify(packageName.hashCode(), Notification.Builder(context, "notifyRuleAdaptId").apply {
|
notify(packageName.hashCode(), Notification.Builder(context, IconRuleManagerTool.NOTIFY_CHANNEL).apply {
|
||||||
setShowWhen(true)
|
setShowWhen(true)
|
||||||
setContentTitle("您已安装 ${context.findAppName(packageName)}")
|
setContentTitle("您已安装 ${context.findAppName(packageName)}")
|
||||||
setContentText("尚未适配此应用,点按打开在线规则。")
|
setContentText("尚未适配此应用,点按打开在线规则。")
|
||||||
|
@@ -91,10 +91,7 @@ object IconRuleManagerTool {
|
|||||||
setText(customUrl)
|
setText(customUrl)
|
||||||
setSelection(customUrl.length)
|
setSelection(customUrl.length)
|
||||||
}
|
}
|
||||||
doOnTextChanged { text, _, _, _ ->
|
doOnTextChanged { text, _, _, _ -> customUrl = text.toString() }
|
||||||
customUrl = text.toString()
|
|
||||||
context.modulePrefs.putString(SOURCE_SYNC_WAY_CUSTOM_URL, text.toString())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
diaSfTextLin.isVisible = sourceType == TYPE_SOURCE_SYNC_WAY_3
|
diaSfTextLin.isVisible = sourceType == TYPE_SOURCE_SYNC_WAY_3
|
||||||
diaSfRd1.isChecked = sourceType == TYPE_SOURCE_SYNC_WAY_1
|
diaSfRd1.isChecked = sourceType == TYPE_SOURCE_SYNC_WAY_1
|
||||||
@@ -105,24 +102,25 @@ object IconRuleManagerTool {
|
|||||||
diaSfRd3.isChecked = false
|
diaSfRd3.isChecked = false
|
||||||
diaSfTextLin.isVisible = false
|
diaSfTextLin.isVisible = false
|
||||||
sourceType = TYPE_SOURCE_SYNC_WAY_1
|
sourceType = TYPE_SOURCE_SYNC_WAY_1
|
||||||
context.modulePrefs.putInt(SOURCE_SYNC_WAY, TYPE_SOURCE_SYNC_WAY_1)
|
|
||||||
}
|
}
|
||||||
diaSfRd2.setOnClickListener {
|
diaSfRd2.setOnClickListener {
|
||||||
diaSfRd1.isChecked = false
|
diaSfRd1.isChecked = false
|
||||||
diaSfRd3.isChecked = false
|
diaSfRd3.isChecked = false
|
||||||
diaSfTextLin.isVisible = false
|
diaSfTextLin.isVisible = false
|
||||||
sourceType = TYPE_SOURCE_SYNC_WAY_2
|
sourceType = TYPE_SOURCE_SYNC_WAY_2
|
||||||
context.modulePrefs.putInt(SOURCE_SYNC_WAY, TYPE_SOURCE_SYNC_WAY_2)
|
|
||||||
}
|
}
|
||||||
diaSfRd3.setOnClickListener {
|
diaSfRd3.setOnClickListener {
|
||||||
diaSfRd1.isChecked = false
|
diaSfRd1.isChecked = false
|
||||||
diaSfRd2.isChecked = false
|
diaSfRd2.isChecked = false
|
||||||
diaSfTextLin.isVisible = true
|
diaSfTextLin.isVisible = true
|
||||||
sourceType = TYPE_SOURCE_SYNC_WAY_3
|
sourceType = TYPE_SOURCE_SYNC_WAY_3
|
||||||
context.modulePrefs.putInt(SOURCE_SYNC_WAY, TYPE_SOURCE_SYNC_WAY_3)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
confirmButton { sync(context, it) }
|
confirmButton {
|
||||||
|
context.modulePrefs.putInt(SOURCE_SYNC_WAY, sourceType)
|
||||||
|
context.modulePrefs.putString(SOURCE_SYNC_WAY_CUSTOM_URL, customUrl)
|
||||||
|
sync(context, sourceType, customUrl, it)
|
||||||
|
}
|
||||||
cancelButton()
|
cancelButton()
|
||||||
neutralButton(text = "自定义规则") {
|
neutralButton(text = "自定义规则") {
|
||||||
context.showDialog {
|
context.showDialog {
|
||||||
@@ -172,11 +170,16 @@ object IconRuleManagerTool {
|
|||||||
/**
|
/**
|
||||||
* 从在线地址同步规则
|
* 从在线地址同步规则
|
||||||
* @param context 实例
|
* @param context 实例
|
||||||
|
* @param sourceType 同步地址类型 - 默认自动获取已存储的键值
|
||||||
|
* @param customUrl 自定义同步地址 - 默认自动获取已存储的键值
|
||||||
* @param it 成功后回调
|
* @param it 成功后回调
|
||||||
*/
|
*/
|
||||||
fun sync(context: Context, it: () -> Unit) {
|
fun sync(
|
||||||
val sourceType = context.modulePrefs.getInt(SOURCE_SYNC_WAY, TYPE_SOURCE_SYNC_WAY_1)
|
context: Context,
|
||||||
val customUrl = context.modulePrefs.getString(SOURCE_SYNC_WAY_CUSTOM_URL)
|
sourceType: Int = context.modulePrefs.getInt(SOURCE_SYNC_WAY, TYPE_SOURCE_SYNC_WAY_1),
|
||||||
|
customUrl: String = context.modulePrefs.getString(SOURCE_SYNC_WAY_CUSTOM_URL),
|
||||||
|
it: () -> Unit
|
||||||
|
) {
|
||||||
when (sourceType) {
|
when (sourceType) {
|
||||||
TYPE_SOURCE_SYNC_WAY_1 ->
|
TYPE_SOURCE_SYNC_WAY_1 ->
|
||||||
onRefreshing(context, url = "https://raw.fastgit.org/fankes/AndroidNotifyIconAdapt/main", it)
|
onRefreshing(context, url = "https://raw.fastgit.org/fankes/AndroidNotifyIconAdapt/main", it)
|
||||||
|
Reference in New Issue
Block a user