diff --git a/app/src/main/java/be/scri/helpers/MyKeyboard.kt b/app/src/main/java/be/scri/helpers/KeyboardBase.kt similarity index 91% rename from app/src/main/java/be/scri/helpers/MyKeyboard.kt rename to app/src/main/java/be/scri/helpers/KeyboardBase.kt index 485bcd41..6a1fd791 100644 --- a/app/src/main/java/be/scri/helpers/MyKeyboard.kt +++ b/app/src/main/java/be/scri/helpers/KeyboardBase.kt @@ -41,7 +41,7 @@ import java.io.IOException * @attr ref android.R.styleable#Keyboard_horizontalGap */ @Suppress("LongMethod", "NestedBlockDepth", "CyclomaticComplexMethod") -class MyKeyboard { +class KeyboardBase { /** Horizontal gap default for all rows */ private var mDefaultHorizontalGap = 0 @@ -104,7 +104,7 @@ class MyKeyboard { * Container for keys in the keyboard. * All keys in a row are at the same Y-coordinate. * Some of the key size defaults can be overridden per row from - * what the [MyKeyboard] defines. + * what the [KeyboardBase] defines. * @attr ref android.R.styleable#Keyboard_keyWidth * @attr ref android.R.styleable#Keyboard_horizontalGap */ @@ -120,19 +120,19 @@ class MyKeyboard { var mKeys = ArrayList() - var parent: MyKeyboard + var parent: KeyboardBase - constructor(parent: MyKeyboard) { + constructor(parent: KeyboardBase) { this.parent = parent } - constructor(res: Resources, parent: MyKeyboard, parser: XmlResourceParser?) { + constructor(res: Resources, parent: KeyboardBase, parser: XmlResourceParser?) { this.parent = parent - val a = res.obtainAttributes(Xml.asAttributeSet(parser), R.styleable.MyKeyboard) + val a = res.obtainAttributes(Xml.asAttributeSet(parser), R.styleable.KeyboardBase) defaultWidth = getDimensionOrFraction( a, - R.styleable.MyKeyboard_keyWidth, + R.styleable.KeyboardBase_keyWidth, parent.mDisplayWidth, parent.mDefaultWidth, ) @@ -145,7 +145,7 @@ class MyKeyboard { defaultHorizontalGap = getDimensionOrFraction( a, - R.styleable.MyKeyboard_horizontalGap, + R.styleable.KeyboardBase_horizontalGap, parent.mDisplayWidth, parent.mDefaultHorizontalGap, ) @@ -209,7 +209,7 @@ class MyKeyboard { /** * Flags that specify the anchoring to edges of the keyboard for detecting touch events, * that are just out of the boundary of the key. - * This is a bit mask of [MyKeyboard.EDGE_LEFT], [MyKeyboard.EDGE_RIGHT]. + * This is a bit mask of [KeyboardBase.EDGE_LEFT], [KeyboardBase.EDGE_RIGHT]. */ private var edgeFlags = 0 @@ -224,7 +224,7 @@ class MyKeyboard { /** Create a key with the given top-left coordinate and extract its attributes from the XML parser. * @param res resources associated with the caller's context - * @param parent the row that this key belongs to. The row must already be attached to a [MyKeyboard]. + * @param parent the row that this key belongs to. The row must already be attached to a [KeyboardBase]. * @param x the x coordinate of the top-left * @param y the y coordinate of the top-left * @param parser the XML parser containing the attributes for this key @@ -235,13 +235,13 @@ class MyKeyboard { var a = res.obtainAttributes( Xml.asAttributeSet(parser), - R.styleable.MyKeyboard, + R.styleable.KeyboardBase, ) width = getDimensionOrFraction( a, - R.styleable.MyKeyboard_keyWidth, + R.styleable.KeyboardBase_keyWidth, keyboard.mDisplayWidth, parent.defaultWidth, ) @@ -251,25 +251,25 @@ class MyKeyboard { gap = getDimensionOrFraction( a, - R.styleable.MyKeyboard_horizontalGap, + R.styleable.KeyboardBase_horizontalGap, keyboard.mDisplayWidth, parent.defaultHorizontalGap, ) this.x += gap a.recycle() - a = res.obtainAttributes(Xml.asAttributeSet(parser), R.styleable.MyKeyboard_Key) - code = a.getInt(R.styleable.MyKeyboard_Key_code, 0) - - popupCharacters = a.getText(R.styleable.MyKeyboard_Key_popupCharacters) - popupResId = a.getResourceId(R.styleable.MyKeyboard_Key_popupKeyboard, 0) - repeatable = a.getBoolean(R.styleable.MyKeyboard_Key_isRepeatable, false) - edgeFlags = a.getInt(R.styleable.MyKeyboard_Key_keyEdgeFlags, 0) - icon = a.getDrawable(R.styleable.MyKeyboard_Key_keyIcon) + a = res.obtainAttributes(Xml.asAttributeSet(parser), R.styleable.KeyboardBase_Key) + code = a.getInt(R.styleable.KeyboardBase_Key_code, 0) + + popupCharacters = a.getText(R.styleable.KeyboardBase_Key_popupCharacters) + popupResId = a.getResourceId(R.styleable.KeyboardBase_Key_popupKeyboard, 0) + repeatable = a.getBoolean(R.styleable.KeyboardBase_Key_isRepeatable, false) + edgeFlags = a.getInt(R.styleable.KeyboardBase_Key_keyEdgeFlags, 0) + icon = a.getDrawable(R.styleable.KeyboardBase_Key_keyIcon) icon?.setBounds(0, 0, icon!!.intrinsicWidth, icon!!.intrinsicHeight) - label = a.getText(R.styleable.MyKeyboard_Key_keyLabel) ?: "" - topSmallNumber = a.getString(R.styleable.MyKeyboard_Key_topSmallNumber) ?: "" + label = a.getText(R.styleable.KeyboardBase_Key_keyLabel) ?: "" + topSmallNumber = a.getString(R.styleable.KeyboardBase_Key_topSmallNumber) ?: "" if (label.isNotEmpty() && code != KEYCODE_MODE_CHANGE && code != KEYCODE_SHIFT) { code = label[0].code @@ -465,9 +465,9 @@ class MyKeyboard { } } } catch (e: XmlPullParserException) { - Log.e("MyKeyboard", "XML Parsing error: ${e.message}") + Log.e("KeyboardBase", "XML Parsing error: ${e.message}") } catch (e: IOException) { - Log.e("MyKeyboard", "I/O error: ${e.message}") + Log.e("KeyboardBase", "I/O error: ${e.message}") } mHeight = y } @@ -476,12 +476,12 @@ class MyKeyboard { res: Resources, parser: XmlResourceParser, ) { - val a = res.obtainAttributes(Xml.asAttributeSet(parser), R.styleable.MyKeyboard) - val keyWidthResId = R.styleable.MyKeyboard_keyWidth + val a = res.obtainAttributes(Xml.asAttributeSet(parser), R.styleable.KeyboardBase) + val keyWidthResId = R.styleable.KeyboardBase_keyWidth val defaultWidth = mDisplayWidth / WIDTH_DIVIDER mDefaultWidth = getDimensionOrFraction(a, keyWidthResId, mDisplayWidth, defaultWidth) mDefaultHeight = res.getDimension(R.dimen.key_height).toInt() - mDefaultHorizontalGap = getDimensionOrFraction(a, R.styleable.MyKeyboard_horizontalGap, mDisplayWidth, 0) + mDefaultHorizontalGap = getDimensionOrFraction(a, R.styleable.KeyboardBase_horizontalGap, mDisplayWidth, 0) a.recycle() } diff --git a/app/src/main/java/be/scri/services/EnglishKeyboardIME.kt b/app/src/main/java/be/scri/services/EnglishKeyboardIME.kt index 9bf01535..c9017c17 100644 --- a/app/src/main/java/be/scri/services/EnglishKeyboardIME.kt +++ b/app/src/main/java/be/scri/services/EnglishKeyboardIME.kt @@ -25,7 +25,7 @@ import android.view.View import android.view.inputmethod.EditorInfo.IME_ACTION_NONE import be.scri.R import be.scri.databinding.KeyboardViewCommandOptionsBinding -import be.scri.helpers.MyKeyboard +import be.scri.helpers.KeyboardBase import be.scri.views.KeyboardView class EnglishKeyboardIME : GeneralKeyboardIME("English") { @@ -40,7 +40,7 @@ class EnglishKeyboardIME : GeneralKeyboardIME("English") { override val keyboardSymbols = 1 override val keyboardSymbolShift = 2 - override var keyboard: MyKeyboard? = null + override var keyboard: KeyboardBase? = null override var keyboardView: KeyboardView? = null override var lastShiftPressTS = 0L override var keyboardMode = keyboardLetters @@ -72,34 +72,34 @@ class EnglishKeyboardIME : GeneralKeyboardIME("English") { if (keyboard == null || inputConnection == null) { return } - if (code != MyKeyboard.KEYCODE_SHIFT) { + if (code != KeyboardBase.KEYCODE_SHIFT) { lastShiftPressTS = 0 } when (code) { - MyKeyboard.KEYCODE_DELETE -> { + KeyboardBase.KEYCODE_DELETE -> { handleKeycodeDelete() keyboardView!!.invalidateAllKeys() disableAutoSuggest() } - MyKeyboard.KEYCODE_SHIFT -> { + KeyboardBase.KEYCODE_SHIFT -> { super.handleKeyboardLetters(keyboardMode, keyboardView) keyboardView!!.invalidateAllKeys() disableAutoSuggest() } - MyKeyboard.KEYCODE_ENTER -> { + KeyboardBase.KEYCODE_ENTER -> { handleKeycodeEnter() disableAutoSuggest() } - MyKeyboard.KEYCODE_MODE_CHANGE -> { + KeyboardBase.KEYCODE_MODE_CHANGE -> { handleModeChange(keyboardMode, keyboardView, this) disableAutoSuggest() } - MyKeyboard.KEYCODE_SPACE -> { + KeyboardBase.KEYCODE_SPACE -> { handleElseCondition(code, keyboardMode, binding = null) updateAutoSuggestText(nounTypeSuggestion) } @@ -122,7 +122,7 @@ class EnglishKeyboardIME : GeneralKeyboardIME("English") { Log.d("Debug", "$autosuggestEmojis") Log.d("MY-TAG", "$nounTypeSuggestion") updateButtonText(isAutoSuggestEnabled, autosuggestEmojis) - if (code != MyKeyboard.KEYCODE_SHIFT) { + if (code != KeyboardBase.KEYCODE_SHIFT) { super.updateShiftKeyState() } } @@ -148,7 +148,7 @@ class EnglishKeyboardIME : GeneralKeyboardIME("English") { override fun onCreate() { super.onCreate() - keyboard = MyKeyboard(this, getKeyboardLayoutXML(), enterKeyType) + keyboard = KeyboardBase(this, getKeyboardLayoutXML(), enterKeyType) onCreateInputView() setupCommandBarTheme(binding) } diff --git a/app/src/main/java/be/scri/services/FrenchKeyboardIME.kt b/app/src/main/java/be/scri/services/FrenchKeyboardIME.kt index a7b44d17..e430fad8 100644 --- a/app/src/main/java/be/scri/services/FrenchKeyboardIME.kt +++ b/app/src/main/java/be/scri/services/FrenchKeyboardIME.kt @@ -25,7 +25,7 @@ import android.view.View import android.view.inputmethod.EditorInfo.IME_ACTION_NONE import be.scri.R import be.scri.databinding.KeyboardViewCommandOptionsBinding -import be.scri.helpers.MyKeyboard +import be.scri.helpers.KeyboardBase import be.scri.views.KeyboardView class FrenchKeyboardIME : GeneralKeyboardIME("French") { @@ -38,7 +38,7 @@ class FrenchKeyboardIME : GeneralKeyboardIME("French") { override lateinit var binding: KeyboardViewCommandOptionsBinding override var keyboardView: KeyboardView? = null - override var keyboard: MyKeyboard? = null + override var keyboard: KeyboardBase? = null override var enterKeyType = IME_ACTION_NONE override val keyboardLetters = 0 override val keyboardSymbols = 1 @@ -68,34 +68,34 @@ class FrenchKeyboardIME : GeneralKeyboardIME("French") { if (keyboard == null || inputConnection == null) { return } - if (code != MyKeyboard.KEYCODE_SHIFT) { + if (code != KeyboardBase.KEYCODE_SHIFT) { lastShiftPressTS = 0 } when (code) { - MyKeyboard.KEYCODE_DELETE -> { + KeyboardBase.KEYCODE_DELETE -> { handleKeycodeDelete() keyboardView!!.invalidateAllKeys() disableAutoSuggest() } - MyKeyboard.KEYCODE_SHIFT -> { + KeyboardBase.KEYCODE_SHIFT -> { super.handleKeyboardLetters(keyboardMode, keyboardView) keyboardView!!.invalidateAllKeys() disableAutoSuggest() } - MyKeyboard.KEYCODE_ENTER -> { + KeyboardBase.KEYCODE_ENTER -> { handleKeycodeEnter() disableAutoSuggest() } - MyKeyboard.KEYCODE_MODE_CHANGE -> { + KeyboardBase.KEYCODE_MODE_CHANGE -> { handleModeChange(keyboardMode, keyboardView, this) disableAutoSuggest() } - MyKeyboard.KEYCODE_SPACE -> { + KeyboardBase.KEYCODE_SPACE -> { handleElseCondition(code, keyboardMode, binding = null) updateAutoSuggestText(nounTypeSuggestion) } @@ -118,7 +118,7 @@ class FrenchKeyboardIME : GeneralKeyboardIME("French") { Log.d("Debug", "$autosuggestEmojis") Log.d("MY-TAG", "$nounTypeSuggestion") updateButtonText(isAutoSuggestEnabled, autosuggestEmojis) - if (code != MyKeyboard.KEYCODE_SHIFT) { + if (code != KeyboardBase.KEYCODE_SHIFT) { super.updateShiftKeyState() } } @@ -144,7 +144,7 @@ class FrenchKeyboardIME : GeneralKeyboardIME("French") { override fun onCreate() { super.onCreate() - keyboard = MyKeyboard(this, getKeyboardLayoutXML(), enterKeyType) + keyboard = KeyboardBase(this, getKeyboardLayoutXML(), enterKeyType) onCreateInputView() setupCommandBarTheme(binding) } diff --git a/app/src/main/java/be/scri/services/GeneralKeyboardIME.kt b/app/src/main/java/be/scri/services/GeneralKeyboardIME.kt index e2c5c2c8..02612029 100644 --- a/app/src/main/java/be/scri/services/GeneralKeyboardIME.kt +++ b/app/src/main/java/be/scri/services/GeneralKeyboardIME.kt @@ -46,7 +46,7 @@ import be.scri.databinding.KeyboardViewCommandOptionsBinding import be.scri.databinding.KeyboardViewKeyboardBinding import be.scri.helpers.DatabaseHelper import be.scri.helpers.HintUtils -import be.scri.helpers.MyKeyboard +import be.scri.helpers.KeyboardBase import be.scri.helpers.SHIFT_OFF import be.scri.helpers.SHIFT_ON_ONE_CHAR import be.scri.helpers.SHIFT_ON_PERMANENT @@ -65,7 +65,7 @@ abstract class GeneralKeyboardIME( abstract val keyboardSymbols: Int abstract val keyboardSymbolShift: Int - abstract var keyboard: MyKeyboard? + abstract var keyboard: KeyboardBase? abstract var keyboardView: KeyboardView? abstract var lastShiftPressTS: Long abstract var keyboardMode: Int @@ -116,7 +116,7 @@ abstract class GeneralKeyboardIME( override fun onCreate() { super.onCreate() keyboardBinding = KeyboardViewKeyboardBinding.inflate(layoutInflater) - keyboard = MyKeyboard(this, getKeyboardLayoutXML(), enterKeyType) + keyboard = KeyboardBase(this, getKeyboardLayoutXML(), enterKeyType) onCreateInputView() setupCommandBarTheme(binding) } @@ -138,11 +138,11 @@ abstract class GeneralKeyboardIME( updateCommandBarHintandPrompt() enterKeyType = if (isCommandMode) { - MyKeyboard.MyCustomActions.IME_ACTION_COMMAND + KeyboardBase.MyCustomActions.IME_ACTION_COMMAND } else { currentEnterKeyType!! } - keyboard = MyKeyboard(this, getKeyboardLayoutXML(), enterKeyType) + keyboard = KeyboardBase(this, getKeyboardLayoutXML(), enterKeyType) } fun getIsAccentCharacterDisabled(): Boolean { @@ -347,7 +347,7 @@ abstract class GeneralKeyboardIME( override fun onInitializeInterface() { super.onInitializeInterface() - keyboard = MyKeyboard(this, getKeyboardLayoutXML(), enterKeyType) + keyboard = KeyboardBase(this, getKeyboardLayoutXML(), enterKeyType) } override fun hasTextBeforeCursor(): Boolean { @@ -534,7 +534,7 @@ abstract class GeneralKeyboardIME( emojiKeywords = dbHelper.getEmojiKeywords(languageAlias) nounKeywords = dbHelper.getNounKeywords(languageAlias) - keyboard = MyKeyboard(this, keyboardXml, enterKeyType) + keyboard = KeyboardBase(this, keyboardXml, enterKeyType) keyboardView?.setKeyboard(keyboard!!) } @@ -570,7 +570,7 @@ abstract class GeneralKeyboardIME( override fun onActionUp() { if (switchToLetters) { keyboardMode = keyboardLetters - keyboard = MyKeyboard(this, getKeyboardLayoutXML(), enterKeyType) + keyboard = KeyboardBase(this, getKeyboardLayoutXML(), enterKeyType) val editorInfo = currentInputEditorInfo if ( @@ -653,7 +653,7 @@ abstract class GeneralKeyboardIME( this.keyboardMode = keyboardLetters getKeyboardLayoutXML() } - keyboard = MyKeyboard(context, keyboardXml, enterKeyType) + keyboard = KeyboardBase(context, keyboardXml, enterKeyType) keyboardView?.invalidateAllKeys() keyboardView?.setKeyboard(keyboard!!) } @@ -688,7 +688,7 @@ abstract class GeneralKeyboardIME( this.keyboardMode = keyboardSymbols R.xml.keys_symbols } - keyboard = MyKeyboard(this, keyboardXml, enterKeyType) + keyboard = KeyboardBase(this, keyboardXml, enterKeyType) keyboardView!!.setKeyboard(keyboard!!) } } @@ -752,7 +752,7 @@ abstract class GeneralKeyboardIME( } } else { // Handling space key logic. - if (keyboardMode != keyboardLetters && code == MyKeyboard.KEYCODE_SPACE) { + if (keyboardMode != keyboardLetters && code == KeyboardBase.KEYCODE_SPACE) { binding?.commandBar?.text = " " val originalText = inputConnection.getExtractedText(ExtractedTextRequest(), 0).text inputConnection.commitText(codeChar.toString(), 1) diff --git a/app/src/main/java/be/scri/services/GermanKeyboardIME.kt b/app/src/main/java/be/scri/services/GermanKeyboardIME.kt index 2f2419e1..64600da1 100644 --- a/app/src/main/java/be/scri/services/GermanKeyboardIME.kt +++ b/app/src/main/java/be/scri/services/GermanKeyboardIME.kt @@ -25,7 +25,7 @@ import android.view.View import android.view.inputmethod.EditorInfo.IME_ACTION_NONE import be.scri.R import be.scri.databinding.KeyboardViewCommandOptionsBinding -import be.scri.helpers.MyKeyboard +import be.scri.helpers.KeyboardBase import be.scri.views.KeyboardView class GermanKeyboardIME : GeneralKeyboardIME("German") { @@ -42,7 +42,7 @@ class GermanKeyboardIME : GeneralKeyboardIME("German") { override lateinit var binding: KeyboardViewCommandOptionsBinding override var keyboardView: KeyboardView? = null - override var keyboard: MyKeyboard? = null + override var keyboard: KeyboardBase? = null override var enterKeyType = IME_ACTION_NONE override val keyboardLetters = 0 override val keyboardSymbols = 1 @@ -76,34 +76,34 @@ class GermanKeyboardIME : GeneralKeyboardIME("German") { if (keyboard == null || inputConnection == null) { return } - if (code != MyKeyboard.KEYCODE_SHIFT) { + if (code != KeyboardBase.KEYCODE_SHIFT) { lastShiftPressTS = 0 } when (code) { - MyKeyboard.KEYCODE_DELETE -> { + KeyboardBase.KEYCODE_DELETE -> { handleKeycodeDelete() keyboardView!!.invalidateAllKeys() disableAutoSuggest() } - MyKeyboard.KEYCODE_SHIFT -> { + KeyboardBase.KEYCODE_SHIFT -> { super.handleKeyboardLetters(keyboardMode, keyboardView) keyboardView!!.invalidateAllKeys() disableAutoSuggest() } - MyKeyboard.KEYCODE_ENTER -> { + KeyboardBase.KEYCODE_ENTER -> { handleKeycodeEnter() disableAutoSuggest() } - MyKeyboard.KEYCODE_MODE_CHANGE -> { + KeyboardBase.KEYCODE_MODE_CHANGE -> { handleModeChange(keyboardMode, keyboardView, this) disableAutoSuggest() } - MyKeyboard.KEYCODE_SPACE -> { + KeyboardBase.KEYCODE_SPACE -> { handleElseCondition(code, keyboardMode, binding = null) updateAutoSuggestText(nounTypeSuggestion) } @@ -126,7 +126,7 @@ class GermanKeyboardIME : GeneralKeyboardIME("German") { Log.d("Debug", "$autosuggestEmojis") Log.d("MY-TAG", "$nounTypeSuggestion") updateButtonText(isAutoSuggestEnabled, autosuggestEmojis) - if (code != MyKeyboard.KEYCODE_SHIFT) { + if (code != KeyboardBase.KEYCODE_SHIFT) { super.updateShiftKeyState() } } @@ -152,7 +152,7 @@ class GermanKeyboardIME : GeneralKeyboardIME("German") { override fun onCreate() { super.onCreate() - keyboard = MyKeyboard(this, getKeyboardLayoutXML(), enterKeyType) + keyboard = KeyboardBase(this, getKeyboardLayoutXML(), enterKeyType) onCreateInputView() setupCommandBarTheme(binding) } diff --git a/app/src/main/java/be/scri/services/ItalianKeyboardIME.kt b/app/src/main/java/be/scri/services/ItalianKeyboardIME.kt index b1279b6a..44e1a375 100644 --- a/app/src/main/java/be/scri/services/ItalianKeyboardIME.kt +++ b/app/src/main/java/be/scri/services/ItalianKeyboardIME.kt @@ -25,7 +25,7 @@ import android.view.View import android.view.inputmethod.EditorInfo.IME_ACTION_NONE import be.scri.R import be.scri.databinding.KeyboardViewCommandOptionsBinding -import be.scri.helpers.MyKeyboard +import be.scri.helpers.KeyboardBase import be.scri.views.KeyboardView class ItalianKeyboardIME : GeneralKeyboardIME("Italian") { @@ -38,7 +38,7 @@ class ItalianKeyboardIME : GeneralKeyboardIME("Italian") { override lateinit var binding: KeyboardViewCommandOptionsBinding override var keyboardView: KeyboardView? = null - override var keyboard: MyKeyboard? = null + override var keyboard: KeyboardBase? = null override var enterKeyType = IME_ACTION_NONE override val keyboardLetters = 0 override val keyboardSymbols = 1 @@ -68,34 +68,34 @@ class ItalianKeyboardIME : GeneralKeyboardIME("Italian") { if (keyboard == null || inputConnection == null) { return } - if (code != MyKeyboard.KEYCODE_SHIFT) { + if (code != KeyboardBase.KEYCODE_SHIFT) { lastShiftPressTS = 0 } when (code) { - MyKeyboard.KEYCODE_DELETE -> { + KeyboardBase.KEYCODE_DELETE -> { handleKeycodeDelete() keyboardView!!.invalidateAllKeys() disableAutoSuggest() } - MyKeyboard.KEYCODE_SHIFT -> { + KeyboardBase.KEYCODE_SHIFT -> { super.handleKeyboardLetters(keyboardMode, keyboardView) keyboardView!!.invalidateAllKeys() disableAutoSuggest() } - MyKeyboard.KEYCODE_ENTER -> { + KeyboardBase.KEYCODE_ENTER -> { handleKeycodeEnter() disableAutoSuggest() } - MyKeyboard.KEYCODE_MODE_CHANGE -> { + KeyboardBase.KEYCODE_MODE_CHANGE -> { handleModeChange(keyboardMode, keyboardView, this) disableAutoSuggest() } - MyKeyboard.KEYCODE_SPACE -> { + KeyboardBase.KEYCODE_SPACE -> { handleElseCondition(code, keyboardMode, binding = null) updateAutoSuggestText(nounTypeSuggestion) } @@ -118,7 +118,7 @@ class ItalianKeyboardIME : GeneralKeyboardIME("Italian") { Log.d("Debug", "$autosuggestEmojis") Log.d("MY-TAG", "$nounTypeSuggestion") updateButtonText(isAutoSuggestEnabled, autosuggestEmojis) - if (code != MyKeyboard.KEYCODE_SHIFT) { + if (code != KeyboardBase.KEYCODE_SHIFT) { super.updateShiftKeyState() } } @@ -144,7 +144,7 @@ class ItalianKeyboardIME : GeneralKeyboardIME("Italian") { override fun onCreate() { super.onCreate() - keyboard = MyKeyboard(this, getKeyboardLayoutXML(), enterKeyType) + keyboard = KeyboardBase(this, getKeyboardLayoutXML(), enterKeyType) onCreateInputView() setupCommandBarTheme(binding) } diff --git a/app/src/main/java/be/scri/services/PortugueseKeyboardIME.kt b/app/src/main/java/be/scri/services/PortugueseKeyboardIME.kt index 8b73eadb..cb9e2df8 100644 --- a/app/src/main/java/be/scri/services/PortugueseKeyboardIME.kt +++ b/app/src/main/java/be/scri/services/PortugueseKeyboardIME.kt @@ -25,7 +25,7 @@ import android.view.View import android.view.inputmethod.EditorInfo.IME_ACTION_NONE import be.scri.R import be.scri.databinding.KeyboardViewCommandOptionsBinding -import be.scri.helpers.MyKeyboard +import be.scri.helpers.KeyboardBase import be.scri.views.KeyboardView class PortugueseKeyboardIME : GeneralKeyboardIME("Portuguese") { @@ -38,7 +38,7 @@ class PortugueseKeyboardIME : GeneralKeyboardIME("Portuguese") { override lateinit var binding: KeyboardViewCommandOptionsBinding override var keyboardView: KeyboardView? = null - override var keyboard: MyKeyboard? = null + override var keyboard: KeyboardBase? = null override var enterKeyType = IME_ACTION_NONE override val keyboardLetters = 0 override val keyboardSymbols = 1 @@ -68,34 +68,34 @@ class PortugueseKeyboardIME : GeneralKeyboardIME("Portuguese") { if (keyboard == null || inputConnection == null) { return } - if (code != MyKeyboard.KEYCODE_SHIFT) { + if (code != KeyboardBase.KEYCODE_SHIFT) { lastShiftPressTS = 0 } when (code) { - MyKeyboard.KEYCODE_DELETE -> { + KeyboardBase.KEYCODE_DELETE -> { handleKeycodeDelete() keyboardView!!.invalidateAllKeys() disableAutoSuggest() } - MyKeyboard.KEYCODE_SHIFT -> { + KeyboardBase.KEYCODE_SHIFT -> { super.handleKeyboardLetters(keyboardMode, keyboardView) keyboardView!!.invalidateAllKeys() disableAutoSuggest() } - MyKeyboard.KEYCODE_ENTER -> { + KeyboardBase.KEYCODE_ENTER -> { handleKeycodeEnter() disableAutoSuggest() } - MyKeyboard.KEYCODE_MODE_CHANGE -> { + KeyboardBase.KEYCODE_MODE_CHANGE -> { handleModeChange(keyboardMode, keyboardView, this) disableAutoSuggest() } - MyKeyboard.KEYCODE_SPACE -> { + KeyboardBase.KEYCODE_SPACE -> { handleElseCondition(code, keyboardMode, binding = null) updateAutoSuggestText(nounTypeSuggestion) } @@ -118,7 +118,7 @@ class PortugueseKeyboardIME : GeneralKeyboardIME("Portuguese") { Log.d("Debug", "$autosuggestEmojis") Log.d("MY-TAG", "$nounTypeSuggestion") updateButtonText(isAutoSuggestEnabled, autosuggestEmojis) - if (code != MyKeyboard.KEYCODE_SHIFT) { + if (code != KeyboardBase.KEYCODE_SHIFT) { super.updateShiftKeyState() } } @@ -144,7 +144,7 @@ class PortugueseKeyboardIME : GeneralKeyboardIME("Portuguese") { override fun onCreate() { super.onCreate() - keyboard = MyKeyboard(this, getKeyboardLayoutXML(), enterKeyType) + keyboard = KeyboardBase(this, getKeyboardLayoutXML(), enterKeyType) onCreateInputView() setupCommandBarTheme(binding) } diff --git a/app/src/main/java/be/scri/services/RussianKeyboardIME.kt b/app/src/main/java/be/scri/services/RussianKeyboardIME.kt index b62fc348..424bf7c3 100644 --- a/app/src/main/java/be/scri/services/RussianKeyboardIME.kt +++ b/app/src/main/java/be/scri/services/RussianKeyboardIME.kt @@ -25,7 +25,7 @@ import android.view.View import android.view.inputmethod.EditorInfo.IME_ACTION_NONE import be.scri.R import be.scri.databinding.KeyboardViewCommandOptionsBinding -import be.scri.helpers.MyKeyboard +import be.scri.helpers.KeyboardBase import be.scri.views.KeyboardView class RussianKeyboardIME : GeneralKeyboardIME("Russian") { @@ -38,7 +38,7 @@ class RussianKeyboardIME : GeneralKeyboardIME("Russian") { override lateinit var binding: KeyboardViewCommandOptionsBinding override var keyboardView: KeyboardView? = null - override var keyboard: MyKeyboard? = null + override var keyboard: KeyboardBase? = null override var enterKeyType = IME_ACTION_NONE override val keyboardLetters = 0 override val keyboardSymbols = 1 @@ -68,34 +68,34 @@ class RussianKeyboardIME : GeneralKeyboardIME("Russian") { if (keyboard == null || inputConnection == null) { return } - if (code != MyKeyboard.KEYCODE_SHIFT) { + if (code != KeyboardBase.KEYCODE_SHIFT) { lastShiftPressTS = 0 } when (code) { - MyKeyboard.KEYCODE_DELETE -> { + KeyboardBase.KEYCODE_DELETE -> { handleKeycodeDelete() keyboardView!!.invalidateAllKeys() disableAutoSuggest() } - MyKeyboard.KEYCODE_SHIFT -> { + KeyboardBase.KEYCODE_SHIFT -> { super.handleKeyboardLetters(keyboardMode, keyboardView) keyboardView!!.invalidateAllKeys() disableAutoSuggest() } - MyKeyboard.KEYCODE_ENTER -> { + KeyboardBase.KEYCODE_ENTER -> { handleKeycodeEnter() disableAutoSuggest() } - MyKeyboard.KEYCODE_MODE_CHANGE -> { + KeyboardBase.KEYCODE_MODE_CHANGE -> { handleModeChange(keyboardMode, keyboardView, this) disableAutoSuggest() } - MyKeyboard.KEYCODE_SPACE -> { + KeyboardBase.KEYCODE_SPACE -> { handleElseCondition(code, keyboardMode, binding = null) updateAutoSuggestText(nounTypeSuggestion) } @@ -118,7 +118,7 @@ class RussianKeyboardIME : GeneralKeyboardIME("Russian") { Log.d("Debug", "$autosuggestEmojis") Log.d("MY-TAG", "$nounTypeSuggestion") updateButtonText(isAutoSuggestEnabled, autosuggestEmojis) - if (code != MyKeyboard.KEYCODE_SHIFT) { + if (code != KeyboardBase.KEYCODE_SHIFT) { super.updateShiftKeyState() } } @@ -144,7 +144,7 @@ class RussianKeyboardIME : GeneralKeyboardIME("Russian") { override fun onCreate() { super.onCreate() - keyboard = MyKeyboard(this, getKeyboardLayoutXML(), enterKeyType) + keyboard = KeyboardBase(this, getKeyboardLayoutXML(), enterKeyType) onCreateInputView() setupCommandBarTheme(binding) } diff --git a/app/src/main/java/be/scri/services/SpanishKeyboardIME.kt b/app/src/main/java/be/scri/services/SpanishKeyboardIME.kt index 60305927..4476114c 100644 --- a/app/src/main/java/be/scri/services/SpanishKeyboardIME.kt +++ b/app/src/main/java/be/scri/services/SpanishKeyboardIME.kt @@ -25,7 +25,7 @@ import android.view.View import android.view.inputmethod.EditorInfo.IME_ACTION_NONE import be.scri.R import be.scri.databinding.KeyboardViewCommandOptionsBinding -import be.scri.helpers.MyKeyboard +import be.scri.helpers.KeyboardBase import be.scri.views.KeyboardView class SpanishKeyboardIME : GeneralKeyboardIME("Spanish") { @@ -42,7 +42,7 @@ class SpanishKeyboardIME : GeneralKeyboardIME("Spanish") { override lateinit var binding: KeyboardViewCommandOptionsBinding override var keyboardView: KeyboardView? = null - override var keyboard: MyKeyboard? = null + override var keyboard: KeyboardBase? = null override var enterKeyType = IME_ACTION_NONE override val keyboardLetters = 0 override val keyboardSymbols = 1 @@ -72,34 +72,34 @@ class SpanishKeyboardIME : GeneralKeyboardIME("Spanish") { if (keyboard == null || inputConnection == null) { return } - if (code != MyKeyboard.KEYCODE_SHIFT) { + if (code != KeyboardBase.KEYCODE_SHIFT) { lastShiftPressTS = 0 } when (code) { - MyKeyboard.KEYCODE_DELETE -> { + KeyboardBase.KEYCODE_DELETE -> { handleKeycodeDelete() keyboardView!!.invalidateAllKeys() disableAutoSuggest() } - MyKeyboard.KEYCODE_SHIFT -> { + KeyboardBase.KEYCODE_SHIFT -> { super.handleKeyboardLetters(keyboardMode, keyboardView) keyboardView!!.invalidateAllKeys() disableAutoSuggest() } - MyKeyboard.KEYCODE_ENTER -> { + KeyboardBase.KEYCODE_ENTER -> { handleKeycodeEnter() disableAutoSuggest() } - MyKeyboard.KEYCODE_MODE_CHANGE -> { + KeyboardBase.KEYCODE_MODE_CHANGE -> { handleModeChange(keyboardMode, keyboardView, this) disableAutoSuggest() } - MyKeyboard.KEYCODE_SPACE -> { + KeyboardBase.KEYCODE_SPACE -> { handleElseCondition(code, keyboardMode, binding = null) updateAutoSuggestText(nounTypeSuggestion) } @@ -122,7 +122,7 @@ class SpanishKeyboardIME : GeneralKeyboardIME("Spanish") { Log.d("Debug", "$autosuggestEmojis") Log.d("MY-TAG", "$nounTypeSuggestion") updateButtonText(isAutoSuggestEnabled, autosuggestEmojis) - if (code != MyKeyboard.KEYCODE_SHIFT) { + if (code != KeyboardBase.KEYCODE_SHIFT) { super.updateShiftKeyState() } } @@ -148,7 +148,7 @@ class SpanishKeyboardIME : GeneralKeyboardIME("Spanish") { override fun onCreate() { super.onCreate() - keyboard = MyKeyboard(this, getKeyboardLayoutXML(), enterKeyType) + keyboard = KeyboardBase(this, getKeyboardLayoutXML(), enterKeyType) onCreateInputView() setupCommandBarTheme(binding) } diff --git a/app/src/main/java/be/scri/services/SwedishKeyboardIME.kt b/app/src/main/java/be/scri/services/SwedishKeyboardIME.kt index 4d8b6c27..88dd2953 100644 --- a/app/src/main/java/be/scri/services/SwedishKeyboardIME.kt +++ b/app/src/main/java/be/scri/services/SwedishKeyboardIME.kt @@ -25,7 +25,7 @@ import android.view.View import android.view.inputmethod.EditorInfo.IME_ACTION_NONE import be.scri.R import be.scri.databinding.KeyboardViewCommandOptionsBinding -import be.scri.helpers.MyKeyboard +import be.scri.helpers.KeyboardBase import be.scri.views.KeyboardView class SwedishKeyboardIME : GeneralKeyboardIME("Swedish") { @@ -42,7 +42,7 @@ class SwedishKeyboardIME : GeneralKeyboardIME("Swedish") { override lateinit var binding: KeyboardViewCommandOptionsBinding override var keyboardView: KeyboardView? = null - override var keyboard: MyKeyboard? = null + override var keyboard: KeyboardBase? = null override var enterKeyType = IME_ACTION_NONE override val keyboardLetters = 0 override val keyboardSymbols = 1 @@ -72,34 +72,34 @@ class SwedishKeyboardIME : GeneralKeyboardIME("Swedish") { if (keyboard == null || inputConnection == null) { return } - if (code != MyKeyboard.KEYCODE_SHIFT) { + if (code != KeyboardBase.KEYCODE_SHIFT) { lastShiftPressTS = 0 } when (code) { - MyKeyboard.KEYCODE_DELETE -> { + KeyboardBase.KEYCODE_DELETE -> { handleKeycodeDelete() keyboardView!!.invalidateAllKeys() disableAutoSuggest() } - MyKeyboard.KEYCODE_SHIFT -> { + KeyboardBase.KEYCODE_SHIFT -> { super.handleKeyboardLetters(keyboardMode, keyboardView) keyboardView!!.invalidateAllKeys() disableAutoSuggest() } - MyKeyboard.KEYCODE_ENTER -> { + KeyboardBase.KEYCODE_ENTER -> { handleKeycodeEnter() disableAutoSuggest() } - MyKeyboard.KEYCODE_MODE_CHANGE -> { + KeyboardBase.KEYCODE_MODE_CHANGE -> { handleModeChange(keyboardMode, keyboardView, this) disableAutoSuggest() } - MyKeyboard.KEYCODE_SPACE -> { + KeyboardBase.KEYCODE_SPACE -> { handleElseCondition(code, keyboardMode, binding = null) updateAutoSuggestText(nounTypeSuggestion) } @@ -122,7 +122,7 @@ class SwedishKeyboardIME : GeneralKeyboardIME("Swedish") { Log.d("Debug", "$autosuggestEmojis") Log.d("MY-TAG", "$nounTypeSuggestion") updateButtonText(isAutoSuggestEnabled, autosuggestEmojis) - if (code != MyKeyboard.KEYCODE_SHIFT) { + if (code != KeyboardBase.KEYCODE_SHIFT) { super.updateShiftKeyState() } } @@ -148,7 +148,7 @@ class SwedishKeyboardIME : GeneralKeyboardIME("Swedish") { override fun onCreate() { super.onCreate() - keyboard = MyKeyboard(this, getKeyboardLayoutXML(), enterKeyType) + keyboard = KeyboardBase(this, getKeyboardLayoutXML(), enterKeyType) onCreateInputView() setupCommandBarTheme(binding) } diff --git a/app/src/main/java/be/scri/views/KeyboardView.kt b/app/src/main/java/be/scri/views/KeyboardView.kt index 71c08f62..718bfca4 100644 --- a/app/src/main/java/be/scri/views/KeyboardView.kt +++ b/app/src/main/java/be/scri/views/KeyboardView.kt @@ -64,12 +64,12 @@ import be.scri.extensions.getProperTextColor import be.scri.extensions.getStrokeColor import be.scri.extensions.performHapticFeedback import be.scri.helpers.MAX_KEYS_PER_MINI_ROW -import be.scri.helpers.MyKeyboard -import be.scri.helpers.MyKeyboard.Companion.KEYCODE_DELETE -import be.scri.helpers.MyKeyboard.Companion.KEYCODE_ENTER -import be.scri.helpers.MyKeyboard.Companion.KEYCODE_MODE_CHANGE -import be.scri.helpers.MyKeyboard.Companion.KEYCODE_SHIFT -import be.scri.helpers.MyKeyboard.Companion.KEYCODE_SPACE +import be.scri.helpers.KeyboardBase +import be.scri.helpers.KeyboardBase.Companion.KEYCODE_DELETE +import be.scri.helpers.KeyboardBase.Companion.KEYCODE_ENTER +import be.scri.helpers.KeyboardBase.Companion.KEYCODE_MODE_CHANGE +import be.scri.helpers.KeyboardBase.Companion.KEYCODE_SHIFT +import be.scri.helpers.KeyboardBase.Companion.KEYCODE_SPACE import be.scri.helpers.SHIFT_OFF import be.scri.helpers.SHIFT_ON_ONE_CHAR import be.scri.helpers.SHIFT_ON_PERMANENT @@ -126,7 +126,7 @@ class KeyboardView fun commitPeriodAfterSpace() } - private var mKeyboard: MyKeyboard? = null + private var mKeyboard: KeyboardBase? = null private var mCurrentKeyIndex: Int = NOT_A_KEY private var mLabelTextSize = 0 @@ -150,8 +150,8 @@ class KeyboardView private var mPopupParent: View private var mMiniKeyboardOffsetX = 0 private var mMiniKeyboardOffsetY = 0 - private val mMiniKeyboardCache: MutableMap - private var mKeys = ArrayList() + private val mMiniKeyboardCache: MutableMap + private var mKeys = ArrayList() private var mMiniKeyboardSelectedKeyIndex = -1 var mOnKeyboardActionListener: OnKeyboardActionListener? = null @@ -450,7 +450,7 @@ class KeyboardView * The keyboard can be switched at any time and the view will re-layout itself to accommodate the keyboard. * @param keyboard the keyboard to display in this view */ - fun setKeyboard(keyboard: MyKeyboard) { + fun setKeyboard(keyboard: KeyboardBase) { if (mKeyboard != null) { showPreview(NOT_A_KEY) } @@ -458,7 +458,7 @@ class KeyboardView removeMessages() mKeyboard = keyboard val keys = mKeyboard!!.mKeys - mKeys = keys!!.toMutableList() as ArrayList + mKeys = keys!!.toMutableList() as ArrayList requestLayout() mKeyboardChanged = true invalidateAllKeys() @@ -544,7 +544,7 @@ class KeyboardView * We use a square here and in computing the touch distance from a key's center to avoid taking a square root. * @param keyboard */ - private fun computeProximityThreshold(keyboard: MyKeyboard?) { + private fun computeProximityThreshold(keyboard: KeyboardBase?) { if (keyboard == null) { return } @@ -979,7 +979,7 @@ class KeyboardView * Invalidates a key so that it will be redrawn on the next repaint. * Use this method if only one key is changing it's content. Any changes that * affect the position or size of the key may not be honored. - * @param keyIndex the index of the key in the attached [MyKeyboard]. + * @param keyIndex the index of the key in the attached [KeyboardBase]. */ private fun invalidateKey(keyIndex: Int) { if (keyIndex < 0 || keyIndex >= mKeys.size) { @@ -1027,7 +1027,7 @@ class KeyboardView * handle the call. */ private fun onLongPress( - popupKey: MyKeyboard.Key, + popupKey: KeyboardBase.Key, me: MotionEvent, ): Boolean { val popupKeyboardId = popupKey.popupResId @@ -1079,9 +1079,9 @@ class KeyboardView val keyboard = if (popupKey.popupCharacters != null) { - MyKeyboard(context, popupKeyboardId, popupKey.popupCharacters!!, popupKey.width) + KeyboardBase(context, popupKeyboardId, popupKey.popupCharacters!!, popupKey.width) } else { - MyKeyboard(context, popupKeyboardId, 0) + KeyboardBase(context, popupKeyboardId, 0) } mMiniKeyboard!!.setKeyboard(keyboard) diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml index cabdec88..dfeae39c 100644 --- a/app/src/main/res/values/attrs.xml +++ b/app/src/main/res/values/attrs.xml @@ -8,12 +8,12 @@ - + - + diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index b185c863..cece5b79 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -2,15 +2,15 @@ - -