From b6a73d46291d0e14e28448ae420500530710f009 Mon Sep 17 00:00:00 2001 From: KawaiiZapic <577358285@qq.com> Date: Tue, 18 Jul 2023 16:12:34 +0800 Subject: [PATCH] fix(messaging-style): apply missing patches --- .../util/NonNTMessageStyleNotification.kt | 4 +-- .../zapic/hook/MessagingStyleNotification.kt | 34 +++++++++++-------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/me/singleneuron/util/NonNTMessageStyleNotification.kt b/app/src/main/java/me/singleneuron/util/NonNTMessageStyleNotification.kt index 5e54bed47f..cd90f81cd7 100644 --- a/app/src/main/java/me/singleneuron/util/NonNTMessageStyleNotification.kt +++ b/app/src/main/java/me/singleneuron/util/NonNTMessageStyleNotification.kt @@ -248,14 +248,14 @@ class NonNTMessageStyleNotification(private val parent: MessagingStyleNotificati if (uinType != -1) { param.result = null val uin = intent.getStringExtra("TO_UIN") ?: return - val result = RemoteInput.getResultsFromIntent(intent)?.getString("KEY_REPLY") ?: return + val result = RemoteInput.getResultsFromIntent(intent)?.getCharSequence("KEY_REPLY") ?: return val selfUin = AppRuntimeHelper.getAccount() // send message ChatActivityFacade.sendMessage( AppRuntimeHelper.getQQAppInterface(), hostInfo.application, SessionInfoImpl.createSessionInfo(uin, uinType), - result + result.toString() ) // update exist notification diff --git a/app/src/main/java/moe/zapic/hook/MessagingStyleNotification.kt b/app/src/main/java/moe/zapic/hook/MessagingStyleNotification.kt index 5571ebee24..27e6c118cb 100644 --- a/app/src/main/java/moe/zapic/hook/MessagingStyleNotification.kt +++ b/app/src/main/java/moe/zapic/hook/MessagingStyleNotification.kt @@ -88,12 +88,12 @@ object MessagingStyleNotification : CommonSwitchFunctionHook(SyncUtils.PROC_ANY) if (!HostInfo.requireMinQQVersion(QQVersion.QQ_8_9_63)) { return NonNTMessageStyleNotification(this).hook() } - val cNotificationFacede = "com.tencent.qqnt.notification.NotificationFacade".clazz!! + val cNotificationFacade = "com.tencent.qqnt.notification.NotificationFacade".clazz!! val cAppRuntime = "mqq.app.AppRuntime".clazz!! val cCommonInfo = "com.tencent.qqnt.kernel.nativeinterface.NotificationCommonInfo".clazz!! val cRecentInfo = "com.tencent.qqnt.kernel.nativeinterface.RecentContactInfo".clazz!! val postNotification = Reflex.findSingleMethod( - cNotificationFacede, + cNotificationFacade, null, false, Notification::class.java, @@ -101,7 +101,7 @@ object MessagingStyleNotification : CommonSwitchFunctionHook(SyncUtils.PROC_ANY) ) lateinit var buildNotification: Method lateinit var recentInfoBuilder: Method - cNotificationFacede.declaredMethods.forEach { + cNotificationFacade.declaredMethods.forEach { if (it.parameterTypes.size != 3) return@forEach if (it.parameterTypes[0] != cAppRuntime) return@forEach if (it.parameterTypes[2] == cCommonInfo) { @@ -143,19 +143,23 @@ object MessagingStyleNotification : CommonSwitchFunctionHook(SyncUtils.PROC_ANY) var groupIcon: IconCompat? = null // 好友消息 - if (info.chatType == 1) { - senderIcon = IconCompat.createFromIcon(hostInfo.application, oldNotification.getLargeIcon()) ?: IconCompat.createWithBitmap(ResUtils.loadDrawableFromAsset("face.png", context).toBitmap()) - shortcut = getShortcut("private_$senderUin", senderName, senderIcon, pair.second) - } else if (info.chatType == 2) { - groupName = info.peerName ?: return@hookBeforeIfEnabled - groupUin = info.peerUin ?: return@hookBeforeIfEnabled + when (info.chatType) { + 1 -> { + senderIcon = IconCompat.createFromIcon(hostInfo.application, oldNotification.getLargeIcon()) ?: IconCompat.createWithBitmap(ResUtils.loadDrawableFromAsset("face.png", context).toBitmap()) + shortcut = getShortcut("private_$senderUin", senderName, senderIcon, pair.second) + } + 2 -> { + groupName = info.peerName ?: return@hookBeforeIfEnabled + groupUin = info.peerUin ?: return@hookBeforeIfEnabled - senderIcon = avatarHelper.getAvatar(senderUin.toString()) ?: IconCompat.createWithBitmap(ResUtils.loadDrawableFromAsset("face.png", context).toBitmap()) - groupIcon = IconCompat.createFromIcon(hostInfo.application, oldNotification.getLargeIcon()) ?: IconCompat.createWithBitmap(ResUtils.loadDrawableFromAsset("face.png", context).toBitmap()) - shortcut = getShortcut("group_$groupUin", groupName, groupIcon, pair.second) - } else { - // Impossible - throw Error("what the hell?") + senderIcon = avatarHelper.getAvatar(senderUin.toString()) ?: IconCompat.createWithBitmap(ResUtils.loadDrawableFromAsset("face.png", context).toBitmap()) + groupIcon = IconCompat.createFromIcon(hostInfo.application, oldNotification.getLargeIcon()) ?: IconCompat.createWithBitmap(ResUtils.loadDrawableFromAsset("face.png", context).toBitmap()) + shortcut = getShortcut("group_$groupUin", groupName, groupIcon, pair.second) + } + else -> { + // Impossible + throw Error("what the hell?") + } } val notification = createNotification( content,