Skip to content

Commit

Permalink
Separate JVM datastoreflow module
Browse files Browse the repository at this point in the history
  • Loading branch information
w2sv committed Jun 23, 2024
1 parent a1e2edd commit cc376c3
Show file tree
Hide file tree
Showing 16 changed files with 76 additions and 19 deletions.
3 changes: 2 additions & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
plugins {
alias(libs.plugins.kotlin.jvm) apply false
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.android.library) apply false
}
File renamed without changes.
41 changes: 41 additions & 0 deletions datastoreflow/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
plugins {
alias(libs.plugins.kotlin.jvm)
`maven-publish`
}

kotlin {
jvmToolchain(libs.versions.java.get().toInt())
}

publishing {
publications {
register<MavenPublication>("mavenJava") {
groupId = "com.w2sv.datastoreutils.datastoreflow"
artifactId = "datastoreflow"
version = version.toString()
afterEvaluate {
from(components["java"])
}
pom {
developers {
developer {
id.set("w2sv")
name.set("Janek Zangenberg")
}
}
description.set("Utilities for working with the androidx DataStore.")
url.set("https://github.com/w2sv/DataStoreUtils")
licenses {
license {
name.set("The Apache Software License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
}
}
}
}

dependencies {
implementation(libs.kotlinx.coroutines)
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@file:Suppress("unused")

package com.w2sv.preferences_datastore_repository.flow
package com.w2sv.datastoreutils.datastoreflow

import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.Flow
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@file:Suppress("unused")

package com.w2sv.preferences_datastore_repository.flow
package com.w2sv.datastoreutils.datastoreflow

import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.Flow
Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
org.gradle.parallel=true
org.gradle.caching=true
org.gradle.configuration-cache=true
org.gradle.configureondemand=true
#org.gradle.configureondemand=true
# =========== Kotlin ===========
kotlin.code.style=official
Expand Down
6 changes: 5 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@ java = "17"
kotlin = "2.0.0"
agp = "8.3.2"

kotlinx-coroutines = "1.8.1"

[libraries]
kotlinutils = "com.github.w2sv:KotlinUtils:0.1.1-rc1"
kotlinx-coroutines-android = "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.1"
kotlinx-coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinx-coroutines" }
kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "kotlinx-coroutines" }
androidx-datastore-preferences = 'androidx.datastore:datastore-preferences:1.1.1'
slimber = "com.github.PaulWoitaschek:Slimber:2.0.0"
#junit = "junit:junit:4.13.2"

[plugins]
android-library = { id = "com.android.library", version.ref = "agp" }
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
1 change: 1 addition & 0 deletions preferences/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ kotlin {
}

android {
namespace = "com.w2sv.preferences_data_store"
namespace = "com.w2sv.datastoreutils.preferences"
compileSdk = libs.versions.compileSdk.get().toInt()

defaultConfig {
Expand Down Expand Up @@ -45,8 +45,8 @@ android {
publishing {
publications {
register<MavenPublication>("release") {
groupId = "com.w2sv.preferences_datastore_repository"
artifactId = "preferences_datastore_repository"
groupId = "com.w2sv.datastoreutils.preferences"
artifactId = "datastoreutils.preferences"
version = version.toString()
afterEvaluate {
from(components["release"])
Expand All @@ -58,8 +58,8 @@ publishing {
name.set("Janek Zangenberg")
}
}
description.set("A repository that facilitates working with the Preferences DataStore.")
url.set("https://github.com/w2sv/PreferencesDataStoreRepository")
description.set("Utilities for working with the androidx DataStore.")
url.set("https://github.com/w2sv/DataStoreUtils")
licenses {
license {
name.set("The Apache Software License, Version 2.0")
Expand All @@ -72,6 +72,7 @@ publishing {
}

dependencies {
api(project(":datastoreflow"))
api(libs.androidx.datastore.preferences)
implementation(libs.slimber)
implementation(libs.kotlinutils)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@file:Suppress("unused")

package com.w2sv.preferences_datastore_repository
package com.w2sv.datastoreutils.preferences

import android.net.Uri
import android.os.Build
Expand All @@ -9,8 +9,9 @@ import androidx.datastore.core.DataStore
import androidx.datastore.preferences.core.MutablePreferences
import androidx.datastore.preferences.core.Preferences
import androidx.datastore.preferences.core.edit
import com.w2sv.preferences_datastore_repository.flow.DataStoreFlow
import com.w2sv.preferences_datastore_repository.flow.DataStoreFlowMap
import com.w2sv.datastoreutils.datastoreflow.DataStoreFlow
import com.w2sv.datastoreutils.preferences.map.DataStoreEntry
import com.w2sv.datastoreutils.preferences.map.DataStoreFlowMap
import com.w2sv.kotlinutils.generic.enumEntryByOrdinal
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.Flow
Expand Down Expand Up @@ -208,7 +209,8 @@ abstract class PreferencesDataStoreRepository(
DataStoreFlow(default = default, flow = getFlow(key, default), save = { save(key, it) })

protected inline fun <reified E : Enum<E>> dataStoreFlow(
key: Preferences.Key<Int>, default: E
key: Preferences.Key<Int>,
default: E
): DataStoreFlow<E> =
DataStoreFlow(
default = default,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@file:Suppress("unused")

package com.w2sv.preferences_datastore_repository
package com.w2sv.datastoreutils.preferences.map

import android.net.Uri
import androidx.datastore.preferences.core.Preferences
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.w2sv.preferences_datastore_repository.flow
package com.w2sv.datastoreutils.preferences.map

import com.w2sv.preferences_datastore_repository.DataStoreEntry
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.SharingStarted
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.w2sv.preferences_datastore_repository.flow
package com.w2sv.datastoreutils.preferences.map

import com.w2sv.preferences_datastore_repository.DataStoreEntry
import kotlinx.coroutines.flow.StateFlow

class DataStoreStateFlowMap<K, V>(
Expand Down
3 changes: 2 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ dependencyResolutionManagement {
}
}

include("preferences_datastore_repository")
include(":datastoreflow")
include(":preferences")

0 comments on commit cc376c3

Please sign in to comment.