Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disabled autocorrect on Samsung device with Samsung keyboard on API 33+ #1063

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions aztec/src/main/kotlin/org/wordpress/aztec/AztecText.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import android.os.Parcelable
import android.provider.Settings
import android.text.Editable
import android.text.InputFilter
import android.text.InputType
import android.text.Spannable
import android.text.SpannableStringBuilder
import android.text.Spanned
Expand Down Expand Up @@ -695,13 +696,14 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
}

override fun onCreateInputConnection(outAttrs: EditorInfo): InputConnection {
val baseInputConnection = requireNotNull(super.onCreateInputConnection(outAttrs)).wrapWithBackSpaceHandler()
return if (shouldOverridePredictiveTextBehavior()) {
AppLog.d(AppLog.T.EDITOR, "Overriding predictive text behavior on Samsung device with Samsung Keyboard with API 33")
SamsungInputConnection(this, baseInputConnection)
} else {
baseInputConnection
val inputConnection = requireNotNull(super.onCreateInputConnection(outAttrs)).wrapWithBackSpaceHandler()

if (shouldOverridePredictiveTextBehavior()) {
AppLog.d(AppLog.T.EDITOR, "Disabling autocorrect on Samsung device with Samsung Keyboard with API 33")
outAttrs.inputType = outAttrs.inputType or InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS
}

return inputConnection
}

private fun InputConnection.wrapWithBackSpaceHandler(): InputConnection {
Expand Down Expand Up @@ -1800,7 +1802,7 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
bypassMediaDeletedListener = false
}

// removes Grammarly suggestions from default keyboard on Samsung devices on Android 13 (API 33)
// removes auto-correct from default keyboard on Samsung devices on Android 13 (API 33)
// Grammarly implementation is often messing spans and cursor position, as described here:
// https://github.com/wordpress-mobile/AztecEditor-Android/issues/1023
fun enableSamsungPredictiveBehaviorOverride() {
Expand Down
187 changes: 0 additions & 187 deletions aztec/src/main/kotlin/org/wordpress/aztec/SamsungInputConnection.kt

This file was deleted.

Loading