Skip to content

Commit 1614ca1

Browse files
authored
Merge pull request #1063 from wordpress-mobile/issue/disabled-autocorrect-on-certain-samsung-devices
Disabled autocorrect on Samsung device with Samsung keyboard on API 33+
2 parents caf8f43 + cff5d94 commit 1614ca1

File tree

2 files changed

+9
-194
lines changed

2 files changed

+9
-194
lines changed

aztec/src/main/kotlin/org/wordpress/aztec/AztecText.kt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import android.os.Parcelable
3636
import android.provider.Settings
3737
import android.text.Editable
3838
import android.text.InputFilter
39+
import android.text.InputType
3940
import android.text.Spannable
4041
import android.text.SpannableStringBuilder
4142
import android.text.Spanned
@@ -695,13 +696,14 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
695696
}
696697

697698
override fun onCreateInputConnection(outAttrs: EditorInfo): InputConnection {
698-
val baseInputConnection = requireNotNull(super.onCreateInputConnection(outAttrs)).wrapWithBackSpaceHandler()
699-
return if (shouldOverridePredictiveTextBehavior()) {
700-
AppLog.d(AppLog.T.EDITOR, "Overriding predictive text behavior on Samsung device with Samsung Keyboard with API 33")
701-
SamsungInputConnection(this, baseInputConnection)
702-
} else {
703-
baseInputConnection
699+
val inputConnection = requireNotNull(super.onCreateInputConnection(outAttrs)).wrapWithBackSpaceHandler()
700+
701+
if (shouldOverridePredictiveTextBehavior()) {
702+
AppLog.d(AppLog.T.EDITOR, "Disabling autocorrect on Samsung device with Samsung Keyboard with API 33")
703+
outAttrs.inputType = outAttrs.inputType or InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS
704704
}
705+
706+
return inputConnection
705707
}
706708

707709
private fun InputConnection.wrapWithBackSpaceHandler(): InputConnection {
@@ -1800,7 +1802,7 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
18001802
bypassMediaDeletedListener = false
18011803
}
18021804

1803-
// removes Grammarly suggestions from default keyboard on Samsung devices on Android 13 (API 33)
1805+
// removes auto-correct from default keyboard on Samsung devices on Android 13 (API 33)
18041806
// Grammarly implementation is often messing spans and cursor position, as described here:
18051807
// https://github.com/wordpress-mobile/AztecEditor-Android/issues/1023
18061808
fun enableSamsungPredictiveBehaviorOverride() {

aztec/src/main/kotlin/org/wordpress/aztec/SamsungInputConnection.kt

Lines changed: 0 additions & 187 deletions
This file was deleted.

0 commit comments

Comments
 (0)