added soundplayer
This commit is contained in:
parent
4466f3646f
commit
4519bf2e30
4 changed files with 11 additions and 25 deletions
|
@ -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)
|
|
||||||
}
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
package be.ugent.sel.studeez.screens.session.sessionScreens
|
||||||
|
|
||||||
|
class SoundPlayer {
|
||||||
|
}
|
|
@ -3,7 +3,6 @@ package be.ugent.sel.studeez.screens.session.sessionScreens.composables
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.layout.*
|
import androidx.compose.foundation.layout.*
|
||||||
import androidx.compose.foundation.shape.CircleShape
|
import androidx.compose.foundation.shape.CircleShape
|
||||||
import androidx.compose.material.Text
|
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
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.data.local.models.timer_functional.FunctionalPomodoroTimer
|
||||||
import be.ugent.sel.studeez.resources
|
import be.ugent.sel.studeez.resources
|
||||||
import be.ugent.sel.studeez.screens.session.SessionActions
|
import be.ugent.sel.studeez.screens.session.SessionActions
|
||||||
|
import be.ugent.sel.studeez.screens.session.sessionScreens.SoundPlayer
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun BreakSessionScreenComposable(
|
fun BreakSessionScreenComposable(
|
||||||
open: (String) -> Unit,
|
open: (String) -> Unit,
|
||||||
sessionActions: SessionActions,
|
sessionActions: SessionActions,
|
||||||
pomodoroTimer: FunctionalPomodoroTimer,
|
pomodoroTimer: FunctionalPomodoroTimer,
|
||||||
|
soundPlayer: SoundPlayer,
|
||||||
) {
|
) {
|
||||||
SessionScreen(
|
SessionScreen(
|
||||||
open = open,
|
open = open,
|
||||||
sessionActions = sessionActions,
|
sessionActions = sessionActions,
|
||||||
midSection = { Dots(pomodoroTimer = pomodoroTimer) },
|
midSection = { Dots(pomodoroTimer = pomodoroTimer) },
|
||||||
|
callMediaPlayer = { soundPlayer.playOn(pomodoroTimer.hasCurrentCountdownEnded()) },
|
||||||
motivationString = { motivationString (pomodoroTimer = pomodoroTimer) }
|
motivationString = { motivationString (pomodoroTimer = pomodoroTimer) }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -69,8 +71,3 @@ private fun motivationString(pomodoroTimer: FunctionalPomodoroTimer): String {
|
||||||
|
|
||||||
return resources().getString(R.string.state_focus)
|
return resources().getString(R.string.state_focus)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
|
||||||
private fun test(pomodoroTimer: FunctionalPomodoroTimer): String {
|
|
||||||
return pomodoroTimer.breaksRemaining.toString()
|
|
||||||
}
|
|
|
@ -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.data.local.models.timer_functional.FunctionalCustomTimer
|
||||||
import be.ugent.sel.studeez.resources
|
import be.ugent.sel.studeez.resources
|
||||||
import be.ugent.sel.studeez.screens.session.SessionActions
|
import be.ugent.sel.studeez.screens.session.SessionActions
|
||||||
|
import be.ugent.sel.studeez.screens.session.sessionScreens.SoundPlayer
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun CustomTimerSessionScreenComposable(
|
fun CustomTimerSessionScreenComposable(
|
||||||
open: (String) -> Unit,
|
open: (String) -> Unit,
|
||||||
sessionActions: SessionActions,
|
sessionActions: SessionActions,
|
||||||
customTimer: FunctionalCustomTimer
|
customTimer: FunctionalCustomTimer,
|
||||||
|
soundPlayer: SoundPlayer
|
||||||
) {
|
) {
|
||||||
SessionScreen(
|
SessionScreen(
|
||||||
open = open,
|
open = open,
|
||||||
|
callMediaPlayer = { soundPlayer.playOn(customTimer.hasEnded()) },
|
||||||
sessionActions = sessionActions
|
sessionActions = sessionActions
|
||||||
) {
|
) {
|
||||||
motivationString(customTimer = customTimer)
|
motivationString(customTimer = customTimer)
|
||||||
|
|
Reference in a new issue