This repository has been archived by the owner on Oct 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
增加语音评论保存
- Loading branch information
Showing
22 changed files
with
223 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
1.1.6-36 | ||
1.1.7-44 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
aweme/src/main/java/com/ss/android/ugc/aweme/comment/model/Comment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
12 changes: 12 additions & 0 deletions
12
aweme/src/main/java/com/ss/android/ugc/aweme/comment/model/CommentAudioStruct.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
core/src/main/java/com/freegang/douyin/HCommentAudioView.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, "保存失败,出现错误!") | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.