Skip to content

Commit 79ad637

Browse files
committed
#1773 feat: allow showing floating buttons on top of the status bar or input method
1 parent 0721bf0 commit 79ad637

File tree

13 files changed

+590
-21
lines changed

13 files changed

+590
-21
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
- #1788 dismiss lockscreen when launching app action from lockscreen
1212
- Show tips for parallel and sequence triggers, and constraints in the trigger screen
1313
- #397 enable/disable all key maps in a group
14+
- #1773 Option to show floating buttons on top of keyboard or notification panel.
1415

1516
## Removed
1617

base/src/main/assets/whats-new.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ Version 4.0! 🎉
66

77
Enable/disable all the key maps in a group
88

9+
Option to show floating buttons on top of keyboard or notification panel
10+
911
Many other bug fixes and optimisations
1012

1113
See all the changes at http://changelog.keymapper.club.

base/src/main/java/io/github/sds100/keymapper/base/backup/BackupManager.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,9 @@ class BackupManagerImpl @Inject constructor(
257257

258258
// Do nothing. Just added columns to the accessibility node table.
259259
JsonMigration(19, 20) { json -> json },
260+
261+
// Do nothing. Just added columns to floating button entity.
262+
JsonMigration(20, 21) { json -> json },
260263
)
261264

262265
if (keyMapListJsonArray != null) {

base/src/main/java/io/github/sds100/keymapper/base/floating/FloatingButtonData.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ data class FloatingButtonData(
1616
val layoutName: String,
1717
val appearance: FloatingButtonAppearance,
1818
val location: Location,
19+
val showOverStatusBar: Boolean,
20+
val showOverInputMethod: Boolean,
1921
) {
2022
/**
2123
* This stores data about where a draggable overlay is located. It needs extra information
@@ -79,6 +81,8 @@ object FloatingButtonEntityMapper {
7981
orientation = ConstantTypeConverters.ORIENTATION_MAP.getKey(entity.orientation)!!,
8082
displaySize = SizeKM(entity.displayWidth, entity.displayHeight),
8183
),
84+
showOverStatusBar = entity.showOverStatusBar ?: false,
85+
showOverInputMethod = entity.showOverInputMethod ?: false,
8286
)
8387
}
8488

@@ -95,6 +99,8 @@ object FloatingButtonEntityMapper {
9599
orientation = ConstantTypeConverters.ORIENTATION_MAP[button.location.orientation]!!,
96100
displayWidth = button.location.displaySize.width,
97101
displayHeight = button.location.displaySize.height,
102+
showOverStatusBar = button.showOverStatusBar,
103+
showOverInputMethod = button.showOverInputMethod,
98104
)
99105
}
100106
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package io.github.sds100.keymapper.base.utils.ui.compose.icons
2+
3+
import androidx.compose.foundation.clickable
4+
import androidx.compose.foundation.layout.Row
5+
import androidx.compose.foundation.layout.padding
6+
import androidx.compose.material3.MaterialTheme
7+
import androidx.compose.material3.Surface
8+
import androidx.compose.material3.Switch
9+
import androidx.compose.material3.Text
10+
import androidx.compose.runtime.Composable
11+
import androidx.compose.ui.Alignment
12+
import androidx.compose.ui.Modifier
13+
import androidx.compose.ui.graphics.Color
14+
import androidx.compose.ui.text.style.TextOverflow
15+
import androidx.compose.ui.unit.dp
16+
17+
@Composable
18+
fun SwitchText(
19+
modifier: Modifier = Modifier,
20+
text: String,
21+
isChecked: Boolean,
22+
isEnabled: Boolean = true,
23+
onCheckedChange: (Boolean) -> Unit,
24+
) {
25+
Surface(modifier = modifier, shape = MaterialTheme.shapes.medium, color = Color.Transparent) {
26+
Row(
27+
modifier = Modifier
28+
.clickable(enabled = isEnabled) { onCheckedChange(!isChecked) }
29+
.padding(8.dp),
30+
verticalAlignment = Alignment.CenterVertically,
31+
) {
32+
Switch(
33+
enabled = isEnabled,
34+
checked = isChecked,
35+
// This is null so tapping on the checkbox highlights the whole row.
36+
onCheckedChange = null,
37+
)
38+
39+
Text(
40+
modifier = Modifier.padding(horizontal = 12.dp),
41+
42+
text = text,
43+
style = if (isEnabled) {
44+
MaterialTheme.typography.bodyLarge
45+
} else {
46+
MaterialTheme.typography.bodyLarge.copy(
47+
color = MaterialTheme.colorScheme.onSurface.copy(
48+
alpha = 0.5f,
49+
),
50+
)
51+
},
52+
maxLines = 2,
53+
overflow = TextOverflow.Ellipsis,
54+
)
55+
}
56+
}
57+
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,6 +1296,8 @@
12961296
<string name="floating_button_config_cancel_button">Cancel</string>
12971297
<string name="floating_button_config_done_button">Done</string>
12981298
<string name="floating_button_config_empty_text_error">The button must have text!</string>
1299+
<string name="floating_button_config_show_over_status_bar">Show over notification panel</string>
1300+
<string name="floating_button_config_show_over_input_method">Show over keyboard</string>
12991301
<string name="floating_buttons_product_title">Floating buttons</string>
13001302
<string name="floating_buttons_product_description">Floating buttons display over the apps you want. They work just like real buttons, and you can place, style, and map them however you like.</string>
13011303
<string name="floating_button_text_key_map_list_item">Floating button %s (%s)</string>

data/schemas/io.github.sds100.keymapper.data.db.AppDatabase/20.json

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"formatVersion": 1,
33
"database": {
44
"version": 20,
5-
"identityHash": "f2f5eac59b7bdee472c0dd7ff9bae4b2",
5+
"identityHash": "924d05910c30626072186db67e664837",
66
"entities": [
77
{
88
"tableName": "keymaps",
@@ -220,7 +220,7 @@
220220
},
221221
{
222222
"tableName": "floating_buttons",
223-
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`uid` TEXT NOT NULL, `layout_uid` TEXT NOT NULL, `text` TEXT NOT NULL, `button_size` INTEGER NOT NULL, `x` INTEGER NOT NULL, `y` INTEGER NOT NULL, `orientation` TEXT NOT NULL, `display_width` INTEGER NOT NULL, `display_height` INTEGER NOT NULL, `border_opacity` REAL, `background_opacity` REAL, PRIMARY KEY(`uid`), FOREIGN KEY(`layout_uid`) REFERENCES `floating_layouts`(`uid`) ON UPDATE NO ACTION ON DELETE CASCADE )",
223+
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`uid` TEXT NOT NULL, `layout_uid` TEXT NOT NULL, `text` TEXT NOT NULL, `button_size` INTEGER NOT NULL, `x` INTEGER NOT NULL, `y` INTEGER NOT NULL, `orientation` TEXT NOT NULL, `display_width` INTEGER NOT NULL, `display_height` INTEGER NOT NULL, `border_opacity` REAL, `background_opacity` REAL, `show_over_status_bar` INTEGER NOT NULL DEFAULT 0, `show_over_input_method` INTEGER NOT NULL DEFAULT 0, PRIMARY KEY(`uid`), FOREIGN KEY(`layout_uid`) REFERENCES `floating_layouts`(`uid`) ON UPDATE NO ACTION ON DELETE CASCADE )",
224224
"fields": [
225225
{
226226
"fieldPath": "uid",
@@ -285,6 +285,20 @@
285285
"fieldPath": "backgroundOpacity",
286286
"columnName": "background_opacity",
287287
"affinity": "REAL"
288+
},
289+
{
290+
"fieldPath": "showOverStatusBar",
291+
"columnName": "show_over_status_bar",
292+
"affinity": "INTEGER",
293+
"notNull": true,
294+
"defaultValue": "0"
295+
},
296+
{
297+
"fieldPath": "showOverInputMethod",
298+
"columnName": "show_over_input_method",
299+
"affinity": "INTEGER",
300+
"notNull": true,
301+
"defaultValue": "0"
288302
}
289303
],
290304
"primaryKey": {
@@ -454,7 +468,7 @@
454468
],
455469
"setupQueries": [
456470
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
457-
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'f2f5eac59b7bdee472c0dd7ff9bae4b2')"
471+
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '924d05910c30626072186db67e664837')"
458472
]
459473
}
460474
}

0 commit comments

Comments
 (0)