Extract AddRecipeInput proto file to a module
This commit is contained in:
@@ -1,9 +1,5 @@
|
|||||||
@file:Suppress("UnstableApiUsage")
|
@file:Suppress("UnstableApiUsage")
|
||||||
|
|
||||||
import com.google.protobuf.gradle.builtins
|
|
||||||
import com.google.protobuf.gradle.generateProtoTasks
|
|
||||||
import com.google.protobuf.gradle.protobuf
|
|
||||||
import com.google.protobuf.gradle.protoc
|
|
||||||
import java.io.FileInputStream
|
import java.io.FileInputStream
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
@@ -16,7 +12,6 @@ plugins {
|
|||||||
id("com.google.gms.google-services")
|
id("com.google.gms.google-services")
|
||||||
id("com.google.firebase.crashlytics")
|
id("com.google.firebase.crashlytics")
|
||||||
alias(libs.plugins.appsweep)
|
alias(libs.plugins.appsweep)
|
||||||
alias(libs.plugins.protobuf)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
@@ -72,6 +67,7 @@ android {
|
|||||||
dependencies {
|
dependencies {
|
||||||
|
|
||||||
implementation(project(":database"))
|
implementation(project(":database"))
|
||||||
|
implementation(project(":datastore"))
|
||||||
|
|
||||||
implementation(libs.android.material.material)
|
implementation(libs.android.material.material)
|
||||||
|
|
||||||
@@ -126,8 +122,6 @@ dependencies {
|
|||||||
implementation(libs.androidx.datastore.preferences)
|
implementation(libs.androidx.datastore.preferences)
|
||||||
implementation(libs.androidx.datastore.datastore)
|
implementation(libs.androidx.datastore.datastore)
|
||||||
|
|
||||||
implementation(libs.google.protobuf.javalite)
|
|
||||||
|
|
||||||
implementation(libs.androidx.security.crypto)
|
implementation(libs.androidx.security.crypto)
|
||||||
|
|
||||||
implementation(platform(libs.google.firebase.bom))
|
implementation(platform(libs.google.firebase.bom))
|
||||||
@@ -150,24 +144,4 @@ dependencies {
|
|||||||
debugImplementation(libs.squareup.leakcanary)
|
debugImplementation(libs.squareup.leakcanary)
|
||||||
|
|
||||||
debugImplementation(libs.chuckerteam.chucker)
|
debugImplementation(libs.chuckerteam.chucker)
|
||||||
}
|
|
||||||
|
|
||||||
protobuf {
|
|
||||||
protoc {
|
|
||||||
artifact = libs.google.protobuf.protoc.get().toString()
|
|
||||||
}
|
|
||||||
|
|
||||||
generateProtoTasks {
|
|
||||||
all().forEach { task ->
|
|
||||||
task.builtins {
|
|
||||||
val java by registering {
|
|
||||||
option("lite")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
kapt {
|
|
||||||
correctErrorTypes = true
|
|
||||||
}
|
}
|
||||||
@@ -2,8 +2,8 @@ package gq.kirmanak.mealient.data.add.impl
|
|||||||
|
|
||||||
import androidx.datastore.core.DataStore
|
import androidx.datastore.core.DataStore
|
||||||
import gq.kirmanak.mealient.data.add.AddRecipeStorage
|
import gq.kirmanak.mealient.data.add.AddRecipeStorage
|
||||||
import gq.kirmanak.mealient.data.add.models.AddRecipeInput
|
|
||||||
import gq.kirmanak.mealient.data.add.models.AddRecipeRequest
|
import gq.kirmanak.mealient.data.add.models.AddRecipeRequest
|
||||||
|
import gq.kirmanak.mealient.datastore.recipe.AddRecipeInput
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlinx.coroutines.flow.map
|
import kotlinx.coroutines.flow.map
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package gq.kirmanak.mealient.data.add.models
|
package gq.kirmanak.mealient.data.add.models
|
||||||
|
|
||||||
|
import gq.kirmanak.mealient.datastore.recipe.AddRecipeInput
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,9 @@
|
|||||||
package gq.kirmanak.mealient.di
|
package gq.kirmanak.mealient.di
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import androidx.datastore.core.DataStore
|
|
||||||
import androidx.datastore.core.DataStoreFactory
|
|
||||||
import androidx.datastore.dataStoreFile
|
|
||||||
import dagger.Binds
|
import dagger.Binds
|
||||||
import dagger.Module
|
import dagger.Module
|
||||||
import dagger.Provides
|
import dagger.Provides
|
||||||
import dagger.hilt.InstallIn
|
import dagger.hilt.InstallIn
|
||||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
|
||||||
import dagger.hilt.components.SingletonComponent
|
import dagger.hilt.components.SingletonComponent
|
||||||
import gq.kirmanak.mealient.data.add.AddRecipeDataSource
|
import gq.kirmanak.mealient.data.add.AddRecipeDataSource
|
||||||
import gq.kirmanak.mealient.data.add.AddRecipeRepo
|
import gq.kirmanak.mealient.data.add.AddRecipeRepo
|
||||||
@@ -17,8 +12,6 @@ import gq.kirmanak.mealient.data.add.impl.AddRecipeDataSourceImpl
|
|||||||
import gq.kirmanak.mealient.data.add.impl.AddRecipeRepoImpl
|
import gq.kirmanak.mealient.data.add.impl.AddRecipeRepoImpl
|
||||||
import gq.kirmanak.mealient.data.add.impl.AddRecipeService
|
import gq.kirmanak.mealient.data.add.impl.AddRecipeService
|
||||||
import gq.kirmanak.mealient.data.add.impl.AddRecipeStorageImpl
|
import gq.kirmanak.mealient.data.add.impl.AddRecipeStorageImpl
|
||||||
import gq.kirmanak.mealient.data.add.models.AddRecipeInput
|
|
||||||
import gq.kirmanak.mealient.data.add.models.AddRecipeInputSerializer
|
|
||||||
import gq.kirmanak.mealient.data.baseurl.BaseURLStorage
|
import gq.kirmanak.mealient.data.baseurl.BaseURLStorage
|
||||||
import gq.kirmanak.mealient.data.network.RetrofitBuilder
|
import gq.kirmanak.mealient.data.network.RetrofitBuilder
|
||||||
import gq.kirmanak.mealient.data.network.ServiceFactory
|
import gq.kirmanak.mealient.data.network.ServiceFactory
|
||||||
@@ -34,14 +27,6 @@ interface AddRecipeModule {
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
@Provides
|
|
||||||
@Singleton
|
|
||||||
fun provideAddRecipeInputStore(
|
|
||||||
@ApplicationContext context: Context
|
|
||||||
): DataStore<AddRecipeInput> = DataStoreFactory.create(AddRecipeInputSerializer) {
|
|
||||||
context.dataStoreFile("add_recipe_input")
|
|
||||||
}
|
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
fun provideAddRecipeServiceFactory(
|
fun provideAddRecipeServiceFactory(
|
||||||
|
|||||||
@@ -39,5 +39,4 @@ dependencies {
|
|||||||
testImplementation(libs.google.truth)
|
testImplementation(libs.google.truth)
|
||||||
|
|
||||||
testImplementation(libs.io.mockk)
|
testImplementation(libs.io.mockk)
|
||||||
|
|
||||||
}
|
}
|
||||||
1
datastore/.gitignore
vendored
Normal file
1
datastore/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
/build
|
||||||
60
datastore/build.gradle.kts
Normal file
60
datastore/build.gradle.kts
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
import com.google.protobuf.gradle.builtins
|
||||||
|
import com.google.protobuf.gradle.generateProtoTasks
|
||||||
|
import com.google.protobuf.gradle.protobuf
|
||||||
|
import com.google.protobuf.gradle.protoc
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
id("gq.kirmanak.mealient.library")
|
||||||
|
id("kotlin-kapt")
|
||||||
|
id("dagger.hilt.android.plugin")
|
||||||
|
alias(libs.plugins.protobuf)
|
||||||
|
}
|
||||||
|
|
||||||
|
android {
|
||||||
|
namespace = "gq.kirmanak.mealient.datastore"
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation(libs.androidx.datastore.preferences)
|
||||||
|
implementation(libs.androidx.datastore.datastore)
|
||||||
|
|
||||||
|
implementation(libs.google.protobuf.javalite)
|
||||||
|
|
||||||
|
implementation(libs.androidx.security.crypto)
|
||||||
|
|
||||||
|
implementation(libs.google.dagger.hiltAndroid)
|
||||||
|
kapt(libs.google.dagger.hiltCompiler)
|
||||||
|
kaptTest(libs.google.dagger.hiltAndroidCompiler)
|
||||||
|
testImplementation(libs.google.dagger.hiltAndroidTesting)
|
||||||
|
|
||||||
|
implementation(libs.jetbrains.kotlinx.datetime)
|
||||||
|
|
||||||
|
implementation(libs.jetbrains.kotlinx.coroutinesAndroid)
|
||||||
|
testImplementation(libs.jetbrains.kotlinx.coroutinesTest)
|
||||||
|
|
||||||
|
testImplementation(libs.androidx.test.junit)
|
||||||
|
|
||||||
|
testImplementation(libs.google.truth)
|
||||||
|
|
||||||
|
testImplementation(libs.io.mockk)
|
||||||
|
}
|
||||||
|
|
||||||
|
protobuf {
|
||||||
|
protoc {
|
||||||
|
artifact = libs.google.protobuf.protoc.get().toString()
|
||||||
|
}
|
||||||
|
|
||||||
|
generateProtoTasks {
|
||||||
|
all().forEach { task ->
|
||||||
|
task.builtins {
|
||||||
|
val java by registering {
|
||||||
|
option("lite")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
kapt {
|
||||||
|
correctErrorTypes = true
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package gq.kirmanak.mealient.datastore
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import androidx.datastore.core.DataStore
|
||||||
|
import androidx.datastore.core.DataStoreFactory
|
||||||
|
import androidx.datastore.dataStoreFile
|
||||||
|
import dagger.Module
|
||||||
|
import dagger.Provides
|
||||||
|
import dagger.hilt.InstallIn
|
||||||
|
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||||
|
import dagger.hilt.components.SingletonComponent
|
||||||
|
import gq.kirmanak.mealient.datastore.recipe.AddRecipeInput
|
||||||
|
import gq.kirmanak.mealient.datastore.recipe.AddRecipeInputSerializer
|
||||||
|
import javax.inject.Singleton
|
||||||
|
|
||||||
|
@Module
|
||||||
|
@InstallIn(SingletonComponent::class)
|
||||||
|
interface DataStoreModule {
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
fun provideAddRecipeInputStore(
|
||||||
|
@ApplicationContext context: Context
|
||||||
|
): DataStore<AddRecipeInput> = DataStoreFactory.create(AddRecipeInputSerializer) {
|
||||||
|
context.dataStoreFile("add_recipe_input")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package gq.kirmanak.mealient.data.add.models
|
package gq.kirmanak.mealient.datastore.recipe
|
||||||
|
|
||||||
import androidx.datastore.core.CorruptionException
|
import androidx.datastore.core.CorruptionException
|
||||||
import androidx.datastore.core.Serializer
|
import androidx.datastore.core.Serializer
|
||||||
14
datastore/src/main/proto/AddRecipeInput.proto
Normal file
14
datastore/src/main/proto/AddRecipeInput.proto
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
|
||||||
|
option java_package = "gq.kirmanak.mealient.datastore.recipe";
|
||||||
|
option java_multiple_files = true;
|
||||||
|
|
||||||
|
message AddRecipeInput {
|
||||||
|
string recipeName = 1;
|
||||||
|
string recipeDescription = 2;
|
||||||
|
string recipeYield = 3;
|
||||||
|
repeated string recipeInstructions = 4;
|
||||||
|
repeated string recipeIngredients = 5;
|
||||||
|
bool isRecipePublic = 6;
|
||||||
|
bool areCommentsDisabled = 7;
|
||||||
|
}
|
||||||
@@ -21,3 +21,4 @@ rootProject.name = "Mealient"
|
|||||||
|
|
||||||
include(":app")
|
include(":app")
|
||||||
include(":database")
|
include(":database")
|
||||||
|
include(":datastore")
|
||||||
|
|||||||
Reference in New Issue
Block a user