Closed francelu closed 23 hours ago
Timer
data class and TimerDto
:
time
which is the elapsed time of that timer.TimerDtoTest.kt
was updated as necessary.TimerViewModel.kt
.verify()
statements as requested in the TimerViewModelTest.kt
.deleteTimer()
implemented as Supabase recommends with a filter. (Actually two functions, one by timerId
the other by userId
.)Timer.kt
and TimerDto.kt
: change of the data class.TimerDtoTest.kt
: tests for the previous point updated.TimerModel.kt
and TimerModelSupabase.kt
now have addTimer()
, getTimersOfUser()
, deleteTimerByTimerId()
and `deleteTimersByUserId().TimerModelSupabaseTest.kt
: tests for the previous point updated.TimerManager.kt
: implemented callbacks.TimerManagerTest.kt
: tests for the previous point updated.TimerViewModel.kt
:
userTimerList
a public attribute of all the timers of a user, its private mutable counterpart _userTimerList
.startTimer()
, resetTimer()
, stopTimer()
, fetchTimersOfUser()
and getRemainingTimer()
functions for the UI.TimerViewModelTest.kt
: tests for the previous point updated.TimerDto
, TimerModelSupabase
, TimerManager
and TimerViewModel
have been updated.runTest
instances to ensure that the coroutine code inside the tests is executed in a controlled environmentNOTE: ~I'm still trying to implement the automatic stop of the timer. However, I'm currently struggling with the tests.~
For now, we just let the timer countdown go to -00:30:00 times and below.
Issues
3 New issues
0 Accepted issues
Measures
0 Security Hotspots
79.1% Coverage on New Code
0.0% Duplication on New Code
Integrate Timer Feature
Description
This PR introduces a new timer feature to the project, which includes the implementation of the timer model, data transfer objects, repository, view model, and associated tests. It integrates the logic for managing timers, including starting, stopping, and resetting timers, as well as synchronizing data with the Supabase backend.
It closes issue #217.
Note
This PR will not handle the delete functions on Timer VM since it's not useful for now. I'm creating a task in for later, when we will need it on the deletion of a user.
I know I should have made a separate PR for the M from the VM. However, as I was implementing the VM, I had to change multiple times the M. That would have lead to a PR from M, and a PR for VM which would have overwritten the PR for M.
This PR has as new lines a lot of documentation , and mainly tests code. Hence, the thousand lines. I'm sorryyy...
Changes
Timer
data class with methods for serialization and state management.TimerDto
data transfer object to facilitate conversion between theTimer
model and API data (for Supabase).TimerRepository
interface and implementedTimerRepositorySupabase
for API interactions.TimerViewModel
for handling timer-related operations and UI state.TimerManager
to manage timer actions (start, stop, reset) and have a persistent timer (running after app closed).Note
Files
Added
app/src/main/java/com/android/periodpals/model/timer/Timer.kt
app/src/main/java/com/android/periodpals/model/timer/TimerDto.kt
app/src/main/java/com/android/periodpals/model/timer/TimerManager.kt
app/src/main/java/com/android/periodpals/model/timer/TimerModel.kt
app/src/main/java/com/android/periodpals/model/timer/TimerModelSupabase.kt
app/src/main/java/com/android/periodpals/model/timer/TimerViewModel.kt
app/src/test/java/com/android/periodpals/model/timer/TimerDtoTest.kt
app/src/test/java/com/android/periodpals/model/timer/TimerManagerTest.kt
app/src/test/java/com/android/periodpals/model/timer/TimerModelSupabaseTest.kt
Modified
app/src/main/java/com/android/periodpals/model/user/UserDto.kt
: I saw the documentation wasn't up-to-date when trying to understand who VM worked with Supabase.app/build.gradle.kts
: addviewBinding
inbuildFeatures
.Removed
Dependencies Added
Testing
TimerDto
,TimerManager
, andTimerRepositorySupabase
to ensure correct functionality.