mirror of
https://github.com/rhunk/SnapEnhance.git
synced 2025-05-29 04:50:15 +02:00
feat(core): disable confirmation dialogs
This commit is contained in:
parent
e956400ffe
commit
feee29509d
@ -408,6 +408,10 @@
|
||||
"name": "Snapchat Plus",
|
||||
"description": "Enables Snapchat Plus features\nSome Server-sided features may not work"
|
||||
},
|
||||
"disable_confirmation_dialogs": {
|
||||
"name": "Disable Confirmation Dialogs",
|
||||
"description": "Automatically confirms selected actions"
|
||||
},
|
||||
"auto_updater": {
|
||||
"name": "Auto Updater",
|
||||
"description": "Automatically checks for new updates"
|
||||
@ -738,6 +742,14 @@
|
||||
"old_bitmoji_selfie": {
|
||||
"2d": "2D Bitmoji",
|
||||
"3d": "3D Bitmoji"
|
||||
},
|
||||
"disable_confirmation_dialogs": {
|
||||
"remove_friend": "Remove Friend",
|
||||
"block_friend": "Block Friend",
|
||||
"ignore_friend": "Ignore Friend",
|
||||
"hide_friend": "Hide Friend",
|
||||
"hide_conversation": "Hide Conversation",
|
||||
"clear_conversation": "Clear Conversation from Friend Feed"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -9,6 +9,7 @@ class Global : ConfigContainer() {
|
||||
}
|
||||
val spoofLocation = container("spoofLocation", SpoofLocation())
|
||||
val snapchatPlus = boolean("snapchat_plus") { requireRestart() }
|
||||
val disableConfirmationDialogs = multiple("disable_confirmation_dialogs", "remove_friend", "block_friend", "ignore_friend", "hide_friend", "hide_conversation", "clear_conversation") { requireRestart() }
|
||||
val disableMetrics = boolean("disable_metrics")
|
||||
val blockAds = boolean("block_ads")
|
||||
val bypassVideoLengthRestriction = unique("bypass_video_length_restriction", "split", "single") { addNotices(
|
||||
|
@ -0,0 +1,54 @@
|
||||
package me.rhunk.snapenhance.core.features.impl.ui
|
||||
|
||||
import android.view.View
|
||||
import android.widget.TextView
|
||||
import me.rhunk.snapenhance.core.event.events.impl.AddViewEvent
|
||||
import me.rhunk.snapenhance.core.features.Feature
|
||||
import me.rhunk.snapenhance.core.features.FeatureLoadParams
|
||||
import me.rhunk.snapenhance.core.util.ktx.getId
|
||||
import me.rhunk.snapenhance.core.util.ktx.getIdentifier
|
||||
import java.util.regex.Pattern
|
||||
|
||||
class DisableConfirmationDialogs : Feature("Disable Confirmation Dialogs", loadParams = FeatureLoadParams.ACTIVITY_CREATE_SYNC) {
|
||||
override fun onActivityCreate() {
|
||||
val disableConfirmationDialogs = context.config.global.disableConfirmationDialogs.get().takeIf { it.isNotEmpty() } ?: return
|
||||
val dialogContent = context.resources.getId("dialog_content")
|
||||
val alertDialogTitle = context.resources.getId("alert_dialog_title")
|
||||
|
||||
val questions = listOf(
|
||||
"remove_friend" to "action_menu_remove_friend_question",
|
||||
"block_friend" to "action_menu_block_friend_question",
|
||||
"ignore_friend" to "action_menu_ignore_friend_question",
|
||||
"hide_friend" to "action_menu_hide_friend_question",
|
||||
"hide_conversation" to "hide_or_block_clear_conversation_dialog_title",
|
||||
"clear_conversation" to "action_menu_clear_conversation_dialog_title"
|
||||
).associate { pair ->
|
||||
pair.first to runCatching {
|
||||
Pattern.compile(
|
||||
context.resources.getString(context.resources.getIdentifier(pair.second, "string"))
|
||||
.split("%s").joinToString(".*") {
|
||||
Pattern.quote(it)
|
||||
}, Pattern.CASE_INSENSITIVE)
|
||||
}.onFailure {
|
||||
context.log.error("Failed to compile regex for ${pair.second}", it)
|
||||
}.getOrNull()
|
||||
}
|
||||
|
||||
context.event.subscribe(AddViewEvent::class) { event ->
|
||||
if (event.parent.id != dialogContent || !event.view::class.java.name.endsWith("SnapButtonView")) return@subscribe
|
||||
|
||||
val dialogTitle = event.parent.findViewById<TextView>(alertDialogTitle)?.text?.toString() ?: return@subscribe
|
||||
|
||||
questions.forEach { (key, value) ->
|
||||
if (!disableConfirmationDialogs.contains(key)) return@forEach
|
||||
|
||||
if (value?.matcher(dialogTitle)?.matches() == true) {
|
||||
event.parent.visibility = View.GONE
|
||||
event.parent.postDelayed({
|
||||
event.view.callOnClick()
|
||||
}, 400)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -107,6 +107,7 @@ class FeatureManager(
|
||||
InstantDelete::class,
|
||||
BypassScreenshotDetection::class,
|
||||
HalfSwipeNotifier::class,
|
||||
DisableConfirmationDialogs::class,
|
||||
)
|
||||
|
||||
initializeFeatures()
|
||||
|
Loading…
x
Reference in New Issue
Block a user