Skip to content

Commit 9eb2fb0

Browse files
authored
Adding setting to ignore bottom padding. (#1477)
* Reapply "Fix bottom padding for Android 15+ (#1463)" (#1465) This reverts commit 726549b. * Adding setting to ignore bottom padding. - Also add back safeDrawingPadding() - Fixes #1187
1 parent d9b96aa commit 9eb2fb0

6 files changed

Lines changed: 60 additions & 17 deletions

File tree

app/src/main/java/com/dessalines/thumbkey/db/AppDb.kt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ const val DEFAULT_CLOCKWISE_DRAG_ACTION = 0
6060
const val DEFAULT_COUNTERCLOCKWISE_DRAG_ACTION = 1
6161
const val DEFAULT_GHOST_KEYS_ENABLED = 0
6262
const val DEFAULT_KEY_MODIFICATIONS = ""
63+
const val DEFAULT_IGNORE_BOTTOM_PADDING = 0
6364

6465
@Entity
6566
data class AppSettings(
@@ -262,6 +263,11 @@ data class AppSettings(
262263
defaultValue = DEFAULT_KEY_HEIGHT.toString(),
263264
)
264265
val keyHeight: Int,
266+
@ColumnInfo(
267+
name = "ignore_bottom_padding",
268+
defaultValue = DEFAULT_IGNORE_BOTTOM_PADDING.toString(),
269+
)
270+
val ignoreBottomPadding: Int,
265271
)
266272

267273
data class LayoutsUpdate(
@@ -350,6 +356,10 @@ data class LookAndFeelUpdate(
350356
name = "key_height_v18",
351357
)
352358
val keyHeight: Int,
359+
@ColumnInfo(
360+
name = "ignore_bottom_padding",
361+
)
362+
val ignoreBottomPadding: Int,
353363
)
354364

355365
data class BehaviorUpdate(
@@ -474,7 +484,7 @@ class AppSettingsRepository(
474484
}
475485

476486
@Database(
477-
version = 18,
487+
version = 19,
478488
entities = [AppSettings::class],
479489
exportSchema = true,
480490
)
@@ -514,6 +524,7 @@ abstract class AppDB : RoomDatabase() {
514524
MIGRATION_15_16,
515525
MIGRATION_16_17,
516526
MIGRATION_17_18,
527+
MIGRATION_18_19,
517528
)
518529
// Necessary because it can't insert data on creation
519530
.addCallback(

app/src/main/java/com/dessalines/thumbkey/db/Migrations.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,3 +210,12 @@ val MIGRATION_17_18 =
210210
)
211211
}
212212
}
213+
214+
val MIGRATION_18_19 =
215+
object : Migration(18, 19) {
216+
override fun migrate(db: SupportSQLiteDatabase) {
217+
db.execSQL(
218+
"alter table AppSettings add column ignore_bottom_padding INTEGER NOT NULL default $DEFAULT_IGNORE_BOTTOM_PADDING",
219+
)
220+
}
221+
}

app/src/main/java/com/dessalines/thumbkey/ui/components/keyboard/KeyboardScreen.kt

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import androidx.compose.foundation.layout.Column
1212
import androidx.compose.foundation.layout.Row
1313
import androidx.compose.foundation.layout.fillMaxWidth
1414
import androidx.compose.foundation.layout.height
15-
import androidx.compose.foundation.layout.navigationBarsPadding
1615
import androidx.compose.foundation.layout.padding
16+
import androidx.compose.foundation.layout.safeDrawingPadding
1717
import androidx.compose.foundation.shape.RoundedCornerShape
1818
import androidx.compose.material3.MaterialTheme
1919
import androidx.compose.runtime.Composable
@@ -44,6 +44,7 @@ import com.dessalines.thumbkey.db.DEFAULT_DRAG_RETURN_ENABLED
4444
import com.dessalines.thumbkey.db.DEFAULT_GHOST_KEYS_ENABLED
4545
import com.dessalines.thumbkey.db.DEFAULT_HIDE_LETTERS
4646
import com.dessalines.thumbkey.db.DEFAULT_HIDE_SYMBOLS
47+
import com.dessalines.thumbkey.db.DEFAULT_IGNORE_BOTTOM_PADDING
4748
import com.dessalines.thumbkey.db.DEFAULT_KEYBOARD_LAYOUT
4849
import com.dessalines.thumbkey.db.DEFAULT_KEY_BORDER_WIDTH
4950
import com.dessalines.thumbkey.db.DEFAULT_KEY_HEIGHT
@@ -137,6 +138,7 @@ fun KeyboardScreen(
137138
]
138139

139140
val pushupSizeDp = (settings?.pushupSize ?: DEFAULT_PUSHUP_SIZE).dp
141+
val ignoreBottomPadding = (settings?.ignoreBottomPadding ?: DEFAULT_IGNORE_BOTTOM_PADDING).toBool()
140142

141143
val autoCapitalize = (settings?.autoCapitalize ?: DEFAULT_AUTO_CAPITALIZE).toBool()
142144
val spacebarMultiTaps = (settings?.spacebarMultiTaps ?: DEFAULT_SPACEBAR_MULTITAPS).toBool()
@@ -220,7 +222,7 @@ fun KeyboardScreen(
220222
Row(
221223
modifier =
222224
Modifier
223-
.navigationBarsPadding()
225+
.then(if (!ignoreBottomPadding) Modifier.safeDrawingPadding() else Modifier)
224226
.padding(bottom = pushupSizeDp)
225227
.fillMaxWidth()
226228
.then(
@@ -397,7 +399,15 @@ fun KeyboardScreen(
397399
modifier =
398400
Modifier
399401
.then(if (drawBackdrop) Modifier.background(backdropColor) else (Modifier))
400-
.padding(bottom = pushupSizeDp),
402+
.then(if (!ignoreBottomPadding) Modifier.safeDrawingPadding() else Modifier)
403+
.padding(bottom = pushupSizeDp)
404+
.then(
405+
if (backdropEnabled) {
406+
Modifier.padding(top = backdropPadding)
407+
} else {
408+
(Modifier)
409+
},
410+
),
401411
) {
402412
// adds a pretty line if you're using the backdrop
403413
if (drawBackdrop) {
@@ -410,18 +420,7 @@ fun KeyboardScreen(
410420
.background(color = MaterialTheme.colorScheme.surfaceVariant),
411421
)
412422
}
413-
Column(
414-
modifier =
415-
Modifier
416-
.navigationBarsPadding()
417-
.then(
418-
if (backdropEnabled) {
419-
Modifier.padding(top = backdropPadding)
420-
} else {
421-
(Modifier)
422-
},
423-
),
424-
) {
423+
Column {
425424
keyboard.arr.forEachIndexed { i, row ->
426425
Row {
427426
row.forEachIndexed { j, key ->

app/src/main/java/com/dessalines/thumbkey/ui/components/settings/backupandrestore/BackupAndRestoreScreen.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import com.dessalines.thumbkey.db.DEFAULT_DRAG_RETURN_ENABLED
4646
import com.dessalines.thumbkey.db.DEFAULT_GHOST_KEYS_ENABLED
4747
import com.dessalines.thumbkey.db.DEFAULT_HIDE_LETTERS
4848
import com.dessalines.thumbkey.db.DEFAULT_HIDE_SYMBOLS
49+
import com.dessalines.thumbkey.db.DEFAULT_IGNORE_BOTTOM_PADDING
4950
import com.dessalines.thumbkey.db.DEFAULT_KEYBOARD_LAYOUT
5051
import com.dessalines.thumbkey.db.DEFAULT_KEY_BORDERS
5152
import com.dessalines.thumbkey.db.DEFAULT_KEY_BORDER_WIDTH
@@ -256,6 +257,7 @@ private fun resetAppSettingsToDefault(appSettingsViewModel: AppSettingsViewModel
256257
nonSquareKeys = DEFAULT_NON_SQUARE_KEYS,
257258
keyWidth = DEFAULT_KEY_WIDTH,
258259
keyHeight = DEFAULT_KEY_HEIGHT,
260+
ignoreBottomPadding = DEFAULT_IGNORE_BOTTOM_PADDING,
259261
),
260262
)
261263
}

app/src/main/java/com/dessalines/thumbkey/ui/components/settings/lookandfeel/LookAndFeelScreen.kt

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import androidx.compose.foundation.rememberScrollState
99
import androidx.compose.foundation.verticalScroll
1010
import androidx.compose.material.icons.Icons
1111
import androidx.compose.material.icons.outlined.Animation
12+
import androidx.compose.material.icons.outlined.BorderBottom
1213
import androidx.compose.material.icons.outlined.BorderOuter
1314
import androidx.compose.material.icons.outlined.Colorize
1415
import androidx.compose.material.icons.outlined.Crop75
@@ -50,6 +51,7 @@ import com.dessalines.thumbkey.db.DEFAULT_AUTO_SIZE_KEYS
5051
import com.dessalines.thumbkey.db.DEFAULT_BACKDROP_ENABLED
5152
import com.dessalines.thumbkey.db.DEFAULT_HIDE_LETTERS
5253
import com.dessalines.thumbkey.db.DEFAULT_HIDE_SYMBOLS
54+
import com.dessalines.thumbkey.db.DEFAULT_IGNORE_BOTTOM_PADDING
5355
import com.dessalines.thumbkey.db.DEFAULT_KEY_BORDER_WIDTH
5456
import com.dessalines.thumbkey.db.DEFAULT_KEY_HEIGHT
5557
import com.dessalines.thumbkey.db.DEFAULT_KEY_PADDING
@@ -120,6 +122,7 @@ fun LookAndFeelScreen(
120122
var soundOnTapState = (settings?.soundOnTap ?: DEFAULT_SOUND_ON_TAP).toBool()
121123
var hideLettersState = (settings?.hideLetters ?: DEFAULT_HIDE_LETTERS).toBool()
122124
var hideSymbolsState = (settings?.hideSymbols ?: DEFAULT_HIDE_SYMBOLS).toBool()
125+
var ignoreBottomPaddingState = (settings?.ignoreBottomPadding ?: DEFAULT_IGNORE_BOTTOM_PADDING).toBool()
123126

124127
var backdropEnabledState = (settings?.backdropEnabled ?: DEFAULT_BACKDROP_ENABLED).toBool()
125128

@@ -135,6 +138,7 @@ fun LookAndFeelScreen(
135138
soundOnTap = soundOnTapState.toInt(),
136139
hideLetters = hideLettersState.toInt(),
137140
hideSymbols = hideSymbolsState.toInt(),
141+
ignoreBottomPadding = ignoreBottomPaddingState.toInt(),
138142
theme = themeState.ordinal,
139143
themeColor = themeColorState.ordinal,
140144
backdropEnabled = backdropEnabledState.toInt(),
@@ -295,6 +299,23 @@ fun LookAndFeelScreen(
295299
},
296300
)
297301

302+
SwitchPreference(
303+
value = ignoreBottomPaddingState,
304+
onValueChange = {
305+
ignoreBottomPaddingState = it
306+
updateLookAndFeel()
307+
},
308+
title = {
309+
Text(stringResource(R.string.ignore_bottom_padding))
310+
},
311+
icon = {
312+
Icon(
313+
imageVector = Icons.Outlined.BorderBottom,
314+
contentDescription = null,
315+
)
316+
},
317+
)
318+
298319
SwitchPreference(
299320
value = autoSizeKeysState,
300321
onValueChange = {
@@ -374,7 +395,7 @@ fun LookAndFeelScreen(
374395
val keyHeightStr =
375396
stringResource(
376397
R.string.key_height,
377-
(keyHeightSliderState ?: DEFAULT_KEY_HEIGHT.toFloat()).toInt().toString(),
398+
keyHeightSliderState.toInt().toString(),
378399
)
379400
Text(keyHeightStr)
380401
},

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,5 @@
9999
<string name="modify_keys">Modify keys</string>
100100
<string name="key_modification_placeholder">Enter YAML</string>
101101
<string name="how_to_modify_keys">How to modify keys</string>
102+
<string name="ignore_bottom_padding">Ignore bottom padding</string>
102103
</resources>

0 commit comments

Comments
 (0)