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 Sep 6, 2023
1 parent 4643c78 commit 94bafd2
Show file tree
Hide file tree
Showing 11 changed files with 186 additions and 19 deletions.
28 changes: 24 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ plugins {

android {
namespace 'com.freegang.fplus'
compileSdk 33
compileSdk 34

defaultConfig {
applicationId "com.freegang.fplus"
minSdk 24
targetSdk 33
versionCode 50
versionName "1.1.8"
targetSdk 34
versionCode 52
versionName "1.1.9"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand Down Expand Up @@ -55,6 +55,26 @@ android {
excludes += '/META-INF/{AL2.0,LGPL2.1}'
}
}

// 更新version的内容
tasks.register('updateVersionFile') {
def versionName = android.defaultConfig.versionName
def versionCode = android.defaultConfig.versionCode
def versionContent = "${versionName}-${versionCode}"

File versionFile = file("src/main/assets/version")
versionFile.write(versionContent)
}

//执行task任务
applicationVariants.configureEach { variant ->
variant.assembleProvider.get().dependsOn updateVersionFile

variant.outputs.configureEach { output ->
def filename = "freedom+_${android.defaultConfig.versionName}.apk"
output.outputFileName filename
}
}
}

dependencies {
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/assets/update.log
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
v1.1.9
增加隐藏群聊底部分享卡片
修复部分已知问题

v1.1.8
增加模块图标隐藏
增加WebDav多配置
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.8-47
1.1.9-52
5 changes: 2 additions & 3 deletions app/src/main/java/com/freegang/fplus/viewmodel/HomeVM.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.freegang.fplus.viewmodel

import android.app.Application
import android.content.res.AssetManager
import android.os.Environment
import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.LiveData
Expand All @@ -11,9 +10,7 @@ import com.freegang.config.ConfigV1
import com.freegang.config.Version
import com.freegang.config.VersionConfig
import com.freegang.ktutils.app.KAppUtils
import com.freegang.ktutils.app.appVersionCode
import com.freegang.ktutils.app.appVersionName
import com.freegang.ktutils.app.readAssetsAsText
import com.freegang.ktutils.io.child
import com.freegang.ktutils.io.storageRootFile
import kotlinx.coroutines.Dispatchers
Expand Down Expand Up @@ -56,6 +53,8 @@ class HomeVM(application: Application) : AndroidViewModel(application) {

// 获取远程版本适配列表
fun updateVersions() {
if (KAppUtils.isAppInDebug(app)) return //测试包不检查更新
if (app.appVersionName.contains(Regex("beta|alpha"))) return //非release包不检查更新
viewModelScope.launch {
withContext(Dispatchers.IO) {
val versions = Version.getVersions() ?: return@withContext
Expand Down
1 change: 0 additions & 1 deletion core/src/main/java/com/freegang/config/Version.kt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ object Version {
// 获取适配版本列表
fun getVersions(): String? {
return try {
//if (null == null) return null //一般用作逻辑阻断
val body = KHttpUtils.get(githubVersionApi)
val content = body.parseJSON().getString("content")
Base64.decode(content, Base64.DEFAULT).toString(Charsets.UTF_8)
Expand Down
17 changes: 17 additions & 0 deletions core/src/main/java/com/freegang/hook/DouYinMain.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class DouYinMain(private val app: Application) {
var detailPageFragmentClazz: Class<*>? = null
var videoPinchClazz: Class<*>? = null
var emojiMethods: List<Method> = emptyList()
var ripsChatRoomFragmentClazz: Class<*>? = null

var timedExitCountDown: CountDownTimer? = null
var freeExitCountDown: CountDownTimer? = null
Expand Down Expand Up @@ -79,6 +80,7 @@ class DouYinMain(private val app: Application) {
HEmojiDetailDialogNew(lpparam)
HHomeSideBarEntranceManagerV1(lpparam)
HDouYinSettingNewVersionActivity(lpparam)
HChatRoomActivity(lpparam)
}.onFailure {
KToastUtils.show(app, "Freedom+ Error: ${it.message}")
}
Expand Down Expand Up @@ -123,6 +125,21 @@ class DouYinMain(private val app: Application) {
methodParamTypes = arrayOf("Lcom/ss/android/ugc/aweme/emoji/model/Emoji;")
}.filter { it.isMethod }.map { it.getMethodInstance(lpparam.classLoader) }
}

if (ripsChatRoomFragmentClazz == null) {
val findMaps = bridge.batchFindClassesUsingStrings {
addQuery(
"RipsChatRoomFragment",
setOf(
"com/ss/android/ugc/aweme/im/sdk/chat/rips/RipsChatRoomFragment",
"RipsChatRoomFragment",
"a1128.b17614",
"content_source",
),
)
}
ripsChatRoomFragmentClazz = findMaps["RipsChatRoomFragment"]?.firstOrNull()?.getClassInstance(lpparam.classLoader)
}
}
}

Expand Down
45 changes: 45 additions & 0 deletions core/src/main/java/com/freegang/hook/HChatRoomActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.freegang.hook

import android.os.Bundle
import android.view.ViewTreeObserver
import androidx.core.view.isVisible
import com.freegang.base.BaseHook
import com.freegang.ktutils.app.contentView
import com.freegang.ktutils.view.parentView
import com.freegang.ktutils.view.traverse
import com.freegang.xpler.core.OnAfter
import com.freegang.xpler.core.OnBefore
import com.freegang.xpler.core.thisActivity
import de.robv.android.xposed.XC_MethodHook
import de.robv.android.xposed.callbacks.XC_LoadPackage

class HChatRoomActivity(lpparam: XC_LoadPackage.LoadPackageParam) : BaseHook<Any>(lpparam) {
override fun setTargetClass(): Class<*> {
return findClass("com.ss.android.ugc.aweme.im.sdk.chat.ChatRoomActivity")
}

private var onGlobalLayoutListener: ViewTreeObserver.OnGlobalLayoutListener? = null

@OnAfter("onCreate")
fun onCreateAfter(it: XC_MethodHook.MethodHookParam, bundle: Bundle?) {
hookBlock(it) {
val contentView = thisActivity.contentView
onGlobalLayoutListener = ViewTreeObserver.OnGlobalLayoutListener {
contentView.traverse {
if ("${it.contentDescription}".contains("邀请朋友")) {
it.parent.parentView.isVisible = false
}
}
}
contentView.viewTreeObserver.addOnGlobalLayoutListener(onGlobalLayoutListener)
}
}

@OnBefore("onDestroy")
fun onDestroyBefore(it: XC_MethodHook.MethodHookParam) {
hookBlock(it) {
thisActivity.contentView.viewTreeObserver.removeOnGlobalLayoutListener(onGlobalLayoutListener)
onGlobalLayoutListener = null
}
}
}
18 changes: 11 additions & 7 deletions core/src/main/java/com/freegang/hook/HMainFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import android.view.ViewGroup
import androidx.core.view.isVisible
import com.freegang.base.BaseHook
import com.freegang.config.ConfigV1
import com.freegang.ktutils.view.findViewsByDesc
import com.freegang.ktutils.view.traverse
import com.freegang.xpler.core.FieldGet
import com.freegang.xpler.core.KtCallMethods
Expand Down Expand Up @@ -43,14 +42,19 @@ class HMainFragment(lpparam: XC_LoadPackage.LoadPackageParam) : BaseHook<MainFra
}

private fun changeTabItem(viewGroup: ViewGroup) {
val hideTabKeywords = config.hideTabKeywords
.removePrefix(",").removePrefix("")
.removeSuffix(",").removeSuffix("")
.replace("\\s".toRegex(), "")
.replace("[,,]".toRegex(), "|")
.toRegex()
viewGroup.traverse {
if (it is MainTabStripScrollView) {
val hideTabKeywords = config.hideTabKeywords
.removePrefix(",").removePrefix("")
.removeSuffix(",").removeSuffix("")
.replace("\\s".toRegex(), "")
.replace("[,,]".toRegex(), "|")
it.findViewsByDesc(View::class.java, hideTabKeywords.toRegex()).forEach { v -> v.isVisible = false }
it.traverse { v ->
if ("${v.contentDescription}".contains(hideTabKeywords)) {
v.isVisible = false
}
}
}
}
}
Expand Down
7 changes: 5 additions & 2 deletions core/src/main/java/com/freegang/hook/HVerticalViewPager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ class HVerticalViewPager(lpparam: XC_LoadPackage.LoadPackageParam) : BaseHook<Ve
lpparam.hookClass(VideoViewHolderRootView::class.java)
.constructorsAll {
onAfter {
onDragListener?.let { thisView.viewTreeObserver.removeOnDrawListener(it) }
onDragListener?.let {
thisView.viewTreeObserver.removeOnDrawListener(it)
onDragListener = null
}
onDragListener = ViewTreeObserver.OnDrawListener { toggleView(thisViewGroup) }
thisView.viewTreeObserver.addOnDrawListener(onDragListener)
}
Expand Down Expand Up @@ -240,7 +243,7 @@ class HVerticalViewPager(lpparam: XC_LoadPackage.LoadPackageParam) : BaseHook<Ve
}

"模块设置" -> {
val intent = Intent(it.context, FreedomSettingActivity::class.java)
val intent = Intent().setClass(it.context, FreedomSettingActivity::class.java)
intent.putExtra("isDark", view.context.isDarkMode)
val options = ActivityOptions.makeCustomAnimation(
activeActivity,
Expand Down
76 changes: 76 additions & 0 deletions core/src/main/java/com/freegang/plugin/PluginInstrumentation.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ import android.app.Application
import android.app.Instrumentation
import android.content.Context
import android.content.Intent
import android.os.Build
import android.os.Bundle
import android.os.IBinder
import android.os.PersistableBundle
import androidx.annotation.Keep
import androidx.annotation.RequiresApi
import com.freegang.ktutils.log.KLogCat
import com.freegang.ktutils.reflect.classLoader
import com.freegang.xpler.loader.moduleClassloader
Expand All @@ -31,6 +34,79 @@ class PluginInstrumentation(
mBase.callApplicationOnCreate(app)
}

override fun callActivityOnCreate(activity: Activity?, icicle: Bundle?) {
mBase.callActivityOnCreate(activity, icicle)
}

override fun callActivityOnCreate(activity: Activity?, icicle: Bundle?, persistentState: PersistableBundle?) {
mBase.callActivityOnCreate(activity, icicle, persistentState)
}

override fun callActivityOnDestroy(activity: Activity?) {
mBase.callActivityOnDestroy(activity)
}

override fun callActivityOnRestoreInstanceState(activity: Activity, savedInstanceState: Bundle) {
mBase.callActivityOnRestoreInstanceState(activity, savedInstanceState)
}

override fun callActivityOnRestoreInstanceState(
activity: Activity,
savedInstanceState: Bundle?,
persistentState: PersistableBundle?
) {
mBase.callActivityOnRestoreInstanceState(activity, savedInstanceState, persistentState)
}

override fun callActivityOnPostCreate(activity: Activity, savedInstanceState: Bundle?) {
mBase.callActivityOnPostCreate(activity, savedInstanceState)
}

override fun callActivityOnPostCreate(activity: Activity, savedInstanceState: Bundle?, persistentState: PersistableBundle?) {
mBase.callActivityOnPostCreate(activity, savedInstanceState, persistentState)
}

override fun callActivityOnNewIntent(activity: Activity?, intent: Intent?) {
mBase.callActivityOnNewIntent(activity, intent)
}

override fun callActivityOnStart(activity: Activity?) {
mBase.callActivityOnStart(activity)
}

override fun callActivityOnRestart(activity: Activity?) {
mBase.callActivityOnRestart(activity)
}

override fun callActivityOnResume(activity: Activity?) {
mBase.callActivityOnResume(activity)
}

override fun callActivityOnStop(activity: Activity?) {
mBase.callActivityOnStop(activity)
}

override fun callActivityOnSaveInstanceState(activity: Activity, outState: Bundle) {
mBase.callActivityOnSaveInstanceState(activity, outState)
}

override fun callActivityOnSaveInstanceState(activity: Activity, outState: Bundle, outPersistentState: PersistableBundle) {
mBase.callActivityOnSaveInstanceState(activity, outState, outPersistentState)
}

override fun callActivityOnPause(activity: Activity?) {
mBase.callActivityOnPause(activity)
}

override fun callActivityOnUserLeaving(activity: Activity?) {
mBase.callActivityOnUserLeaving(activity)
}

@RequiresApi(Build.VERSION_CODES.R)
override fun callActivityOnPictureInPictureRequested(activity: Activity) {
mBase.callActivityOnPictureInPictureRequested(activity)
}

@Keep
@SuppressLint("DiscouragedPrivateApi")
fun execStartActivity(
Expand Down
2 changes: 1 addition & 1 deletion versions.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
["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","26.3.0","26.4.0","26.5.0","26.6.0","26.7.0","26.8.0"]
["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","26.3.0","26.4.0","26.5.0","26.6.0","26.7.0","26.8.0","26.9.0"]

0 comments on commit 94bafd2

Please sign in to comment.