Closed coder2699 closed 4 years ago
@rob729 Please test the app and review the PR whenever possible.
@coder2699 Can you briefly mention the approach you have used to add this feature?
@coder2699 Can you briefly mention the approach you have used to add this feature?
@rob729 The basic approach that I have used is:
@rob729 I have made all the changes that were asked till now. Please have a look
Similar to the shared pref implementation in the app, the same has to be implemented in the case of work manager because passing context from profileListAdapter does not seems to be good. Make a WorkManagerHelper object similar to StoreSession and make a single instance of the work manager. That instance has to be initialized in the application class so that it can be used anywhere in the app without having to initialize a new instance every time. The functions which are added in Utils.kt in this PR have to be shifted to the WorkManagerHelper object file. The above implementation will remove the setAlarm functions dependency on context.
@rob729 I have added WorkManagerHelper by reading the official docs and your above comment. If something needs to be modified please let me know.
@rob729 Please have a look, I have tried to solve the bug
@coder2699 Can you also tell me what is the role of lines 86-94 in the adapter?
@coder2699 Can you also tell me what is the role of lines 86-94 in the adapter?
Lines 86-94 ensures that at starting time, we have the active profile id stored and the begin status also. And at when the end time strikes they don't store those values. So that when we perform the check (active profile or not) on clicking the switch, the correct values remain there
Without these lines we were storing the Active profile id and begin status when the notification was triggering (in StartAlarm.kt and EndAlarm.kt). But if we take up the case, say we have start time 8:25PM & end time 8:30PM, and we pause the profile anytime before 8:25Pm and resume it anytime after 8:25PM but before 8:30PM. Since notification was not triggering (at 8:25PM we had profile paused), the values stored in BeginStatus and ActiveProfileId were causing problem.
@coder2699 Can you also tell me what is the role of lines 86-94 in the adapter?
Lines 86-94 ensures that at starting time, we have the active profile id stored and the begin status also. And at when the end time strikes they don't store those values. So that when we perform the check (active profile or not) on clicking the switch, the correct values remain there
Without these lines we were storing the Active profile id and begin status when the notification was triggering (in StartAlarm.kt and EndAlarm.kt). But if we take up the case, say we have start time 8:25PM & end time 8:30PM, and we pause the profile anytime before 8:25Pm and resume it anytime after 8:25PM but before 8:30PM. Since notification was not triggering (at 8:25PM we had profile paused), the values stored in BeginStatus and ActiveProfileId were causing problem.
Regarding end time also, say taking the above mentioned example if you paused the profile before 8:30PM but after 8:25PM, and left the switch off, Active Profile Id would still be storing that Id (since end alarm notification would not trigger)
@coder2699 Feel free to work on any other issue/feature. I will need some more time to test the PR.
@coder2699 resolve the merge conflicts.
@coder2699 Profile start time: 11:50 AM and end time: 11:51 AM Profile paused at 11:49 AM and resumed at 11:50 AM. The profile gets activate at 11:51 AM but does not disable.
Basically, if the profile is activated 1 min before the end time then the app is not working as expected. Might be happening because both start and end alarm are set for the same time and the order of execution is not fixed. Check on your device and tell if you are also facing this issue.
@coder2699 Profile start time: 11:50 AM and end time: 11:51 AM Profile paused at 11:49 AM and resumed at 11:50 AM. The profile gets activate at 11:51 AM but does not disable.
Basically, if the profile is activated 1 min before the end time then the app is not working as expected. Might be happening because both start and end alarm are set for the same time and the order of execution is not fixed. Check on your device and tell if you are also facing this issue.
@rob729 I did not face this issue. I have tried out something, please check if you are still facing it.
give @coder2699 150 points
Fixes #7 Changes: Added Profile Pause/Resume Feature
Video for the change: https://drive.google.com/file/d/1u5c6VwxyAdkD-zutTCkmeq7AI7QEGTYk/view?usp=sharing