Skip to content

Commit

Permalink
Merge pull request #484 from DimensionDev/feature/room
Browse files Browse the repository at this point in the history
migrate to jetpack room
  • Loading branch information
Tlaster committed Sep 20, 2024
2 parents ebc1ba2 + 523b8f1 commit 62437e9
Show file tree
Hide file tree
Showing 116 changed files with 2,362 additions and 1,722 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ plugins {
alias(libs.plugins.kotlin.serialization) apply false
alias(libs.plugins.ktorfit) apply false
alias(libs.plugins.ktlint) apply false
alias(libs.plugins.sqldelight) apply false
alias(libs.plugins.skie) apply false
alias(libs.plugins.ben.manes.versions)
alias(libs.plugins.compose.compiler) apply false
alias(libs.plugins.room) apply false
}

allprojects {
Expand Down
14 changes: 5 additions & 9 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ compose-lint-checks = "1.3.1"
ktlintPlugin = "12.1.1"
apng-android = "3.0.1"
ktlint = "1.3.1"
sqldelight = "2.0.2"
okio = "3.9.1"
skie = "0.9.0-RC.3"
ksoup = "0.1.8"
Expand All @@ -46,6 +45,7 @@ google-services = "4.4.2"
firebase-crashlytics = "3.0.2"
napier = "2.7.1"
materialKolor = "1.7.1"
room = "2.7.0-alpha08"

[libraries]
bluesky = { module = "moe.tlaster.ozone:bluesky", version.ref = "bluesky" }
Expand Down Expand Up @@ -83,6 +83,9 @@ datastore = { group = "androidx.datastore", name = "datastore", version = "1.1.1
desugar_jdk_libs = { module = "com.android.tools:desugar_jdk_libs", version.ref = "desugar_jdk_libs" }
androidx-window = { group = "androidx.window", name = "window-core", version = "1.3.0" }
androidx-splash = { group = "androidx.core", name = "core-splashscreen", version = "1.2.0-alpha02" }
room-runtime = { group = "androidx.room", name = "room-runtime", version.ref = "room" }
room-paging = { group = "androidx.room", name = "room-paging", version.ref = "room" }
room-compiler = { group = "androidx.room", name = "room-compiler", version.ref = "room" }

media3-exoplayer = { group = "androidx.media3", name = "media3-exoplayer", version.ref = "media3" }
media3-ui = { group = "androidx.media3", name = "media3-ui", version.ref = "media3" }
Expand Down Expand Up @@ -141,12 +144,6 @@ compose-webview = { group = "io.github.kevinnzou", name = "compose-webview", ver

compose-placeholder-material3 = { group = "com.eygraber", name = "compose-placeholder-material3", version = "1.0.8" }

sqldelight-android-driver = { group = "app.cash.sqldelight", name = "android-driver", version.ref = "sqldelight" }
sqldelight-native-driver = { group = "app.cash.sqldelight", name = "native-driver", version.ref = "sqldelight" }
sqldelight-coroutines-extensions = { group = "app.cash.sqldelight", name = "coroutines-extensions", version.ref = "sqldelight" }
sqldelight-androidx-paging3-extensions = { group = "app.cash.sqldelight", name = "androidx-paging3-extensions", version.ref = "sqldelight" }
sqldelight-jvm-driver = { group = "app.cash.sqldelight", name = "sqlite-driver", version.ref = "sqldelight" }

okio = { group = "com.squareup.okio", name = "okio", version.ref = "okio" }

napier = { group = "io.github.aakira", name = "napier", version.ref = "napier" }
Expand All @@ -173,7 +170,6 @@ ktor = ["ktor-client-content-negotiation", "ktor-serialization-kotlinx-json", "k
coil = ["coil-compose", "coil-gif", "apng", "coil-svg", "awebp", "vectordrawable-animated", "zoomable-image"]
accompanist = ["accompanist-permissions", "accompanist-drawablepainter"]
compose-destinations = ["compose-destinations"]
sqldelight = ["sqldelight-coroutines-extensions", "sqldelight-androidx-paging3-extensions"]
media3 = ["media3-exoplayer", "media3-ui", "media3-hls"]
firebase = ["firebase-analytics-ktx", "firebase-crashlytics-ktx"]
ktorfit = ["ktorfit-lib", "ktorfit-converters-response", "ktorfit-converters-flow", "ktorfit-converters-call"]
Expand All @@ -187,9 +183,9 @@ kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", versi
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
ktorfit = { id = "de.jensklingenberg.ktorfit", version.ref = "ktorfit" }
ktlint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktlintPlugin" }
sqldelight = { id = "app.cash.sqldelight", version.ref = "sqldelight" }
skie = { id = "co.touchlab.skie", version.ref = "skie" }
ben-manes-versions = { id = "com.github.ben-manes.versions", version.ref = "versionUpdate" }
google-services = { id = "com.google.gms.google-services", version.ref = "google-services" }
firebase-crashlytics = { id = "com.google.firebase.crashlytics", version.ref = "firebase-crashlytics" }
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
room = { id = "androidx.room", version.ref = "room" }
6 changes: 4 additions & 2 deletions iosApp/iosApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,8 @@
"PRODUCT_BUNDLE_IDENTIFIER[sdk=iphoneos*]" = dev.dimension.flare;
PRODUCT_NAME = "${APP_NAME}";
PROVISIONING_PROFILE_SPECIFIER = "";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
REGISTER_APP_GROUPS = NO;
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx";
SUPPORTS_MACCATALYST = NO;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
SWIFT_VERSION = 5.0;
Expand Down Expand Up @@ -816,7 +817,8 @@
"PRODUCT_BUNDLE_IDENTIFIER[sdk=iphoneos*]" = dev.dimension.flare;
PRODUCT_NAME = "${APP_NAME}";
PROVISIONING_PROFILE_SPECIFIER = "";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
REGISTER_APP_GROUPS = NO;
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx";
SUPPORTS_MACCATALYST = NO;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
SWIFT_VERSION = 5.0;
Expand Down
41 changes: 16 additions & 25 deletions shared/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@

import app.cash.sqldelight.core.capitalize
import java.util.Locale

plugins {
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin.multiplatform)
alias(libs.plugins.sqldelight)
alias(libs.plugins.kotlin.serialization)
alias(libs.plugins.ksp)
alias(libs.plugins.ktorfit)
alias(libs.plugins.skie)
alias(libs.plugins.ktlint)
alias(libs.plugins.compose.compiler)
alias(libs.plugins.room)
}

kotlin {
Expand All @@ -22,29 +21,35 @@ kotlin {
iosX64(),
iosArm64(),
iosSimulatorArm64(),
// macosArm64(),
// macosX64(),
macosArm64(),
macosX64(),
).forEach { appleTarget ->
appleTarget.binaries.framework {
baseName = "shared"
isStatic = true
embedBitcode(org.jetbrains.kotlin.gradle.plugin.mpp.BitcodeEmbeddingMode.DISABLE)
linkerOpts.add("-lsqlite3")
}
}
targets.forEach { target ->
target.name.takeIf {
it != "metadata"
}?.let {
"ksp${it.capitalize()}"
"ksp${it.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() }}"
}?.let {
dependencies.add(it, libs.ktorfit.ksp)
dependencies.add(it, libs.room.compiler)
}
}

sourceSets {
all {
languageSettings {
optIn("kotlin.uuid.ExperimentalUuidApi")
}
}
val commonMain by getting {
dependencies {
implementation(libs.bundles.sqldelight)
implementation(libs.bundles.kotlinx)
implementation(dependencies.platform(libs.koin.bom))
implementation(libs.koin.core)
Expand All @@ -60,6 +65,8 @@ kotlin {
implementation(libs.twitter.parser)
implementation(libs.molecule.runtime)
api(libs.bluesky)
implementation(libs.room.runtime)
implementation(libs.room.paging)
}
}
val commonTest by getting {
Expand All @@ -69,7 +76,6 @@ kotlin {
}
val androidMain by getting {
dependencies {
implementation(libs.sqldelight.android.driver)
implementation(project.dependencies.platform(libs.compose.bom))
implementation(libs.compose.foundation)
}
Expand All @@ -81,30 +87,15 @@ kotlin {
}
val nativeMain by getting {
dependencies {
implementation(libs.sqldelight.native.driver)
implementation(libs.stately.isolate)
implementation(libs.stately.iso.collections)
}
}
}
}

sqldelight {
databases {
create("AppDatabase") {
packageName.set("dev.dimension.flare.data.database.app")
srcDirs("src/commonMain/sqldelight/app")
}
create("CacheDatabase") {
packageName.set("dev.dimension.flare.data.database.cache")
srcDirs("src/commonMain/sqldelight/cache")
}
create("VersionDatabase") {
packageName.set("dev.dimension.flare.data.database.version")
srcDirs("src/commonMain/sqldelight/version")
}
}
linkSqlite.set(true)
room {
schemaDirectory("$projectDir/schemas")
}

android {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
{
"formatVersion": 1,
"database": {
"version": 3,
"identityHash": "eb270b69d739601dc27be96b9c8aa192",
"entities": [
{
"tableName": "DbAccount",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`account_key` TEXT NOT NULL, `credential_json` TEXT NOT NULL, `platform_type` TEXT NOT NULL, `last_active` INTEGER NOT NULL, PRIMARY KEY(`account_key`))",
"fields": [
{
"fieldPath": "account_key",
"columnName": "account_key",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "credential_json",
"columnName": "credential_json",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "platform_type",
"columnName": "platform_type",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "last_active",
"columnName": "last_active",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"autoGenerate": false,
"columnNames": [
"account_key"
]
}
},
{
"tableName": "DbApplication",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`host` TEXT NOT NULL, `credential_json` TEXT NOT NULL, `platform_type` TEXT NOT NULL, `has_pending_oauth_request` INTEGER NOT NULL, PRIMARY KEY(`host`))",
"fields": [
{
"fieldPath": "host",
"columnName": "host",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "credential_json",
"columnName": "credential_json",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "platform_type",
"columnName": "platform_type",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "has_pending_oauth_request",
"columnName": "has_pending_oauth_request",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"autoGenerate": false,
"columnNames": [
"host"
]
}
},
{
"tableName": "DbKeywordFilter",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`keyword` TEXT NOT NULL, `for_timeline` INTEGER NOT NULL, `for_notification` INTEGER NOT NULL, `for_search` INTEGER NOT NULL, `expired_at` INTEGER NOT NULL, PRIMARY KEY(`keyword`))",
"fields": [
{
"fieldPath": "keyword",
"columnName": "keyword",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "for_timeline",
"columnName": "for_timeline",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "for_notification",
"columnName": "for_notification",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "for_search",
"columnName": "for_search",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "expired_at",
"columnName": "expired_at",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"autoGenerate": false,
"columnNames": [
"keyword"
]
}
},
{
"tableName": "DbSearchHistory",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`search` TEXT NOT NULL, `created_at` INTEGER NOT NULL, PRIMARY KEY(`search`))",
"fields": [
{
"fieldPath": "search",
"columnName": "search",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "created_at",
"columnName": "created_at",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"autoGenerate": false,
"columnNames": [
"search"
]
}
}
],
"setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'eb270b69d739601dc27be96b9c8aa192')"
]
}
}
Loading

0 comments on commit 62437e9

Please sign in to comment.