-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Decoupled Notification From Widget #9411
Decoupled Notification From Widget #9411
Conversation
6e0a4a4
to
a811f84
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
This could do with more documentation, either by splitting out the commits, or a message in the commit message and PR summary.
I'll need to reread this after the comments are added, but from scanning, this seems to remove functionality (widgets cause notifications) with no replacement
a811f84
to
8a76ac5
Compare
Issues
|
To move this along: we either need to re-instate the widget based logic, or provide a better replacement |
Yes, I also think so that we have to re-engineer the widget part . Should I create a new issue ? |
I thought we'd discussed in the issue that the widget based logic would need to be improved/replaced? I don't think we need a new issue |
I am unable to find any discussion on widget based logic. There is only one issue related to this i.e #6476.
|
Our widget-based notification code is known to be buggy, and better alternatives exist. But, people are using the widget to get some notification-based functionality in AnkiDroid, and this removes this possibility without providing an alterative. I don't think we should remove this functionality for users until we have a better alternative. I'd approve this PR as just a refactoring to make future replacement easier, or if it refactors and replaces the widget code with something better |
8a76ac5
to
c72be85
Compare
@david-allison-1 I will refactor the widget part first. |
REFACTORED WIDGET WIDGET WORKING WIDGET NOTIFICATION DONE TODO
LEARNING RESOURSE |
Commit : 8047da5
Removed Widget.update() from on Stop of these activities. TESTING PROCESS
|
9f38230
to
8047da5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking better!
Could you split this out into more commits (ideally breaking out the "functional" change from the "refactoring" changes)
I'll come back to this tomorrow with a fresh pair of eyes (there's more to review), I'm finding it difficult to understand the context of the refactorings, vs the functional change, and more atomic commits would help here
AnkiDroid/src/main/java/com/ichi2/anki/services/NotificationService.java
Outdated
Show resolved
Hide resolved
AnkiDroid/src/main/java/com/ichi2/anki/services/NotificationService.java
Outdated
Show resolved
Hide resolved
AnkiDroid/src/main/java/com/ichi2/widget/AnkiDroidWidgetSmall.java
Outdated
Show resolved
Hide resolved
fc170d4
to
8456093
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm following this a bit more, but could you break up the commits into more atomic changes.
This combines Mike's suggested battery improvement with other changes, and attributing a line change to an intention is difficult currently.
I think we'll be able to remove a fair amount of code from this, it feels more complicated than it should be.
311afe9
to
bd8ce6e
Compare
Done with atomic commits, David kindly review this once again. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much nicer!
Needs a little more done on the first commit (review comments, and removing/splitting out the functional change)
I don't think the fourth commit needs to exist. I don't think there needs to be a linkage between the notification and the widget.
If we still need one, the reasoning needs to be well documented
AnkiDroid/src/main/java/com/ichi2/widget/AnkiDroidWidgetSmall.java
Outdated
Show resolved
Hide resolved
AnkiDroid/src/main/java/com/ichi2/widget/AnkiDroidWidgetSmall.java
Outdated
Show resolved
Hide resolved
AnkiDroid/src/main/java/com/ichi2/anki/services/NotificationService.java
Outdated
Show resolved
Hide resolved
AnkiDroid/src/main/java/com/ichi2/widget/AnkiDroidWidgetSmall.java
Outdated
Show resolved
Hide resolved
AnkiDroid/src/main/java/com/ichi2/anki/services/BootService.java
Outdated
Show resolved
Hide resolved
Yes it is needed. If we don't want to send the the notification when user is using our app. |
b165394
to
4e8c8dd
Compare
David Please review it once again. Done All things as per plan |
I'm not sure if this is an issue or not but If we recompute the counts as a poll, instead of doing this as an event-based thing we'll be put in the "you use too much power" penalty bucket and background services will be adaptively killed (or start-denied) by power algorithms on device and notifications won't work for anyone This stuff is hard to get right, but the fundamental thing is that notifications and widget counts need to be updated (not delete+re-create - same notification id re-used and just posted with new content) via an event subscription of some sort for the cases where the user is actually altering counts, then they should have zero activity except a PendingIntent for the notification to fire at the scheduled time (if any). |
Is there documentation for the criteria (from the most strict OS) for being put in the 'low power' bucket? Is this "too many wakeups", or "using too much time when woken up" From a scheduling perspective, we can calculate the next time deterministically: Reviews/day learn: We only need to check once per day at the day cutoff threshold - no issue. BUT: We may want this on a separate notification channel which won't cause vibrations, nobody wants a 4AM wakeup call to do their cards Intraday, except when the app is being used, all we care about is:
If we show "you have over 250 cards due", then we don't need to calculate the exact number, as we don't display it. If the issue is "using too much time when woken up", when the app is running, we can calculate the next time to wake up in a background thread (event based, rather than database-based). This would add a lot of complexity to the app, so I'd rather avoid it |
The ranking of terrible Android implementations changes constantly, this site is useful: https://dontkillmyapp.com/ |
Sorry, I was a little busy from past few weeks. Regarding the algorithm which calculates the next time of notification. |
Glad to see you back! This seems rather complicated. Why do we need three services here? As for the criteria: I'm open to suggestions but for a sensible first step, I'd use:
@mikehardy @Arthur-Milchior - pinging as this is off the top of my head and I haven't worked through consequences |
Hello 👋, this PR has been opened for more than 2 months with no activity on it. If you think this is a mistake please comment and ping a maintainer to get this merged ASAP! Thanks for contributing! You have 7 days until this gets closed automatically |
@prateek-singh-3212 Added the "needs a new dev" label as it went stable, let me know if you'll have the time to finish this one off |
@david-allison-1 Sorry I am unable to proceed this further as I am busy in my college classes. |
No worries! Life takes priority. |
Hello 👋, this PR has been opened for more than 2 months with no activity on it. If you think this is a mistake please comment and ping a maintainer to get this merged ASAP! Thanks for contributing! You have 7 days until this gets closed automatically |
Hello 👋, this PR has been opened for more than 2 months with no activity on it. If you think this is a mistake please comment and ping a maintainer to get this merged ASAP! Thanks for contributing! You have 7 days until this gets closed automatically |
@prateek-singh-3212 I think you are implementing in another PR #11487. If you wish to continue this PR then its okay, otherwise current PR can be closed. |
No this PR for reference only. I am impleting this in new PR. |
Hello 👋, this PR has been opened for more than 2 months with no activity on it. If you think this is a mistake please comment and ping a maintainer to get this merged ASAP! Thanks for contributing! You have 7 days until this gets closed automatically |
Pull Request template
Purpose / Description
Notification is tightly coupled with SmallWidget status which results in Notification whenever widget updates.
Fixes
Fixes #8114
Fixes #6476
Approach
We can make the new repository which holds the meta Data (or Meta information) of all decks like Total deck cards, Total New cards to Review, Total Learning cards etc in sqlite Database and whenever the data is required by widget , Notification or any other activity, Service.
This discussion is documented in this PR (this).
Flow Chart of Above Explained.
Flow Chart of Above Explained.
How Has This Been Tested?
Firefox browser and Galaxy M51 (API 30) Aspect ratio 20:9
Checklist
Please, go through these checks before submitting the PR.
if
statements)