mirror of
https://github.com/rhunk/SnapEnhance.git
synced 2025-06-13 05:37:48 +02:00
feat: call start confirmation
This commit is contained in:
@ -332,6 +332,10 @@
|
|||||||
"name": "Message Preview Length",
|
"name": "Message Preview Length",
|
||||||
"description": "Specify the amount of messages to get previewed"
|
"description": "Specify the amount of messages to get previewed"
|
||||||
},
|
},
|
||||||
|
"call_start_confirmation": {
|
||||||
|
"name": "Call Start Confirmation",
|
||||||
|
"description": "Shows a confirmation dialog when starting a call"
|
||||||
|
},
|
||||||
"prevent_message_sending": {
|
"prevent_message_sending": {
|
||||||
"name": "Prevent Message Sending",
|
"name": "Prevent Message Sending",
|
||||||
"description": "Prevents sending certain types of messages"
|
"description": "Prevents sending certain types of messages"
|
||||||
@ -785,6 +789,11 @@
|
|||||||
"background_option": "Background"
|
"background_option": "Background"
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"call_start_confirmation": {
|
||||||
|
"dialog_title": "Start Call",
|
||||||
|
"dialog_message": "Are you sure you want to start a call?"
|
||||||
|
},
|
||||||
|
|
||||||
"download_processor": {
|
"download_processor": {
|
||||||
"attachment_type": {
|
"attachment_type": {
|
||||||
"snap": "Snap",
|
"snap": "Snap",
|
||||||
|
@ -11,6 +11,7 @@ class MessagingTweaks : ConfigContainer() {
|
|||||||
val unlimitedSnapViewTime = boolean("unlimited_snap_view_time")
|
val unlimitedSnapViewTime = boolean("unlimited_snap_view_time")
|
||||||
val disableReplayInFF = boolean("disable_replay_in_ff")
|
val disableReplayInFF = boolean("disable_replay_in_ff")
|
||||||
val messagePreviewLength = integer("message_preview_length", defaultValue = 20)
|
val messagePreviewLength = integer("message_preview_length", defaultValue = 20)
|
||||||
|
val callStartConfirmation = boolean("call_start_confirmation") { requireRestart() }
|
||||||
val autoSaveMessagesInConversations = multiple("auto_save_messages_in_conversations",
|
val autoSaveMessagesInConversations = multiple("auto_save_messages_in_conversations",
|
||||||
"CHAT",
|
"CHAT",
|
||||||
"SNAP",
|
"SNAP",
|
||||||
|
@ -0,0 +1,53 @@
|
|||||||
|
package me.rhunk.snapenhance.core.features.impl.messaging
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
|
import android.view.MotionEvent
|
||||||
|
import android.view.View
|
||||||
|
import me.rhunk.snapenhance.core.features.Feature
|
||||||
|
import me.rhunk.snapenhance.core.features.FeatureLoadParams
|
||||||
|
import me.rhunk.snapenhance.core.ui.ViewAppearanceHelper
|
||||||
|
import me.rhunk.snapenhance.core.util.hook.HookAdapter
|
||||||
|
import me.rhunk.snapenhance.core.util.hook.HookStage
|
||||||
|
import me.rhunk.snapenhance.core.util.hook.hook
|
||||||
|
|
||||||
|
class CallStartConfirmation : Feature("CallStartConfirmation", loadParams = FeatureLoadParams.ACTIVITY_CREATE_SYNC) {
|
||||||
|
private fun hookTouchEvent(param: HookAdapter, motionEvent: MotionEvent, onConfirm: () -> Unit) {
|
||||||
|
if (motionEvent.action != MotionEvent.ACTION_UP) return
|
||||||
|
param.setResult(true)
|
||||||
|
ViewAppearanceHelper.newAlertDialogBuilder(context.mainActivity)
|
||||||
|
.setTitle(context.translation["call_start_confirmation.dialog_title"])
|
||||||
|
.setMessage(context.translation["call_start_confirmation.dialog_message"])
|
||||||
|
.setPositiveButton(context.translation["button.positive"]) { _, _ -> onConfirm() }
|
||||||
|
.setNeutralButton(context.translation["button.negative"]) { _, _ -> }
|
||||||
|
.show()
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("DiscouragedApi")
|
||||||
|
override fun onActivityCreate() {
|
||||||
|
if (!context.config.messaging.callStartConfirmation.get()) return
|
||||||
|
|
||||||
|
findClass("com.snap.composer.views.ComposerRootView").hook("dispatchTouchEvent", HookStage.BEFORE) { param ->
|
||||||
|
if (param.thisObject<Any>()::class.java.name != "com.snap.talk.CallButtonsView") return@hook
|
||||||
|
hookTouchEvent(param, param.arg(0)) {
|
||||||
|
param.invokeOriginal()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val callButton1 = context.resources.getIdentifier("friend_action_button3", "id", "com.snapchat.android")
|
||||||
|
val callButton2 = context.resources.getIdentifier("friend_action_button4", "id", "com.snapchat.android")
|
||||||
|
|
||||||
|
findClass("com.snap.ui.view.stackdraw.StackDrawLayout").hook("onTouchEvent", HookStage.BEFORE) { param ->
|
||||||
|
val view = param.thisObject<View>()
|
||||||
|
if (view.id != callButton1 && view.id != callButton2) return@hook
|
||||||
|
|
||||||
|
hookTouchEvent(param, param.arg(0)) {
|
||||||
|
arrayOf(
|
||||||
|
MotionEvent.obtain(0, 0, MotionEvent.ACTION_DOWN, 0f, 0f, 0),
|
||||||
|
MotionEvent.obtain(0, 0, MotionEvent.ACTION_UP, 0f, 0f, 0)
|
||||||
|
).forEach {
|
||||||
|
param.invokeOriginal(arrayOf(it))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -101,6 +101,7 @@ class FeatureManager(
|
|||||||
HideStreakRestore::class,
|
HideStreakRestore::class,
|
||||||
HideFriendFeedEntry::class,
|
HideFriendFeedEntry::class,
|
||||||
HideQuickAddFriendFeed::class,
|
HideQuickAddFriendFeed::class,
|
||||||
|
CallStartConfirmation::class,
|
||||||
)
|
)
|
||||||
|
|
||||||
initializeFeatures()
|
initializeFeatures()
|
||||||
|
Reference in New Issue
Block a user