Merge pull request #215 from esensar/feature/126-more-height-options
Add keyboard height percentage options
This commit is contained in:
commit
1316d7fc21
4 changed files with 28 additions and 36 deletions
|
@ -11,9 +11,7 @@ import com.simplemobiletools.keyboard.R
|
|||
import com.simplemobiletools.keyboard.extensions.config
|
||||
import com.simplemobiletools.keyboard.extensions.getKeyboardLanguageText
|
||||
import com.simplemobiletools.keyboard.extensions.getKeyboardLanguages
|
||||
import com.simplemobiletools.keyboard.helpers.KEYBOARD_HEIGHT_MULTIPLIER_LARGE
|
||||
import com.simplemobiletools.keyboard.helpers.KEYBOARD_HEIGHT_MULTIPLIER_MEDIUM
|
||||
import com.simplemobiletools.keyboard.helpers.KEYBOARD_HEIGHT_MULTIPLIER_SMALL
|
||||
import com.simplemobiletools.keyboard.helpers.*
|
||||
import kotlinx.android.synthetic.main.activity_settings.*
|
||||
import java.util.*
|
||||
import kotlin.system.exitProcess
|
||||
|
@ -130,29 +128,26 @@ class SettingsActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
private fun setupKeyboardHeightMultiplier() {
|
||||
settings_keyboard_height_multiplier.text = getKeyboardHeightMultiplierText(config.keyboardHeightMultiplier)
|
||||
settings_keyboard_height_multiplier.text = getKeyboardHeightPercentageText(config.keyboardHeightPercentage)
|
||||
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_LARGE, getKeyboardHeightMultiplierText(KEYBOARD_HEIGHT_MULTIPLIER_LARGE)),
|
||||
RadioItem(KEYBOARD_HEIGHT_70_PERCENT, getKeyboardHeightPercentageText(KEYBOARD_HEIGHT_70_PERCENT)),
|
||||
RadioItem(KEYBOARD_HEIGHT_80_PERCENT, getKeyboardHeightPercentageText(KEYBOARD_HEIGHT_80_PERCENT)),
|
||||
RadioItem(KEYBOARD_HEIGHT_90_PERCENT, getKeyboardHeightPercentageText(KEYBOARD_HEIGHT_90_PERCENT)),
|
||||
RadioItem(KEYBOARD_HEIGHT_100_PERCENT, getKeyboardHeightPercentageText(KEYBOARD_HEIGHT_100_PERCENT)),
|
||||
RadioItem(KEYBOARD_HEIGHT_120_PERCENT, getKeyboardHeightPercentageText(KEYBOARD_HEIGHT_120_PERCENT)),
|
||||
RadioItem(KEYBOARD_HEIGHT_140_PERCENT, getKeyboardHeightPercentageText(KEYBOARD_HEIGHT_140_PERCENT)),
|
||||
RadioItem(KEYBOARD_HEIGHT_160_PERCENT, getKeyboardHeightPercentageText(KEYBOARD_HEIGHT_160_PERCENT)),
|
||||
)
|
||||
|
||||
RadioGroupDialog(this@SettingsActivity, items, config.keyboardHeightMultiplier) {
|
||||
config.keyboardHeightMultiplier = it as Int
|
||||
settings_keyboard_height_multiplier.text = getKeyboardHeightMultiplierText(config.keyboardHeightMultiplier)
|
||||
RadioGroupDialog(this@SettingsActivity, items, config.keyboardHeightPercentage) {
|
||||
config.keyboardHeightPercentage = it as Int
|
||||
settings_keyboard_height_multiplier.text = getKeyboardHeightPercentageText(config.keyboardHeightPercentage)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getKeyboardHeightMultiplierText(multiplier: Int): String {
|
||||
return when (multiplier) {
|
||||
KEYBOARD_HEIGHT_MULTIPLIER_SMALL -> getString(R.string.small)
|
||||
KEYBOARD_HEIGHT_MULTIPLIER_MEDIUM -> getString(R.string.medium)
|
||||
KEYBOARD_HEIGHT_MULTIPLIER_LARGE -> getString(R.string.large)
|
||||
else -> getString(R.string.small)
|
||||
}
|
||||
}
|
||||
private fun getKeyboardHeightPercentageText(keyboardHeightPercentage: Int): String = "$keyboardHeightPercentage%"
|
||||
|
||||
private fun setupShowClipboardContent() {
|
||||
settings_show_clipboard_content.isChecked = config.showClipboardContent
|
||||
|
|
|
@ -35,9 +35,9 @@ 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()
|
||||
var keyboardHeightPercentage: Int
|
||||
get() = prefs.getInt(HEIGHT_PERCENTAGE, 100)
|
||||
set(keyboardHeightMultiplier) = prefs.edit().putInt(HEIGHT_PERCENTAGE, keyboardHeightMultiplier).apply()
|
||||
|
||||
var showClipboardContent: Boolean
|
||||
get() = prefs.getBoolean(SHOW_CLIPBOARD_CONTENT, true)
|
||||
|
|
|
@ -17,7 +17,7 @@ const val SHOW_KEY_BORDERS = "show_key_borders"
|
|||
const val SENTENCES_CAPITALIZATION = "sentences_capitalization"
|
||||
const val LAST_EXPORTED_CLIPS_FOLDER = "last_exported_clips_folder"
|
||||
const val KEYBOARD_LANGUAGE = "keyboard_language"
|
||||
const val HEIGHT_MULTIPLIER = "height_multiplier"
|
||||
const val HEIGHT_PERCENTAGE = "height_percentage"
|
||||
const val SHOW_CLIPBOARD_CONTENT = "show_clipboard_content"
|
||||
const val SHOW_NUMBERS_ROW = "show_numbers_row"
|
||||
|
||||
|
@ -45,10 +45,14 @@ const val LANGUAGE_DANISH = 16
|
|||
const val LANGUAGE_FRENCH_BEPO = 17
|
||||
const val LANGUAGE_VIETNAMESE_TELEX = 18
|
||||
|
||||
// keyboard height multiplier options
|
||||
const val KEYBOARD_HEIGHT_MULTIPLIER_SMALL = 1
|
||||
const val KEYBOARD_HEIGHT_MULTIPLIER_MEDIUM = 2
|
||||
const val KEYBOARD_HEIGHT_MULTIPLIER_LARGE = 3
|
||||
// keyboard height percentage options
|
||||
const val KEYBOARD_HEIGHT_70_PERCENT = 70
|
||||
const val KEYBOARD_HEIGHT_80_PERCENT = 80
|
||||
const val KEYBOARD_HEIGHT_90_PERCENT = 90
|
||||
const val KEYBOARD_HEIGHT_100_PERCENT = 100
|
||||
const val KEYBOARD_HEIGHT_120_PERCENT = 120
|
||||
const val KEYBOARD_HEIGHT_140_PERCENT = 140
|
||||
const val KEYBOARD_HEIGHT_160_PERCENT = 160
|
||||
|
||||
const val EMOJI_SPEC_FILE_PATH = "media/emoji_spec.txt"
|
||||
const val LANGUAGE_VN_TELEX = "language/extension.json"
|
||||
|
|
|
@ -273,7 +273,7 @@ class MyKeyboard {
|
|||
mDefaultHorizontalGap = 0
|
||||
mDefaultWidth = mDisplayWidth / 10
|
||||
mDefaultHeight = mDefaultWidth
|
||||
mKeyboardHeightMultiplier = getKeyboardHeightMultiplier(context.config.keyboardHeightMultiplier)
|
||||
mKeyboardHeightMultiplier = getKeyboardHeightMultiplier(context.config.keyboardHeightPercentage)
|
||||
mKeys = ArrayList()
|
||||
mEnterKeyType = enterKeyType
|
||||
loadKeyboard(context, context.resources.getXml(xmlLayoutResId))
|
||||
|
@ -296,7 +296,7 @@ class MyKeyboard {
|
|||
row.defaultHeight = mDefaultHeight
|
||||
row.defaultWidth = keyWidth
|
||||
row.defaultHorizontalGap = mDefaultHorizontalGap
|
||||
mKeyboardHeightMultiplier = getKeyboardHeightMultiplier(context.config.keyboardHeightMultiplier)
|
||||
mKeyboardHeightMultiplier = getKeyboardHeightMultiplier(context.config.keyboardHeightPercentage)
|
||||
|
||||
characters.forEachIndexed { index, character ->
|
||||
val key = Key(row)
|
||||
|
@ -425,12 +425,5 @@ class MyKeyboard {
|
|||
a.recycle()
|
||||
}
|
||||
|
||||
private fun getKeyboardHeightMultiplier(multiplierType: Int): Float {
|
||||
return when (multiplierType) {
|
||||
KEYBOARD_HEIGHT_MULTIPLIER_SMALL -> 1.0F
|
||||
KEYBOARD_HEIGHT_MULTIPLIER_MEDIUM -> 1.2F
|
||||
KEYBOARD_HEIGHT_MULTIPLIER_LARGE -> 1.4F
|
||||
else -> 1.0F
|
||||
}
|
||||
}
|
||||
private fun getKeyboardHeightMultiplier(percentage: Int): Float = percentage / 100.0F
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue