Skip to content

Commit a1dd2fd

Browse files
authored
Merge pull request #141 from Naveen3Singh/add_key_borders
Add a setting for showing key borders
2 parents bb80352 + 2999ccd commit a1dd2fd

26 files changed

+296
-127
lines changed

app/src/main/kotlin/com/simplemobiletools/keyboard/activities/SettingsActivity.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class SettingsActivity : SimpleActivity() {
4040
setupManageClipboardItems()
4141
setupVibrateOnKeypress()
4242
setupShowPopupOnKeypress()
43+
setupShowKeyBorders()
4344
setupKeyboardLanguage()
4445
setupKeyboardHeightMultiplier()
4546

@@ -106,6 +107,14 @@ class SettingsActivity : SimpleActivity() {
106107
}
107108
}
108109

110+
private fun setupShowKeyBorders() {
111+
settings_show_key_borders.isChecked = config.showKeyBorders
112+
settings_show_key_borders_holder.setOnClickListener {
113+
settings_show_key_borders.toggle()
114+
config.showKeyBorders = settings_show_key_borders.isChecked
115+
}
116+
}
117+
109118
private fun setupKeyboardLanguage() {
110119
settings_keyboard_language.text = getKeyboardLanguageText(config.keyboardLanguage)
111120
settings_keyboard_language_holder.setOnClickListener {

app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/Config.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ class Config(context: Context) : BaseConfig(context) {
1717
get() = prefs.getBoolean(SHOW_POPUP_ON_KEYPRESS, true)
1818
set(showPopupOnKeypress) = prefs.edit().putBoolean(SHOW_POPUP_ON_KEYPRESS, showPopupOnKeypress).apply()
1919

20+
var showKeyBorders: Boolean
21+
get() = prefs.getBoolean(SHOW_KEY_BORDERS, false)
22+
set(showKeyBorders) = prefs.edit().putBoolean(SHOW_KEY_BORDERS, showKeyBorders).apply()
23+
2024
var lastExportedClipsFolder: String
2125
get() = prefs.getString(LAST_EXPORTED_CLIPS_FOLDER, "")!!
2226
set(lastExportedClipsFolder) = prefs.edit().putString(LAST_EXPORTED_CLIPS_FOLDER, lastExportedClipsFolder).apply()

app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/Constants.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const val MAX_KEYS_PER_MINI_ROW = 9
1010
// shared prefs
1111
const val VIBRATE_ON_KEYPRESS = "vibrate_on_keypress"
1212
const val SHOW_POPUP_ON_KEYPRESS = "show_popup_on_keypress"
13+
const val SHOW_KEY_BORDERS = "show_key_borders"
1314
const val LAST_EXPORTED_CLIPS_FOLDER = "last_exported_clips_folder"
1415
const val KEYBOARD_LANGUAGE = "keyboard_language"
1516
const val HEIGHT_MULTIPLIER = "height_multiplier"

app/src/main/kotlin/com/simplemobiletools/keyboard/services/SimpleKeyboardIME.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.simplemobiletools.keyboard.services
22

3+
import android.content.SharedPreferences
34
import android.inputmethodservice.InputMethodService
45
import android.text.InputType
56
import android.text.InputType.TYPE_CLASS_DATETIME
@@ -14,14 +15,15 @@ import android.view.inputmethod.EditorInfo.IME_ACTION_NONE
1415
import android.view.inputmethod.EditorInfo.IME_FLAG_NO_ENTER_ACTION
1516
import android.view.inputmethod.EditorInfo.IME_MASK_ACTION
1617
import android.view.inputmethod.ExtractedTextRequest
18+
import com.simplemobiletools.commons.extensions.getSharedPrefs
1719
import com.simplemobiletools.keyboard.R
1820
import com.simplemobiletools.keyboard.extensions.config
1921
import com.simplemobiletools.keyboard.helpers.*
2022
import com.simplemobiletools.keyboard.views.MyKeyboardView
2123
import kotlinx.android.synthetic.main.keyboard_view_keyboard.view.*
2224

2325
// based on https://www.androidauthority.com/lets-build-custom-keyboard-android-832362/
24-
class SimpleKeyboardIME : InputMethodService(), MyKeyboardView.OnKeyboardActionListener {
26+
class SimpleKeyboardIME : InputMethodService(), MyKeyboardView.OnKeyboardActionListener, SharedPreferences.OnSharedPreferenceChangeListener {
2527
private var SHIFT_PERM_TOGGLE_SPEED = 500 // how quickly do we have to doubletap shift to enable permanent caps lock
2628
private val KEYBOARD_LETTERS = 0
2729
private val KEYBOARD_SYMBOLS = 1
@@ -38,6 +40,7 @@ class SimpleKeyboardIME : InputMethodService(), MyKeyboardView.OnKeyboardActionL
3840
override fun onInitializeInterface() {
3941
super.onInitializeInterface()
4042
keyboard = MyKeyboard(this, getKeyboardLayoutXML(), enterKeyType)
43+
getSharedPrefs().registerOnSharedPreferenceChangeListener(this)
4144
}
4245

4346
override fun onCreateInputView(): View {
@@ -275,4 +278,8 @@ class SimpleKeyboardIME : InputMethodService(), MyKeyboardView.OnKeyboardActionL
275278
else -> R.xml.keys_letters_english_qwerty
276279
}
277280
}
281+
282+
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
283+
keyboardView?.setupKeyboard()
284+
}
278285
}

0 commit comments

Comments
 (0)