added soundplayer

This commit is contained in:
lbarraga 2023-05-15 18:57:24 +02:00
parent 4466f3646f
commit 4519bf2e30
4 changed files with 11 additions and 25 deletions

View file

@ -1,18 +0,0 @@
package be.ugent.sel.studeez.screens.session.sessionScreens
import android.media.MediaPlayer
import be.ugent.sel.studeez.data.local.models.timer_functional.FunctionalCustomTimer
import be.ugent.sel.studeez.data.local.models.timer_functional.FunctionalEndlessTimer
import be.ugent.sel.studeez.data.local.models.timer_functional.FunctionalPomodoroTimer
import be.ugent.sel.studeez.data.local.models.timer_functional.FunctionalTimerVisitor
class GetSessionScreen(private val mediaplayer: MediaPlayer?) : FunctionalTimerVisitor<AbstractSessionScreen> {
override fun visitFunctionalCustomTimer(functionalCustomTimer: FunctionalCustomTimer): AbstractSessionScreen =
CustomSessionScreen(functionalCustomTimer, mediaplayer)
override fun visitFunctionalEndlessTimer(functionalEndlessTimer: FunctionalEndlessTimer): AbstractSessionScreen =
EndlessSessionScreen()
override fun visitFunctionalBreakTimer(functionalPomodoroTimer: FunctionalPomodoroTimer): AbstractSessionScreen =
BreakSessionScreen(functionalPomodoroTimer, mediaplayer)
}

View file

@ -0,0 +1,4 @@
package be.ugent.sel.studeez.screens.session.sessionScreens
class SoundPlayer {
}

View file

@ -3,7 +3,6 @@ package be.ugent.sel.studeez.screens.session.sessionScreens.composables
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
@ -14,17 +13,20 @@ import be.ugent.sel.studeez.R
import be.ugent.sel.studeez.data.local.models.timer_functional.FunctionalPomodoroTimer
import be.ugent.sel.studeez.resources
import be.ugent.sel.studeez.screens.session.SessionActions
import be.ugent.sel.studeez.screens.session.sessionScreens.SoundPlayer
@Composable
fun BreakSessionScreenComposable(
open: (String) -> Unit,
sessionActions: SessionActions,
pomodoroTimer: FunctionalPomodoroTimer,
soundPlayer: SoundPlayer,
) {
SessionScreen(
open = open,
sessionActions = sessionActions,
midSection = { Dots(pomodoroTimer = pomodoroTimer) },
callMediaPlayer = { soundPlayer.playOn(pomodoroTimer.hasCurrentCountdownEnded()) },
motivationString = { motivationString (pomodoroTimer = pomodoroTimer) }
)
}
@ -68,9 +70,4 @@ private fun motivationString(pomodoroTimer: FunctionalPomodoroTimer): String {
}
return resources().getString(R.string.state_focus)
}
@Composable
private fun test(pomodoroTimer: FunctionalPomodoroTimer): String {
return pomodoroTimer.breaksRemaining.toString()
}

View file

@ -5,15 +5,18 @@ import be.ugent.sel.studeez.R
import be.ugent.sel.studeez.data.local.models.timer_functional.FunctionalCustomTimer
import be.ugent.sel.studeez.resources
import be.ugent.sel.studeez.screens.session.SessionActions
import be.ugent.sel.studeez.screens.session.sessionScreens.SoundPlayer
@Composable
fun CustomTimerSessionScreenComposable(
open: (String) -> Unit,
sessionActions: SessionActions,
customTimer: FunctionalCustomTimer
customTimer: FunctionalCustomTimer,
soundPlayer: SoundPlayer
) {
SessionScreen(
open = open,
callMediaPlayer = { soundPlayer.playOn(customTimer.hasEnded()) },
sessionActions = sessionActions
) {
motivationString(customTimer = customTimer)