Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move SQLDelight to a Dedicated Module and Update Dependencies #239

Merged
merged 14 commits into from
Dec 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app-watch/app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
-dontwarn reactor.blockhound.integration.BlockHoundIntegration
-dontwarn reactor.blockhound.integration.BlockHoundIntegration
-dontwarn java.sql.JDBCType
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ private fun <T> NavBackStackEntry.parcelableData(key: String): T? {

private inline fun <reified T : Parcelable> Bundle.parcelable(key: String): T? =
when {
Build.VERSION.SDK_INT >= 33 ->
Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU ->
getParcelable(key, T::class.java)

else ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ import ir.composenews.marketdetail.formatNumber
import ir.composenews.marketdetail.preview_provider.MarketDetailStateProvider
import ir.composenews.uimarket.model.MarketModel

private const val HALF_WIDTH_RATIO = 0.5f
private const val SMALL_WIDTH_RATIO = 0.2f

@Composable
fun MarketDetailWearRoute(
market: MarketModel?,
Expand Down Expand Up @@ -182,14 +185,14 @@ fun MarketDetailLoadingView() {
)
Box(
modifier = Modifier
.fillMaxWidth(0.5f)
.fillMaxWidth(HALF_WIDTH_RATIO)
.clip(RoundedCornerShape(4.dp))
.height(20.dp)
.shimmerEffect(),
)
Box(
modifier = Modifier
.fillMaxWidth(0.2f)
.fillMaxWidth(SMALL_WIDTH_RATIO)
.clip(RoundedCornerShape(4.dp))
.height(12.dp)
.shimmerEffect(),
Expand Down
6 changes: 2 additions & 4 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@
-keepattributes *Annotation*, InnerClasses
-dontnote kotlinx.serialization.AnnotationsKt

-keep class ir.composenews.db.** { *; }
-keep interface ir.composenews.db.** { *; }

-keep class io.kotest.** { *; }
-dontwarn io.kotest.**
-keep class kotlinx.coroutines.test.** { *; }
Expand All @@ -77,4 +74,5 @@
-dontwarn java.lang.management.**
-dontwarn reactor.blockhound.**

-dontwarn reactor.blockhound.**
-dontwarn reactor.blockhound.**
-dontwarn java.sql.JDBCType
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,14 @@ class HiltConventionPlugin : Plugin<Project> {
private fun Project.applyPlugins() {
pluginManager.apply {
apply("dagger.hilt.android.plugin")
apply("org.jetbrains.kotlin.kapt")
// apply("com.google.devtools.ksp")
apply("com.google.devtools.ksp")
}
}

private fun Project.applyDependencies() {
dependencies {
"implementation"(libs.findLibrary("hilt.android").get())
// "ksp"(libs.findLibrary("hilt.compiler").get())
"kapt"(libs.findLibrary("hilt.compiler").get())
"ksp"(libs.findLibrary("hilt.compiler").get())
}
}
}
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
alias(hilt.android) apply false
alias(kotliner) apply false
alias(detekt) apply false
// alias(ksp) apply false
alias(ksp) apply false
alias(compose) apply false
}
}
Expand Down
4 changes: 2 additions & 2 deletions config/detekt/detekt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ naming:
packagePattern: '[a-z]+(\.[a-z][A-Za-z0-9]*)*'
TopLevelPropertyNaming:
active: true
constantPattern: '[A-Z][A-Za-z0-9]*'
constantPattern: '[A-Z][_A-Z0-9]*'
propertyPattern: '[A-Za-z][_A-Za-z0-9]*'
privatePropertyPattern: '_?[A-Za-z][_A-Za-z0-9]*'
VariableMaxLength:
Expand Down Expand Up @@ -511,7 +511,7 @@ style:
singleLine: 'never'
multiLine: 'always'
BracesOnWhenStatements:
active: false
active: true
singleLine: 'necessary'
multiLine: 'consistent'
CanBeNonNullable:
Expand Down
8 changes: 6 additions & 2 deletions core/base/src/main/java/ir/composenews/base/BaseScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,17 @@ private fun BaseScreen(
}
}

BaseContract.BaseState.OnLoadingDialog -> TODO()
BaseContract.BaseState.OnLoadingDialog -> {
TODO()
}

is BaseContract.BaseState.OnError -> {
ErrorView(errorMessage = errorViewMapper(targetState.errors))
}

BaseContract.BaseState.OnSuccess -> content()
BaseContract.BaseState.OnSuccess -> {
content()
}
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions core/sync/src/main/java/ir/composenews/sync/Sync.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ object Sync {
.initializeComponent(SyncInitializer::class.java)
}

internal const val SyncWorkName = "SyncWorkName"
private const val SyncNotificationId = 0
private const val SyncNotificationChannelID = "SyncNotificationChannel"
internal const val SYNC_WORK_NAME = "SyncWorkName"
private const val SYNC_NOTIFICATION_ID = 0
private const val SYNC_NOTIFICATION_CHANNEL_ID = "SyncNotificationChannel"

val SyncConstraints = Constraints.Builder()
.setRequiredNetworkType(NetworkType.CONNECTED)
Expand All @@ -31,7 +31,7 @@ val SyncConstraints = Constraints.Builder()
* run with a foreground service
*/
fun Context.syncForegroundInfo() = ForegroundInfo(
SyncNotificationId,
SYNC_NOTIFICATION_ID,
syncWorkNotification(),
)

Expand All @@ -42,7 +42,7 @@ fun Context.syncForegroundInfo() = ForegroundInfo(
private fun Context.syncWorkNotification(): Notification {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val channel = NotificationChannel(
SyncNotificationChannelID,
SYNC_NOTIFICATION_CHANNEL_ID,
"sync",
NotificationManager.IMPORTANCE_DEFAULT,
).apply {
Expand All @@ -57,7 +57,7 @@ private fun Context.syncWorkNotification(): Notification {

// TODO
return NotificationCompat
.Builder(this, SyncNotificationChannelID)
.Builder(this, SYNC_NOTIFICATION_CHANNEL_ID)
// .setSmallIcon(androidx.hilt.work.R.drawable.notification_action_background)
.setContentTitle("Background tasks for Compose News")
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ import androidx.startup.Initializer
import androidx.work.ExistingWorkPolicy
import androidx.work.WorkManager
import androidx.work.WorkManagerInitializer
import ir.composenews.sync.SYNC_WORK_NAME
import ir.composenews.sync.Sync
import ir.composenews.sync.SyncWorkName
import ir.composenews.sync.worker.SyncWorker

class SyncInitializer : Initializer<Sync> {
override fun create(context: Context): Sync {
WorkManager.getInstance(context).apply {
// Run sync on app startup and ensure only one sync worker runs at any time
enqueueUniqueWork(
SyncWorkName,
SYNC_WORK_NAME,
ExistingWorkPolicy.KEEP,
SyncWorker.startUpSyncWork(),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ data class MarketModel(
parcel.readDouble(),
parcel.readString().orEmpty(),
parcel.readByte() != 0.toByte(),
) {
}
)

override fun writeToParcel(parcel: Parcel, flags: Int) {
parcel.writeString(id)
Expand Down
13 changes: 1 addition & 12 deletions data/market-local/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
plugins {
alias(libs.plugins.composenews.android.library)
id("composenews.android.hilt")
alias(libs.plugins.sqldelight)
}

android {
Expand All @@ -11,20 +10,10 @@ android {
namespace = "ir.composenews.localdatasource"
}

sqldelight {
databases {
create("MarketDatabase") {
packageName.set("ir.composenews.db")
}
}
}


dependencies {
api(projects.data.sqldelight)
libs.apply {
implementation(sqldelight.android)
implementation(sqldelight.coroutines)
testImplementation(sqldelight.test)
testImplementation(runner)
}
projects.apply {
Expand Down
1 change: 1 addition & 0 deletions data/sqldelight/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
30 changes: 30 additions & 0 deletions data/sqldelight/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
plugins {
alias(libs.plugins.composenews.android.library)
id("composenews.android.hilt")
alias(libs.plugins.sqldelight)
}
android {
namespace = "ir.composenews.sqldelight"
}


sqldelight {
databases {
create("MarketDatabase") {
packageName.set("ir.composenews.db")
}
}
}


dependencies {
libs.apply {
api(sqldelight.android)
api(sqldelight.coroutines)
api(sqldelight.test)
api(runner)
}
projects.apply {
testImplementation(core.test)
}
}
2 changes: 2 additions & 0 deletions data/sqldelight/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-keep class ir.composenews.db.** { *; }
-keep interface ir.composenews.db.** { *; }
38 changes: 19 additions & 19 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@ projectApplicationId = "ir.composenews"
projectVersionName = "1.0.0"
projectMinSdkVersion = "23"
projectMinSdkVersionWear = "30"
projectTargetSdkVersion = "34"
projectCompileSdkVersion = "34"
projectTargetSdkVersion = "35"
projectCompileSdkVersion = "35"
projectVersionCode = "1"

kotlin = "2.0.20"
kotlin = "2.0.21"
kotlinter = "3.16.0"
#ksp = "2.0.20-1.0.25"
ksp = "2.0.21-1.0.28"
kotlinxImmutableCollection = "0.3.8"
androidGradlePlugin = "8.6.1"
androidGradlePlugin = "8.7.3"

ktx = "1.13.1"
ktx = "1.15.0"

composeBOM = "2024.09.03"
composeActivity = "1.9.2"
composeBOM = "2024.11.00"
composeActivity = "1.9.3"
composeCoil = "2.7.0"
composeMaterial3 = "1.3.0"
composeMaterial3 = "1.3.1"
material3Adaptive = "1.0.0"
composeWear = "1.4.0"
wearToolingPreview = "1.0.0"
Expand All @@ -34,16 +34,16 @@ lottieAnimation = "6.3.0"

coroutinesCore = "1.9.0"

lifeCycle = "2.8.6"
lifeCycleViewModelKtx = "2.8.6"
lifeCycleRuntimeCompose = "2.8.6"
lifeCycle = "2.8.7"
lifeCycleViewModelKtx = "2.8.7"
lifeCycleRuntimeCompose = "2.8.7"

navigationCompose = "2.8.2"
navigationCompose = "2.8.4"

retrofit = "2.11.0"
loggingInterceptor = "4.12.0"
chucker = "4.0.0"
kotlinx-serialization = "1.7.2"
kotlinx-serialization = "1.7.3"
kotlinx-serialization-converter = "1.0.0"

sqldelight = "2.0.2"
Expand All @@ -57,15 +57,15 @@ runner = "1.6.2"

startupRuntime = "1.2.0"

workRuntimeKtx = "2.9.1"
workRuntimeKtx = "2.10.0"

windowsSizeClass = "1.3.0"
windowsSizeClass = "1.3.1"
adaptive = "0.26.2-beta"

ktor = "2.3.12"
ktor = "3.0.1"
konsist = "0.16.1"

kotest = "5.7.2"
kotest = "5.9.1"
espressoCore = "3.6.1"

[libraries]
Expand Down Expand Up @@ -159,7 +159,7 @@ android-library = { id = "com.android.library", version.ref = "androidGradlePlug
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
hilt-android = { id = "com.google.dagger.hilt.android", version.ref = "hilt" }
kotlin-parcelize = { id = "org.jetbrains.kotlin.plugin.parcelize", version.ref = "kotlin" }
#ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
kotlinx-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" }
kotliner = { id = "org.jmailen.kotlinter", version.ref = "kotlinter" }
Expand Down
Loading
Loading