-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Notification can now take to reviewer Activity if review was in progress before. #8238
Conversation
First PR! 🚀 We sincerely appreciate that you have taken the time to propose a change to AnkiDroid! Please have patience with us as we are all volunteers - we will get to this as soon as possible. |
Codecov Report
@@ Coverage Diff @@
## master #8238 +/- ##
============================================
+ Coverage 36.95% 37.11% +0.15%
- Complexity 3783 3842 +59
============================================
Files 354 359 +5
Lines 35820 36244 +424
Branches 4736 4795 +59
============================================
+ Hits 13239 13451 +212
- Misses 21072 21266 +194
- Partials 1509 1527 +18 Continue to review full report at Codecov.
|
@IAmJaishree Can you please a screenshot/video of the change if possible? |
@haran2248 initially I thought there is no UI change so it doesn't require screenshots, but yes as there is a change in behavior I'll add a video in a while. thanks for the suggestion :) |
When the user has an in progress review the notification tap takes to that deck instead of deck list page. ankiNotify.mp4 |
When user has completed the Review of a deck but still there are pending cards to review from other decks, the user will be notified by the notification and on tapping the notification the Deck List Page will open. ankiNotify2.mp4 |
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.
Some small changes. You can format your code using ctrl+alt+L
. This would help in proper code readability.
AnkiDroid/src/main/java/com/ichi2/anki/services/NotificationService.java
Outdated
Show resolved
Hide resolved
@mrudultora the thing is doing ctrl + alt + l in Reviewer.java added many extra lines as un necessary white spaces, so I didn't do it. |
No, don't select the whole file. Assume, you added 5 lines of code. So, select those 5 lines only and then do ctrl+alt+L. I hope the point in clear now? |
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.
Hi,
Thanks a lot for your first PR.
I have never heard about this bug, as I personally don't use notification. It's really nice to see it solved, seems that'll indeed help quite some people.
A few remarks you can see in code comment.
I would like, if possible, that you edit your PR description in order to give a high level explanation of what you are doing. I have used notification in the past and improved them a little bit, but I don't remember exactly what Notificationservice, OnReceive and Notification are.
It would help me, I think, to simply read, for example:
If the notification is triggered during a review, clicking on the notification let the user in the reviewer, unless there is no card to see in which case it goes back to deck picker
and also, for example:
This is done as follow:
- If the notification is triggered during review, then the intent will contains the field "throughNotification" to indicate that the notification was sent through review
- If the activity is opened and the reviewer has no card, then we go to the deck picker
Currently, I am not sure what you are trying to do exactly, so it's hard to review and ensure that's correctly what you wanted to do.
In particular, I've got a question. What occurs if the user click on the notification later. For example later in the day, when some cards that were hard are due to review a second time. Or a day later, when cards are back in the deck to be reviewed. It is not clear to
@mrudultora and @haran2248 Thank you a lot for your help reviewing. Given the increase in amount of time AnkiDroid suddenly require, this is very welcome. However, I'd like to ask for a change. As a general rule, I'd really appreciate if you can start by a positive message before starting with remarks of problem. Of course, the politeness rules depends of plenty of things, and that may not be needed for everybody, but that's still something that would ensure that even people with doubt will know that there were no mistake, that the whole process is good even if there are details to change. I believe that this help being a welcoming community to every people who wants to contribute. It also ensures simply that it is worth working on the PR; because after all, there is nothing that confirmed that it is a good approach globally.
To be clear, this is a general rule, for all PR, and not about this one in particular.
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
2702034
to
68882a5
Compare
@IAmJaishree I am assigned for issue in this repository . But I am stuck ,would you like to work with me on that issue |
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/anki/services/NotificationService.java
Outdated
Show resolved
Hide resolved
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.
Code's really clean, thanks :)
sure :) |
What's the status on this one? I don't see any status labels or clear approvals / request changes on review status from maintainers, though there is lots of interaction ? |
22e5407
to
dfa5f53
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.
Tiny change then good to go, thanks!!
@IAmJaishree Do you still intend to work on it? Normally, it's almost done |
@Arthur-Milchior sorry for the delay I was involved in my college exams, will complete this in a while |
if review was in progress then tapping the notification will open Review Activity otherwise DeckList page will open.
No emergency, we are all volunteers. We wondered whether we drove a contributor away somehow, and whether we should reassign this task |
@david-allison-1 @Arthur-Milchior could you please review this PR :) |
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! Looks good to me
@@ -162,6 +163,7 @@ public void onPostExecute(PairWithBoolean<Card[]> result) { | |||
|
|||
@Override | |||
protected void onCreate(Bundle savedInstanceState) { | |||
|
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.
nit: remove spacing change here
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 looks good in general, but I left a comment about Intent handling - could you check it @IAmJaishree ?
Thanks for your patience on the review I did not see this until just now!
else the control will go to the DeckPicker Activity to show the Deck List | ||
*/ | ||
if (col.getSched().count() == 0) { | ||
startActivityWithoutAnimation(new Intent(this, DeckPicker.class)); |
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 something really subtle, but I have experienced bugs before where Intents were passed around, and the extras were erased crazycodeboy/react-native-splash-screen#289 (comment)
Philosophically, if we cannot handle an Intent, we should do our best to pass the original Intent to some Activity that can handle it, in the same way that if you cannot handle an Exception it is best to log something about why but then re-throw the original exception. Wrapping the exception or throwing a new one actually destroys information (the stack trace), and in the same way, making a new Intent here destroys information (any other possible Extras on the Intent, it's flags, category etc)
I don't believe we can just re-launch the Intent, but we can at least make sure we pass everything possible, which is the Extras Bundle (if it exists) and any flags (if they exist?)
I think the correct way to do that is either:
1- call setComponent (or maybe setClassName?) https://developer.android.com/reference/android/content/Intent#setComponent(android.content.ComponentName) to simply take this intent but re-direct it to DeckPicker.class or
2- call fillIn on the new Intent (directed at DeckPicker) but with the contents of the one we could not handle here in Reviewer https://developer.android.com/reference/android/content/Intent#fillIn(android.content.Intent,%20int)
I strongly prefer solution 1 because we know we are passing everything without having to think more, but if it does not work then solution 2 could work, as long as extras were manually copied as well
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 |
Purpose / Description
Currently, tapping the notification opens Deck List instead of Review page when pending reviews are present.
This PR contains the code which will allow user to go to Review page instead of deck list page by tapping the notification when a review is already in progress.
If no review is in progress the deck list page will open.
Fixes #3593
Approach
Added a check in NotificationService.java => onReceive function which checks if there are pending card to review and decides the intent of Notification click based on this.
Step 1 happens while the Notification onReceive method gets triggered and this can contain the lagging data as well.
For example when this onReceive is triggered there may be pending cards to review and based on the logic it decides to open Review page on tapping the notification but there are cases where the user taps the notification after completing the deck also in this case the Review page will open and there will be no card to review.
For this case added a check in Review activity where it checks if the Review Activity is open through Notification and verifies if there are pending cards or not, if there are no pending cards then it opens Deck List page instead.
How Has This Been Tested?
This has been tested by me manually going through each of the following scenario:
When user is reviewing a deck => Goes out of the app and there are pending cards to review. Notification appears and on tapping the notification the user is resumed to the Review page to continue the review process.
When user is reviewing a deck => Completes the Deck Review => app closes automatically as the review is complete. Notification appears and on tapping the notification the deck list is opened.
There are no review in progress but there are decks to review. Notification appears and on tapping the notification the deck list is opened.
Checklist Please, go through these checks before submitting the PR.
if
statements) -