feat: hide quick add in friend feed
This commit is contained in:
@@ -262,6 +262,10 @@
|
||||
"name": "Hide Streak Restore",
|
||||
"description": "Hides the Restore button in the friend feed"
|
||||
},
|
||||
"hide_quick_add_friend_feed": {
|
||||
"name": "Hide Quick Add in Friend Feed",
|
||||
"description": "Hides the Quick Add section in the friend feed"
|
||||
},
|
||||
"hide_story_sections": {
|
||||
"name": "Hide Story Section",
|
||||
"description": "Hide certain UI Elements shown in the story section"
|
||||
|
||||
@@ -30,6 +30,7 @@ class MappingsWrapper : FileLoaderWrapper(BridgeFileType.MAPPINGS, "{}".toByteAr
|
||||
ScoreUpdateMapper::class,
|
||||
FriendRelationshipChangerMapper::class,
|
||||
ViewBinderMapper::class,
|
||||
FriendingDataSourcesMapper::class,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ class UserInterfaceTweaks : ConfigContainer() {
|
||||
val streakExpirationInfo = boolean("streak_expiration_info") { requireRestart() }
|
||||
val hideFriendFeedEntry = boolean("hide_friend_feed_entry") { requireRestart() }
|
||||
val hideStreakRestore = boolean("hide_streak_restore") { requireRestart() }
|
||||
val hideQuickAddFriendFeed = boolean("hide_quick_add_friend_feed") { requireRestart() }
|
||||
val hideStorySections = multiple("hide_story_sections",
|
||||
"hide_friend_suggestions", "hide_friends", "hide_suggested", "hide_for_you") { requireRestart() }
|
||||
val hideUiComponents = multiple("hide_ui_components",
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package me.rhunk.snapenhance.core.features.impl.ui
|
||||
|
||||
import me.rhunk.snapenhance.core.features.Feature
|
||||
import me.rhunk.snapenhance.core.features.FeatureLoadParams
|
||||
import me.rhunk.snapenhance.core.util.hook.HookStage
|
||||
import me.rhunk.snapenhance.core.util.hook.hookConstructor
|
||||
import me.rhunk.snapenhance.core.util.ktx.setObjectField
|
||||
|
||||
class HideQuickAddFriendFeed : Feature("HideQuickAddFriendFeed", loadParams = FeatureLoadParams.ACTIVITY_CREATE_SYNC) {
|
||||
override fun onActivityCreate() {
|
||||
if (!context.config.userInterface.hideQuickAddFriendFeed.get()) return
|
||||
|
||||
val friendingDataSource = context.mappings.getMappedMap("FriendingDataSources")
|
||||
findClass(friendingDataSource["class"].toString()).hookConstructor(HookStage.AFTER) { param ->
|
||||
param.thisObject<Any>().setObjectField(
|
||||
friendingDataSource["quickAddSourceListField"].toString(),
|
||||
arrayListOf<Any>()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -100,6 +100,7 @@ class FeatureManager(
|
||||
FriendFeedMessagePreview::class,
|
||||
HideStreakRestore::class,
|
||||
HideFriendFeedEntry::class,
|
||||
HideQuickAddFriendFeed::class,
|
||||
)
|
||||
|
||||
initializeFeatures()
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package me.rhunk.snapenhance.mapper.impl
|
||||
|
||||
import me.rhunk.snapenhance.mapper.AbstractClassMapper
|
||||
import me.rhunk.snapenhance.mapper.ext.findConstString
|
||||
import me.rhunk.snapenhance.mapper.ext.getClassName
|
||||
import me.rhunk.snapenhance.mapper.ext.searchNextFieldReference
|
||||
|
||||
class FriendingDataSourcesMapper: AbstractClassMapper() {
|
||||
init {
|
||||
mapper {
|
||||
for (classDef in classes) {
|
||||
val constructor = classDef.methods.firstOrNull { it.name == "<init>" } ?: continue
|
||||
if (constructor.parameterTypes.size < 4 || (0..3).any { constructor.parameterTypes[it] != "Ljava/util/List;" }) continue
|
||||
|
||||
val toStringMethod = classDef.methods.firstOrNull { it.name == "toString" } ?: continue
|
||||
if (toStringMethod.implementation?.findConstString("quickaddSource", contains = true) != true) continue
|
||||
|
||||
val quickAddSourceListField = toStringMethod.implementation?.searchNextFieldReference("quickaddSource", contains = true)
|
||||
?: continue
|
||||
|
||||
addMapping("FriendingDataSources",
|
||||
"class" to classDef.getClassName(),
|
||||
"quickAddSourceListField" to quickAddSourceListField.name
|
||||
)
|
||||
return@mapper
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,7 @@ class TestMappings {
|
||||
ScoreUpdateMapper::class,
|
||||
FriendRelationshipChangerMapper::class,
|
||||
ViewBinderMapper::class,
|
||||
FriendingDataSourcesMapper::class,
|
||||
)
|
||||
|
||||
val gson = GsonBuilder().setPrettyPrinting().create()
|
||||
|
||||
Reference in New Issue
Block a user