diff --git a/app/src/main/kotlin/com/simplemobiletools/keyboard/activities/SettingsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/keyboard/activities/SettingsActivity.kt index 5bfe2b14..df9aa832 100644 --- a/app/src/main/kotlin/com/simplemobiletools/keyboard/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/activities/SettingsActivity.kt @@ -44,6 +44,7 @@ class SettingsActivity : SimpleActivity() { setupKeyboardLanguage() setupKeyboardHeightMultiplier() setupShowClipboardContent() + setupShowNumbersRow() updateTextColors(settings_nested_scrollview) @@ -159,4 +160,11 @@ class SettingsActivity : SimpleActivity() { config.showClipboardContent = settings_show_clipboard_content.isChecked } } + private fun setupShowNumbersRow() { + settings_show_numbers_row.isChecked = config.showNumbersRow + settings_show_numbers_row_holder.setOnClickListener { + settings_show_numbers_row.toggle() + config.showNumbersRow = settings_show_numbers_row.isChecked + } + } } diff --git a/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/Config.kt b/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/Config.kt index 694293ee..cb17a744 100644 --- a/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/Config.kt +++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/Config.kt @@ -37,6 +37,9 @@ class Config(context: Context) : BaseConfig(context) { get() = prefs.getBoolean(SHOW_CLIPBOARD_CONTENT, true) set(showClipboardContent) = prefs.edit().putBoolean(SHOW_CLIPBOARD_CONTENT, showClipboardContent).apply() + var showNumbersRow: Boolean + get() = prefs.getBoolean(SHOW_NUMBERS_ROW, false) + set(showNumbersRow) = prefs.edit().putBoolean(SHOW_NUMBERS_ROW, showNumbersRow).apply() private fun getDefaultLanguage(): Int { val conf = context.resources.configuration diff --git a/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/Constants.kt index ddc2838a..78a59fc6 100644 --- a/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/Constants.kt @@ -15,6 +15,7 @@ const val LAST_EXPORTED_CLIPS_FOLDER = "last_exported_clips_folder" const val KEYBOARD_LANGUAGE = "keyboard_language" const val HEIGHT_MULTIPLIER = "height_multiplier" const val SHOW_CLIPBOARD_CONTENT = "show_clipboard_content" +const val SHOW_NUMBERS_ROW = "show_numbers_row" // differentiate current and pinned clips at the keyboards' Clipboard section const val ITEM_SECTION_LABEL = 0 diff --git a/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/MyKeyboard.kt b/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/MyKeyboard.kt index 69d37b33..b2c77c00 100644 --- a/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/MyKeyboard.kt +++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/MyKeyboard.kt @@ -97,6 +97,8 @@ class MyKeyboard { var parent: MyKeyboard + var isNumbersRow: Boolean = false + constructor(parent: MyKeyboard) { this.parent = parent } @@ -107,6 +109,7 @@ class MyKeyboard { defaultWidth = getDimensionOrFraction(a, R.styleable.MyKeyboard_keyWidth, parent.mDisplayWidth, parent.mDefaultWidth) defaultHeight = (res.getDimension(R.dimen.key_height) * this.parent.mKeyboardHeightMultiplier).roundToInt() defaultHorizontalGap = getDimensionOrFraction(a, R.styleable.MyKeyboard_horizontalGap, parent.mDisplayWidth, parent.mDefaultHorizontalGap) + isNumbersRow = a.getBoolean(R.styleable.MyKeyboard_isNumbersRow, false) a.recycle() } } @@ -342,14 +345,31 @@ class MyKeyboard { if (event == XmlResourceParser.START_TAG) { when (parser.name) { TAG_ROW -> { + currentRow = createRowFromXml(res, parser) + if (currentRow.isNumbersRow && !context.config.showNumbersRow) { + continue + } inRow = true x = 0 - currentRow = createRowFromXml(res, parser) mRows.add(currentRow) } + TAG_KEY -> { + if (currentRow?.isNumbersRow == true && !context.config.showNumbersRow) { + continue + } inKey = true key = createKeyFromXml(res, currentRow!!, x, y, parser) + if (context.config.showNumbersRow) { + // Removes numbers (i.e 0-9) from the popupCharacters if numbers row is enabled + key.apply { + popupCharacters = popupCharacters?.replace(Regex("\\d+"), "") + if (popupCharacters.isNullOrEmpty()) { + popupResId = 0 + } + } + + } mKeys!!.add(key) if (key.code == KEYCODE_ENTER) { val enterResourceId = when (mEnterKeyType) { @@ -362,6 +382,7 @@ class MyKeyboard { } currentRow.mKeys.add(key) } + TAG_KEYBOARD -> { parseKeyboardAttributes(res, parser) } diff --git a/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt b/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt index 262450e1..dd1f5202 100644 --- a/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt +++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt @@ -138,6 +138,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut private var mLastKey = 0 private var mLastCodeX = 0 private var mLastCodeY = 0 + private var mLastKeyPressedCode = 0 private var mCurrentKey: Int = NOT_A_KEY private var mLastKeyTime = 0L private var mCurrentKeyTime = 0L @@ -263,6 +264,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut val repeat = Message.obtain(this, MSG_REPEAT) sendMessageDelayed(repeat, REPEAT_INTERVAL.toLong()) } + MSG_LONGPRESS -> openPopupIfRequired(msg.obj as MotionEvent) } } @@ -591,7 +593,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut label, (key.width / 2).toFloat(), key.height / 2 + (paint.textSize - paint.descent()) / 2, paint ) - if (key.topSmallNumber.isNotEmpty()) { + if (key.topSmallNumber.isNotEmpty() && !context.config.showNumbersRow) { canvas.drawText(key.topSmallNumber, key.width - mTopSmallNumberMarginWidth, mTopSmallNumberMarginHeight, smallLetterPaint) } @@ -1204,6 +1206,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut } } } + MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> { mMiniKeyboard?.mKeys?.firstOrNull { it.focused }?.apply { mOnKeyboardActionListener!!.onKey(code) @@ -1262,6 +1265,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut invalidateKey(mCurrentKey) return true } + MotionEvent.ACTION_DOWN -> { mAbortKey = false mLastCodeX = touchX @@ -1278,8 +1282,8 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut } else { 0 } - mOnKeyboardActionListener!!.onPress(onPressKey) + mLastKeyPressedCode = onPressKey var wasHandled = false if (mCurrentKey >= 0 && mKeys[mCurrentKey].repeatable) { @@ -1310,6 +1314,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut showPreview(keyIndex) } } + MotionEvent.ACTION_MOVE -> { var continueLongPress = false if (keyIndex != NOT_A_KEY) { @@ -1363,6 +1368,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut mLastMoveTime = eventTime } } + MotionEvent.ACTION_UP -> { mLastSpaceMoveX = 0 removeMessages() @@ -1391,11 +1397,14 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut detectAndSendKey(mCurrentKey, touchX, touchY, eventTime) } - invalidateKey(keyIndex) + if (mLastKeyPressedCode != KEYCODE_MODE_CHANGE) { + invalidateKey(keyIndex) + } mRepeatKeyIndex = NOT_A_KEY mOnKeyboardActionListener!!.onActionUp() mIsLongPressingSpace = false } + MotionEvent.ACTION_CANCEL -> { mIsLongPressingSpace = false mLastSpaceMoveX = 0 @@ -1515,12 +1524,14 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut mHandler!!.sendMessageDelayed(msg, REPEAT_START_DELAY.toLong()) true } + MotionEvent.ACTION_UP -> { mHandler!!.removeMessages(MSG_REPEAT) mRepeatKeyIndex = NOT_A_KEY isPressed = false false } + else -> false } } diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index 832b3971..1230d13b 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -189,6 +189,20 @@ android:layout_height="wrap_content" android:text="@string/show_clipboard_content" /> + + + + + + diff --git a/app/src/main/res/xml/keys_letters_bengali.xml b/app/src/main/res/xml/keys_letters_bengali.xml index c57ffbfc..8803bbbe 100644 --- a/app/src/main/res/xml/keys_letters_bengali.xml +++ b/app/src/main/res/xml/keys_letters_bengali.xml @@ -1,5 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + app:keyWidth="10%p" + app:secondaryKeyIcon="@drawable/ic_language_outlined" /> + app:popupKeyboard="@xml/keyboard_popup_template" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +