mirror of
https://github.com/rhunk/SnapEnhance.git
synced 2025-05-07 18:04:32 +02:00
feat(core): edit text override
This commit is contained in:
parent
ce2fe64c37
commit
35016b589f
@ -322,6 +322,10 @@
|
||||
"fidelius_indicator": {
|
||||
"name": "Fidelius Indicator",
|
||||
"description": "Adds a green circle next to messages that have been sent only to you"
|
||||
},
|
||||
"edit_text_override": {
|
||||
"name": "Edit Text Override",
|
||||
"description": "Overrides text field behavior"
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -795,6 +799,10 @@
|
||||
"auto_reload": {
|
||||
"snapchat_only": "Snapchat Only",
|
||||
"all": "All (Snapchat + SnapEnhance)"
|
||||
},
|
||||
"edit_text_override": {
|
||||
"multi_line_chat_input": "Multi Line Chat Input",
|
||||
"bypass_text_input_limit": "Bypass Text Input Limit"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -50,4 +50,7 @@ class UserInterfaceTweaks : ConfigContainer() {
|
||||
val hideSettingsGear = boolean("hide_settings_gear") { requireRestart() }
|
||||
val verticalStoryViewer = boolean("vertical_story_viewer") { requireRestart() }
|
||||
val fideliusIndicator = boolean("fidelius_indicator") { requireRestart() }
|
||||
val editTextOverride = multiple("edit_text_override", "multi_line_chat_input", "bypass_text_input_limit") {
|
||||
requireRestart(); addNotices(FeatureNotice.BAN_RISK, FeatureNotice.INTERNAL_BEHAVIOR)
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,36 @@
|
||||
package me.rhunk.snapenhance.core.features.impl.ui
|
||||
|
||||
import android.text.InputFilter
|
||||
import android.text.InputType
|
||||
import android.widget.EditText
|
||||
import android.widget.TextView
|
||||
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.hook
|
||||
import me.rhunk.snapenhance.core.util.hook.hookConstructor
|
||||
|
||||
class EditTextOverride : Feature("Edit Text Override", loadParams = FeatureLoadParams.ACTIVITY_CREATE_SYNC) {
|
||||
override fun onActivityCreate() {
|
||||
val editTextOverride by context.config.userInterface.editTextOverride
|
||||
if (editTextOverride.isEmpty()) return
|
||||
|
||||
if (editTextOverride.contains("bypass_text_input_limit")) {
|
||||
TextView::class.java.getMethod("setFilters", Array<InputFilter>::class.java)
|
||||
.hook(HookStage.BEFORE) { param ->
|
||||
param.setArg(0, param.arg<Array<InputFilter>>(0).filter {
|
||||
it !is InputFilter.LengthFilter
|
||||
}.toTypedArray())
|
||||
}
|
||||
}
|
||||
|
||||
if (editTextOverride.contains("multi_line_chat_input")) {
|
||||
findClass("com.snap.messaging.chat.features.input.InputBarEditText").apply {
|
||||
hookConstructor(HookStage.AFTER) { param ->
|
||||
val editText = param.thisObject<EditText>()
|
||||
editText.inputType = editText.inputType or InputType.TYPE_TEXT_FLAG_MULTI_LINE
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -113,6 +113,7 @@ class FeatureManager(
|
||||
Stories::class,
|
||||
DisableComposerModules::class,
|
||||
FideliusIndicator::class,
|
||||
EditTextOverride::class,
|
||||
)
|
||||
|
||||
initializeFeatures()
|
||||
|
Loading…
x
Reference in New Issue
Block a user