Skip to content

Commit

Permalink
适配抖音25.2.0
Browse files Browse the repository at this point in the history
适配抖音25.2.0
  • Loading branch information
GangJust committed May 3, 2023
1 parent d41a8a9 commit 72ce499
Show file tree
Hide file tree
Showing 20 changed files with 162 additions and 388 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 "com.freegang.fplus"
minSdk 24
targetSdk 33
versionCode 12
versionName "1.0.9"
versionCode 13
versionName "1.1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand Down
9 changes: 8 additions & 1 deletion app/src/main/assets/update.log
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,11 @@ minSdk更改为24
致谢@LuckyPray/DexKit

v1.0.9
视频/图文下载文件名账号问题
视频/图文下载文件名账号问题

v1.1.0
适配抖音25.2.0
修复好友分享内容顶部被重构
修复首页顶部tab切换时半透明丢失
修复底部弹层样式表情包无法保存
适配列表仅作为参考,请自行测试各项功能
4 changes: 0 additions & 4 deletions app/src/main/java/com/freegang/fplus/activity/HomeActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ import androidx.compose.ui.draw.rotate
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.core.content.FileProvider
import androidx.documentfile.provider.DocumentFile
import androidx.lifecycle.lifecycleScope
import com.freegang.fplus.FreedomTheme
import com.freegang.fplus.R
Expand All @@ -35,11 +33,9 @@ import com.freegang.fplus.resource.StringRes
import com.freegang.fplus.viewmodel.HomeVM
import com.freegang.xpler.HookStatus
import com.freegang.xpler.utils.app.appVersionName
import com.freegang.xpler.utils.io.storageRootPath
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import java.io.File
import kotlin.random.Random


Expand Down
20 changes: 15 additions & 5 deletions core/src/main/java/com/freegang/douyin/DouYinMain.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ import com.freegang.xpler.utils.log.KLogCat
import com.ss.android.ugc.aweme.app.host.AwemeHostApplication
import de.robv.android.xposed.callbacks.XC_LoadPackage
import io.luckypray.dexkit.DexKitBridge
import java.lang.reflect.Method

class DouYinMain(lpparam: XC_LoadPackage.LoadPackageParam) : BaseHook<EmptyHook>(lpparam) {
companion object {
private var _commonPageFragment: Class<*>? = null
val commonPageFragment get() = _commonPageFragment!!
var commonPageClazz: Class<*>? = null
var emojiMethods: List<Method> = emptyList()
}

override fun onInit() {
Expand Down Expand Up @@ -59,10 +60,19 @@ class DouYinMain(lpparam: XC_LoadPackage.LoadPackageParam) : BaseHook<EmptyHook>
private fun initDexKit() {
System.loadLibrary("dexkit")
DexKitBridge.create(lpparam.appInfo.sourceDir)?.use { bridge ->
val findMaps = bridge.batchFindClassesUsingStrings {
addQuery("CommonPageFragment", setOf("a1128.b7947", "DetailActOtherNitaView"))
if (commonPageClazz == null) {
val findMaps = bridge.batchFindClassesUsingStrings {
addQuery("CommonPage", setOf("a1128.b7947", "DetailActOtherNitaView"))
}
commonPageClazz = findMaps["CommonPage"]?.firstOrNull()?.getClassInstance(lpparam.classLoader)
}

if (emojiMethods.isEmpty()) {
emojiMethods = bridge.findMethod {
methodReturnType = "V"
methodParamTypes = arrayOf("Lcom/ss/android/ugc/aweme/emoji/model/Emoji;")
}.filter { it.isMethod }.map { it.getMethodInstance(lpparam.classLoader) }
}
_commonPageFragment = findMaps["CommonPageFragment"]?.first()?.getClassInstance(lpparam.classLoader)
}
}
}
220 changes: 0 additions & 220 deletions core/src/main/java/com/freegang/douyin/HAbsActivity.kt

This file was deleted.

13 changes: 7 additions & 6 deletions core/src/main/java/com/freegang/douyin/HCommonPageFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import com.freegang.base.BaseHook
import com.freegang.douyin.logic.SaveCommentLogic
import com.freegang.xpler.R
import com.freegang.xpler.core.KtXposedHelpers
import com.freegang.xpler.core.NoneHook
import com.freegang.xpler.core.OnAfter
import com.freegang.xpler.core.call
import com.freegang.xpler.core.findMethodsByReturnType
Expand All @@ -20,24 +21,24 @@ import de.robv.android.xposed.callbacks.XC_LoadPackage
import kotlinx.coroutines.delay

class HCommonPageFragment(lpparam: XC_LoadPackage.LoadPackageParam) : BaseHook<Any>(lpparam) {
override fun setTargetClass(): Class<*> = DouYinMain.commonPageFragment
override fun setTargetClass(): Class<*> = DouYinMain.commonPageClazz ?: NoneHook::class.java

@OnAfter("onViewCreated")
fun onViewCreatedAfter(param: XC_MethodHook.MethodHookParam, view: View, bundle: Bundle?) {
hookBlock(param) {
rebuildDetailFragmentTopBarView(thisObject, view as ViewGroup)
rebuildTopBarView(thisObject, view as ViewGroup)
}
}

private fun rebuildDetailFragmentTopBarView(thisObject: Any, view: ViewGroup) {
private fun rebuildTopBarView(thisObject: Any, view: ViewGroup) {
launch {
delay(200L)

val methods = thisObject.findMethodsByReturnType(Aweme::class.java)
val aweme = methods.first().call<Aweme>(thisObject) ?: return@launch
val aweme = methods.firstOrNull()?.call<Aweme>(thisObject) ?: return@launch

// awemeType 【134:评论区图片, 133:评论区视频, 0:主页视频详情, 68:主页图文详情】 by 25.1.0
if (aweme.awemeType == 0 || aweme.awemeType == 68) return@launch
// awemeType 【134:评论区图片, 133:评论区视频, 0:主页视频详情, 68:主页图文详情, 13:好友分享视频/图文】 by 25.1.0、25.2.0
if (aweme.awemeType == 0 || aweme.awemeType == 68 || aweme.awemeType == 13) return@launch

val views = KViewUtils.findViewsByDesc(view, ImageView::class.java, "返回")
if (views.isEmpty()) return@launch
Expand Down
8 changes: 4 additions & 4 deletions core/src/main/java/com/freegang/douyin/HEmojiDetailDialog.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import com.freegang.xpler.core.findFieldByType
import com.freegang.xpler.core.getObjectField
import com.freegang.xpler.core.hookClass
import com.freegang.xpler.core.hookMethodAll
import com.freegang.xpler.core.toClass
import com.freegang.xpler.utils.app.KActivityUtils.contentView
import com.freegang.xpler.utils.view.KViewUtils
import com.ss.android.ugc.aweme.base.model.UrlModel
import com.ss.android.ugc.aweme.emoji.store.view.EmojiBottomSheetDialog
import com.ss.android.ugc.aweme.emoji.views.EmojiDetailDialog
import de.robv.android.xposed.XC_MethodHook
Expand All @@ -28,8 +28,7 @@ class HEmojiDetailDialog(lpparam: XC_LoadPackage.LoadPackageParam) : BaseHook<Em
if (!config.isEmoji) return@onAfter
if (urlList.isNotEmpty()) return@onAfter

val clazz = "com.ss.android.ugc.aweme.base.model.UrlModel".toClass(lpparam.classLoader)!!
val fields = thisObject.findFieldByType(clazz)
val fields = thisObject.findFieldByType(UrlModel::class.java)
if (fields.isNotEmpty()) {
val urlModel = fields.first().get(thisObject)
urlList = urlModel?.getObjectField<List<String>>("urlList") ?: listOf()
Expand All @@ -50,10 +49,11 @@ class HEmojiDetailDialog(lpparam: XC_LoadPackage.LoadPackageParam) : BaseHook<Em
hookBlock(it) {
if (!targetClazz.isInstance(thisObject)) return //非 EmojiDetailDialog, 直接结束
launch {
delay(200L)
delay(500L)

//重新构建当前视图
val emojiDialog = thisObject as EmojiDetailDialog
if (urlList.isEmpty()) return@launch

val contentView = emojiDialog.window?.contentView ?: return@launch
val views = KViewUtils.findViewsExact(contentView, TextView::class.java) { it.text.contains("添加") }
Expand Down
Loading

0 comments on commit 72ce499

Please sign in to comment.