-
-
Notifications
You must be signed in to change notification settings - Fork 81
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
Compose Navigation: start migration with AccountsActivity #1211
base: main-ose
Are you sure you want to change the base?
Conversation
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
I think this can be a good first PR on the topic. |
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
@Composable
fun Example() {
val navController = LocalNavController.current
navController.navigate(ExampleRoute) |
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
AccountsActivity
to MainActivity
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.
Can we move the NavController
to the navigation
package? Just so that there are no packages that only contain one class.
But didn't have an in-depth look yet. Please @sunkup also have a look first (we can talk tomorrow about it).
@ArnyminerZ maybe you can make the suggested change and request a new review from me? I will use the opportunity to get to know compose navigation. |
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
# Conflicts: # app/src/main/kotlin/at/bitfire/davdroid/sync/account/AddressBookAuthenticatorService.kt # app/src/main/res/xml/sync_prefs.xml
Done |
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.
Looks really good!
For some reason I am sceptical about moving the AccountsDrawerHandler
injection to the model. I feel like it does not really belong there, but in favor of the new navigation paradigm I can't give a good reason not to do it ...
See the comment about broken reference, but yeah, otherwise it's really nice.
Also I think we could inject the Also, the idea is that the intro check occurs / the intro is potentially shown when the app UI starts. In the past we could only put it into the launcher activity ( In the future we could put it into the |
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
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.
Looks like it's working now 👍
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
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 have renamed Routes
to Destination
, hope that's in compliance with Compose Navigation terminology. Otherwise please correct me.
Also I think we should think about how to pass destinations directly to MainScreen
(see comments).
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
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 played around a bit and changed some things. Notably:
- move navigation to separate file, because it's not related to the Activity itself
- don't pass
NavController
between routes, keep future relations between screens inNavHost
- move
AccountsDrawerHandler
injection back to model for simplicity - tried to generate/parse deep links with builders
@ArnyminerZ Do you have further comments / suggestions?
I haven't tested it, but it looks good to me. |
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.
Looks okay.
One thing, where I am not sure if it's desired: If I open the app via launcher and see the accounts screen I can go back (system) to the launcher directly. If I start it like so: adb shell am start -n at.bitfire.davdroid/at.bitfire.davdroid.ui.AccountsActivity
I will have to "go back" twice before the app is closed and I get to see the launcher.
I think it should only take one "go back". @ArnyminerZ Can you have a look? |
Okay, so the issue comes because we are redirecting to the same page when launching from When we launch I've fixed it by setting single-top to the navigation: navController.navigate(
deepLinkRq,
NavOptions.Builder().setLaunchSingleTop(true).build()
) |
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
Purpose
As the first step of #1172, started by renaming
AccountsActivity
toMainActivity
, and start adding navigation functionality.Short description
AccountsActivity
and its usages toMainActivity
.AccountsRoute
from the intent data ofMainActivity
.LocalNavController
which holds a reference to the currently being used nav controller.Moved injection ofAccountsDrawerHandler
from activity to model to decouple it completely from activities.AccountsActivity
toMainActivity
for external applications.Checklist