Skip to content
This repository has been archived by the owner on Oct 14, 2024. It is now read-only.

Commit

Permalink
fix recalled hint
Browse files Browse the repository at this point in the history
  • Loading branch information
GangJust committed Jul 5, 2024
1 parent af770b9 commit 4b4dbf9
Show file tree
Hide file tree
Showing 30 changed files with 1,675 additions and 88 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ android {
applicationId "io.github.fplus"
minSdk 24
targetSdk 33
versionCode 135
versionName "1.3.3"
versionCode 138
versionName "1.3.4"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/assets/update.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
v1.3.4
修复高版本已撤回提示文本不显示问题
修复部分已知问题

v1.3.3
修复高版本评论区颜色不跟随主题问题
修复部分已知问题
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/assets/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.3.3-135
1.3.4-138
5 changes: 4 additions & 1 deletion app/src/main/java/io/github/fplus/activity/ErrorActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ import io.github.fplus.FreedomTheme
import io.github.fplus.R
import io.github.fplus.Themes
import io.github.fplus.core.ui.component.ScrollableContainer
import io.github.fplus.resource.IconRes
import io.github.fplus.resource.StringRes
import io.github.fplus.resource.icons.Acute
import kotlin.system.exitProcess

class ErrorActivity : ComponentActivity() {
Expand Down Expand Up @@ -64,7 +66,8 @@ class ErrorActivity : ComponentActivity() {
)
}
Icon(
painter = painterResource(R.drawable.ic_acute),
// painter = painterResource(R.drawable.ic_acute),
imageVector = IconRes.Acute,
contentDescription = "分享",
tint = Themes.nowColors.icon,
modifier = Modifier
Expand Down
22 changes: 14 additions & 8 deletions app/src/main/java/io/github/fplus/activity/HomeActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.rotate
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.text.withStyle
Expand All @@ -63,12 +62,19 @@ import com.freegang.ktutils.log.KLogCat
import io.github.fplus.Constant
import io.github.fplus.FreedomTheme
import io.github.fplus.HookStatus
import io.github.fplus.R
import io.github.fplus.Themes
import io.github.fplus.core.config.ConfigV1
import io.github.fplus.core.ui.component.FCard
import io.github.fplus.core.ui.component.FMessageDialog
import io.github.fplus.resource.IconRes
import io.github.fplus.resource.StringRes
import io.github.fplus.resource.icons.FindFile
import io.github.fplus.resource.icons.Github
import io.github.fplus.resource.icons.Motion
import io.github.fplus.resource.icons.SpicyStrips
import io.github.fplus.resource.icons.Telegram
import io.github.fplus.resource.icons.Visibility
import io.github.fplus.resource.icons.VisibilityOff
import io.github.fplus.viewmodel.HomeVM
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
Expand Down Expand Up @@ -142,7 +148,7 @@ class HomeActivity : ComponentActivity() {
)
}
Icon(
painter = painterResource(id = if (visible) R.drawable.ic_visibility else R.drawable.ic_visibility_off),
imageVector = if (visible) IconRes.Visibility else IconRes.VisibilityOff,
contentDescription = "显示/隐藏图标",
tint = Themes.nowColors.icon,
modifier = Modifier
Expand All @@ -162,7 +168,7 @@ class HomeActivity : ComponentActivity() {
)
Spacer(modifier = Modifier.padding(horizontal = 12.dp))
Icon(
painter = painterResource(id = R.drawable.ic_motion),
imageVector = IconRes.Motion,
contentDescription = "检查更新/日志",
tint = Themes.nowColors.icon,
modifier = Modifier
Expand Down Expand Up @@ -458,7 +464,7 @@ class HomeActivity : ComponentActivity() {
) {
Icon(
modifier = Modifier.size(24.dp),
painter = painterResource(id = R.drawable.ic_find_file),
imageVector = IconRes.FindFile,
contentDescription = "下载目录",
tint = Themes.nowColors.icon,
)
Expand Down Expand Up @@ -495,7 +501,7 @@ class HomeActivity : ComponentActivity() {
verticalAlignment = Alignment.CenterVertically,
) {
Icon(
painter = painterResource(id = R.drawable.ic_github),
imageVector = IconRes.Github,
contentDescription = "Github",
tint = Themes.nowColors.icon,
modifier = Modifier.size(24.dp)
Expand Down Expand Up @@ -571,7 +577,7 @@ class HomeActivity : ComponentActivity() {
verticalAlignment = Alignment.CenterVertically,
) {
Icon(
painter = painterResource(id = R.drawable.ic_telegram),
imageVector = IconRes.Telegram,
contentDescription = "Telegram频道",
tint = Themes.nowColors.icon,
modifier = Modifier.size(24.dp)
Expand Down Expand Up @@ -609,7 +615,7 @@ class HomeActivity : ComponentActivity() {
verticalAlignment = Alignment.CenterVertically,
) {
Icon(
painter = painterResource(id = R.drawable.ic_spicy_strips),
imageVector = IconRes.SpicyStrips,
contentDescription = "请我吃辣条",
tint = Themes.nowColors.icon,
modifier = Modifier.size(24.dp)
Expand Down
27 changes: 27 additions & 0 deletions aweme/src/main/java/com/bytedance/im/core/model/Message.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,31 @@
package com.bytedance.im.core.model;

import java.util.Map;

public class Message {


public final byte[] getContentByte() {
throw new RuntimeException("stub!!");
}

public final Object getContentObj() {
throw new RuntimeException("stub!!");
}

public final String getContent() {
throw new RuntimeException("stub!!");
}

public final String getExtStr() {
throw new RuntimeException("stub!!");
}

public final Map<String, String> getExt() {
throw new RuntimeException("stub!!");
}

public final boolean isSelf() {
throw new RuntimeException("stub!!");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ object AutoPlayHelper {

fun openAutoPlay(context: Context) {
runCatching {
val controllerGetFiled = DexkitBuilder.autoPlayControllerClazz?.fields?.firstOrNull { Modifier.isStatic(it.modifiers) }
val controllerGetFiled =
DexkitBuilder.autoPlayControllerClazz?.fields?.firstOrNull { Modifier.isStatic(it.modifiers) }
val controllerGet = controllerGetFiled?.get(null)
val controller = controllerGet?.findMethodInvoke<Any>(context) {
parameterTypes(listOf(Context::class.java))
Expand Down
28 changes: 28 additions & 0 deletions core/src/main/java/io/github/fplus/core/helper/DexkitBuilder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ object DexkitBuilder {
var emojiPopupWindowClazz: Class<*>? = null
var bottomCtrlBarClazz: Class<*>? = null
var chatListRecyclerViewAdapterClazz: Class<*>? = null
var chatListRecyclerViewAdapterNewClazz: Class<*>? = null
var chatListRecalledHintClazz: Class<*>? = null
var restartUtilsClazz: Class<*>? = null
var longPressEventClazz: Class<*>? = null
Expand Down Expand Up @@ -433,6 +434,32 @@ object DexkitBuilder {
}
chatListRecyclerViewAdapterClazz = chatListRecyclerViewAdapter.instance("chatListRecyclerViewAdapter")

val chatListRecyclerViewAdapterNew = bridge.findClass {
// searchPackages("X")
matcher {
addField {
type = "com.ss.android.ugc.aweme.im.sdk.chat.SessionInfo"
}

addMethod {
returnType = "com.ss.android.ugc.aweme.rips.InjectionAware"
}

addMethod {
name = "getItemId"
}

addMethod {
name = "getItemCount"
}

addMethod {
name = "onCreateViewHolder"
}
}
}
chatListRecyclerViewAdapterNewClazz = chatListRecyclerViewAdapterNew.instance("chatListRecyclerViewAdapterNew")

val chatListRecalledHint = bridge.findClass {
matcher {
fields {
Expand Down Expand Up @@ -727,6 +754,7 @@ object DexkitBuilder {
detailPageFragmentClazz = classCache.getStringOrDefault("detailPageFragment").loadOrFindClass()
bottomCtrlBarClazz = classCache.getStringOrDefault("bottomCtrlBar").loadOrFindClass()
chatListRecyclerViewAdapterClazz = classCache.getStringOrDefault("chatListRecyclerViewAdapter").loadOrFindClass()
chatListRecyclerViewAdapterNewClazz = classCache.getStringOrDefault("chatListRecyclerViewAdapterNew").loadOrFindClass()
chatListRecalledHintClazz = classCache.getStringOrDefault("chatListRecalledHint").loadOrFindClass()
restartUtilsClazz = classCache.getStringOrDefault("restartUtils").loadOrFindClass()
longPressEventClazz = classCache.getStringOrDefault("longPressEvent").loadOrFindClass()
Expand Down
8 changes: 3 additions & 5 deletions core/src/main/java/io/github/fplus/core/hook/DouYinMain.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,15 @@ class DouYinMain(private val app: Application) {
val intent = Intent()
val className = "${Constant.modulePackage}.activity.ErrorActivity"
intent.setClassName(Constant.modulePackage, className)
KAppCrashUtils.init(app, "抖音异常退出!", intent) { e, m ->
KActivityUtils.unregister(app)
true
}
KAppCrashUtils.init(app, "抖音异常退出!", intent)

// 定时退出
initTimedShutdown(app)

// search and hook
DexkitBuilder.running(
app = app,
version = 26,
version = 30,
searchBefore = {
HPhoneWindow()
HActivity()
Expand Down Expand Up @@ -92,6 +89,7 @@ class DouYinMain(private val app: Application) {
HBottomCtrlBar()
HMessage()
HChatListRecyclerViewAdapter()
HChatListRecyclerViewAdapterNew()
HChatListRecalledHint()
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@ package io.github.fplus.core.hook
import android.annotation.SuppressLint
import android.graphics.Color
import android.view.Gravity
import android.view.View
import android.view.ViewGroup
import android.widget.FrameLayout
import android.widget.TextView
import androidx.core.view.children
import androidx.core.view.isVisible
import com.bytedance.im.core.model.Message
import com.freegang.extension.asOrNull
import com.freegang.extension.findFieldGetValue
import com.freegang.extension.firstOrNull
import com.freegang.extension.idName
import com.freegang.extension.findMethodInvoke
import com.freegang.extension.parentView
import de.robv.android.xposed.XC_MethodHook
import io.github.fplus.core.base.BaseHook
Expand All @@ -29,65 +27,67 @@ class HChatListRecyclerViewAdapter : BaseHook() {
const val TAG = "HChatListRecyclerViewAdapter"
}

private val config get() = ConfigV1.get()
private val recallMsgId = View.generateViewId()

private val config get() = ConfigV1.get()

override fun setTargetClass(): Class<*> {
return DexkitBuilder.chatListRecyclerViewAdapterClazz ?: NoneHook::class.java
}

@SuppressLint("SetTextI18n")
@OnAfter("onBindViewHolder")
fun onBindViewHolderAfter(params: XC_MethodHook.MethodHookParam) {
@OnAfter("onCreateViewHolder")
fun onCreateViewHolderAfter(
params: XC_MethodHook.MethodHookParam,
parent: ViewGroup,
viewType: Int,
) {
hookBlockRunning(params) {
if (!config.isPreventRecalled) {
return
}

val itemView = args[0]?.findFieldGetValue<FrameLayout> { name("itemView") } ?: return

val vh = result
val itemView = vh.findFieldGetValue<ViewGroup> { name("itemView") }
val contentContainer = itemView
?.firstOrNull(ViewGroup::class.java) { it.idName == "@id/content" }
?.parentView

val message = args[0]?.findMethodInvoke<Message> {
returnType(Message::class.java, true)
predicate {
it.parameterTypes.isEmpty()
}
contentContainer?.run {
val textView = TextView(context)
textView.id = recallMsgId
textView.setTextColor(Color.GRAY)
textView.textSize = 10f
textView.isVisible = false
textView.gravity = Gravity.CENTER
addView(textView)
}
}.onFailure {
XplerLog.tagE(HChatListRecyclerViewAdapterNew.TAG, it)
}
}

val ext = message?.findMethodInvoke<Map<String, String>> { name(("getExt")) } ?: return
val isSelf = message.findMethodInvoke<Boolean> { name("isSelf") }
@SuppressLint("SetTextI18n")
@OnAfter("onBindViewHolder")
fun onBindViewHolderAfter(params: XC_MethodHook.MethodHookParam) {
hookBlockRunning(params) {
if (!config.isPreventRecalled) {
return
}

val addedFlag = "RecalledHint"
val viewGroup = itemView
.firstOrNull(ViewGroup::class.java) { it.idName == "@id/content" }
?.parentView
?: return
val vh = args[0] // ViewHolder
val itemView = args[0]?.findFieldGetValue<FrameLayout> { name("itemView") } ?: return
val recallMsg = itemView.findViewById<TextView>(recallMsgId) ?: return

val last = viewGroup.children.last()
if (last.tag != addedFlag) {
val view = TextView(itemView.context)
view.text = "已撤回"
view.setTextColor(Color.GRAY)
view.textSize = 12f
view.isVisible = false
view.gravity = Gravity.CENTER
view.tag = addedFlag
viewGroup.addView(view)
}
val message = vh.findFieldGetValue<Message> { type(Message::class.java, true) }
?: throw NullPointerException("message is null.")

if (ext.containsKey("f:prevent_recalled")) {
if (last.tag == addedFlag) {
last.isVisible = true
last.asOrNull<TextView>()?.gravity = if (isSelf == true) {
Gravity.START
} else {
Gravity.END
}
}
if (message.ext.containsKey("f:prevent_recalled")) {
recallMsg.gravity = if (message.isSelf) Gravity.START else Gravity.END
recallMsg.isVisible = true
recallMsg.text = "已撤回"
} else {
if (last.tag == addedFlag) {
last.isVisible = false
}
recallMsg.isVisible = false
recallMsg.text = ""
}
}.onFailure {
XplerLog.e(it)
Expand Down
Loading

0 comments on commit 4b4dbf9

Please sign in to comment.