Timer speelt notificatie bij het start en einde van een pauze
This commit is contained in:
parent
2071b31f72
commit
18d11ffbbd
3 changed files with 38 additions and 2 deletions
5
.idea/inspectionProfiles/Project_Default.xml
generated
5
.idea/inspectionProfiles/Project_Default.xml
generated
|
@ -37,5 +37,10 @@
|
||||||
<option name="composableFile" value="true" />
|
<option name="composableFile" value="true" />
|
||||||
<option name="previewFile" value="true" />
|
<option name="previewFile" value="true" />
|
||||||
</inspection_tool>
|
</inspection_tool>
|
||||||
|
<inspection_tool class="SpellCheckingInspection" enabled="false" level="TYPO" enabled_by_default="false">
|
||||||
|
<option name="processCode" value="true" />
|
||||||
|
<option name="processLiterals" value="true" />
|
||||||
|
<option name="processComments" value="true" />
|
||||||
|
</inspection_tool>
|
||||||
</profile>
|
</profile>
|
||||||
</component>
|
</component>
|
|
@ -16,4 +16,7 @@ abstract class FunctionalTimer(initialValue: Int) {
|
||||||
|
|
||||||
abstract fun hasEnded(): Boolean
|
abstract fun hasEnded(): Boolean
|
||||||
|
|
||||||
|
fun hasCurrentCountdownEnded(): Boolean {
|
||||||
|
return time.getTime() == 0
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,8 +1,14 @@
|
||||||
package be.ugent.sel.studeez.screens.session
|
package be.ugent.sel.studeez.screens.session
|
||||||
|
|
||||||
|
import android.media.MediaPlayer
|
||||||
|
import android.media.RingtoneManager
|
||||||
|
import android.net.Uri
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.border
|
import androidx.compose.foundation.border
|
||||||
import androidx.compose.foundation.layout.*
|
import androidx.compose.foundation.layout.Box
|
||||||
|
import androidx.compose.foundation.layout.Column
|
||||||
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.material.Text
|
import androidx.compose.material.Text
|
||||||
import androidx.compose.material.TextButton
|
import androidx.compose.material.TextButton
|
||||||
|
@ -10,6 +16,7 @@ import androidx.compose.runtime.*
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
import androidx.compose.ui.text.style.TextAlign
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
|
@ -20,13 +27,15 @@ import be.ugent.sel.studeez.domain.implementation.LogServiceImpl
|
||||||
import be.ugent.sel.studeez.navigation.StudeezDestinations
|
import be.ugent.sel.studeez.navigation.StudeezDestinations
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
|
|
||||||
|
var timerEnd = false
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun SessionScreen(
|
fun SessionScreen(
|
||||||
open: (String) -> Unit,
|
open: (String) -> Unit,
|
||||||
openAndPopUp: (String, String) -> Unit,
|
openAndPopUp: (String, String) -> Unit,
|
||||||
viewModel: SessionViewModel = hiltViewModel()
|
viewModel: SessionViewModel = hiltViewModel()
|
||||||
) {
|
) {
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier.padding(10.dp)
|
modifier = Modifier.padding(10.dp)
|
||||||
) {
|
) {
|
||||||
Timer(viewModel)
|
Timer(viewModel)
|
||||||
|
@ -65,6 +74,25 @@ private fun Timer(viewModel: SessionViewModel = hiltViewModel()) {
|
||||||
tikker = !tikker
|
tikker = !tikker
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val context = LocalContext.current
|
||||||
|
val uri: Uri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)
|
||||||
|
val mediaplayer = MediaPlayer.create(context, uri)
|
||||||
|
mediaplayer.setOnCompletionListener {
|
||||||
|
mediaplayer.stop()
|
||||||
|
if (timerEnd) {
|
||||||
|
mediaplayer.release()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (viewModel.getTimer().hasCurrentCountdownEnded() && !viewModel.getTimer().hasEnded()) {
|
||||||
|
mediaplayer.start()
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!timerEnd && viewModel.getTimer().hasEnded()) {
|
||||||
|
mediaplayer.start()
|
||||||
|
timerEnd = true // Placeholder, vanaf hier moet het report opgestart worden en de sessie afgesloten
|
||||||
|
}
|
||||||
|
|
||||||
val hms = viewModel.getTimer().getHoursMinutesSeconds()
|
val hms = viewModel.getTimer().getHoursMinutesSeconds()
|
||||||
Column {
|
Column {
|
||||||
Text(
|
Text(
|
||||||
|
|
Reference in a new issue