Modify merge to YukiHookAPI new usage

This commit is contained in:
2023-02-01 05:02:15 +08:00
parent 4fd017fed1
commit 77ff08f6d7

View File

@@ -25,7 +25,6 @@
package com.fankes.coloros.notify.hook.entity package com.fankes.coloros.notify.hook.entity
import android.app.WallpaperManager import android.app.WallpaperManager
import android.content.BroadcastReceiver
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.content.IntentFilter import android.content.IntentFilter
@@ -540,36 +539,31 @@ object SystemUIHooker : YukiBaseHooker() {
if (isEnableHookColorNotifyIcon() && prefs.get(DataConst.ENABLE_NOTIFY_ICON_FIX_AUTO)) if (isEnableHookColorNotifyIcon() && prefs.get(DataConst.ENABLE_NOTIFY_ICON_FIX_AUTO))
IconAdaptationTool.prepareAutoUpdateIconRule(context, prefs.get(DataConst.NOTIFY_ICON_FIX_AUTO_TIME)) IconAdaptationTool.prepareAutoUpdateIconRule(context, prefs.get(DataConst.NOTIFY_ICON_FIX_AUTO_TIME))
} }
onCreate { /** 注册发送适配新的 APP 图标通知监听 */
/** 注入模块资源 */ registerReceiver(IntentFilter().apply {
injectModuleAppResources() addDataScheme("package")
/** 注册发送适配新的 APP 图标通知监听 */ addAction(Intent.ACTION_PACKAGE_ADDED)
registerReceiver(object : BroadcastReceiver() { addAction(Intent.ACTION_PACKAGE_REPLACED)
override fun onReceive(context: Context, intent: Intent?) { addAction(Intent.ACTION_PACKAGE_REMOVED)
if (isEnableHookColorNotifyIcon()) intent?.also { }) { context, intent ->
if (it.action.equals(Intent.ACTION_PACKAGE_REPLACED).not() && if (isEnableHookColorNotifyIcon().not()) return@registerReceiver
it.getBooleanExtra(Intent.EXTRA_REPLACING, false) if (intent.action.equals(Intent.ACTION_PACKAGE_REPLACED).not() &&
) return@also intent.getBooleanExtra(Intent.EXTRA_REPLACING, false)
it.data?.schemeSpecificPart?.also { packageName -> ) return@registerReceiver
when (it.action) { intent.data?.schemeSpecificPart?.also { packageName ->
Intent.ACTION_PACKAGE_ADDED -> { when (intent.action) {
if (iconDatas.takeIf { e -> e.isNotEmpty() } Intent.ACTION_PACKAGE_ADDED -> {
?.filter { e -> e.packageName == packageName } if (iconDatas.takeIf { e -> e.isNotEmpty() }
.isNullOrEmpty() ?.filter { e -> e.packageName == packageName }
) IconAdaptationTool.pushNewAppSupportNotify(context, packageName) .isNullOrEmpty()
} ) IconAdaptationTool.pushNewAppSupportNotify(context, packageName)
Intent.ACTION_PACKAGE_REMOVED -> IconAdaptationTool.removeNewAppSupportNotify(context, packageName)
}
}
} }
Intent.ACTION_PACKAGE_REMOVED -> IconAdaptationTool.removeNewAppSupportNotify(context, packageName)
} }
}, IntentFilter().apply { }
addDataScheme("package")
addAction(Intent.ACTION_PACKAGE_ADDED)
addAction(Intent.ACTION_PACKAGE_REPLACED)
addAction(Intent.ACTION_PACKAGE_REMOVED)
})
} }
/** 注入模块资源 */
onCreate { injectModuleAppResources() }
} }
/** 刷新图标缓存 */ /** 刷新图标缓存 */
SystemUITool.Host.onRefreshSystemUI(param = this) { recachingPrefs(it) } SystemUITool.Host.onRefreshSystemUI(param = this) { recachingPrefs(it) }