DittoAndroidTools for Ditto Kotlin SDK 5.0#171
Open
Kristopher Johnson (kristopherjohnson) wants to merge 31 commits intomainfrom
Open
DittoAndroidTools for Ditto Kotlin SDK 5.0#171Kristopher Johnson (kristopherjohnson) wants to merge 31 commits intomainfrom
Kristopher Johnson (kristopherjohnson) wants to merge 31 commits intomainfrom
Conversation
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.
- 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
Author
|
Responsibility for DittoAndroidTools is being moved to the SDKs team, so we will need to add SDK members as reviewers for this PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This branch contains a version of DittoAndroidTools that is compatible with the Ditto Kotlin SDK v5.0. It will be merged into the
mainbranch when the v5.0 SDK is officially released.Closes SDKS-3006