mirror of
https://github.com/fankes/MIUINativeNotifyIcon.git
synced 2025-09-05 10:15:31 +08:00
refactor: update KavaRef usage to 1.0.1
This commit is contained in:
@@ -77,6 +77,7 @@ import com.fankes.miui.notify.utils.tool.ActivationPromptTool
|
|||||||
import com.fankes.miui.notify.utils.tool.BitmapCompatTool
|
import com.fankes.miui.notify.utils.tool.BitmapCompatTool
|
||||||
import com.fankes.miui.notify.utils.tool.IconAdaptationTool
|
import com.fankes.miui.notify.utils.tool.IconAdaptationTool
|
||||||
import com.fankes.miui.notify.utils.tool.SystemUITool
|
import com.fankes.miui.notify.utils.tool.SystemUITool
|
||||||
|
import com.highcapable.kavaref.KavaRef.Companion.asResolver
|
||||||
import com.highcapable.kavaref.KavaRef.Companion.resolve
|
import com.highcapable.kavaref.KavaRef.Companion.resolve
|
||||||
import com.highcapable.kavaref.condition.MethodCondition
|
import com.highcapable.kavaref.condition.MethodCondition
|
||||||
import com.highcapable.kavaref.extension.VariousClass
|
import com.highcapable.kavaref.extension.VariousClass
|
||||||
@@ -424,11 +425,11 @@ object SystemUIHooker : YukiBaseHooker() {
|
|||||||
/** 刷新通知小图标 */
|
/** 刷新通知小图标 */
|
||||||
private fun refreshNotificationIcons() = runInSafe {
|
private fun refreshNotificationIcons() = runInSafe {
|
||||||
val updateNotificationMethodName = "updateNotificationsOnDensityOrFontScaleChanged"
|
val updateNotificationMethodName = "updateNotificationsOnDensityOrFontScaleChanged"
|
||||||
val result = notificationPresenter?.resolve()?.optional(silent = true)?.firstMethodOrNull {
|
val result = notificationPresenter?.asResolver()?.optional(silent = true)?.firstMethodOrNull {
|
||||||
name = updateNotificationMethodName
|
name = updateNotificationMethodName
|
||||||
emptyParameters()
|
emptyParameters()
|
||||||
}?.invoke()
|
}?.invoke()
|
||||||
if (result == null) settingsManager?.resolve()?.optional(silent = true)?.apply {
|
if (result == null) settingsManager?.asResolver()?.optional(silent = true)?.apply {
|
||||||
firstFieldOrNull { name = "notifStyle" }?.set(-100)
|
firstFieldOrNull { name = "notifStyle" }?.set(-100)
|
||||||
firstMethodOrNull { name = "onNotifStyleChanged" }?.invoke()
|
firstMethodOrNull { name = "onNotifStyleChanged" }?.invoke()
|
||||||
}
|
}
|
||||||
@@ -645,7 +646,7 @@ object SystemUIHooker : YukiBaseHooker() {
|
|||||||
*/
|
*/
|
||||||
private fun ImageView.isGrayscaleIcon(): Boolean {
|
private fun ImageView.isGrayscaleIcon(): Boolean {
|
||||||
/** 获取 [StatusBarNotification] 实例 */
|
/** 获取 [StatusBarNotification] 实例 */
|
||||||
val notifyInstance = resolve().optional().firstFieldOrNull { name = "mNotification" }?.get<StatusBarNotification>() ?: return false
|
val notifyInstance = asResolver().optional().firstFieldOrNull { name = "mNotification" }?.get<StatusBarNotification>() ?: return false
|
||||||
|
|
||||||
/** 获取通知小图标 */
|
/** 获取通知小图标 */
|
||||||
val iconDrawable = notifyInstance.notification?.smallIcon?.loadDrawable(context) ?: return false
|
val iconDrawable = notifyInstance.notification?.smallIcon?.loadDrawable(context) ?: return false
|
||||||
@@ -699,12 +700,12 @@ object SystemUIHooker : YukiBaseHooker() {
|
|||||||
* @param container 当前 [NotificationIconContainerClass] 的实例
|
* @param container 当前 [NotificationIconContainerClass] 的实例
|
||||||
*/
|
*/
|
||||||
private fun updateStatusBarIconsAlpha(container: ViewGroup) {
|
private fun updateStatusBarIconsAlpha(container: ViewGroup) {
|
||||||
val iconStatesMap = container.resolve().optional().firstFieldOrNull { name = "mIconStates" }?.get<HashMap<View, Any>>()
|
val iconStatesMap = container.asResolver().optional().firstFieldOrNull { name = "mIconStates" }?.get<HashMap<View, Any>>()
|
||||||
if (container.isNotEmpty()) container.children.forEach { iconView ->
|
if (container.isNotEmpty()) container.children.forEach { iconView ->
|
||||||
if (iconView !is ImageView) return@forEach
|
if (iconView !is ImageView) return@forEach
|
||||||
val iconAlpha = if (iconView.isGrayscaleIcon()) statusBarIconAlpha else 1f
|
val iconAlpha = if (iconView.isGrayscaleIcon()) statusBarIconAlpha else 1f
|
||||||
iconView.alpha = iconAlpha
|
iconView.alpha = iconAlpha
|
||||||
iconStatesMap?.get(iconView)?.resolve()?.optional()?.firstFieldOrNull {
|
iconStatesMap?.get(iconView)?.asResolver()?.optional()?.firstFieldOrNull {
|
||||||
name { it == "alpha" || it == "mAlpha" }
|
name { it == "alpha" || it == "mAlpha" }
|
||||||
superclass()
|
superclass()
|
||||||
}?.set(iconAlpha)
|
}?.set(iconAlpha)
|
||||||
@@ -811,7 +812,7 @@ object SystemUIHooker : YukiBaseHooker() {
|
|||||||
.optional(silent = true)
|
.optional(silent = true)
|
||||||
.firstFieldOrNull {
|
.firstFieldOrNull {
|
||||||
name = "mEntry"
|
name = "mEntry"
|
||||||
}?.of(this)?.get()?.resolve()
|
}?.of(this)?.get()?.asResolver()
|
||||||
?.optional(silent = true)
|
?.optional(silent = true)
|
||||||
?.firstFieldOrNull { name = "mSbn" }
|
?.firstFieldOrNull { name = "mSbn" }
|
||||||
?.get<StatusBarNotification>()
|
?.get<StatusBarNotification>()
|
||||||
@@ -984,7 +985,7 @@ object SystemUIHooker : YukiBaseHooker() {
|
|||||||
val mIcon = firstFieldOrNull { name = "mIcon" }?.of(instance)?.get()
|
val mIcon = firstFieldOrNull { name = "mIcon" }?.of(instance)?.get()
|
||||||
if (ConfigData.isEnableModuleLog)
|
if (ConfigData.isEnableModuleLog)
|
||||||
YLog.debug("FocusedNotifPromptView DEBUG $isDark $mIcon")
|
YLog.debug("FocusedNotifPromptView DEBUG $isDark $mIcon")
|
||||||
mIcon?.resolve()?.optional()?.firstMethodOrNull {
|
mIcon?.asResolver()?.optional()?.firstMethodOrNull {
|
||||||
name = "setColorFilter"
|
name = "setColorFilter"
|
||||||
superclass()
|
superclass()
|
||||||
}?.invoke(if (isDark <= 0.5f) Color.WHITE else Color.BLACK)
|
}?.invoke(if (isDark <= 0.5f) Color.WHITE else Color.BLACK)
|
||||||
@@ -1029,7 +1030,7 @@ object SystemUIHooker : YukiBaseHooker() {
|
|||||||
emptyParameters()
|
emptyParameters()
|
||||||
}?.hook()?.after {
|
}?.hook()?.after {
|
||||||
val iconView = instance<ImageView>()
|
val iconView = instance<ImageView>()
|
||||||
val expandedNf = iconView.resolve().optional().firstFieldOrNull { name = "mNotification" }?.get<StatusBarNotification>()
|
val expandedNf = iconView.asResolver().optional().firstFieldOrNull { name = "mNotification" }?.get<StatusBarNotification>()
|
||||||
/** Hook 状态栏小图标 */
|
/** Hook 状态栏小图标 */
|
||||||
compatStatusIcon(
|
compatStatusIcon(
|
||||||
context = iconView.context,
|
context = iconView.context,
|
||||||
@@ -1253,7 +1254,7 @@ object SystemUIHooker : YukiBaseHooker() {
|
|||||||
name = "isUnimportantEntry"
|
name = "isUnimportantEntry"
|
||||||
parameterCount = 1
|
parameterCount = 1
|
||||||
}?.hook()?.replaceAny {
|
}?.hook()?.replaceAny {
|
||||||
args().first().resolve().optional().firstMethodOrNull {
|
args().first().any()?.asResolver()?.optional()?.firstMethodOrNull {
|
||||||
name = "getSbn"
|
name = "getSbn"
|
||||||
superclass()
|
superclass()
|
||||||
}?.invoke<StatusBarNotification>()?.let { sbn ->
|
}?.invoke<StatusBarNotification>()?.let { sbn ->
|
||||||
|
@@ -48,9 +48,9 @@ libraries:
|
|||||||
version-ref: <this>::api
|
version-ref: <this>::api
|
||||||
com.highcapable.kavaref:
|
com.highcapable.kavaref:
|
||||||
kavaref-core:
|
kavaref-core:
|
||||||
version: 1.0.0
|
version: 1.0.1
|
||||||
kavaref-extension:
|
kavaref-extension:
|
||||||
version: 1.0.0
|
version: 1.0.1
|
||||||
com.github.topjohnwu.libsu:
|
com.github.topjohnwu.libsu:
|
||||||
core:
|
core:
|
||||||
version: 5.2.2
|
version: 5.2.2
|
||||||
|
Reference in New Issue
Block a user