Skip to content

feat(ui): Compose login screen for Login Flow v2 and account chooser - #1143

Draft
tobiasKaminsky wants to merge 2 commits into
mainfrom
feature/login-flow-v2-ui
Draft

tobiasKaminsky wants to merge 2 commits into
mainfrom
feature/login-flow-v2-ui

Conversation

@tobiasKaminsky

Copy link
Copy Markdown
Member

Adds two Compose building blocks for Nextcloud apps, starting with the new Photos app:

  • Login Flow v2 screen (ui.login): server address entry, opening the login page in a Custom Tab, polling while the user logs in, and error states with retry. A stateless LoginFlowScreen(state, onEvent) plus LoginFlowViewModel that the app hosts.
  • Account chooser (ui.account): account list with an avatar slot, server host, a "Files app" badge for SSO accounts, a check mark for the current account, and "Add account" / "Manage accounts". Usable as AccountChooser (a lazy list), accountChooserItems inside another lazy list, or AccountChooserBottomSheet.

android-common must not depend on android-library, so the network part sits behind a small interface the app implements, for example on top of android-library's Login Flow v2 operations (PR in progress there):

interface LoginFlowV2Client {
    suspend fun start(serverUrl: String): LoginFlowStart              // loginUrl, pollEndpoint, pollToken
    suspend fun poll(start: LoginFlowStart): LoginFlowCredentials?    // null = not granted yet
}

The QR code scanner stays in the app. The screen only shows a "Scan QR code" button, and the app passes the scanned text back as LoginFlowEvent.QrCodeScanned, which LoginQrCodeParser turns into credentials.

Behaviour compared with Files and Talk

Files Talk This PR
Missing scheme — https:// added https:// added
http:// allowed offered as fallback if https fails allowed after a confirmation dialog, not asked for localhost
Path cleanup /index.php, /index.php/apps/…, /remote.php/dav trailing / everything from /index.php, /remote.php or /status.php, plus query, fragment and trailing /
IDN converted to ASCII — converted to ASCII
Browser Auth Tab, then external browser Custom Tab Custom Tab, then ACTION_VIEW
Poll interval 30 s, plus right away when the app returns 1 s, plus right away when the app returns 2 s (configurable), plus right away on ON_RESUME
Poll timeout none 20 min 20 min (configurable)
Failed poll stops polling keeps polling keeps polling (devices may block background network)
Process death pending flow restored — pending flow restored from SavedStateHandle
QR nc://login/ partial data allowed all three values required all three values required; & or / separators; server normalized
QR nc://onetime-login/ supported supported not supported yet (needs a network call, could be added to the client interface)

I could not find the /user: / /password: separator in the current Files parser (it splits on & only). The parser still accepts it, because it costs nothing and keeps older codes working.

Also:

  • New dependency: androidx.browser:browser:1.10.0. New test dependency: kotlinx-coroutines-test:1.10.2, matching the coroutines version already on the classpath. verification-metadata.xml updated through --write-verification-metadata.
  • LoginFlowCredentials and LoginFlowStart mask the app password and poll token in toString().
  • LoginFlowViewModel has no Hilt dependency. Apps use LoginFlowViewModelFactory { client } or construct it themselves.

Not validated on a live Nextcloud instance yet: the network adapter lives in the app and android-library, and isn't done. To test once the Photos app or the sample uses it: enter a server address without a scheme, log in through the browser, come back to the app (it should finish within a second), then try an http:// address, a wrong address, cancel while waiting, and a QR code from Personal settings > Security.

🖼️ Screenshots

🏚️ Before 🏡 After
— (new components) Compose previews for every login step and the account chooser states (LoginFlowScreenPreview, AccountChooserPreview)

🏁 Checklist

  • ⛑️ Tests (unit and/or integration) are included or not needed: URL normalization, QR parsing and the ViewModel's polling, timeout, cancel, retry, http confirmation and restore
  • 📅 Milestone is set
  • 🌸 PR title is meaningful (if it should be in the changelog: is it meaningful to users?)

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI

Written with Claude Code (Claude Opus 5.5). The commits carry an Assisted-by trailer. They are not signed off yet: the contributor needs to review the code and add the DCO sign-off (git rebase --signoff main and force-push) before this leaves draft.

Agent notes

Local runs on ac5bb89: ./gradlew test lint assembleDebug spotlessKotlinCheck detekt passed. The 40 :ui unit tests (including 36 new ones) pass. Lint reports nothing new except NewerVersionAvailable for kotlinx-coroutines-test 1.11.0, kept at 1.10.2 to match coroutines-core.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Nb4eMg7ShMcjycNqaRBq3z

tobiasKaminsky and others added 2 commits December 3, 2026 09:17
Every Nextcloud app implements server address entry and Login Flow v2
on its own, with diverging URL handling and polling behaviour. Sharing
the UI and its state handling here lets new Compose apps such as
Photos reuse it.

The network part stays in the app (e.g. on top of android-library)
behind LoginFlowV2Client, so android-common does not depend on
android-library.

Assisted-by: Claude Code:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Nb4eMg7ShMcjycNqaRBq3z
Apps with several accounts need the same switcher: account list with
the current account marked, Files app (SSO) accounts badged, and
entries to add or manage accounts. The app provides the avatars, so
the component stays independent of how they are loaded.

Assisted-by: Claude Code:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Nb4eMg7ShMcjycNqaRBq3z
@codacy-production

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 7 medium · 24 minor

Alerts:
⚠ 31 issues (≤ 0 issues of at least minor severity)

Results:
31 new issues

Category Results
Documentation 23 minor
CodeStyle 1 minor
Complexity 7 medium

View in Codacy

🟢 Metrics 170 complexity · 2 duplication

Metric Results
Complexity 170
Duplication 2

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

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.

1 participant