Skip to content

Conversation

@kristopherjohnson
Copy link
Collaborator

@kristopherjohnson kristopherjohnson commented Nov 4, 2024

  1. Create a new Jetpack Compose app in Android Studio Koala with current versions of the Android SDK and all dependencies. The minimum supported SDK version will be 23, which is the oldest version supported by Ditto.
  2. Copy the screen layouts and code from https://github.com/getditto/template-app-jetpack-compose-kotlin-todo, which is already pretty close to what we want for our final app.
  3. Update the app’s data model to match the specifications in QuickStart Apps: Task App data model
  4. Update the UI to match the design specifications in Docs Quickstart & Install Guides

For more details, see QuickStart Apps Android Task App Development Notes

@kristopherjohnson kristopherjohnson self-assigned this Nov 4, 2024
@kristopherjohnson kristopherjohnson changed the title QuickStart Android Tasks app QuickStart Apps - Android Tasks app Nov 4, 2024
@kristopherjohnson kristopherjohnson marked this pull request as ready for review November 15, 2024 18:44
Copy link
Collaborator

@S4H S4H left a comment

Choose a reason for hiding this comment

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

I'll have to defer to @phatblat to review the android app as that is outside of my wheelhouse but I was able to easily follow the readme and build the application without issue so can say it passes the dummies check :)


### Adding the Ditto SDK

At the bottom of `app/build.gradle.kts`, you will see this line that causes Android Studio to automatically download the Ditto SDK from Maven Central and add it to the project:
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we run a formatter on this file? It's a little jarring having inconsistant line lengths.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm not sure we can. Different Markdown processors handle list items differently, and adding newlines to break them into shorter lines might not be handled consistently. I think GitHub-flavored Markdown has changed the way it handles newlines more than once.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've fixed the line wrapping on a couple of paragraphs.

viewModelScope.launch {
try {
val item = ditto.store.execute(
"SELECT * FROM tasks WHERE _id = :_id",
Copy link
Member

@phatblat phatblat Nov 18, 2024

Choose a reason for hiding this comment

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

Should this DQL query include NOT deleted or deleted != true in the WHERE clause?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It would only matter if another device deletes the task between the time a user taps the Edit button and the Edit Task screen appears, in which case the user will be editing a just-deleted task. When they tap Save, the task's properties will be edited, but will also be deleted.

But I agree we should include the WHERE clause for correctness.

Comment on lines +25 to +26
androidComponents {
onVariants {
Copy link
Member

Choose a reason for hiding this comment

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

I haven't used this type of config before but it looks like a good way to reduce duplication when you're using the same properties in every build variant.

compose = true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.5.14"
Copy link
Member

Choose a reason for hiding this comment

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

Not something that needs to be done in this PR, but since the kotlin compiler version will need to change with the kotlin dependencies, this would be a good value to extract into the version catalog. There are several examples in the Ditto Kotlin SDK of using the version catalog for arbitrary version numbers:

https://github.com/getditto/ditto/blob/ba44fb0f182fe5274f976d0462ec7cfef421916f/android/ditto/build.gradle.kts#L32-L33
https://github.com/getditto/ditto/blob/ba44fb0f182fe5274f976d0462ec7cfef421916f/android/gradle/libs.versions.toml#L23-L28

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'll review that. I actually had a few problems with getting a compatible set of versions of the Kotlin compiler, gradle, Android compileSdk setting, and other tools, so I've probably overlooked an easy way to keep them in sync.

viewModelScope.launch {
try {
val doc = ditto.store.execute(
"SELECT * FROM tasks WHERE _id = :_id",
Copy link
Member

Choose a reason for hiding this comment

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

Does this query need to filter out deleted tasks?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, it should. However, similar to the earlier case, the task would only be displayed in the UI if it is not deleted, so this would only matter if another device deletes it during the interval between the last observer notification and the app responding to the toggle click.

@phatblat
Copy link
Member

Everything looks great in this PR. I left a couple comments and minor questions.

@kristopherjohnson kristopherjohnson merged commit 5f77aec into main Nov 18, 2024
1 check passed
@kristopherjohnson kristopherjohnson deleted the kj/quickstart-android branch November 18, 2024 21:09
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.

4 participants