Use more descriptive names for showSleepTimerPermission arguments

This commit is contained in:
Ensar Sarajčić
2023-10-13 11:27:53 +02:00
parent e190cac2a3
commit 1600a072ef

View File

@ -151,9 +151,10 @@ class MainActivity : ComponentActivity() {
openSettings = ::launchSettings, openSettings = ::launchSettings,
openAbout = ::launchAbout, openAbout = ::launchAbout,
openSleepTimer = { openSleepTimer = {
showSleepTimerPermission(sleepTimerPermissionDialogState) { showSleepTimerPermission(
sleepTimerDialogState.show() requestAlarmPermission = sleepTimerPermissionDialogState::show,
} onNoPermissionRequired = sleepTimerDialogState::show
)
}, },
moreAppsFromUs = ::launchMoreAppsFromUsIntent moreAppsFromUs = ::launchMoreAppsFromUsIntent
) )
@ -353,15 +354,15 @@ class MainActivity : ComponentActivity() {
} }
private fun showSleepTimerPermission( private fun showSleepTimerPermission(
showSleepTimerDialogState: AlertDialogState, requestAlarmPermission: () -> Unit,
callback: () -> Unit onNoPermissionRequired: () -> Unit
) { ) {
val alarmManager = getSystemService(Context.ALARM_SERVICE) as AlarmManager val alarmManager = getSystemService(Context.ALARM_SERVICE) as AlarmManager
if (isSPlus() && !alarmManager.canScheduleExactAlarms()) { if (isSPlus() && !alarmManager.canScheduleExactAlarms()) {
showSleepTimerDialogState.show() requestAlarmPermission()
return return
} }
callback() onNoPermissionRequired()
} }
private fun secondsToString(seconds: Int): String { private fun secondsToString(seconds: Int): String {