Skip to content

Add calendar local-only name override - #2143

Open
heieisch wants to merge 9 commits into
bitfireAT:mainfrom
heieisch:main
Open

Add calendar local-only name override#2143
heieisch wants to merge 9 commits into
bitfireAT:mainfrom
heieisch:main

Conversation

@heieisch

@heieisch heieisch commented Apr 17, 2026

Copy link
Copy Markdown

Purpose

Let users give calendars a local-only display name that differs from the server-side one. The override is shown in DAVx5 and used as CALENDAR_DISPLAY_NAME in the Android CalendarProvider, while the DAV collection on the server remains unchanged. This is useful when the server-provided name is generic, duplicated across accounts, or just not how the user wants to see the calendar on their device.

Short description

  • Added nullable localDisplayName column to the Collection entity (auto-migration 18 → 19).
  • Collection.title() now prefers localDisplayName over the server displayName.
  • LocalCalendarStore writes localDisplayName (if set) to Calendars.CALENDAR_DISPLAY_NAME, so renames are picked up by the CalendarProvider on the next update.
  • Added DavCollectionRepository.setLocalDisplayName() (trims blanks → null) and wired it through CollectionScreenModel.
  • UI: new "Local rename" entry on the collection screen with a Switch and a rename dialog. Entry is gated to TYPE_CALENDAR and TYPE_WEBCAL — address books are excluded for now.
  • insertOrUpdateByUrlRememberSync preserves localDisplayName in addition to sync and forceReadOnly, so a "Refresh list" dose not wipe the override.

Not included: local rename for address books (requires a separate decision because Android Contacts shows the raw account name, not a per-account-local name).

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.

Copilot AI review requested due to automatic review settings April 17, 2026 13:54
@CLAassistant

CLAassistant commented Apr 17, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

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

Adds support for a per-device (local-only) calendar display name override that is shown in the app and propagated to Android’s CalendarProvider, without changing the server-side DAV collection name.

Changes:

  • Added localDisplayName to the Collection Room entity and preserved it across collection refreshes.
  • Updated title/display name resolution so UI and CalendarProvider prefer localDisplayName when present.
  • Added collection-screen UI (switch + dialog) and repository/DAO plumbing to set/clear the local override.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
core/src/main/res/values/strings.xml Adds new UI strings for the local rename flow and a generic “Save” label.
core/src/main/kotlin/at/bitfire/davdroid/ui/account/CollectionScreenModel.kt Adds setLocalDisplayName() to update DB and trigger a delayed refresh.
core/src/main/kotlin/at/bitfire/davdroid/ui/account/CollectionScreen.kt Adds local rename entry + dialog; makes entries optionally clickable.
core/src/main/kotlin/at/bitfire/davdroid/resource/LocalCalendarStore.kt Writes CALENDAR_DISPLAY_NAME from localDisplayName (fallback to server/URL name).
core/src/main/kotlin/at/bitfire/davdroid/repository/DavCollectionRepository.kt Preserves localDisplayName on refresh; adds setter that trims blanks to null.
core/src/main/kotlin/at/bitfire/davdroid/db/CollectionDao.kt Adds updateLocalDisplayName() query.
core/src/main/kotlin/at/bitfire/davdroid/db/Collection.kt Adds localDisplayName field and prefers it in title().
core/src/main/kotlin/at/bitfire/davdroid/db/AppDatabase.kt Bumps Room DB version to 19 and adds auto-migration 18→19.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread core/src/main/kotlin/at/bitfire/davdroid/db/AppDatabase.kt
Comment thread core/src/main/kotlin/at/bitfire/davdroid/ui/account/CollectionScreen.kt Outdated
@heieisch
heieisch marked this pull request as draft April 17, 2026 14:05
@heieisch
heieisch marked this pull request as ready for review April 17, 2026 14:30
@heieisch

Copy link
Copy Markdown
Author

this is how it looks in the app
grafik

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

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


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread core/src/main/kotlin/at/bitfire/davdroid/db/Collection.kt

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

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


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread core/src/main/kotlin/at/bitfire/davdroid/ui/account/CollectionScreen.kt Outdated

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

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +53 to 55
], exportSchema = true, version = 19, autoMigrations = [
AutoMigration(from = 18, to = 19), // collection: add localDisplayName
AutoMigration(from = 17, to = 18, spec = AutoMigration18::class),

Copilot AI Apr 18, 2026

Copy link

Choose a reason for hiding this comment

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

Room schema was bumped to v19 with an AutoMigration (18→19) adding collection.localDisplayName, but there is no corresponding migration test in core/src/androidTest/kotlin/at/bitfire/davdroid/db/migration/ like the existing AutoMigration18Test. Adding an AutoMigration19Test (or equivalent) that opens a v18 schema DB and validates the new nullable column exists (and that existing collection rows migrate without data loss) would help catch migration regressions.

Copilot uses AI. Check for mistakes.
Comment on lines 106 to +110
private fun valuesFromCollectionInfo(info: Collection, withColor: Boolean): ContentValues {
val serverDisplayName = if (info.displayName.isNullOrBlank()) info.url.lastSegment else info.displayName
val values = contentValuesOf(
Calendars._SYNC_ID to info.id,
Calendars.CALENDAR_DISPLAY_NAME to
if (info.displayName.isNullOrBlank()) info.url.lastSegment else info.displayName,
Calendars.CALENDAR_DISPLAY_NAME to (info.localDisplayName ?: serverDisplayName),

Copilot AI Apr 18, 2026

Copy link

Choose a reason for hiding this comment

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

valuesFromCollectionInfo() now prefers info.localDisplayName for Calendars.CALENDAR_DISPLAY_NAME, but there’s no test exercising this new behavior. Since LocalCalendarStoreTest exists, consider adding a test case that creates a Collection with localDisplayName set and verifies the resulting calendar row in the CalendarProvider gets that value (and falls back to the server/url name when the override is null).

Copilot uses AI. Check for mistakes.
@heieisch heieisch changed the title Add calendar local-only display name Add calendar local-only name override Apr 18, 2026
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