Skip to content

Commit a18664e

Browse files
committed
fix: alarm setting buttons hard to click when gesture navigation disabled (closes #401)
1 parent 0a86682 commit a18664e

File tree

4 files changed

+58
-32
lines changed

4 files changed

+58
-32
lines changed

.idea/AndroidProjectSystem.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/runConfigurations.xml

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/main/java/com/bnyro/clock/presentation/screens/alarmpicker/components/AlarmSettingsSheet.kt

Lines changed: 48 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.bnyro.clock.presentation.screens.alarmpicker.components
22

3+
import android.content.ContentResolver
4+
import android.provider.Settings
35
import androidx.compose.animation.AnimatedVisibility
46
import androidx.compose.foundation.background
57
import androidx.compose.foundation.border
@@ -8,8 +10,10 @@ import androidx.compose.foundation.layout.Arrangement
810
import androidx.compose.foundation.layout.Box
911
import androidx.compose.foundation.layout.Column
1012
import androidx.compose.foundation.layout.Row
13+
import androidx.compose.foundation.layout.Spacer
1114
import androidx.compose.foundation.layout.fillMaxSize
1215
import androidx.compose.foundation.layout.fillMaxWidth
16+
import androidx.compose.foundation.layout.height
1317
import androidx.compose.foundation.layout.padding
1418
import androidx.compose.foundation.layout.size
1519
import androidx.compose.foundation.rememberScrollState
@@ -26,7 +30,6 @@ import androidx.compose.material3.Icon
2630
import androidx.compose.material3.MaterialTheme
2731
import androidx.compose.material3.OutlinedButton
2832
import androidx.compose.material3.OutlinedTextField
29-
import androidx.compose.material3.Surface
3033
import androidx.compose.material3.Text
3134
import androidx.compose.runtime.Composable
3235
import androidx.compose.runtime.getValue
@@ -84,11 +87,15 @@ fun AlarmPicker(currentAlarm: Alarm, onSave: (Alarm) -> Unit, onCancel: () -> Un
8487
var minutes by remember { mutableIntStateOf(initialTime.minutes) }
8588

8689
val scrollState = rememberScrollState()
87-
Surface {
90+
Column(
91+
modifier = Modifier
92+
.fillMaxSize()
93+
.padding(horizontal = 8.dp, vertical = 16.dp)
94+
) {
8895
Column(
8996
Modifier
90-
.fillMaxSize()
91-
.padding(horizontal = 8.dp, vertical = 16.dp)
97+
.weight(1f)
98+
.fillMaxWidth()
9299
.verticalScroll(scrollState),
93100
horizontalAlignment = Alignment.CenterHorizontally,
94101
verticalArrangement = Arrangement.SpaceEvenly
@@ -218,35 +225,41 @@ fun AlarmPicker(currentAlarm: Alarm, onSave: (Alarm) -> Unit, onCancel: () -> Un
218225
}
219226
)
220227
}
221-
Row(
222-
Modifier.align(Alignment.End),
223-
horizontalArrangement = Arrangement.spacedBy(16.dp)
224-
) {
225-
OutlinedButton(onClick = { onCancel.invoke() }) {
226-
Text(text = stringResource(id = android.R.string.cancel))
227-
}
228-
Button(onClick = {
229-
val alarm =
230-
currentAlarm.copy(
231-
time = (hours * 60 + minutes) * 60 * 1000L,
232-
label = label.takeIf { l -> l.isNotBlank() },
233-
days = chosenDays.sorted(),
234-
vibrate = vibrationEnabled,
235-
soundName = soundName,
236-
soundUri = soundUri,
237-
repeat = repeat,
238-
snoozeEnabled = snoozeEnabled,
239-
snoozeMinutes = snoozeMinutes,
240-
soundEnabled = soundEnabled,
241-
vibrationPattern = vibrationPattern,
242-
vibrationPatternName = vibrationPatternName
243-
)
244-
onSave(alarm)
245-
}) {
246-
Text(text = stringResource(id = android.R.string.ok))
247-
}
228+
}
229+
230+
Row(
231+
Modifier.align(Alignment.End),
232+
horizontalArrangement = Arrangement.spacedBy(16.dp)
233+
) {
234+
OutlinedButton(onClick = { onCancel.invoke() }) {
235+
Text(text = stringResource(id = android.R.string.cancel))
236+
}
237+
Button(onClick = {
238+
val alarm =
239+
currentAlarm.copy(
240+
time = (hours * 60 + minutes) * 60 * 1000L,
241+
label = label.takeIf { l -> l.isNotBlank() },
242+
days = chosenDays.sorted(),
243+
vibrate = vibrationEnabled,
244+
soundName = soundName,
245+
soundUri = soundUri,
246+
repeat = repeat,
247+
snoozeEnabled = snoozeEnabled,
248+
snoozeMinutes = snoozeMinutes,
249+
soundEnabled = soundEnabled,
250+
vibrationPattern = vibrationPattern,
251+
vibrationPatternName = vibrationPatternName
252+
)
253+
onSave(alarm)
254+
}) {
255+
Text(text = stringResource(id = android.R.string.ok))
248256
}
249257
}
258+
259+
// extra spacing to fix that the buttons are overlapped by the navigation bar
260+
if (!isGestureNavigationMode(context.contentResolver)) {
261+
Spacer(modifier = Modifier.height(40.dp))
262+
}
250263
}
251264
if (showRingtoneDialog) {
252265
RingtonePickerDialog(onDismissRequest = {
@@ -278,3 +291,7 @@ fun AlarmPicker(currentAlarm: Alarm, onSave: (Alarm) -> Unit, onCancel: () -> Un
278291
)
279292
}
280293
}
294+
295+
fun isGestureNavigationMode(content: ContentResolver?): Boolean {
296+
return Settings.Secure.getInt(content, "navigation_mode", 0) == 2
297+
}

0 commit comments

Comments
 (0)