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: Single review activity instance #17036

Merged

Conversation

leobugeja
Copy link
Contributor

@leobugeja leobugeja commented Sep 7, 2024

Fixes

Purpose / Description

This fixes the issue where the error message "Not at top of the queue" appears when a review is in progress and the user opens another deck through the deck picker widget or a deck shortcut. The message appears when attempting to review a card after using the back button on the first deck which takes the user to a deck 'underneath' it. There should not be multiple review activity instances and so restricting there to be only a single review instance on the activity stack removes the possiblity of the "Not at top of the queue" error message occuring.

Intent.FLAG_ACTIVITY_CLEAR_TOP docs:

If set, and the activity being launched is already running in the current task, then instead of launching a new instance of that activity, all of the other activities on top of it will be closed and this Intent will be delivered to the (now on top) old activity as a new Intent.

For example, consider a task consisting of the activities: A, B, C, D. If D calls startActivity() with an Intent that resolves to the component of activity B, then C and D will be finished and B receive the given Intent, resulting in the stack now being: A, B.

deck-shortcut-single-activity.webm

Copy link
Member

@Arthur-Milchior Arthur-Milchior left a comment

Choose a reason for hiding this comment

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

Thank you very much.
As a user of shortcut, it'll certainly improve my experience!
And it'll allow us to enable the deck picker widget of @xenonnn4w , I think, so that's cool!

@Arthur-Milchior Arthur-Milchior added the Needs Second Approval Has one approval, one more approval to merge label Sep 8, 2024
@xenonnn4w
Copy link
Contributor

xenonnn4w commented Sep 8, 2024

Thanks, looks great🌸

Copy link
Member

@mikehardy mikehardy left a comment

Choose a reason for hiding this comment

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

There is a lack of consistency in our Intent back stack management

https://github.com/search?q=repo%3Aankidroid%2FAnki-Android+Intent.FLAG_ACTIVITY_CLEAR&type=code

...shows we use CLEAR_TASK sometimes, an or if flags other times, and CLEAR_TOP other times

I believe this is sufficient and an improvement here, so I'm approving this PR

But it looks like there should be a low-priority issue to look at:

  • any case where we create an Intent to start an activity
  • ...to verify that we are actually using the correct back stack management flags

@mikehardy mikehardy removed the Needs Second Approval Has one approval, one more approval to merge label Sep 16, 2024
@mikehardy mikehardy added this pull request to the merge queue Sep 16, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Sep 16, 2024
@mikehardy mikehardy added this pull request to the merge queue Sep 16, 2024
@mikehardy mikehardy added the Pending Merge Things with approval that are waiting future merge (e.g. targets a future release, CI wait, etc) label Sep 16, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Sep 16, 2024
@mikehardy mikehardy added this pull request to the merge queue Sep 16, 2024
Merged via the queue into ankidroid:main with commit c2b2ef3 Sep 16, 2024
12 checks passed
@github-actions github-actions bot removed the Pending Merge Things with approval that are waiting future merge (e.g. targets a future release, CI wait, etc) label Sep 16, 2024
@github-actions github-actions bot added this to the 2.19 release milestone Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants