Skip to content

Commit d421b91

Browse files
committed
Merge branch 'main' of github.com:SimpleMobileTools/Simple-Keyboard into main
2 parents c26b18c + 0e8b8a3 commit d421b91

21 files changed

+543
-8
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class SettingsActivity : SimpleActivity() {
4444
setupKeyboardLanguage()
4545
setupKeyboardHeightMultiplier()
4646
setupShowClipboardContent()
47+
setupShowNumbersRow()
4748

4849
updateTextColors(settings_nested_scrollview)
4950

@@ -159,4 +160,11 @@ class SettingsActivity : SimpleActivity() {
159160
config.showClipboardContent = settings_show_clipboard_content.isChecked
160161
}
161162
}
163+
private fun setupShowNumbersRow() {
164+
settings_show_numbers_row.isChecked = config.showNumbersRow
165+
settings_show_numbers_row_holder.setOnClickListener {
166+
settings_show_numbers_row.toggle()
167+
config.showNumbersRow = settings_show_numbers_row.isChecked
168+
}
169+
}
162170
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ class Config(context: Context) : BaseConfig(context) {
3737
get() = prefs.getBoolean(SHOW_CLIPBOARD_CONTENT, true)
3838
set(showClipboardContent) = prefs.edit().putBoolean(SHOW_CLIPBOARD_CONTENT, showClipboardContent).apply()
3939

40+
var showNumbersRow: Boolean
41+
get() = prefs.getBoolean(SHOW_NUMBERS_ROW, false)
42+
set(showNumbersRow) = prefs.edit().putBoolean(SHOW_NUMBERS_ROW, showNumbersRow).apply()
4043

4144
private fun getDefaultLanguage(): Int {
4245
val conf = context.resources.configuration

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const val LAST_EXPORTED_CLIPS_FOLDER = "last_exported_clips_folder"
1515
const val KEYBOARD_LANGUAGE = "keyboard_language"
1616
const val HEIGHT_MULTIPLIER = "height_multiplier"
1717
const val SHOW_CLIPBOARD_CONTENT = "show_clipboard_content"
18+
const val SHOW_NUMBERS_ROW = "show_numbers_row"
1819

1920
// differentiate current and pinned clips at the keyboards' Clipboard section
2021
const val ITEM_SECTION_LABEL = 0

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

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ class MyKeyboard {
9797

9898
var parent: MyKeyboard
9999

100+
var isNumbersRow: Boolean = false
101+
100102
constructor(parent: MyKeyboard) {
101103
this.parent = parent
102104
}
@@ -107,6 +109,7 @@ class MyKeyboard {
107109
defaultWidth = getDimensionOrFraction(a, R.styleable.MyKeyboard_keyWidth, parent.mDisplayWidth, parent.mDefaultWidth)
108110
defaultHeight = (res.getDimension(R.dimen.key_height) * this.parent.mKeyboardHeightMultiplier).roundToInt()
109111
defaultHorizontalGap = getDimensionOrFraction(a, R.styleable.MyKeyboard_horizontalGap, parent.mDisplayWidth, parent.mDefaultHorizontalGap)
112+
isNumbersRow = a.getBoolean(R.styleable.MyKeyboard_isNumbersRow, false)
110113
a.recycle()
111114
}
112115
}
@@ -342,14 +345,31 @@ class MyKeyboard {
342345
if (event == XmlResourceParser.START_TAG) {
343346
when (parser.name) {
344347
TAG_ROW -> {
348+
currentRow = createRowFromXml(res, parser)
349+
if (currentRow.isNumbersRow && !context.config.showNumbersRow) {
350+
continue
351+
}
345352
inRow = true
346353
x = 0
347-
currentRow = createRowFromXml(res, parser)
348354
mRows.add(currentRow)
349355
}
356+
350357
TAG_KEY -> {
358+
if (currentRow?.isNumbersRow == true && !context.config.showNumbersRow) {
359+
continue
360+
}
351361
inKey = true
352362
key = createKeyFromXml(res, currentRow!!, x, y, parser)
363+
if (context.config.showNumbersRow) {
364+
// Removes numbers (i.e 0-9) from the popupCharacters if numbers row is enabled
365+
key.apply {
366+
popupCharacters = popupCharacters?.replace(Regex("\\d+"), "")
367+
if (popupCharacters.isNullOrEmpty()) {
368+
popupResId = 0
369+
}
370+
}
371+
372+
}
353373
mKeys!!.add(key)
354374
if (key.code == KEYCODE_ENTER) {
355375
val enterResourceId = when (mEnterKeyType) {
@@ -362,6 +382,7 @@ class MyKeyboard {
362382
}
363383
currentRow.mKeys.add(key)
364384
}
385+
365386
TAG_KEYBOARD -> {
366387
parseKeyboardAttributes(res, parser)
367388
}

app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
138138
private var mLastKey = 0
139139
private var mLastCodeX = 0
140140
private var mLastCodeY = 0
141+
private var mLastKeyPressedCode = 0
141142
private var mCurrentKey: Int = NOT_A_KEY
142143
private var mLastKeyTime = 0L
143144
private var mCurrentKeyTime = 0L
@@ -263,6 +264,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
263264
val repeat = Message.obtain(this, MSG_REPEAT)
264265
sendMessageDelayed(repeat, REPEAT_INTERVAL.toLong())
265266
}
267+
266268
MSG_LONGPRESS -> openPopupIfRequired(msg.obj as MotionEvent)
267269
}
268270
}
@@ -591,7 +593,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
591593
label, (key.width / 2).toFloat(), key.height / 2 + (paint.textSize - paint.descent()) / 2, paint
592594
)
593595

594-
if (key.topSmallNumber.isNotEmpty()) {
596+
if (key.topSmallNumber.isNotEmpty() && !context.config.showNumbersRow) {
595597
canvas.drawText(key.topSmallNumber, key.width - mTopSmallNumberMarginWidth, mTopSmallNumberMarginHeight, smallLetterPaint)
596598
}
597599

@@ -1204,6 +1206,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
12041206
}
12051207
}
12061208
}
1209+
12071210
MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> {
12081211
mMiniKeyboard?.mKeys?.firstOrNull { it.focused }?.apply {
12091212
mOnKeyboardActionListener!!.onKey(code)
@@ -1262,6 +1265,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
12621265
invalidateKey(mCurrentKey)
12631266
return true
12641267
}
1268+
12651269
MotionEvent.ACTION_DOWN -> {
12661270
mAbortKey = false
12671271
mLastCodeX = touchX
@@ -1278,8 +1282,8 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
12781282
} else {
12791283
0
12801284
}
1281-
12821285
mOnKeyboardActionListener!!.onPress(onPressKey)
1286+
mLastKeyPressedCode = onPressKey
12831287

12841288
var wasHandled = false
12851289
if (mCurrentKey >= 0 && mKeys[mCurrentKey].repeatable) {
@@ -1310,6 +1314,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
13101314
showPreview(keyIndex)
13111315
}
13121316
}
1317+
13131318
MotionEvent.ACTION_MOVE -> {
13141319
var continueLongPress = false
13151320
if (keyIndex != NOT_A_KEY) {
@@ -1363,6 +1368,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
13631368
mLastMoveTime = eventTime
13641369
}
13651370
}
1371+
13661372
MotionEvent.ACTION_UP -> {
13671373
mLastSpaceMoveX = 0
13681374
removeMessages()
@@ -1391,11 +1397,14 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
13911397
detectAndSendKey(mCurrentKey, touchX, touchY, eventTime)
13921398
}
13931399

1394-
invalidateKey(keyIndex)
1400+
if (mLastKeyPressedCode != KEYCODE_MODE_CHANGE) {
1401+
invalidateKey(keyIndex)
1402+
}
13951403
mRepeatKeyIndex = NOT_A_KEY
13961404
mOnKeyboardActionListener!!.onActionUp()
13971405
mIsLongPressingSpace = false
13981406
}
1407+
13991408
MotionEvent.ACTION_CANCEL -> {
14001409
mIsLongPressingSpace = false
14011410
mLastSpaceMoveX = 0
@@ -1515,12 +1524,14 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
15151524
mHandler!!.sendMessageDelayed(msg, REPEAT_START_DELAY.toLong())
15161525
true
15171526
}
1527+
15181528
MotionEvent.ACTION_UP -> {
15191529
mHandler!!.removeMessages(MSG_REPEAT)
15201530
mRepeatKeyIndex = NOT_A_KEY
15211531
isPressed = false
15221532
false
15231533
}
1534+
15241535
else -> false
15251536
}
15261537
}

app/src/main/res/layout/activity_settings.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,20 @@
189189
android:layout_height="wrap_content"
190190
android:text="@string/show_clipboard_content" />
191191

192+
</RelativeLayout>
193+
<RelativeLayout
194+
android:id="@+id/settings_show_numbers_row_holder"
195+
style="@style/SettingsHolderCheckboxStyle"
196+
android:layout_width="match_parent"
197+
android:layout_height="wrap_content">
198+
199+
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
200+
android:id="@+id/settings_show_numbers_row"
201+
style="@style/SettingsCheckboxStyle"
202+
android:layout_width="match_parent"
203+
android:layout_height="wrap_content"
204+
android:text="@string/show_numbers_row" />
205+
192206
</RelativeLayout>
193207

194208
<RelativeLayout

app/src/main/res/values/attrs.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<declare-styleable name="MyKeyboard">
1212
<attr name="keyWidth" format="fraction" />
1313
<attr name="horizontalGap" format="fraction" />
14+
<attr name="isNumbersRow" format="boolean" />
1415
</declare-styleable>
1516

1617
<declare-styleable name="MyKeyboard_Key">

app/src/main/res/xml/keys_letters_bengali.xml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,39 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Keyboard xmlns:app="http://schemas.android.com/apk/res-auto">
3+
<Row app:isNumbersRow="true">
4+
<Key
5+
app:keyEdgeFlags="left"
6+
app:keyLabel="1"
7+
app:topSmallNumber="1" />
8+
<Key
9+
app:keyLabel="2"
10+
app:topSmallNumber="2" />
11+
<Key
12+
app:keyLabel="3"
13+
app:topSmallNumber="3" />
14+
<Key
15+
app:keyLabel="4"
16+
app:topSmallNumber="4" />
17+
<Key
18+
app:keyLabel="5"
19+
app:topSmallNumber="5" />
20+
<Key
21+
app:keyLabel="6"
22+
app:topSmallNumber="6" />
23+
<Key
24+
app:keyLabel="7"
25+
app:topSmallNumber="7" />
26+
<Key
27+
app:keyLabel="8"
28+
app:topSmallNumber="8" />
29+
<Key
30+
app:keyLabel="9"
31+
app:topSmallNumber="9" />
32+
<Key
33+
app:keyEdgeFlags="right"
34+
app:keyLabel="0"
35+
app:topSmallNumber="0" />
36+
</Row>
337
<Row app:keyWidth="9.091%p">
438
<Key
539
app:keyEdgeFlags="left"

app/src/main/res/xml/keys_letters_bulgarian.xml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,39 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Keyboard xmlns:app="http://schemas.android.com/apk/res-auto">
3+
<Row app:isNumbersRow="true">
4+
<Key
5+
app:keyEdgeFlags="left"
6+
app:keyLabel="1"
7+
app:topSmallNumber="1" />
8+
<Key
9+
app:keyLabel="2"
10+
app:topSmallNumber="2" />
11+
<Key
12+
app:keyLabel="3"
13+
app:topSmallNumber="3" />
14+
<Key
15+
app:keyLabel="4"
16+
app:topSmallNumber="4" />
17+
<Key
18+
app:keyLabel="5"
19+
app:topSmallNumber="5" />
20+
<Key
21+
app:keyLabel="6"
22+
app:topSmallNumber="6" />
23+
<Key
24+
app:keyLabel="7"
25+
app:topSmallNumber="7" />
26+
<Key
27+
app:keyLabel="8"
28+
app:topSmallNumber="8" />
29+
<Key
30+
app:keyLabel="9"
31+
app:topSmallNumber="9" />
32+
<Key
33+
app:keyEdgeFlags="right"
34+
app:keyLabel="0"
35+
app:topSmallNumber="0" />
36+
</Row>
337
<Row app:keyWidth="9.05%p">
438
<Key
539
app:keyEdgeFlags="left"

app/src/main/res/xml/keys_letters_english_dvorak.xml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,39 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Keyboard xmlns:app="http://schemas.android.com/apk/res-auto">
3+
<Row app:isNumbersRow="true">
4+
<Key
5+
app:keyEdgeFlags="left"
6+
app:keyLabel="1"
7+
app:topSmallNumber="1" />
8+
<Key
9+
app:keyLabel="2"
10+
app:topSmallNumber="2" />
11+
<Key
12+
app:keyLabel="3"
13+
app:topSmallNumber="3" />
14+
<Key
15+
app:keyLabel="4"
16+
app:topSmallNumber="4" />
17+
<Key
18+
app:keyLabel="5"
19+
app:topSmallNumber="5" />
20+
<Key
21+
app:keyLabel="6"
22+
app:topSmallNumber="6" />
23+
<Key
24+
app:keyLabel="7"
25+
app:topSmallNumber="7" />
26+
<Key
27+
app:keyLabel="8"
28+
app:topSmallNumber="8" />
29+
<Key
30+
app:keyLabel="9"
31+
app:topSmallNumber="9" />
32+
<Key
33+
app:keyEdgeFlags="right"
34+
app:keyLabel="0"
35+
app:topSmallNumber="0" />
36+
</Row>
337
<Row>
438
<Key
539
app:keyEdgeFlags="left"

0 commit comments

Comments
 (0)