Skip to content

DittoAndroidTools for Ditto Kotlin SDK 5.0#171

Open
Kristopher Johnson (kristopherjohnson) wants to merge 31 commits intomainfrom
sdk-5.0
Open

DittoAndroidTools for Ditto Kotlin SDK 5.0#171
Kristopher Johnson (kristopherjohnson) wants to merge 31 commits intomainfrom
sdk-5.0

Conversation

@kristopherjohnson
Copy link

@kristopherjohnson Kristopher Johnson (kristopherjohnson) commented Mar 17, 2026

This branch contains a version of DittoAndroidTools that is compatible with the Ditto Kotlin SDK v5.0. It will be merged into the main branch when the v5.0 SDK is officially released.

Closes SDKS-3006

Add CLAUDE.md with project build/architecture docs.
Add PHASE_1.md documenting Ditto Kotlin SDK v5 API research
including package changes, type mappings, and migration plan.
Update .gitignore for Claude Code artifacts.
- Update SDK dependency: live.ditto:ditto:4.11.6 → com.ditto:ditto-kotlin:5.0.0-preview.5
- Bump Kotlin 1.9.25 → 2.1.0, compileSdk 33 → 36, minSdk 23 → 24
- Switch to bundled Kotlin Compose compiler plugin (Kotlin 2.x)
- Replace all live.ditto.* imports with com.ditto.kotlin.*
- Migrate all v4 store/presence APIs to v5 DQL + Flow equivalents
- Delete v4-only DittoExt.kt (observeLocalAsFlow bridge)
- Replace v4 presence viewer JS assets with v5 version
- Update demo app: DittoFactory.create(), auth expiration handler, https URL
- Remove SDK 33 forced dependency version pins from root build.gradle
The hardcoded URL pattern was incorrect — use the configurable
BuildConfig value from local.properties instead.
- CLAUDE.md: note presenceviewer assets are copied from getditto/ditto/sdks/kotlin/ditto-presenceviewer
- PLAN.md: add task to include license notices for bundled JS dependencies (Hammer.js, vis-network, core-js)
…play, dark theme

- CollectionsViewModel: use `SELECT name FROM system:collections` (v5 virtual
  collection) instead of v4's `__collections`. Switch from registerObserver to
  polling with store.execute() since virtual collections don't support observers.
- DocumentsViewModel: add cborToDisplayValue() fallback to toString() for
  non-primitive CBOR types (maps, arrays, byte strings) in document values.
- Documents.kt: observe docProperties via observeAsState() so attributes render
  on initial load without requiring a click. Add explicit onBackground color to
  DocItem text for dark theme visibility.
… not Number

The SHOW config query returns DittoCborSerializable.UnsignedInteger values
in v5, not raw Java Number types. Casting with `as Number` threw
ClassCastException on launch. Use cbor.longOrNull?.toInt() instead.

Verified on Galaxy S20 FE.
…, docs

- Restore presenceSnapshotDirectlyConnectedPeers field in heartbeat document
- Add anyToCbor() helper for proper Map<String, Any> CBOR serialization
  instead of lossy toString()
- Rename isConnectedToDittoCloud key to isConnectedToDittoServer (v5 API)
- Fix HeartbeatScreen crash: safe-cast Boolean instead of hard cast
- CollectionsViewModel: use viewModelScope instead of standalone scope,
  extract POLL_INTERVAL_MS constant
- CLAUDE.md: remove obsolete SDK 33 version pinning, update deps to v5
Restore v4 behavior where "Start Subscriptions" immediately syncs all
known collections. Also picks up newly discovered collections while in
stand-alone mode, and cleans up subscriptions in onCleared().
- Rename liveQuery to observer in DocumentsViewModel (SPO-4)
- Import HealthMetric/HealthMetricProvider in Heartbeat.kt instead of FQCNs
execute() now returns Unit; use executeRaw() where results are needed.
DittoDiskUsageItem.sizeInBytes changed from Int to Long.
Use the auto-closing execute { result -> } overload instead of
executeRaw() to ensure DittoQueryResult lifecycle is managed properly.
Window.statusBarColor is deprecated in API 35+ (Android 15) and returns
transparent with edge-to-edge, resulting in a white banner.
Collection names starting with a digit or containing special characters
cause DQL parse errors without backtick quoting.
Recursively convert DittoCborSerializable.Dictionary and ArrayValue to
native Kotlin collections so toString() produces readable output in the
data browser, matching v4 behavior.
CollectionsViewModel already subscribes to all collections in standalone
mode, so the duplicate subscription in DocumentsViewModel was unnecessary.
v5 appends the database ID to the persistence directory, causing disk
usage items to not display properly. Strip everything up to the first
slash so only file/directory names are shown.
Use ditto.absolutePersistenceDirectory instead of filesDir for log
directory path, since v5 appends the database ID to the persistence
directory. Remove now-unnecessary filesDir parameter from LogUtils,
ViewModels, factories, and Compose screens.

Add THIRD_PARTY_LICENSES.txt for bundled presence viewer JS dependencies
(vis-network, vis-data, Hammer.js, keycharm, color, core-js, uuid).
Update initialization example, requirements, Proguard rules, and
heartbeat data model to reflect v5 API changes.
…itespace

- Add onCleared() to PresenceDegradationReporterViewModel to close
  PeersRepository observers
- Add onCompletion cleanup for PeersRepository in Api.kt flow
- Rename DittoHeartbeatInfo.peerKeyString to peerKey per v5 migration
- Remove trailing whitespace in LogDetailsScreen.kt
Replace the 2-second polling loop on system:collections with a reactive
registerObserver on __collections, which supports observation. Adds a
sync subscription for __collections in standalone mode.
@kristopherjohnson Kristopher Johnson (kristopherjohnson) changed the title SDK 5.0 DittoAndroidTools for Ditto Kotlin SDK 5.0 Mar 17, 2026
- Remove redundant topBar from Collections Scaffold
- Remove isStandAlone flag, use collectionsSubscription null-check instead
- Fix disk usage relativePath for v5 database-ID directory structure
- Add formatDisplayValue() for JSON-like rendering of maps/arrays
- Rename Factory to DocumentsViewModelFactory for clarity
- URI-encode collection names in navigation routes
- Use firstOrNull() in LogUtils to prevent crash on empty results
…s-v5

Migrate DittoAndroidTools to Ditto Kotlin SDK v5
@kristopherjohnson

Responsibility for DittoAndroidTools is being moved to the SDKs team, so we will need to add SDK members as reviewers for this PR.

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