Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: improved stopwatch service and notification #297

Merged
merged 1 commit into from
Mar 12, 2024

Conversation

SuhasDissa
Copy link
Member

Improvements

  • Use a bound service for stopwatch and move it to foreground only when a stopwatch is running 1
  • Move the service connection logic into the MainActivity 2
  • Use a simple integer value to store the stopwatch progress
  • Click the notification to open stopwatch screen

Demo

Old Behavior New Behavior
Screen_recording_old.mp4
Screen_recording_new.mp4

Other tests

I started the stopwatch. Cleared the app from task view and waited for about a half an hour with the device screen turned off. The stopwatch service managed to survive that whole time without crashing.

Footnotes

  1. This should be more responsive than starting and stopping the service for every stopwatch run

  2. This prevents leaking a context object in the viewmodel

@SuhasDissa SuhasDissa linked an issue Feb 20, 2024 that may be closed by this pull request
3 tasks
if (state == WatchState.RUNNING) getString(R.string.pause) else getString(R.string.resume)
return getAction(
text,
7,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move that to a const or variable somewhere, so it's easier to overview which ones we already use and which not. Same for stopAction().

Copy link
Member

@Bnyro Bnyro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works as expected from my testing 👍

@SuhasDissa SuhasDissa merged commit 584eba5 into you-apps:main Mar 12, 2024
1 check passed
@SuhasDissa SuhasDissa deleted the stopwatch branch March 24, 2024 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unresponsive stopwatch notification
2 participants