Merge branch 'development' into sessionscreen_ui
This commit is contained in:
commit
9d2c53d4e6
26 changed files with 477 additions and 79 deletions
|
@ -0,0 +1,14 @@
|
|||
package be.ugent.sel.studeez.data
|
||||
|
||||
import be.ugent.sel.studeez.data.local.models.timer_functional.FunctionalTimer
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
/**
|
||||
* Used to communicate the SelectedTimer from the selection screen to the session screen.
|
||||
* Because this is a singleton-class the view-models of both screens observe the same data.
|
||||
*/
|
||||
@Singleton
|
||||
class SelectedTimerState @Inject constructor(){
|
||||
var selectedTimer: FunctionalTimer? = null
|
||||
}
|
|
@ -1,3 +1,3 @@
|
|||
package be.ugent.sel.studeez.data.local.models
|
||||
|
||||
data class User(val id: String = "", val isAnonymous: Boolean = true)
|
||||
data class User(val id: String = "")
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
package be.ugent.sel.studeez.data.local.models.timer_functional
|
||||
|
||||
class FunctionalCustomTimer(studyTime: Int): FunctionalTimer(studyTime) {
|
||||
class FunctionalCustomTimer(studyTime: Int) : FunctionalTimer(studyTime) {
|
||||
|
||||
override fun tick() {
|
||||
if (time.getTime() == 0) {
|
||||
view = "Done!"
|
||||
if (time.time == 0) {
|
||||
view = StudyState.DONE
|
||||
} else {
|
||||
time.minOne()
|
||||
}
|
||||
}
|
||||
|
||||
override fun hasEnded(): Boolean {
|
||||
return time.getTime() == 0
|
||||
return time.time == 0
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
package be.ugent.sel.studeez.data.local.models.timer_functional
|
||||
|
||||
class FunctionalEndlessTimer() : FunctionalTimer(0){
|
||||
class FunctionalEndlessTimer() : FunctionalTimer(0) {
|
||||
|
||||
override fun hasEnded(): Boolean {
|
||||
return false
|
||||
|
|
|
@ -3,25 +3,25 @@ package be.ugent.sel.studeez.data.local.models.timer_functional
|
|||
class FunctionalPomodoroTimer(
|
||||
private var studyTime: Int,
|
||||
private var breakTime: Int, repeats: Int
|
||||
): FunctionalTimer(studyTime) {
|
||||
) : FunctionalTimer(studyTime) {
|
||||
|
||||
private var breaksRemaining = repeats
|
||||
private var isInBreak = false
|
||||
var breaksRemaining = repeats
|
||||
var isInBreak = false
|
||||
|
||||
override fun tick() {
|
||||
if (time.getTime() == 0 && breaksRemaining == 0){
|
||||
view = "Done!"
|
||||
if (time.time == 0 && breaksRemaining == 0) {
|
||||
view = StudyState.DONE
|
||||
return
|
||||
}
|
||||
|
||||
if (time.getTime() == 0) {
|
||||
if (time.time == 0) {
|
||||
if (isInBreak) {
|
||||
breaksRemaining--
|
||||
view = "Focus! ($breaksRemaining breaks remaining)"
|
||||
time.setTime(studyTime)
|
||||
view = StudyState.FOCUS_REMAINING
|
||||
time.time = studyTime
|
||||
} else {
|
||||
view = "Take a break!"
|
||||
time.setTime(breakTime)
|
||||
view = StudyState.BREAK
|
||||
time.time = breakTime
|
||||
}
|
||||
isInBreak = !isInBreak
|
||||
}
|
||||
|
@ -29,6 +29,6 @@ class FunctionalPomodoroTimer(
|
|||
}
|
||||
|
||||
override fun hasEnded(): Boolean {
|
||||
return breaksRemaining == 0 && time.getTime() == 0
|
||||
return breaksRemaining == 0 && time.time == 0
|
||||
}
|
||||
}
|
|
@ -1,17 +1,13 @@
|
|||
package be.ugent.sel.studeez.data.local.models.timer_functional
|
||||
|
||||
abstract class FunctionalTimer(initialValue: Int) {
|
||||
protected val time: Time = Time(initialValue)
|
||||
protected var view: String = "Focus"
|
||||
val time: Time = Time(initialValue)
|
||||
var view: StudyState = StudyState.FOCUS
|
||||
|
||||
fun getHoursMinutesSeconds(): HoursMinutesSeconds {
|
||||
return time.getAsHMS()
|
||||
}
|
||||
|
||||
fun getViewString(): String {
|
||||
return view
|
||||
}
|
||||
|
||||
abstract fun tick()
|
||||
|
||||
abstract fun hasEnded(): Boolean
|
||||
|
@ -19,4 +15,9 @@ abstract class FunctionalTimer(initialValue: Int) {
|
|||
fun hasCurrentCountdownEnded(): Boolean {
|
||||
return time.getTime() == 0
|
||||
}
|
||||
|
||||
enum class StudyState {
|
||||
FOCUS, DONE, BREAK, FOCUS_REMAINING
|
||||
}
|
||||
|
||||
}
|
|
@ -2,7 +2,7 @@ package be.ugent.sel.studeez.data.local.models.timer_functional
|
|||
|
||||
class Time(initialTime: Int) {
|
||||
|
||||
private var time = initialTime
|
||||
var time = initialTime
|
||||
|
||||
fun minOne() {
|
||||
time--
|
||||
|
@ -12,14 +12,6 @@ class Time(initialTime: Int) {
|
|||
time++
|
||||
}
|
||||
|
||||
fun setTime(newTime: Int) {
|
||||
time = newTime
|
||||
}
|
||||
|
||||
fun getTime(): Int {
|
||||
return time
|
||||
}
|
||||
|
||||
fun getAsHMS(): HoursMinutesSeconds {
|
||||
val hours: Int = time / (60 * 60)
|
||||
val minutes: Int = (time / (60)) % 60
|
||||
|
|
|
@ -3,7 +3,7 @@ package be.ugent.sel.studeez.data.local.models.timer_info
|
|||
import be.ugent.sel.studeez.data.local.models.timer_functional.FunctionalPomodoroTimer
|
||||
import be.ugent.sel.studeez.data.local.models.timer_functional.FunctionalTimer
|
||||
|
||||
class BreakTimerInfo(
|
||||
class PomodoroTimerInfo(
|
||||
name: String,
|
||||
description: String,
|
||||
private val studyTime: Int,
|
Reference in a new issue