mirror of
				https://github.com/fankes/MIUINativeNotifyIcon.git
				synced 2025-10-26 15:39:21 +08:00 
			
		
		
		
	Merge code
This commit is contained in:
		| @@ -37,8 +37,8 @@ object HookConst { | ||||
|     const val NOTIFY_ICON_DATAS = "_notify_icon_datas" | ||||
|     const val HOOK_STATUS_ICON_COUNT = "_hook_status_icon_count" | ||||
|  | ||||
|     const val SOURCE_SYNC_WAY = "_source_sync_way" | ||||
|     const val SOURCE_SYNC_WAY_CUSTOM_URL = "_source_sync_way_custom_url" | ||||
|     const val SOURCE_SYNC_WAY = "_rule_source_sync_way" | ||||
|     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_2 = 2000 | ||||
|   | ||||
| @@ -128,12 +128,22 @@ class HookEntry : YukiHookXposedInitProxy { | ||||
|         ) | ||||
|     } | ||||
|  | ||||
|     /** 缓存的通知优化图标数组 */ | ||||
|     /** 缓存的通知图标优化数组 */ | ||||
|     private var iconDatas = ArrayList<IconDataBean>() | ||||
|  | ||||
|     /** 是否显示通知图标 - 跟随 Hook 保存 */ | ||||
|     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() { | ||||
|         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 { | ||||
| @@ -696,9 +712,7 @@ class HookEntry : YukiHookXposedInitProxy { | ||||
|                                 param(ContextClass, IntentClass) | ||||
|                             } | ||||
|                             afterHook { | ||||
|                                 if (prefs.getBoolean(ENABLE_NOTIFY_ICON_FIX, default = true) && | ||||
|                                     prefs.getBoolean(ENABLE_NOTIFY_ICON_FIX_NOTIFY, default = true) | ||||
|                                 ) (lastArgs as? Intent)?.also { | ||||
|                                 if (isEnableHookColorNotifyIcon()) (lastArgs as? Intent)?.also { | ||||
|                                     if (!it.action.equals(Intent.ACTION_PACKAGE_REPLACED) && | ||||
|                                         it.getBooleanExtra(Intent.EXTRA_REPLACING, false) | ||||
|                                     ) return@also | ||||
| @@ -720,7 +734,7 @@ class HookEntry : YukiHookXposedInitProxy { | ||||
|                             } | ||||
|                         } | ||||
|                     } | ||||
|                     /** 自动检查通知优化图标更新的注入监听 */ | ||||
|                     /** 自动检查通知图标优化更新的注入监听 */ | ||||
|                     MiuiClockClass.hook { | ||||
|                         injectMember { | ||||
|                             method { name = "updateTime" } | ||||
|   | ||||
| @@ -56,7 +56,7 @@ class ConfigureActivity : BaseActivity<ActivityConfigBinding>() { | ||||
|     /** 回调滚动事件改变 */ | ||||
|     private var onScrollEvent: ((Boolean) -> Unit)? = null | ||||
|  | ||||
|     /** 全部的通知优化图标数据 */ | ||||
|     /** 全部的通知图标优化数据 */ | ||||
|     private var iconAllDatas = ArrayList<IconDataBean>() | ||||
|  | ||||
|     override fun onCreate() { | ||||
|   | ||||
| @@ -121,7 +121,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() { | ||||
|                 if (isNotNoificationEnabled && modulePrefs.getBoolean(ENABLE_NOTIFY_ICON_FIX, default = true)) | ||||
|                     showDialog { | ||||
|                         title = "模块的通知权限已关闭" | ||||
|                         msg = "请开启通知权限,以确保你能收到通知优化图标在线规则的更新。" | ||||
|                         msg = "请开启通知权限,以确保你能收到通知图标优化在线规则的更新。" | ||||
|                         confirmButton { | ||||
|                             runCatching { | ||||
|                                 Intent().also { intent -> | ||||
|   | ||||
| @@ -83,11 +83,11 @@ object IconAdaptationTool { | ||||
|         context.getSystemService(NotificationManager::class.java)?.apply { | ||||
|             createNotificationChannel( | ||||
|                 NotificationChannel( | ||||
|                     "notifyRuleAdaptId", "通知图标优化适配", | ||||
|                     IconRuleManagerTool.NOTIFY_CHANNEL, "通知图标优化适配", | ||||
|                     NotificationManager.IMPORTANCE_DEFAULT | ||||
|                 ).apply { enableLights(false) } | ||||
|             ) | ||||
|             notify(packageName.hashCode(), Notification.Builder(context, "notifyRuleAdaptId").apply { | ||||
|             notify(packageName.hashCode(), Notification.Builder(context, IconRuleManagerTool.NOTIFY_CHANNEL).apply { | ||||
|                 setShowWhen(true) | ||||
|                 setContentTitle("您已安装 ${context.findAppName(packageName)}") | ||||
|                 setContentText("尚未适配此应用,点按打开在线规则。") | ||||
|   | ||||
| @@ -91,10 +91,7 @@ object IconRuleManagerTool { | ||||
|                         setText(customUrl) | ||||
|                         setSelection(customUrl.length) | ||||
|                     } | ||||
|                     doOnTextChanged { text, _, _, _ -> | ||||
|                         customUrl = text.toString() | ||||
|                         context.modulePrefs.putString(SOURCE_SYNC_WAY_CUSTOM_URL, text.toString()) | ||||
|                     } | ||||
|                     doOnTextChanged { text, _, _, _ -> customUrl = text.toString() } | ||||
|                 } | ||||
|                 diaSfTextLin.isVisible = sourceType == TYPE_SOURCE_SYNC_WAY_3 | ||||
|                 diaSfRd1.isChecked = sourceType == TYPE_SOURCE_SYNC_WAY_1 | ||||
| @@ -105,24 +102,25 @@ object IconRuleManagerTool { | ||||
|                     diaSfRd3.isChecked = false | ||||
|                     diaSfTextLin.isVisible = false | ||||
|                     sourceType = TYPE_SOURCE_SYNC_WAY_1 | ||||
|                     context.modulePrefs.putInt(SOURCE_SYNC_WAY, TYPE_SOURCE_SYNC_WAY_1) | ||||
|                 } | ||||
|                 diaSfRd2.setOnClickListener { | ||||
|                     diaSfRd1.isChecked = false | ||||
|                     diaSfRd3.isChecked = false | ||||
|                     diaSfTextLin.isVisible = false | ||||
|                     sourceType = TYPE_SOURCE_SYNC_WAY_2 | ||||
|                     context.modulePrefs.putInt(SOURCE_SYNC_WAY, TYPE_SOURCE_SYNC_WAY_2) | ||||
|                 } | ||||
|                 diaSfRd3.setOnClickListener { | ||||
|                     diaSfRd1.isChecked = false | ||||
|                     diaSfRd2.isChecked = false | ||||
|                     diaSfTextLin.isVisible = true | ||||
|                     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() | ||||
|             neutralButton(text = "自定义规则") { | ||||
|                 context.showDialog { | ||||
| @@ -172,11 +170,16 @@ object IconRuleManagerTool { | ||||
|     /** | ||||
|      * 从在线地址同步规则 | ||||
|      * @param context 实例 | ||||
|      * @param sourceType 同步地址类型 - 默认自动获取已存储的键值 | ||||
|      * @param customUrl 自定义同步地址 - 默认自动获取已存储的键值 | ||||
|      * @param it 成功后回调 | ||||
|      */ | ||||
|     fun sync(context: Context, it: () -> Unit) { | ||||
|         val sourceType = context.modulePrefs.getInt(SOURCE_SYNC_WAY, TYPE_SOURCE_SYNC_WAY_1) | ||||
|         val customUrl = context.modulePrefs.getString(SOURCE_SYNC_WAY_CUSTOM_URL) | ||||
|     fun sync( | ||||
|         context: Context, | ||||
|         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) { | ||||
|             TYPE_SOURCE_SYNC_WAY_1 -> | ||||
|                 onRefreshing(context, url = "https://raw.fastgit.org/fankes/AndroidNotifyIconAdapt/main", it) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user