Skip to content

Nav3 migration add subscription activity#642

Merged
sunkup merged 22 commits into
devfrom
nav3-migration-add-subscription-activity
Aug 20, 2025
Merged

Nav3 migration add subscription activity#642
sunkup merged 22 commits into
devfrom
nav3-migration-add-subscription-activity

Conversation

@ArnyminerZ

@ArnyminerZ ArnyminerZ commented Aug 8, 2025

Copy link
Copy Markdown
Member

Purpose

Migrate AddSubscriptionActivity to Nav3.

Depends on #640

Short description

  • Got rid of the Activity, and moved the logic to nav3.

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.

Signed-off-by: Arnau Mora <arnyminerz@proton.me>
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
@ArnyminerZ ArnyminerZ self-assigned this Aug 8, 2025
@github-actions github-actions Bot added the dependent Depends on other issues/PRs label Aug 8, 2025
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
@ArnyminerZ ArnyminerZ requested a review from Copilot August 8, 2025 07:44
@ArnyminerZ ArnyminerZ marked this pull request as ready for review August 8, 2025 07:44

This comment was marked as outdated.

Signed-off-by: Arnau Mora <arnyminerz@proton.me>
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
@github-actions github-actions Bot removed the dependent Depends on other issues/PRs label Aug 14, 2025
@github-actions

Copy link
Copy Markdown

This PR/issue depends on:

# Conflicts:
#	app/src/main/AndroidManifest.xml
#	app/src/main/java/at/bitfire/icsdroid/MainActivity.kt
#	app/src/main/java/at/bitfire/icsdroid/ui/nav/Destination.kt
#	app/src/main/java/at/bitfire/icsdroid/ui/nav/MainApp.kt
#	app/src/main/java/at/bitfire/icsdroid/ui/screen/SubscriptionsScreen.kt
#	app/src/main/java/at/bitfire/icsdroid/ui/views/AddSubscriptionActivity.kt
@ArnyminerZ ArnyminerZ requested review from Copilot and sunkup August 14, 2025 15:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

Migrates the AddSubscriptionActivity to use Nav3 by removing the standalone Activity and integrating its functionality into the Compose navigation system.

  • Replaced standalone Activity with Compose screen navigation
  • Moved intent handling and file picker logic from Activity to Composable functions
  • Updated navigation flow to use Nav3 backstack management

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
AddSubscriptionActivity.kt Removed entire Activity class, eliminating 133 lines of Activity-based navigation
SubscriptionsScreen.kt Modified to accept onAddRequested callback instead of launching Activity directly
AddSubscriptionScreen.kt Added new wrapper Composable with intent handling and file picker logic
MainApp.kt Integrated AddSubscription destination with intent parsing and navigation setup
Destination.kt Added AddSubscription destination with title and color parameters
AccountAuthenticatorService.kt Updated to launch MainActivity instead of the removed AddSubscriptionActivity
AndroidManifest.xml Merged intent filters into MainActivity and removed AddSubscriptionActivity declaration

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

Comment thread app/src/main/java/at/bitfire/icsdroid/ui/nav/MainApp.kt

@sunkup sunkup left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't remember exactly what I did, but when I played around a bit with going forward and backward around the AddSubscriptionScreen, then closing the app and opening via calendar permission request notification and I got this crash:

Details
11:42:21.981  E  FATAL EXCEPTION: main
                 Process: at.bitfire.icsdroid, PID: 14145
                 java.lang.IllegalArgumentException: NavDisplay backstack cannot be empty
                 	at androidx.navigation3.ui.NavDisplayKt.NavDisplay(NavDisplay.kt:170)
                 	at androidx.navigation3.ui.NavDisplayKt.NavDisplay$lambda$11(Unknown Source:36)
                 	at androidx.navigation3.ui.NavDisplayKt.$r8$lambda$SLsTTf3eDnrSQmCrJvKtHwJ4fig(Unknown Source:0)
                 	at androidx.navigation3.ui.NavDisplayKt$$ExternalSyntheticLambda3.invoke(D8$$SyntheticClass:0)
                 	at androidx.compose.runtime.RecomposeScopeImpl.compose(RecomposeScopeImpl.kt:196)
                 	at androidx.compose.runtime.ComposerImpl.recomposeToGroupEnd(Composer.kt:2893)
                 	at androidx.compose.runtime.ComposerImpl.skipCurrentGroup(Composer.kt:3229)
                 	at androidx.compose.runtime.ComposerImpl.doCompose-aFTiNEg(Composer.kt:3853)
                 	at androidx.compose.runtime.ComposerImpl.recompose-aFTiNEg$runtime(Composer.kt:3777)
                 	at androidx.compose.runtime.CompositionImpl.recompose(Composition.kt:1049)
                 	at androidx.compose.runtime.Recomposer.performRecompose(Recomposer.kt:1336)
                 	at androidx.compose.runtime.Recomposer.access$performRecompose(Recomposer.kt:155)
                 	at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2.invokeSuspend$lambda$22(Recomposer.kt:625)
                 	at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2.$r8$lambda$OqADLCDYmRw1RgNUvn1CR0kX32M(Unknown Source:0)
                 	at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$$ExternalSyntheticLambda0.invoke(D8$$SyntheticClass:0)
                 	at androidx.compose.ui.platform.AndroidUiFrameClock$withFrameNanos$2$callback$1.doFrame(AndroidUiFrameClock.android.kt:39)
                 	at androidx.compose.ui.platform.AndroidUiDispatcher.performFrameDispatch(AndroidUiDispatcher.android.kt:108)
                 	at androidx.compose.ui.platform.AndroidUiDispatcher.access$performFrameDispatch(AndroidUiDispatcher.android.kt:41)
                 	at androidx.compose.ui.platform.AndroidUiDispatcher$dispatchCallback$1.doFrame(AndroidUiDispatcher.android.kt:69)
                 	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:964)
                 	at android.view.Choreographer.doCallbacks(Choreographer.java:790)
                 	at android.view.Choreographer.doFrame(Choreographer.java:721)
                 	at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:951)
                 	at android.os.Handler.handleCallback(Handler.java:883)
                 	at android.os.Handler.dispatchMessage(Handler.java:100)
                 	at android.os.Looper.loop(Looper.java:214)
                 	at android.app.ActivityThread.main(ActivityThread.java:7356)
                 	at java.lang.reflect.Method.invoke(Native Method)
                 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
                 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
                 	Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [androidx.compose.runtime.PausableMonotonicFrameClock@3f2828a, androidx.compose.ui.platform.MotionDurationScaleImpl@2c3d0fb, StandaloneCoroutine{Cancelling}@42ea518, AndroidUiDispatcher@6b9cb71]

@ArnyminerZ

Copy link
Copy Markdown
Member Author

Mmmmh... In theory it's possible according to the default onBack implementation:

onBack: (Int) -> Unit = {
    if (backStack is MutableList<T>) {
        repeat(it) { backStack.removeAt(backStack.lastIndex) }
    }
},

Technically, if for some reason it's called when the backstack has length 1, it gets cleared. Maybe we can extend with our own implementation avoiding this scenario

@ArnyminerZ ArnyminerZ requested a review from sunkup August 18, 2025 20:15
@ArnyminerZ ArnyminerZ mentioned this pull request Aug 19, 2025
4 tasks

@sunkup sunkup left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Seems to work now. There was still some strangeness with going back to the same screen twice, but I can't reproduce it anymore, so I will open an issue when it happens again and I know why ...

@sunkup sunkup merged commit 22a99d2 into dev Aug 20, 2025
7 checks passed
@sunkup sunkup deleted the nav3-migration-add-subscription-activity branch August 20, 2025 07:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants