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

Use TaskStackBuilder instead of PendingIntent.getActivity #1293

Open
wants to merge 4 commits into
base: main-ose
Choose a base branch
from

Conversation

ArnyminerZ
Copy link
Member

Purpose

The current state-of-the-art seems to be TaskStackBuilder, also for Compose deep links.

Short description

Replaced all usages of PendingIntent.getActivity with the equivalent TaskStackBuilder.

Checklist

  • The PR has a proper title, description and label.
  • I have self-reviewed the PR.
  • I have added documentation to complex functions and functions that can be used by other modules.
  • I have added reasonable tests or consciously decided to not add tests.

@ArnyminerZ ArnyminerZ linked an issue Feb 3, 2025 that may be closed by this pull request
@ArnyminerZ ArnyminerZ marked this pull request as ready for review February 3, 2025 10:57
@rfc2822 rfc2822 requested a review from sunkup February 3, 2025 12:03
@rfc2822 rfc2822 added the refactoring Internal improvement of existing functions label Feb 3, 2025
Copy link
Member

@sunkup sunkup left a comment

Choose a reason for hiding this comment

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

I am not completely sure, so please tell me, what is the reasoning for using addNextIntent over addNextIntentWithParentStack in all our use cases?

@@ -26,6 +27,7 @@ import at.bitfire.davdroid.InvalidAccountException
import at.bitfire.davdroid.R
import at.bitfire.davdroid.network.HttpClient
import at.bitfire.davdroid.repository.DavServiceRepository
import at.bitfire.davdroid.servicedetection.RefreshCollectionsWorker.Companion.ARG_SERVICE_ID
Copy link
Member

Choose a reason for hiding this comment

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

Added an unused import here

Copy link
Member

Choose a reason for hiding this comment

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

It's still there. ARG_SERVICE_ID does not need to be imported for the usages in it's own file.

@ArnyminerZ
Copy link
Member Author

I am not completely sure, so please tell me, what is the reasoning for using addNextIntent over addNextIntentWithParentStack in all our use cases?

As far as I my understanding goes, addNextIntentWithParentStack would allow going back from the launched activity all the way to the main one, and addNextIntent will only launch the given activity.

So if you always use addNextIntent, going back should close the app? Not sure about this one

@sunkup
Copy link
Member

sunkup commented Feb 5, 2025

I am not completely sure, so please tell me, what is the reasoning for using addNextIntent over addNextIntentWithParentStack in all our use cases?

As far as I my understanding goes, addNextIntentWithParentStack would allow going back from the launched activity all the way to the main one, and addNextIntent will only launch the given activity.

So if you always use addNextIntent, going back should close the app? Not sure about this one

ok. So is that what we want in every case?

@ArnyminerZ
Copy link
Member Author

ok. So is that what we want in every case?

I don't actually know. I think it's more of a personal choice. When accessing from a notification for example, do we want that going back closes the app or navigates back?

@sunkup
Copy link
Member

sunkup commented Feb 12, 2025

ok. So is that what we want in every case?

I don't actually know. I think it's more of a personal choice. When accessing from a notification for example, do we want that going back closes the app or navigates back?

Should there not be something about that expected user expierence somewhere in the docs? Like maybe in the material guide lines?

Personally I would always expect that going back will navigate back - not close the app.

@sunkup
Copy link
Member

sunkup commented Feb 12, 2025

Although we don't use actual deeplinks yet, I would argue that's what we do when entering a deep screen through a notification. This is the expected behaviour:

https://developer.android.com/guide/navigation/design/deep-link#explicit

https://developer.android.com/guide/navigation/principles#deep-link

Also interesting:
https://m2.material.io/design/navigation/understanding-navigation.html

@ArnyminerZ
Copy link
Member Author

Although we don't use actual deeplinks yet

I think that even though we don't use deeplinks, we kind of have a navigation graph, so I agree that we should act like we have them.

@ArnyminerZ
Copy link
Member Author

To sum things up, I think I am going to replace all PendingIntents of activities other than AccountsActivity with addNextIntentWithParentStack, that way the whole stack would be added, and going back would match the expected behavior, and the recommended one by Google.

@ArnyminerZ
Copy link
Member Author

I've merged main into here, and replaced some usages. I've left some ACTION_VIEW intents with addNextIntent because as far as I understand, implicit intents would not have any stack or matching activity to build it from, right?

@ArnyminerZ ArnyminerZ requested a review from sunkup February 12, 2025 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring Internal improvement of existing functions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create PendingIntents using TaskStackBuilder
3 participants