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 f2a970f..53e7703 100644
--- a/app/src/main/kotlin/com/simplemobiletools/keyboard/activities/SettingsActivity.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/activities/SettingsActivity.kt
@@ -31,6 +31,7 @@ class SettingsActivity : SimpleActivity() {
setupVibrateOnKeypress()
setupShowPopupOnKeypress()
setupKeyboardLanguage()
+ setupKeyboardHeightMultiplier()
updateTextColors(settings_nested_scrollview)
@@ -137,4 +138,29 @@ class SettingsActivity : SimpleActivity() {
else -> "${getString(R.string.translation_english)} (QWERTY)"
}
}
+
+ private fun setupKeyboardHeightMultiplier() {
+ settings_height_multiplier.text = getKeyboardHeightMultiplierText(config.keyboardHeightMultiplier)
+ settings_keyboard_height_multiplier_holder.setOnClickListener {
+ val items = arrayListOf(
+ RadioItem(KEYBOARD_HEIGHT_MULTIPLIER_SMALL, getKeyboardHeightMultiplierText(KEYBOARD_HEIGHT_MULTIPLIER_SMALL)),
+ RadioItem(KEYBOARD_HEIGHT_MULTIPLIER_MEDIUM, getKeyboardHeightMultiplierText(KEYBOARD_HEIGHT_MULTIPLIER_MEDIUM)),
+ RadioItem(KEYBOARD_HEIGHT_MULTIPLIER_BIG, getKeyboardHeightMultiplierText(KEYBOARD_HEIGHT_MULTIPLIER_BIG)),
+ )
+
+ RadioGroupDialog(this@SettingsActivity, items, config.keyboardHeightMultiplier) {
+ config.keyboardHeightMultiplier = it as Int
+ settings_height_multiplier.text = getKeyboardHeightMultiplierText(config.keyboardHeightMultiplier)
+ }
+ }
+ }
+
+ private fun getKeyboardHeightMultiplierText(multiplier: Int): String {
+ return when (multiplier) {
+ KEYBOARD_HEIGHT_MULTIPLIER_SMALL -> getString(R.string.settings_keyboard_height_multiplier_option_small)
+ KEYBOARD_HEIGHT_MULTIPLIER_MEDIUM -> getString(R.string.settings_keyboard_height_multiplier_option_medium)
+ KEYBOARD_HEIGHT_MULTIPLIER_BIG -> getString(R.string.settings_keyboard_height_multiplier_option_big)
+ else -> {getString(R.string.settings_keyboard_height_multiplier_option_small)}
+ }
+ }
}
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 d183b4f..175d34e 100644
--- a/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/Config.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/Config.kt
@@ -25,6 +25,11 @@ class Config(context: Context) : BaseConfig(context) {
get() = prefs.getInt(KEYBOARD_LANGUAGE, getDefaultLanguage())
set(keyboardLanguage) = prefs.edit().putInt(KEYBOARD_LANGUAGE, keyboardLanguage).apply()
+ var keyboardHeightMultiplier: Int
+ get() = prefs.getInt(HEIGHT_MULTIPLIER, 1)
+ set(keyboardHeightMultiplier) = prefs.edit().putInt(HEIGHT_MULTIPLIER, keyboardHeightMultiplier).apply()
+
+
private fun getDefaultLanguage(): Int {
val conf = context.resources.configuration
return if (conf.locale.toString().toLowerCase(Locale.getDefault()).startsWith("ru_")) {
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 acbd2ab..7b665c0 100644
--- a/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/Constants.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/Constants.kt
@@ -12,6 +12,7 @@ const val VIBRATE_ON_KEYPRESS = "vibrate_on_keypress"
const val SHOW_POPUP_ON_KEYPRESS = "show_popup_on_keypress"
const val LAST_EXPORTED_CLIPS_FOLDER = "last_exported_clips_folder"
const val KEYBOARD_LANGUAGE = "keyboard_language"
+const val HEIGHT_MULTIPLIER = "height_multiplier"
// differentiate current and pinned clips at the keyboards' Clipboard section
const val ITEM_SECTION_LABEL = 0
@@ -26,3 +27,8 @@ const val LANGUAGE_GERMAN = 5
const val LANGUAGE_ENGLISH_DVORAK = 6
const val LANGUAGE_ROMANIAN = 7
const val LANGUAGE_SLOVENIAN = 8
+
+// keyboard height multiplier options
+const val KEYBOARD_HEIGHT_MULTIPLIER_SMALL = 1
+const val KEYBOARD_HEIGHT_MULTIPLIER_MEDIUM = 2
+const val KEYBOARD_HEIGHT_MULTIPLIER_BIG = 3
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 42cfb9e..674c126 100644
--- a/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/MyKeyboard.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/MyKeyboard.kt
@@ -12,7 +12,9 @@ import android.view.inputmethod.EditorInfo
import android.view.inputmethod.EditorInfo.IME_ACTION_NONE
import androidx.annotation.XmlRes
import com.simplemobiletools.keyboard.R
+import com.simplemobiletools.keyboard.extensions.config
import java.util.*
+import kotlin.math.roundToInt
/**
* Loads an XML description of a keyboard and stores the attributes of the keys. A keyboard consists of rows of keys.
@@ -29,6 +31,9 @@ class MyKeyboard {
/** Default key height */
private var mDefaultHeight = 0
+ /** Multiplier for the keyboard height */
+ var mKeyboardHeightMultiplier: Float = 1F
+
/** Is the keyboard in the shifted state */
var mShiftState = SHIFT_OFF
@@ -100,7 +105,7 @@ class MyKeyboard {
this.parent = parent
val a = res.obtainAttributes(Xml.asAttributeSet(parser), R.styleable.MyKeyboard)
defaultWidth = getDimensionOrFraction(a, R.styleable.MyKeyboard_keyWidth, parent.mDisplayWidth, parent.mDefaultWidth)
- defaultHeight = res.getDimension(R.dimen.key_height).toInt()
+ defaultHeight = (res.getDimension(R.dimen.key_height) * this.parent.mKeyboardHeightMultiplier).roundToInt()
defaultHorizontalGap = getDimensionOrFraction(a, R.styleable.MyKeyboard_horizontalGap, parent.mDisplayWidth, parent.mDefaultHorizontalGap)
a.recycle()
}
@@ -244,6 +249,12 @@ class MyKeyboard {
mDefaultHorizontalGap = 0
mDefaultWidth = mDisplayWidth / 10
mDefaultHeight = mDefaultWidth
+ mKeyboardHeightMultiplier = when (context.config.keyboardHeightMultiplier){
+ KEYBOARD_HEIGHT_MULTIPLIER_SMALL -> 1F
+ KEYBOARD_HEIGHT_MULTIPLIER_MEDIUM -> 1.2F
+ KEYBOARD_HEIGHT_MULTIPLIER_BIG -> 1.4F
+ else -> 1F
+ }
mKeys = ArrayList()
mEnterKeyType = enterKeyType
loadKeyboard(context, context.resources.getXml(xmlLayoutResId))
@@ -267,6 +278,12 @@ class MyKeyboard {
row.defaultHeight = mDefaultHeight
row.defaultWidth = keyWidth
row.defaultHorizontalGap = mDefaultHorizontalGap
+ mKeyboardHeightMultiplier = when (context.config.keyboardHeightMultiplier){
+ KEYBOARD_HEIGHT_MULTIPLIER_SMALL -> 1F
+ KEYBOARD_HEIGHT_MULTIPLIER_MEDIUM -> 1.2F
+ KEYBOARD_HEIGHT_MULTIPLIER_BIG -> 1.4F
+ else -> 1F
+ }
characters.forEachIndexed { index, character ->
val key = Key(row)
diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml
index 43db2eb..3e7419e 100644
--- a/app/src/main/res/layout/activity_settings.xml
+++ b/app/src/main/res/layout/activity_settings.xml
@@ -185,6 +185,30 @@
tools:text="@string/translation_english" />
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/values-ar/strings.xml b/app/src/main/res/values-ar/strings.xml
index 4226e91..dbc7da3 100644
--- a/app/src/main/res/values-ar/strings.xml
+++ b/app/src/main/res/values-ar/strings.xml
@@ -31,6 +31,10 @@
Show a popup on keypress
Vibrate on keypress
Keyboard language
+ Keyboard height
+ Small
+ Medium
+ Large