Skip to content

Migrate settings to compose+coroutines - #7055

Merged
mahibi merged 5 commits into
masterfrom
migrateSettingsToCompose
Nov 17, 2026
Merged

mahibi merged 5 commits into
masterfrom
migrateSettingsToCompose

Conversation

@mahibi

@mahibi mahibi commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

What it does

  • Migrates the settings screen (SettingsActivity) from XML views, RxJava and LiveData to Jetpack Compose and coroutines.
  • SettingsViewModel keeps all screen state in one StateFlow and sends one-off events through a Channel.
  • SettingsRepository makes the server calls through NcApiCoroutines, with a new coroutine setUserData endpoint.
  • DeviceStateReader reads system state (permissions, battery optimisation, notification channels, push distributors) off the main thread.
  • AccountRemover removes the account in the app-wide scope and restarts the app.
  • The UI is split into section composables with previews.
  • New reusable components/IncognitoKeyboard makes the incognito keyboard setting work for Compose text fields.
  • Removes activity_settings.xml, SetPhoneNumberDialogFragment and its layout, the RxJava calls NcApi.getUserData/setUserData, the unused read/typing privacy preferences, blinkDrawable, and unused strings.

This PR also fixes the annoying behavior that the app was restarted after a dark/light theme change. The theme is now changed on the fly.

Testing

  • SettingsViewModelTest: 25 tests. The regression tests were checked to fail when their fix is reverted.
  • ktlint, detekt and lint pass. The full unit-test suite passes, and the generic, gplay and qa builds compile.
  • Manually tested on Android 16 (motorola edge 50 pro, generic build): all sections render in light and dark theme, and these were checked on the phone:
    • proxy fields save, are cleared when the proxy is turned off, and ignore values from fields that were just hidden
    • incognito keyboard flag reaches the keyboard
    • read status changes reach the server
    • theme switch, system settings links, media quality dialog, cancelled certificate picker
    • (new) the app switcher setting takes effect without a restart
    • (new) the notification warning appears with UnifiedPush; its "Settings" button opens Settings scrolled to the notifications section and highlights the problem
    • Tested on a device:
    • removing an account
    • phone number dialog
    • rotation
    • offline mode

🖼️ Screenshots

🏚️ Before

708941191-0c6d35a7-17c6-4940-a5a4-6e4352b46146 (Bearbeitet) grafik

🏡 After

grafik grafik

🏁 Checklist

  • ⛑️ Tests (unit and/or integration) are included or not needed
  • 🔖 Capability is checked or not needed
  • 🔙 Backport requests are created or not needed: /backport to stable-xx.x
  • 📅 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

@mahibi mahibi added this to the 26.0.0 milestone Nov 17, 2026
@mahibi mahibi self-assigned this Nov 17, 2026
Replace the view based SettingsActivity with a Compose screen backed by
SettingsViewModel, which exposes a single StateFlow and one-off events.
Server calls move to SettingsRepository using NcApiCoroutines, device
state is read off the main thread by DeviceStateReader, and the account
is observed via UserManager.userFlow instead of LiveData and RxJava.

- Replace SetPhoneNumberDialogFragment and the MaterialAlertDialogs with
  Compose dialogs; the phone number dialog now shows the error instead
  of closing
- Request permissions with Activity Result APIs
- Show the intended "wrong account" message for servers without Talk
- Remove the now unused read/typing privacy preferences, blinkDrawable,
  ContactAddressBookWorker.checkPermission and unused strings
- Add SettingsViewModel unit tests

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
- Remove accounts via AccountRemover in the application scope, so the
  app still restarts after the settings screen closes, and keep the
  screen open while its account is being removed
- Ignore selecting the current proxy type, which reset a custom port
- Send read and typing status changes one at a time and revert failed
  ones to the value the server confirmed last
- Load the avatar with the Authorization header
- Apply the incognito keyboard setting to Compose text fields via
  IncognitoKeyboard
- Reset the screen lock timeout when the device lock is not secure
- Keep the state update free of side effects
- Store proxy fields when editing ends instead of on every keystroke
- Compute whether the proxy is enabled once in the view model
- Remove the unused NcApi.getUserData

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
- Ignore a cancelled client certificate choice instead of erasing the
  stored certificate
- Send read and typing status changes in the application scope, so
  closing the screen doesn't cancel them, and sync the capabilities
  after a successful change
- Show the account message above the list, so it is shown and consumed
  also when the screen opens scrolled to the notification settings
- Store "No proxy" as the literal RestModule expects and treat the
  translated label stored by older versions as no proxy
- Show snackbars in their own coroutine, so later events don't wait
- Consume the account message outside of the state update
- Reuse User.getCredentials()
- Inject the I/O dispatcher, so tests control preference writes

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
The dialog had no buttons, which left an empty button row at its bottom.
Selecting an option still applies it right away.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
The setting was read once when the screen was composed, so turning the
app switcher on or off in the settings only took effect after a restart
of the app. It is now read again on resume and observed by the screen,
like the notification warning.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
@mahibi
mahibi force-pushed the migrateSettingsToCompose branch from 4813c34 to 458cbfb Compare November 17, 2026 10:08
@mahibi
mahibi marked this pull request as ready for review November 17, 2026 10:50
@mahibi
mahibi requested a review from rapterjet2004 November 17, 2026 10:50
@mahibi mahibi added the 3. to review Waiting for reviews label Nov 17, 2026
@mahibi mahibi mentioned this pull request Nov 17, 2026
3 of 8 tasks
@mahibi mahibi changed the title Migrate settings to compose Migrate settings to compose+coroutines Nov 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Codacy

Lint

TypemasterPR
Warnings1716
Errors00

SpotBugs

CategoryBaseNew
Bad practice77
Correctness88
Dodgy code4040
Internationalization33
Malicious code vulnerability33
Performance77
Security1111
Total7979

@github-actions

Copy link
Copy Markdown
Contributor

📱 QA build

Download app-qa-debug.apk
QR code Open the QR code for this download
Commit 458cbfb
Version 7055
Available until 7 days after this build

The QA build installs alongside a released Nextcloud app, so you can keep
using your existing install while testing.

Downloading the file requires a GitHub account, so open this link on the
device you want to test on, or transfer the APK to it.

@mahibi
mahibi merged commit 772b0f7 into master Nov 17, 2026
21 of 22 checks passed
@mahibi
mahibi deleted the migrateSettingsToCompose branch November 17, 2026 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews AI assisted

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants