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

Commit

Permalink
增加语音评论保存
Browse files Browse the repository at this point in the history
增加语音评论保存
  • Loading branch information
GangJust committed Jul 24, 2023
1 parent dfee82f commit 561d2a7
Show file tree
Hide file tree
Showing 22 changed files with 223 additions and 80 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 37
versionName "1.1.6-beta-1"
versionCode 44
versionName "1.1.7"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand Down
1 change: 1 addition & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
# 抖音
-dontwarn com.ss.android.ugc.aweme.**
-dontwarn com.ss.ugc.aweme.**
-dontwarn dmt.**
-dontwarn org.bouncycastle.jsse.BCSSLParameters
-dontwarn org.bouncycastle.jsse.BCSSLSocket
-dontwarn org.bouncycastle.jsse.provider.BouncyCastleJsseProvider
Expand Down
12 changes: 9 additions & 3 deletions app/src/main/assets/update.log
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
v1.1.7
增加语音评论保存
调整视频下载清晰度
调整抖音支持版本提示
修复图文下载问题

v1.1.6
增加抖音设置页模块入口
增加长按视频唤起模块菜单
Expand All @@ -21,13 +27,13 @@ v1.1.4
v1.1.3
适配抖音25.6.0、25.7.0、25.8.0、25.9.0
隐藏评论区我也发一张
修改清爽模式为半屏长按
迁移模块内置菜单
调整清爽模式为半屏长按
调整模块内置菜单
修复部分小问题

v1.1.2
适配抖音25.5.0
更换清爽模式切换逻辑
调整清爽模式切换逻辑
修复自定义文件名空白字符下载失败

v1.1.1
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.1.6-36
1.1.7-44
10 changes: 10 additions & 0 deletions app/src/main/java/com/freegang/fplus/activity/HomeActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import com.freegang.fplus.R
import com.freegang.fplus.Themes
import com.freegang.fplus.resource.StringRes
import com.freegang.fplus.viewmodel.HomeVM
import com.freegang.ktutils.app.KAppUtils
import com.freegang.ktutils.app.appVersionName
import com.freegang.ui.component.FCard
import com.freegang.ui.component.FMessageDialog
Expand Down Expand Up @@ -262,6 +263,7 @@ class HomeActivity : ComponentActivity() {
modifier = Modifier.align(Alignment.Center),
horizontalAlignment = Alignment.CenterHorizontally
) {
val packageInfo = KAppUtils.getPackageInfo(application, HookPackages.douYinPackageName)
val lspatchActive = HookStatus.isLspatchActive(application, HookPackages.douYinPackageName)
if (lspatchActive.isNotEmpty()) {
Text(
Expand Down Expand Up @@ -298,6 +300,14 @@ class HomeActivity : ComponentActivity() {
style = Themes.nowTypography.body1,
)
}
if (packageInfo != null) {
Spacer(modifier = Modifier.padding(vertical = 2.dp))
Text(
text = "抖音: ${packageInfo.versionName}" +
model.isSupportVersions(packageInfo.versionName),
style = Themes.nowTypography.body2,
)
}
}
},
)
Expand Down
12 changes: 12 additions & 0 deletions app/src/main/java/com/freegang/fplus/viewmodel/HomeVM.kt
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,16 @@ class HomeVM(application: Application) : AndroidViewModel(application) {
app.appVersionCode
)
}

fun isSupportVersions(versionName: String): String {
val list = listOf(
"23.5.0", "23.6.0", "23.7.0", "23.8.0", "23.9.0",
"24.0.0", "24.1.0", "24.2.0", "24.3.0", "24.4.0",
"24.5.0", "24.6.0", "24.7.0", "24.8.0", "24.9.0",
"25.0.0", "25.1.0", "25.2.0", "25.3.0", "25.4.0",
"25.5.0", "25.6.0", "25.7.0", "25.8.0", "25.9.0",
"26.0.0", "26.1.0", "26.2.0"
)
return if (list.contains(versionName)) "版本功能正常" else "自行测试功能"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.ss.android.ugc.aweme.comment.model;

public class Comment {

public String text;
public CommentAudioStruct commentAudio;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.ss.android.ugc.aweme.comment.model;

public class CommentAudioStruct {
public String content;

public Long duration;
public boolean isLocal;

public String vid;

public String wave;
}
2 changes: 1 addition & 1 deletion core/src/main/java/com/freegang/config/Version.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ object Version {

// 获取Github最后一次 releases
fun getRemoteReleasesLatest(): VersionConfig? {
if (null == null) return null //一般用作逻辑阻断
//if (null == null) return null //一般用作逻辑阻断

val get = KHttpUtils.get(githubReleasesApi)
if (get.isEmpty()) return null
Expand Down
1 change: 1 addition & 0 deletions core/src/main/java/com/freegang/douyin/DouYinMain.kt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class DouYinMain(private val app: Application) {
HFlippableViewPager(lpparam)
HVerticalViewPager(lpparam)
HDetailPageFragment(lpparam)
HCommentAudioView(lpparam)
HGifEmojiDetailActivity(lpparam)
HEmojiDetailDialog(lpparam)
HEmojiDetailDialogNew(lpparam)
Expand Down
91 changes: 91 additions & 0 deletions core/src/main/java/com/freegang/douyin/HCommentAudioView.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
package com.freegang.douyin

import android.view.ViewGroup
import android.widget.FrameLayout
import android.widget.ImageView
import android.widget.LinearLayout
import androidx.core.view.children
import com.freegang.base.BaseHook
import com.freegang.douyin.logic.SaveAudioLogic
import com.freegang.ktutils.display.dip2px
import com.freegang.ktutils.json.firstJsonObject
import com.freegang.ktutils.json.getJSONArrayOrDefault
import com.freegang.ktutils.json.getStringOrDefault
import com.freegang.ktutils.json.parseJSON
import com.freegang.ktutils.reflect.fieldGets
import com.freegang.ktutils.text.KTextUtils
import com.freegang.xpler.R
import com.freegang.xpler.core.KtXposedHelpers
import com.freegang.xpler.core.argsOrEmpty
import com.freegang.xpler.core.hookClass
import com.freegang.xpler.core.thisView
import com.ss.android.ugc.aweme.comment.model.Comment
import de.robv.android.xposed.callbacks.XC_LoadPackage

class HCommentAudioView(lpparam: XC_LoadPackage.LoadPackageParam) : BaseHook<Any>(lpparam) {
override fun setTargetClass(): Class<*> {
return findClass("com.ss.android.ugc.aweme.comment.audiocomment.ui.CommentAudioView")
}

override fun onInit() {
lpparam.hookClass(targetClazz)
.methodAll {
onAfter {
val result = runCatching {
if (argsOrEmpty.size != 4) return@onAfter
val value = args[1].fieldGets().filterNotNull().firstOrNull() ?: return@onAfter
val gets = value.fieldGets().filter { it?.javaClass?.`package`?.name == "X" }

var comment: Comment? = null
for (get in gets) {
if (get == null) continue
val fields = get.fieldGets(type = Comment::class.java)
if (fields.isEmpty()) continue
comment = fields.firstOrNull() as? Comment
}
if (comment == null) {
showToast(thisView.context, "未获取到评论内容")
return@onAfter
}

val content = comment.commentAudio.content
val contentJson = content.parseJSON()
val mainUrl = contentJson
.getJSONArrayOrDefault("video_list")
.firstJsonObject()
.getStringOrDefault("main_url")

if (mainUrl.isEmpty()) {
showToast(thisView.context, "未获取到语音内容")
return@onAfter
}

val frameLayout = thisView as FrameLayout
val linearLayout = frameLayout.children.first { it is LinearLayout } as LinearLayout


val find = linearLayout.children.find { "${it.contentDescription}" == "FAudioSave" }
if (find == null) {
ImageView(thisView.context).apply {
setImageDrawable(KtXposedHelpers.getDrawable(R.mipmap.ic_bubbles))
contentDescription = "FAudioSave"
layoutParams = ViewGroup.LayoutParams(context.dip2px(12f), context.dip2px(12f))
setOnClickListener {
SaveAudioLogic(
hook = this@HCommentAudioView,
context = it.context,
url = mainUrl,
filename = KTextUtils.get(comment.text, "${System.currentTimeMillis() / 1000}"),
)
}
linearLayout.addView(this)
}
}
}
if (result.isFailure) {
showToast(thisView.context, "保存失败,出现错误!")
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class HHomeSideBarEntranceManagerV1(lpparam: XC_LoadPackage.LoadPackageParam) :
if (sideRootView.children.last().contentDescription == "扩展功能") return@launch

val text = sideRootView.findViewsByType(TextView::class.java).firstOrNull() ?: return@launch
val isLight = KColorUtils.isDarkColor(text.currentTextColor)
val isDark = KColorUtils.isDarkColor(text.currentTextColor)

val setting = KtXposedHelpers.inflateView<ViewGroup>(v.context, R.layout.side_freedom_setting)
setting.contentDescription = "扩展功能"
Expand All @@ -61,7 +61,7 @@ class HHomeSideBarEntranceManagerV1(lpparam: XC_LoadPackage.LoadPackageParam) :
val iconColorRes: Int
val dividerColorRes: Int
val textColorRes: Int
if (isLight) {
if (!isDark) {
backgroundRes = R.drawable.dialog_background_night
iconColorRes = R.drawable.ic_freedom_night
dividerColorRes = Color.parseColor("#14FFFFFF")
Expand All @@ -77,10 +77,10 @@ class HHomeSideBarEntranceManagerV1(lpparam: XC_LoadPackage.LoadPackageParam) :
binding.freedomSettingText.setTextColor(textColorRes)
binding.freedomSettingDivider.setBackgroundColor(dividerColorRes)
binding.freedomSettingIcon.background = KtXposedHelpers.getDrawable(iconColorRes)
binding.freedomSettingTitle.text = "Freedom+"
binding.freedomSettingTitle.text = String.format("%s", "Freedom+")
binding.freedomSettingTitle.setTextColor(textColorRes)
binding.freedomSetting.setOnClickListener {
val intent = Intent(it.context, FreedomSettingActivity::class.java)
binding.freedomSetting.setOnClickListener { view ->
val intent = Intent(view.context, FreedomSettingActivity::class.java)
intent.putExtra("isDark", view.context.isDarkMode)
val options = ActivityOptions.makeCustomAnimation(
activity,
Expand Down
61 changes: 8 additions & 53 deletions core/src/main/java/com/freegang/douyin/HMainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import android.content.Intent
import android.graphics.Color
import android.net.Uri
import android.os.Bundle
import android.text.Html
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
Expand All @@ -23,7 +22,7 @@ import com.freegang.ktutils.app.appVersionName
import com.freegang.ktutils.app.contentView
import com.freegang.ktutils.app.isDarkMode
import com.freegang.ktutils.color.KColorUtils
import com.freegang.ktutils.reflect.findMethodAndInvoke
import com.freegang.ktutils.reflect.methodInvokes
import com.freegang.ktutils.view.KViewUtils
import com.freegang.ktutils.view.findViewsByDesc
import com.freegang.ktutils.view.findViewsByType
Expand All @@ -49,14 +48,6 @@ import kotlinx.coroutines.withContext
class HMainActivity(lpparam: XC_LoadPackage.LoadPackageParam) : BaseHook<MainActivity>(lpparam) {
private val config get() = ConfigV1.get()
private val clipboardLogic = ClipboardLogic(this)
private val supportVersions = listOf(
"23.5.0", "23.6.0", "23.7.0", "23.8.0", "23.9.0",
"24.0.0", "24.1.0", "24.2.0", "24.3.0", "24.4.0",
"24.5.0", "24.6.0", "24.7.0", "24.8.0", "24.9.0",
"25.0.0", "25.1.0", "25.2.0", "25.3.0", "25.4.0",
"25.5.0", "25.6.0", "25.7.0", "25.8.0", "25.9.0",
"26.0.0", "26.1.0"
)

@OnAfter("onCreate")
fun onCreate(it: XC_MethodHook.MethodHookParam, savedInstanceState: Bundle?) {
Expand All @@ -70,7 +61,6 @@ class HMainActivity(lpparam: XC_LoadPackage.LoadPackageParam) : BaseHook<MainAct
hookBlock(it) {
changeViewAlpha(thisActivity.contentView)
setFreedomSetting(thisActivity)
showSupportDialog(thisActivity)
//checkVersionDialog(thisActivity)
addClipboardListener(thisActivity)
}
Expand All @@ -97,10 +87,10 @@ class HMainActivity(lpparam: XC_LoadPackage.LoadPackageParam) : BaseHook<MainAct
}

if (aweme == null) {
val curFragment = activity.findMethodAndInvoke("getCurFragment")
val curFragment = activity.methodInvokes("getCurFragment").firstOrNull()
val curFragmentMethods = curFragment?.findMethodsByReturnType(Aweme::class.java) ?: listOf()
if (curFragmentMethods.isNotEmpty()) {
aweme = curFragmentMethods.first().call(curFragment!!)
aweme = curFragmentMethods.first().invoke(curFragment!!)
}
}
return aweme as Aweme?
Expand Down Expand Up @@ -135,7 +125,7 @@ class HMainActivity(lpparam: XC_LoadPackage.LoadPackageParam) : BaseHook<MainAct
if (sideRootView.children.last().contentDescription == "扩展功能") return@launch

val text = sideRootView.findViewsByType(TextView::class.java).firstOrNull() ?: return@launch
val isLight = KColorUtils.isDarkColor(text.currentTextColor)
val isDark = KColorUtils.isDarkColor(text.currentTextColor)

val setting = KtXposedHelpers.inflateView<ViewGroup>(v.context, R.layout.side_freedom_setting)
setting.contentDescription = "扩展功能"
Expand All @@ -145,7 +135,7 @@ class HMainActivity(lpparam: XC_LoadPackage.LoadPackageParam) : BaseHook<MainAct
val iconColorRes: Int
val dividerColorRes: Int
val textColorRes: Int
if (isLight) {
if (!isDark) {
backgroundRes = R.drawable.dialog_background_night
iconColorRes = R.drawable.ic_freedom_night
dividerColorRes = Color.parseColor("#14FFFFFF")
Expand All @@ -161,10 +151,10 @@ class HMainActivity(lpparam: XC_LoadPackage.LoadPackageParam) : BaseHook<MainAct
binding.freedomSettingText.setTextColor(textColorRes)
binding.freedomSettingDivider.setBackgroundColor(dividerColorRes)
binding.freedomSettingIcon.background = KtXposedHelpers.getDrawable(iconColorRes)
binding.freedomSettingTitle.text = "Freedom+"
binding.freedomSettingTitle.text = String.format("%s", "Freedom+")
binding.freedomSettingTitle.setTextColor(textColorRes)
binding.freedomSetting.setOnClickListener {
val intent = Intent(it.context, FreedomSettingActivity::class.java)
binding.freedomSetting.setOnClickListener { view ->
val intent = Intent(view.context, FreedomSettingActivity::class.java)
intent.putExtra("isDark", view.context.isDarkMode)
val options = ActivityOptions.makeCustomAnimation(
activity,
Expand Down Expand Up @@ -193,41 +183,6 @@ class HMainActivity(lpparam: XC_LoadPackage.LoadPackageParam) : BaseHook<MainAct
}
}

//抖音版本(版本是否兼容提示)
@Synchronized
private fun showSupportDialog(activity: Activity) {
val versionName = activity.appVersionName
val versionCode = activity.appVersionCode

//此版本是否继续提示
if (!config.isSupportHint
&& versionCode == config.versionConfig.dyVersionCode
&& versionName == config.versionConfig.dyVersionName
) {
return
}

launch {
delay(2000L)
showMessageDialog(
context = activity,
title = "Freedom+",
content = Html.fromHtml(
"""当前抖音版本为: <span style='color:#F56C6C;'>${versionName}</span><br/>
Freedom+最小兼容以下版本:<br/>
${supportVersions.joinToString(", ") { s -> if (s == versionName) "<span style='color:#F56C6C;'>$s</span>" else s }}<br/>
适配列表仅作为参考,请自行测试各项功能!
""".trimIndent()
),
cancel = "此版本不再提示",
confirm = "确定",
onCancel = {
saveConfig(activity)
}
)
}
}

//检查模块版本
@Synchronized
private fun checkVersionDialog(activity: Activity) {
Expand Down
Loading

0 comments on commit 561d2a7

Please sign in to comment.