Skip to content

Commit 5700096

Browse files
committed
Check if the keyboard is samsung keyboard when performing check for predictive text override.
1 parent 4a6a062 commit 5700096

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import android.os.Bundle
3333
import android.os.Looper
3434
import android.os.Parcel
3535
import android.os.Parcelable
36+
import android.provider.Settings
3637
import android.text.Editable
3738
import android.text.InputFilter
3839
import android.text.Spannable
@@ -659,15 +660,20 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
659660

660661
override fun onCreateInputConnection(outAttrs: EditorInfo): InputConnection {
661662
val baseInputConnection = requireNotNull(super.onCreateInputConnection(outAttrs))
662-
return if (Build.MANUFACTURER.lowercase(Locale.US) == "samsung" && Build.VERSION.SDK_INT == 33
663-
&& overrideSamsungPredictiveBehavior) {
664-
AppLog.d(AppLog.T.EDITOR, "Overriding predictive text behavior on Samsung device with API 33")
663+
return if (shouldOverridePredictiveTextBehavior()) {
664+
AppLog.d(AppLog.T.EDITOR, "Overriding predictive text behavior on Samsung device with Samsung Keyboard with API 33")
665665
SamsungInputConnection(this, baseInputConnection)
666666
} else {
667667
baseInputConnection
668668
}
669669
}
670670

671+
private fun shouldOverridePredictiveTextBehavior(): Boolean {
672+
val currentKeyboard = Settings.Secure.getString(context.contentResolver, Settings.Secure.DEFAULT_INPUT_METHOD)
673+
return Build.MANUFACTURER.lowercase(Locale.US) == "samsung" && Build.VERSION.SDK_INT >= 33 &&
674+
(currentKeyboard !== null && currentKeyboard.startsWith("com.samsung.android.honeyboard")) && overrideSamsungPredictiveBehavior
675+
}
676+
671677
// Setup the keyListener(s) for Backspace and Enter key.
672678
// Backspace: If listener does return false we remove the style here
673679
// Enter: Ask the listener if we need to insert or not the char

0 commit comments

Comments
 (0)