├── .gitignore
├── app
├── .gitignore
├── build.gradle.kts
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── msoula
│ │ └── noteappclean
│ │ ├── MainActivity.kt
│ │ ├── NoteAppCleanApplication.kt
│ │ ├── app
│ │ └── NoteAppCleanApp.kt
│ │ ├── navigation
│ │ └── NoteAppCleanNavHost.kt
│ │ ├── presentation
│ │ ├── AppScreen.kt
│ │ └── AppViewModel.kt
│ │ └── ui
│ │ └── theme
│ │ ├── Color.kt
│ │ ├── Theme.kt
│ │ └── Type.kt
│ └── res
│ ├── drawable
│ ├── ic_launcher_background.xml
│ └── ic_launcher_foreground.xml
│ ├── mipmap-anydpi-v26
│ ├── ic_launcher.xml
│ └── ic_launcher_round.xml
│ ├── mipmap-hdpi
│ ├── ic_launcher.webp
│ └── ic_launcher_round.webp
│ ├── mipmap-mdpi
│ ├── ic_launcher.webp
│ └── ic_launcher_round.webp
│ ├── mipmap-xhdpi
│ ├── ic_launcher.webp
│ └── ic_launcher_round.webp
│ ├── mipmap-xxhdpi
│ ├── ic_launcher.webp
│ └── ic_launcher_round.webp
│ ├── mipmap-xxxhdpi
│ ├── ic_launcher.webp
│ └── ic_launcher_round.webp
│ ├── values
│ ├── colors.xml
│ ├── strings.xml
│ └── themes.xml
│ └── xml
│ ├── backup_rules.xml
│ └── data_extraction_rules.xml
├── build.gradle.kts
├── buildSrc
├── build.gradle.kts
├── settings.gradle.kts
└── src
│ └── main
│ └── kotlin
│ ├── AndroidConfig.kt
│ ├── MainGradlePlugin.kt
│ ├── Modules.kt
│ └── Plugins.kt
├── core
├── common
│ ├── .gitignore
│ ├── build.gradle.kts
│ └── src
│ │ └── main
│ │ └── java
│ │ └── com
│ │ └── msoula
│ │ └── noteappclean
│ │ └── core
│ │ └── common
│ │ ├── Result.kt
│ │ ├── StringResourceProvider.kt
│ │ ├── StringResourceProviderImpl.kt
│ │ ├── ValidationResult.kt
│ │ └── di
│ │ └── ResourceModule.kt
├── database
│ ├── .gitignore
│ ├── build.gradle.kts
│ ├── dao
│ │ ├── .gitignore
│ │ ├── build.gradle.kts
│ │ └── src
│ │ │ └── main
│ │ │ └── java
│ │ │ └── com
│ │ │ └── msoula
│ │ │ └── noteappclean
│ │ │ └── core
│ │ │ └── database
│ │ │ └── dao
│ │ │ ├── NoteDAO.kt
│ │ │ └── models
│ │ │ └── NoteEntityModel.kt
│ └── src
│ │ └── main
│ │ └── java
│ │ └── com
│ │ └── msoula
│ │ └── noteappclean
│ │ └── core
│ │ └── database
│ │ ├── NoteAppCleanDatabase.kt
│ │ └── di
│ │ └── DatabaseModule.kt
└── di
│ ├── .gitignore
│ ├── build.gradle.kts
│ └── src
│ └── main
│ └── java
│ └── com
│ └── msoula
│ └── noteappclean
│ └── core
│ └── di
│ ├── modules
│ └── NavigationModule.kt
│ └── navigation
│ ├── NavigationRoute.kt
│ ├── Navigator.kt
│ ├── NavigatorImpl.kt
│ └── ScreenDefinition.kt
├── feature
├── addnote
│ ├── .gitignore
│ ├── build.gradle.kts
│ ├── domain
│ │ ├── .gitignore
│ │ ├── build.gradle.kts
│ │ └── src
│ │ │ └── main
│ │ │ └── java
│ │ │ └── com
│ │ │ └── msoula
│ │ │ └── noteappclean
│ │ │ └── feature
│ │ │ └── addnote
│ │ │ └── domain
│ │ │ ├── di
│ │ │ └── AddNoteDomainModule.kt
│ │ │ └── use_cases
│ │ │ ├── ValidateDescriptionUseCase.kt
│ │ │ └── ValidateTitleUseCase.kt
│ └── presentation
│ │ ├── .gitignore
│ │ ├── build.gradle.kts
│ │ └── src
│ │ └── main
│ │ ├── java
│ │ └── com
│ │ │ └── msoula
│ │ │ └── noteappclean
│ │ │ └── feature
│ │ │ └── addnote
│ │ │ └── presentation
│ │ │ ├── AddNoteFormScreen.kt
│ │ │ ├── AddNoteViewModel.kt
│ │ │ └── models
│ │ │ ├── AddNoteFormEvent.kt
│ │ │ └── AddNoteFormUiState.kt
│ │ └── res
│ │ ├── values-en-rUS
│ │ └── strings.xml
│ │ └── values
│ │ └── values.xml
├── notedetail
│ ├── .gitignore
│ ├── build.gradle.kts
│ └── presentation
│ │ ├── .gitignore
│ │ ├── build.gradle.kts
│ │ └── src
│ │ └── main
│ │ └── java
│ │ └── com
│ │ └── msoula
│ │ └── noteappclean
│ │ └── feature
│ │ └── notedetail
│ │ └── presentation
│ │ ├── NoteDetailScreen.kt
│ │ ├── NoteDetailViewModel.kt
│ │ └── models
│ │ └── NoteDetailUiState.kt
└── notes
│ ├── .gitignore
│ ├── build.gradle.kts
│ ├── data
│ ├── .gitignore
│ ├── build.gradle.kts
│ └── src
│ │ └── main
│ │ └── java
│ │ └── com
│ │ └── msoula
│ │ └── noteappclean
│ │ └── feature
│ │ └── notes
│ │ └── data
│ │ ├── data_sources
│ │ └── local
│ │ │ ├── NoteLocalDataSourceImpl.kt
│ │ │ └── mappers
│ │ │ └── LocalMappers.kt
│ │ └── di
│ │ └── NoteDataSourceModule.kt
│ ├── domain
│ ├── .gitignore
│ ├── build.gradle.kts
│ └── src
│ │ └── main
│ │ └── java
│ │ └── com
│ │ └── msoula
│ │ └── noteappclean
│ │ └── feature
│ │ └── notes
│ │ └── domain
│ │ ├── data_sources
│ │ └── NoteLocalDataSource.kt
│ │ ├── di
│ │ └── NoteDomainModule.kt
│ │ ├── errors
│ │ └── InsertNoteError.kt
│ │ ├── models
│ │ └── NoteDomainModel.kt
│ │ ├── repositories
│ │ └── NoteRepository.kt
│ │ └── use_cases
│ │ ├── FetchNoteByIdUseCase.kt
│ │ ├── InsertNoteUseCase.kt
│ │ └── ObserveNotesUseCase.kt
│ ├── presentation
│ ├── .gitignore
│ ├── build.gradle.kts
│ └── src
│ │ └── main
│ │ └── java
│ │ └── com
│ │ └── msoula
│ │ └── noteappclean
│ │ └── feature
│ │ └── notes
│ │ └── presentation
│ │ ├── NoteScreen.kt
│ │ ├── NoteViewModel.kt
│ │ ├── components
│ │ └── NoteItem.kt
│ │ ├── mappers
│ │ └── Mappers.kt
│ │ └── models
│ │ ├── NoteUiModel.kt
│ │ └── NoteUiStateModel.kt
│ └── src
│ └── main
│ └── java
│ └── com
│ └── msoula
│ └── noteappclean
│ └── feature
│ └── notes
│ └── MyClass.kt
├── gradle.properties
├── gradle
├── libs.versions.toml
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle.kts
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | /.idea/navEditor.xml
9 | /.idea/assetWizardSettings.xml
10 | .DS_Store
11 | /build
12 | /captures
13 | .externalNativeBuild
14 | .cxx
15 | local.properties
16 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/app/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | id("com.android.application")
3 | id("org.jetbrains.kotlin.android")
4 | id(Plugins.DAGGER_HILT)
5 | kotlin(Plugins.KAPT)
6 | }
7 |
8 | android {
9 | namespace = "com.msoula.noteappclean"
10 | compileSdk = 34
11 |
12 | defaultConfig {
13 | applicationId = "com.msoula.noteappclean"
14 | minSdk = 26
15 | targetSdk = 34
16 | versionCode = 1
17 | versionName = "1.0"
18 |
19 | testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
20 | vectorDrawables {
21 | useSupportLibrary = true
22 | }
23 | }
24 |
25 | buildTypes {
26 | release {
27 | isMinifyEnabled = false
28 | proguardFiles(
29 | getDefaultProguardFile("proguard-android-optimize.txt"),
30 | "proguard-rules.pro"
31 | )
32 | }
33 | }
34 | compileOptions {
35 | sourceCompatibility = JavaVersion.VERSION_17
36 | targetCompatibility = JavaVersion.VERSION_17
37 | }
38 |
39 | kotlinOptions {
40 | jvmTarget = "17"
41 | }
42 |
43 | buildFeatures {
44 | compose = true
45 | }
46 | composeOptions {
47 | kotlinCompilerExtensionVersion = "1.5.8"
48 | }
49 | packaging {
50 | resources {
51 | excludes += "/META-INF/{AL2.0,LGPL2.1}"
52 | }
53 | }
54 | }
55 |
56 | dependencies {
57 | // AndroidX
58 | implementation(libs.androidx.core.ktx)
59 | implementation(libs.androidx.lifecycle.runtime.ktx)
60 | implementation(libs.androidx.ui)
61 | implementation(libs.androidx.ui.graphics)
62 | implementation(libs.androidx.ui.tooling.preview)
63 | implementation(libs.lifecycle.runtime.compose)
64 | implementation(platform(libs.androidx.compose.bom))
65 | implementation(libs.lifecycle.viewmodel.compose)
66 | implementation(libs.kotlinx.collections.immutable)
67 |
68 | // Compose
69 | implementation(libs.androidx.activity.compose)
70 | implementation(libs.material3)
71 | implementation(libs.androidx.ui.tooling)
72 |
73 | // Core
74 | implementation(libs.core.ktx)
75 | implementation(libs.runtime)
76 |
77 | // Hilt
78 | implementation(libs.hilt.android)
79 | kapt(libs.hilt.compiler)
80 |
81 | // Modules
82 | implementation(project(Modules.DATABASE))
83 | implementation(project(Modules.DAO))
84 | implementation(project(Modules.DI))
85 | implementation(project(Modules.ADD_NOTE_PRESENTATION))
86 | implementation(project(Modules.NOTE_DATA))
87 | implementation(project(Modules.NOTE_DOMAIN))
88 | implementation(project(Modules.NOTE_PRESENTATION))
89 | implementation(project(Modules.NOTE_DETAIL_PRESENTATION))
90 |
91 | // Navigation
92 | implementation(libs.navigation.ui.ktx)
93 | implementation(libs.androidx.hilt.navigation.compose)
94 | }
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
16 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/app/src/main/java/com/msoula/noteappclean/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.msoula.noteappclean
2 |
3 | import android.os.Bundle
4 | import androidx.activity.ComponentActivity
5 | import androidx.activity.compose.setContent
6 | import com.msoula.noteappclean.app.NoteAppCleanApp
7 | import com.msoula.noteappclean.core.di.navigation.Navigator
8 | import com.msoula.noteappclean.ui.theme.NoteAppCleanTheme
9 | import dagger.hilt.android.AndroidEntryPoint
10 | import javax.inject.Inject
11 |
12 | @AndroidEntryPoint
13 | class MainActivity : ComponentActivity() {
14 |
15 | @Inject
16 | lateinit var navigator: Navigator
17 |
18 | override fun onCreate(savedInstanceState: Bundle?) {
19 | super.onCreate(savedInstanceState)
20 | setContent {
21 | NoteAppCleanTheme {
22 | NoteAppCleanApp(navigator)
23 | }
24 | }
25 | }
26 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/msoula/noteappclean/NoteAppCleanApplication.kt:
--------------------------------------------------------------------------------
1 | package com.msoula.noteappclean
2 |
3 | import android.app.Application
4 | import dagger.hilt.android.HiltAndroidApp
5 |
6 | @HiltAndroidApp
7 | class NoteAppCleanApplication : Application()
--------------------------------------------------------------------------------
/app/src/main/java/com/msoula/noteappclean/app/NoteAppCleanApp.kt:
--------------------------------------------------------------------------------
1 | package com.msoula.noteappclean.app
2 |
3 | import androidx.compose.runtime.Composable
4 | import androidx.compose.runtime.DisposableEffect
5 | import androidx.compose.runtime.Stable
6 | import androidx.navigation.compose.rememberNavController
7 | import com.msoula.noteappclean.core.di.navigation.Navigator
8 | import com.msoula.noteappclean.navigation.NoteAppCleanNavHost
9 |
10 | @Stable
11 | @Composable
12 | fun NoteAppCleanApp(navigator: Navigator) {
13 | val navController = rememberNavController()
14 |
15 | DisposableEffect(key1 = navController) {
16 | navigator.setController(navController)
17 | onDispose {
18 | navigator.clear()
19 | }
20 | }
21 |
22 | NoteAppCleanNavHost(navController = navController, navigator)
23 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/msoula/noteappclean/navigation/NoteAppCleanNavHost.kt:
--------------------------------------------------------------------------------
1 | package com.msoula.noteappclean.navigation
2 |
3 | import androidx.compose.runtime.Composable
4 | import androidx.compose.runtime.Stable
5 | import androidx.compose.runtime.getValue
6 | import androidx.hilt.navigation.compose.hiltViewModel
7 | import androidx.lifecycle.compose.collectAsStateWithLifecycle
8 | import androidx.navigation.NavHostController
9 | import androidx.navigation.compose.NavHost
10 | import androidx.navigation.compose.composable
11 | import com.msoula.noteappclean.core.di.navigation.AppScreenRoute
12 | import com.msoula.noteappclean.core.di.navigation.Navigator
13 | import com.msoula.noteappclean.core.di.navigation.NoteDetailScreenRoute
14 | import com.msoula.noteappclean.core.di.navigation.NoteFormScreenRoute
15 | import com.msoula.noteappclean.feature.addnote.presentation.AddNoteFormScreen
16 | import com.msoula.noteappclean.feature.addnote.presentation.AddNoteViewModel
17 | import com.msoula.noteappclean.feature.notedetail.presentation.NoteDetailScreen
18 | import com.msoula.noteappclean.feature.notedetail.presentation.NoteDetailViewModel
19 | import com.msoula.noteappclean.presentation.AppScreen
20 | import com.msoula.noteappclean.presentation.AppViewModel
21 |
22 | @Stable
23 | @Composable
24 | fun NoteAppCleanNavHost(
25 | navController: NavHostController,
26 | navigator: Navigator,
27 | appViewModel: AppViewModel = hiltViewModel()
28 | ) {
29 | NavHost(navController = navController, startDestination = AppScreenRoute.ROUTE) {
30 | composable(route = AppScreenRoute.ROUTE) {
31 | AppScreen(
32 | openAddNoteScreen = { navigator.navigate(NoteFormScreenRoute) },
33 | openNoteDetail = { id -> navigator.navigate(NoteDetailScreenRoute(id = id.toString())) }
34 | )
35 | }
36 |
37 | composable(route = NoteFormScreenRoute.ROUTE) {
38 | val addNoteViewModel = hiltViewModel()
39 | val addNoteUiState by addNoteViewModel.addNoteState.collectAsStateWithLifecycle()
40 |
41 | AddNoteFormScreen(state = addNoteUiState, onUiEvent = addNoteViewModel::onUiEvent)
42 | }
43 |
44 | composable(route = NoteDetailScreenRoute.route) {
45 | val noteDetailViewModel = hiltViewModel()
46 | val noteDetailState by noteDetailViewModel.noteDetailState.collectAsStateWithLifecycle()
47 |
48 | NoteDetailScreen(state = noteDetailState)
49 | }
50 | }
51 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/msoula/noteappclean/presentation/AppScreen.kt:
--------------------------------------------------------------------------------
1 | package com.msoula.noteappclean.presentation
2 |
3 | import androidx.compose.foundation.layout.padding
4 | import androidx.compose.material.icons.Icons
5 | import androidx.compose.material.icons.filled.Add
6 | import androidx.compose.material3.CircularProgressIndicator
7 | import androidx.compose.material3.FloatingActionButton
8 | import androidx.compose.material3.Icon
9 | import androidx.compose.material3.Scaffold
10 | import androidx.compose.material3.Surface
11 | import androidx.compose.runtime.Composable
12 | import androidx.compose.runtime.getValue
13 | import androidx.compose.ui.Modifier
14 | import androidx.hilt.navigation.compose.hiltViewModel
15 | import androidx.lifecycle.compose.collectAsStateWithLifecycle
16 | import com.msoula.noteappclean.feature.notes.presentation.EmptyNoteScreen
17 | import com.msoula.noteappclean.feature.notes.presentation.NoteScreen
18 | import com.msoula.noteappclean.feature.notes.presentation.NoteViewModel
19 | import com.msoula.noteappclean.feature.notes.presentation.models.NoteUiStateModel
20 |
21 | @Composable
22 | fun AppScreen(
23 | modifier: Modifier = Modifier,
24 | noteViewModel: NoteViewModel = hiltViewModel(),
25 | openAddNoteScreen: () -> Unit,
26 | openNoteDetail: (id: Long) -> Unit
27 | ) {
28 | Scaffold(modifier = modifier, floatingActionButton = {
29 | FloatingActionButton(onClick = { openAddNoteScreen() }) {
30 | Icon(imageVector = Icons.Default.Add, contentDescription = "add new note FAB")
31 | }
32 | }) { paddingValues ->
33 | Surface(modifier = Modifier.padding(paddingValues)) {
34 | val noteState by noteViewModel.noteState.collectAsStateWithLifecycle()
35 |
36 | AppContent(noteState, openNoteDetail)
37 | }
38 | }
39 | }
40 |
41 | @Composable
42 | fun AppContent(
43 | noteState: NoteUiStateModel,
44 | openNoteDetail: (id: Long) -> Unit
45 | ) {
46 | when (noteState) {
47 | is NoteUiStateModel.Loading -> CircularProgressIndicator()
48 | is NoteUiStateModel.Empty -> EmptyNoteScreen()
49 | is NoteUiStateModel.Fetched -> NoteScreen(
50 | notes = noteState.list,
51 | openNoteDetail = openNoteDetail
52 | )
53 | }
54 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/msoula/noteappclean/presentation/AppViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.msoula.noteappclean.presentation
2 |
3 | import androidx.lifecycle.ViewModel
4 | import dagger.hilt.android.lifecycle.HiltViewModel
5 | import javax.inject.Inject
6 |
7 | @HiltViewModel
8 | class AppViewModel @Inject constructor() : ViewModel() {
9 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/msoula/noteappclean/ui/theme/Color.kt:
--------------------------------------------------------------------------------
1 | package com.msoula.noteappclean.ui.theme
2 |
3 | import androidx.compose.ui.graphics.Color
4 |
5 | val Purple80 = Color(0xFFD0BCFF)
6 | val PurpleGrey80 = Color(0xFFCCC2DC)
7 | val Pink80 = Color(0xFFEFB8C8)
8 |
9 | val Purple40 = Color(0xFF6650a4)
10 | val PurpleGrey40 = Color(0xFF625b71)
11 | val Pink40 = Color(0xFF7D5260)
--------------------------------------------------------------------------------
/app/src/main/java/com/msoula/noteappclean/ui/theme/Theme.kt:
--------------------------------------------------------------------------------
1 | package com.msoula.noteappclean.ui.theme
2 |
3 | import android.app.Activity
4 | import android.os.Build
5 | import androidx.compose.foundation.isSystemInDarkTheme
6 | import androidx.compose.material3.MaterialTheme
7 | import androidx.compose.material3.darkColorScheme
8 | import androidx.compose.material3.dynamicDarkColorScheme
9 | import androidx.compose.material3.dynamicLightColorScheme
10 | import androidx.compose.material3.lightColorScheme
11 | import androidx.compose.runtime.Composable
12 | import androidx.compose.runtime.SideEffect
13 | import androidx.compose.ui.graphics.toArgb
14 | import androidx.compose.ui.platform.LocalContext
15 | import androidx.compose.ui.platform.LocalView
16 | import androidx.core.view.WindowCompat
17 |
18 | private val DarkColorScheme = darkColorScheme(
19 | primary = Purple80,
20 | secondary = PurpleGrey80,
21 | tertiary = Pink80
22 | )
23 |
24 | private val LightColorScheme = lightColorScheme(
25 | primary = Purple40,
26 | secondary = PurpleGrey40,
27 | tertiary = Pink40
28 |
29 | /* Other default colors to override
30 | background = Color(0xFFFFFBFE),
31 | surface = Color(0xFFFFFBFE),
32 | onPrimary = Color.White,
33 | onSecondary = Color.White,
34 | onTertiary = Color.White,
35 | onBackground = Color(0xFF1C1B1F),
36 | onSurface = Color(0xFF1C1B1F),
37 | */
38 | )
39 |
40 | @Composable
41 | fun NoteAppCleanTheme(
42 | darkTheme: Boolean = isSystemInDarkTheme(),
43 | // Dynamic color is available on Android 12+
44 | dynamicColor: Boolean = true,
45 | content: @Composable () -> Unit
46 | ) {
47 | val colorScheme = when {
48 | dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
49 | val context = LocalContext.current
50 | if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
51 | }
52 |
53 | darkTheme -> DarkColorScheme
54 | else -> LightColorScheme
55 | }
56 | val view = LocalView.current
57 | if (!view.isInEditMode) {
58 | SideEffect {
59 | val window = (view.context as Activity).window
60 | window.statusBarColor = colorScheme.primary.toArgb()
61 | WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = darkTheme
62 | }
63 | }
64 |
65 | MaterialTheme(
66 | colorScheme = colorScheme,
67 | typography = Typography,
68 | content = content
69 | )
70 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/msoula/noteappclean/ui/theme/Type.kt:
--------------------------------------------------------------------------------
1 | package com.msoula.noteappclean.ui.theme
2 |
3 | import androidx.compose.material3.Typography
4 | import androidx.compose.ui.text.TextStyle
5 | import androidx.compose.ui.text.font.FontFamily
6 | import androidx.compose.ui.text.font.FontWeight
7 | import androidx.compose.ui.unit.sp
8 |
9 | // Set of Material typography styles to start with
10 | val Typography = Typography(
11 | bodyLarge = TextStyle(
12 | fontFamily = FontFamily.Default,
13 | fontWeight = FontWeight.Normal,
14 | fontSize = 16.sp,
15 | lineHeight = 24.sp,
16 | letterSpacing = 0.5.sp
17 | )
18 | /* Other default text styles to override
19 | titleLarge = TextStyle(
20 | fontFamily = FontFamily.Default,
21 | fontWeight = FontWeight.Normal,
22 | fontSize = 22.sp,
23 | lineHeight = 28.sp,
24 | letterSpacing = 0.sp
25 | ),
26 | labelSmall = TextStyle(
27 | fontFamily = FontFamily.Default,
28 | fontWeight = FontWeight.Medium,
29 | fontSize = 11.sp,
30 | lineHeight = 16.sp,
31 | letterSpacing = 0.5.sp
32 | )
33 | */
34 | )
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/morganesoula/NoteAppClean/3bc794640661fcdcdeb26c6ae1d8448abe338125/app/src/main/res/mipmap-hdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/morganesoula/NoteAppClean/3bc794640661fcdcdeb26c6ae1d8448abe338125/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/morganesoula/NoteAppClean/3bc794640661fcdcdeb26c6ae1d8448abe338125/app/src/main/res/mipmap-mdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/morganesoula/NoteAppClean/3bc794640661fcdcdeb26c6ae1d8448abe338125/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/morganesoula/NoteAppClean/3bc794640661fcdcdeb26c6ae1d8448abe338125/app/src/main/res/mipmap-xhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/morganesoula/NoteAppClean/3bc794640661fcdcdeb26c6ae1d8448abe338125/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/morganesoula/NoteAppClean/3bc794640661fcdcdeb26c6ae1d8448abe338125/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/morganesoula/NoteAppClean/3bc794640661fcdcdeb26c6ae1d8448abe338125/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/morganesoula/NoteAppClean/3bc794640661fcdcdeb26c6ae1d8448abe338125/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/morganesoula/NoteAppClean/3bc794640661fcdcdeb26c6ae1d8448abe338125/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FFBB86FC
4 | #FF6200EE
5 | #FF3700B3
6 | #FF03DAC5
7 | #FF018786
8 | #FF000000
9 | #FFFFFFFF
10 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | NoteAppClean
3 |
--------------------------------------------------------------------------------
/app/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/backup_rules.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/data_extraction_rules.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
12 |
13 |
19 |
--------------------------------------------------------------------------------
/build.gradle.kts:
--------------------------------------------------------------------------------
1 | buildscript {
2 | repositories {
3 | google()
4 | mavenCentral()
5 | }
6 |
7 | dependencies {
8 | classpath(libs.gradle)
9 | classpath(libs.runtime)
10 | classpath(libs.hilt.android.gradle.plugin)
11 | classpath(libs.kotlin.gradle.plugin)
12 | }
13 | }
--------------------------------------------------------------------------------
/buildSrc/build.gradle.kts:
--------------------------------------------------------------------------------
1 | import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
2 |
3 | plugins {
4 | `kotlin-dsl`
5 | }
6 |
7 | repositories {
8 | google()
9 | mavenCentral()
10 | maven(url = "https://jitpack.io")
11 | }
12 |
13 | dependencies {
14 | implementation(libs.gradle)
15 | implementation(libs.runtime)
16 | implementation(libs.kotlin.gradle.plugin)
17 | implementation(libs.javapoet)
18 | }
19 |
20 | val compileKotlin: KotlinCompile by tasks
21 | compileKotlin.kotlinOptions {
22 | jvmTarget = "17"
23 | }
--------------------------------------------------------------------------------
/buildSrc/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | dependencyResolutionManagement {
2 | versionCatalogs {
3 | create("libs") {
4 | from(files("../gradle/libs.versions.toml"))
5 | }
6 | }
7 | }
--------------------------------------------------------------------------------
/buildSrc/src/main/kotlin/AndroidConfig.kt:
--------------------------------------------------------------------------------
1 | object AndroidConfig {
2 | const val APPLICATION_ID = "com.msoula.noteappclean"
3 | const val MIN_SDK = 26
4 | const val TARGET_SDK = 34
5 | const val COMPILE_SDK = 34
6 |
7 | private const val VERSION_MAJOR = 1
8 | private const val VERSION_MINOR = 0
9 | private const val VERSION_PATCH = 0
10 |
11 | const val VERSION_CODE = 1
12 | const val VERSION_NAME = "$VERSION_MAJOR.$VERSION_MINOR.$VERSION_PATCH"
13 |
14 | const val TEST_INSTRUMENTATION_RUNNER = "androidx.test.runner.AndroidJUnitRunner"
15 | }
--------------------------------------------------------------------------------
/buildSrc/src/main/kotlin/MainGradlePlugin.kt:
--------------------------------------------------------------------------------
1 | import com.android.build.gradle.LibraryExtension
2 | import org.gradle.api.JavaVersion
3 | import org.gradle.api.Plugin
4 | import org.gradle.api.Project
5 |
6 | class MainGradlePlugin : Plugin {
7 | override fun apply(project: Project) {
8 | applyPlugins(project)
9 | setProjectConfig(project)
10 | }
11 |
12 | private fun applyPlugins(project: Project) {
13 | project.apply {
14 | plugin(Plugins.ANDROID_LIBRARY)
15 | plugin(Plugins.KOTLIN_ANDROID)
16 | plugin(Plugins.KOTLIN_KAPT)
17 | plugin("kotlin-parcelize")
18 | }
19 | }
20 |
21 | private fun setProjectConfig(project: Project) {
22 | project.android().apply {
23 | compileSdk = AndroidConfig.COMPILE_SDK
24 |
25 | defaultConfig {
26 | minSdk = AndroidConfig.MIN_SDK
27 | testInstrumentationRunner = AndroidConfig.TEST_INSTRUMENTATION_RUNNER
28 | }
29 |
30 | compileOptions {
31 | sourceCompatibility = JavaVersion.VERSION_17
32 | targetCompatibility = JavaVersion.VERSION_17
33 | }
34 |
35 | buildFeatures {
36 | buildConfig = true
37 | compose = true
38 | }
39 |
40 | composeOptions {
41 | kotlinCompilerExtensionVersion = "1.5.8"
42 | }
43 | }
44 | }
45 |
46 | private fun Project.android(): LibraryExtension {
47 | return extensions.getByType(LibraryExtension::class.java)
48 | }
49 | }
--------------------------------------------------------------------------------
/buildSrc/src/main/kotlin/Modules.kt:
--------------------------------------------------------------------------------
1 | object Modules {
2 | const val ADD_NOTE_DOMAIN = ":feature:addnote:domain"
3 | const val ADD_NOTE_PRESENTATION = ":feature:addnote:presentation"
4 | const val COMMON = ":core:common"
5 | const val DATABASE = ":core:database"
6 | const val DAO = ":core:database:dao"
7 | const val DI = ":core:di"
8 | const val NOTE_DATA = ":feature:notes:data"
9 | const val NOTE_DOMAIN = ":feature:notes:domain"
10 | const val NOTE_PRESENTATION = ":feature:notes:presentation"
11 | const val NOTE_DETAIL_PRESENTATION = ":feature:notedetail:presentation"
12 | }
--------------------------------------------------------------------------------
/buildSrc/src/main/kotlin/Plugins.kt:
--------------------------------------------------------------------------------
1 | object Plugins {
2 | // Module Level
3 | const val KAPT = "kapt"
4 | const val ANDROID_LIBRARY = "android-library"
5 | const val KOTLIN_ANDROID = "kotlin-android"
6 | const val KOTLIN_KAPT = "kotlin-kapt"
7 | const val DAGGER_HILT = "dagger.hilt.android.plugin"
8 | }
9 |
--------------------------------------------------------------------------------
/core/common/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/core/common/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | `android-library`
3 | `kotlin-android`
4 | id(Plugins.DAGGER_HILT)
5 | kotlin(Plugins.KAPT)
6 | }
7 |
8 | apply()
9 |
10 | android {
11 | namespace = "com.msoula.noteappclean.core.common"
12 | }
13 |
14 | dependencies {
15 | // Core
16 | implementation(libs.core.ktx)
17 | implementation(libs.runtime)
18 |
19 | // Hilt
20 | implementation(libs.hilt.android)
21 | kapt(libs.hilt.compiler)
22 | }
--------------------------------------------------------------------------------
/core/common/src/main/java/com/msoula/noteappclean/core/common/Result.kt:
--------------------------------------------------------------------------------
1 | package com.msoula.noteappclean.core.common
2 |
3 | sealed interface Result {
4 | data class Success(val data: R) : Result
5 | data class Failure(val error: AppError) : Result
6 | }
7 |
8 | interface AppError {
9 | val message: String
10 | }
--------------------------------------------------------------------------------
/core/common/src/main/java/com/msoula/noteappclean/core/common/StringResourceProvider.kt:
--------------------------------------------------------------------------------
1 | package com.msoula.noteappclean.core.common
2 |
3 | import androidx.annotation.StringRes
4 |
5 | interface StringResourceProvider {
6 |
7 | fun getString(@StringRes stringResId: Int): String
8 | }
--------------------------------------------------------------------------------
/core/common/src/main/java/com/msoula/noteappclean/core/common/StringResourceProviderImpl.kt:
--------------------------------------------------------------------------------
1 | package com.msoula.noteappclean.core.common
2 |
3 | import android.content.Context
4 | import dagger.hilt.android.qualifiers.ApplicationContext
5 | import javax.inject.Inject
6 | import javax.inject.Singleton
7 |
8 | @Singleton
9 | class StringResourceProviderImpl @Inject constructor(
10 | @ApplicationContext private val context: Context
11 | ) : StringResourceProvider {
12 |
13 | override fun getString(stringResId: Int): String {
14 | return context.getString(stringResId)
15 | }
16 | }
--------------------------------------------------------------------------------
/core/common/src/main/java/com/msoula/noteappclean/core/common/ValidationResult.kt:
--------------------------------------------------------------------------------
1 | package com.msoula.noteappclean.core.common
2 |
3 | data class ValidationResult(
4 | val successful: Boolean = false,
5 | val errorMessage: String? = null
6 | )
7 |
--------------------------------------------------------------------------------
/core/common/src/main/java/com/msoula/noteappclean/core/common/di/ResourceModule.kt:
--------------------------------------------------------------------------------
1 | package com.msoula.noteappclean.core.common.di
2 |
3 | import android.content.Context
4 | import com.msoula.noteappclean.core.common.StringResourceProvider
5 | import com.msoula.noteappclean.core.common.StringResourceProviderImpl
6 | import dagger.Module
7 | import dagger.Provides
8 | import dagger.hilt.InstallIn
9 | import dagger.hilt.android.qualifiers.ApplicationContext
10 | import dagger.hilt.components.SingletonComponent
11 | import javax.inject.Singleton
12 |
13 | @Module
14 | @InstallIn(SingletonComponent::class)
15 | object ResourceModule {
16 |
17 | @Provides
18 | @Singleton
19 | fun provideResourceProvider(@ApplicationContext context: Context): StringResourceProvider =
20 | StringResourceProviderImpl(context)
21 |
22 | }
--------------------------------------------------------------------------------
/core/database/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/core/database/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | `android-library`
3 | `kotlin-android`
4 | id(Plugins.DAGGER_HILT)
5 | kotlin(Plugins.KAPT)
6 | }
7 |
8 | apply()
9 |
10 | android {
11 | namespace = "com.msoula.noteappclean.core.database"
12 | }
13 |
14 | dependencies {
15 | // Core
16 | implementation(libs.runtime)
17 |
18 | // Hilt
19 | implementation(libs.hilt.android)
20 | kapt(libs.hilt.compiler)
21 |
22 | // Modules
23 | implementation(project(Modules.DAO))
24 |
25 | // Room
26 | api(libs.room.runtime)
27 | kapt(libs.room.compiler)
28 | implementation(libs.room.ktx)
29 | }
--------------------------------------------------------------------------------
/core/database/dao/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/core/database/dao/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | `android-library`
3 | `kotlin-android`
4 | kotlin(Plugins.KAPT)
5 | }
6 |
7 | apply()
8 |
9 | android {
10 | namespace = "com.msoula.noteappclean.core.database.dao"
11 | }
12 |
13 | dependencies {
14 | // Core
15 | implementation(libs.runtime)
16 |
17 | // Room
18 | api(libs.room.runtime)
19 | implementation(libs.room.ktx)
20 | kapt(libs.room.compiler)
21 | }
--------------------------------------------------------------------------------
/core/database/dao/src/main/java/com/msoula/noteappclean/core/database/dao/NoteDAO.kt:
--------------------------------------------------------------------------------
1 | package com.msoula.noteappclean.core.database.dao
2 |
3 | import androidx.room.Dao
4 | import androidx.room.Query
5 | import androidx.room.Upsert
6 | import com.msoula.noteappclean.core.database.dao.models.NoteEntityModel
7 | import kotlinx.coroutines.flow.Flow
8 |
9 | @Dao
10 | interface NoteDAO {
11 | @Query("SELECT * FROM notes")
12 | fun observeNotes(): Flow>
13 |
14 | @Upsert
15 | suspend fun upsertNote(note: NoteEntityModel)
16 |
17 | @Query("DELETE FROM notes WHERE id = :noteId")
18 | suspend fun deleteNote(noteId: Long)
19 |
20 | @Query("SELECT * FROM notes WHERE id = :noteId")
21 | suspend fun fetchNoteByNoteId(noteId: Long): NoteEntityModel
22 | }
--------------------------------------------------------------------------------
/core/database/dao/src/main/java/com/msoula/noteappclean/core/database/dao/models/NoteEntityModel.kt:
--------------------------------------------------------------------------------
1 | package com.msoula.noteappclean.core.database.dao.models
2 |
3 | import androidx.room.Entity
4 | import androidx.room.PrimaryKey
5 |
6 | @Entity(tableName = "notes")
7 | data class NoteEntityModel(
8 | @PrimaryKey(autoGenerate = true) val id: Long,
9 | val title: String,
10 | val description: String
11 | )
--------------------------------------------------------------------------------
/core/database/src/main/java/com/msoula/noteappclean/core/database/NoteAppCleanDatabase.kt:
--------------------------------------------------------------------------------
1 | package com.msoula.noteappclean.core.database
2 |
3 | import androidx.room.Database
4 | import androidx.room.RoomDatabase
5 | import com.msoula.noteappclean.core.database.dao.NoteDAO
6 | import com.msoula.noteappclean.core.database.dao.models.NoteEntityModel
7 |
8 | @Database(entities = [NoteEntityModel::class], version = 1)
9 | abstract class NoteAppCleanDatabase : RoomDatabase() {
10 | abstract fun noteDAO(): NoteDAO
11 | }
--------------------------------------------------------------------------------
/core/database/src/main/java/com/msoula/noteappclean/core/database/di/DatabaseModule.kt:
--------------------------------------------------------------------------------
1 | package com.msoula.noteappclean.core.database.di
2 |
3 | import android.content.Context
4 | import androidx.room.Room
5 | import com.msoula.noteappclean.core.database.NoteAppCleanDatabase
6 | import com.msoula.noteappclean.core.database.dao.NoteDAO
7 | import dagger.Module
8 | import dagger.Provides
9 | import dagger.hilt.InstallIn
10 | import dagger.hilt.android.qualifiers.ApplicationContext
11 | import dagger.hilt.components.SingletonComponent
12 | import javax.inject.Singleton
13 |
14 | @Module
15 | @InstallIn(SingletonComponent::class)
16 | object DatabaseModule {
17 |
18 | @Provides
19 | @Singleton
20 | fun provideDatabase(
21 | @ApplicationContext context: Context
22 | ): NoteAppCleanDatabase =
23 | Room.databaseBuilder(
24 | context,
25 | NoteAppCleanDatabase::class.java,
26 | "database-clean"
27 | )
28 | .build()
29 |
30 | @Provides
31 | fun providesNoteDAO(database: NoteAppCleanDatabase): NoteDAO = database.noteDAO()
32 | }
--------------------------------------------------------------------------------
/core/di/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/core/di/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | `android-library`
3 | `kotlin-android`
4 | id(Plugins.DAGGER_HILT)
5 | kotlin(Plugins.KAPT)
6 | }
7 |
8 | apply()
9 |
10 | android {
11 | namespace = "com.msoula.noteappclean.core.di"
12 | }
13 |
14 | dependencies {
15 | // Core
16 | implementation(libs.runtime)
17 |
18 | // Hilt
19 | implementation(libs.hilt.android)
20 | kapt(libs.hilt.compiler)
21 |
22 | // Navigation
23 | implementation(libs.navigation.ui.ktx)
24 | }
--------------------------------------------------------------------------------
/core/di/src/main/java/com/msoula/noteappclean/core/di/modules/NavigationModule.kt:
--------------------------------------------------------------------------------
1 | package com.msoula.noteappclean.core.di.modules
2 |
3 | import com.msoula.noteappclean.core.di.navigation.Navigator
4 | import com.msoula.noteappclean.core.di.navigation.NavigatorImpl
5 | import dagger.Module
6 | import dagger.Provides
7 | import dagger.hilt.InstallIn
8 | import dagger.hilt.components.SingletonComponent
9 | import javax.inject.Singleton
10 |
11 | @Module
12 | @InstallIn(SingletonComponent::class)
13 | object NavigationModule {
14 |
15 | @Provides
16 | @Singleton
17 | fun provideNavigator(): Navigator = NavigatorImpl()
18 | }
--------------------------------------------------------------------------------
/core/di/src/main/java/com/msoula/noteappclean/core/di/navigation/NavigationRoute.kt:
--------------------------------------------------------------------------------
1 | package com.msoula.noteappclean.core.di.navigation
2 |
3 | interface NavigationRoute {
4 | fun buildRoute(): String
5 | }
--------------------------------------------------------------------------------
/core/di/src/main/java/com/msoula/noteappclean/core/di/navigation/Navigator.kt:
--------------------------------------------------------------------------------
1 | package com.msoula.noteappclean.core.di.navigation
2 |
3 | import androidx.navigation.NavController
4 |
5 | interface Navigator {
6 | fun setController(navController: NavController)
7 | fun navigate(route: NavigationRoute)
8 | fun popBackStack()
9 | fun clear()
10 | }
--------------------------------------------------------------------------------
/core/di/src/main/java/com/msoula/noteappclean/core/di/navigation/NavigatorImpl.kt:
--------------------------------------------------------------------------------
1 | package com.msoula.noteappclean.core.di.navigation
2 |
3 | import androidx.navigation.NavController
4 | import javax.inject.Inject
5 |
6 | class NavigatorImpl @Inject constructor() : Navigator {
7 | private var navController: NavController? = null
8 |
9 | override fun setController(navController: NavController) {
10 | this.navController = navController
11 | }
12 |
13 | override fun navigate(route: NavigationRoute) {
14 | navController?.navigate(route.buildRoute())
15 | }
16 |
17 | override fun popBackStack() {
18 | navController?.popBackStack()
19 | }
20 |
21 | override fun clear() {
22 | navController = null
23 | }
24 | }
--------------------------------------------------------------------------------
/core/di/src/main/java/com/msoula/noteappclean/core/di/navigation/ScreenDefinition.kt:
--------------------------------------------------------------------------------
1 | package com.msoula.noteappclean.core.di.navigation
2 |
3 | import androidx.lifecycle.SavedStateHandle
4 |
5 | object AppScreenRoute: NavigationRoute {
6 | override fun buildRoute(): String = ROUTE
7 | private const val ROOT = "app_screen"
8 | const val ROUTE = ROOT
9 | }
10 |
11 | object NoteFormScreenRoute : NavigationRoute {
12 | override fun buildRoute(): String = ROUTE
13 |
14 | private const val ROOT = "note_form_screen"
15 | const val ROUTE = ROOT
16 | }
17 |
18 | data class NoteDetailScreenRoute(val id: String) : NavigationRoute {
19 | constructor(savedStateHandle: SavedStateHandle) : this(
20 | id = requireNotNull(savedStateHandle.get(inputArg))
21 | )
22 |
23 | override fun buildRoute(): String = "$root/$id"
24 |
25 | companion object {
26 | private const val root = "note_detail_screen"
27 | private const val inputArg = "input"
28 |
29 | const val route = "$root/{$inputArg}"
30 | }
31 | }
--------------------------------------------------------------------------------
/feature/addnote/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/feature/addnote/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | `android-library`
3 | `kotlin-android`
4 | }
5 |
6 | apply()
7 |
8 | android {
9 | namespace = "com.msoula.noteappclean.feature.addnote"
10 | }
11 |
12 | dependencies {
13 | // Core
14 | implementation(libs.runtime)
15 | }
--------------------------------------------------------------------------------
/feature/addnote/domain/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/feature/addnote/domain/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | `android-library`
3 | `kotlin-android`
4 | id(Plugins.DAGGER_HILT)
5 | kotlin(Plugins.KAPT)
6 | }
7 |
8 | apply()
9 |
10 | android {
11 | namespace = "com.msoula.noteappclean.feature.addnote.domain"
12 | }
13 |
14 | dependencies {
15 | // Core
16 | implementation(libs.runtime)
17 |
18 | // Hilt
19 | implementation(libs.hilt.android)
20 | kapt(libs.hilt.compiler)
21 |
22 | // Modules
23 | implementation(project(Modules.COMMON))
24 | }
--------------------------------------------------------------------------------
/feature/addnote/domain/src/main/java/com/msoula/noteappclean/feature/addnote/domain/di/AddNoteDomainModule.kt:
--------------------------------------------------------------------------------
1 | package com.msoula.noteappclean.feature.addnote.domain.di
2 |
3 | import com.msoula.noteappclean.feature.addnote.domain.use_cases.ValidateDescriptionUseCase
4 | import com.msoula.noteappclean.feature.addnote.domain.use_cases.ValidateTitleUseCase
5 | import dagger.Module
6 | import dagger.Provides
7 | import dagger.hilt.InstallIn
8 | import dagger.hilt.components.SingletonComponent
9 |
10 | @Module
11 | @InstallIn(SingletonComponent::class)
12 | object AddNoteDomainModule {
13 |
14 | @Provides
15 | fun provideValidateDescriptionUseCase(): ValidateDescriptionUseCase =
16 | ValidateDescriptionUseCase()
17 |
18 | @Provides
19 | fun provideValidateTitleUseCase(): ValidateTitleUseCase =
20 | ValidateTitleUseCase()
21 | }
--------------------------------------------------------------------------------
/feature/addnote/domain/src/main/java/com/msoula/noteappclean/feature/addnote/domain/use_cases/ValidateDescriptionUseCase.kt:
--------------------------------------------------------------------------------
1 | package com.msoula.noteappclean.feature.addnote.domain.use_cases
2 |
3 | import com.msoula.noteappclean.core.common.ValidationResult
4 |
5 | class ValidateDescriptionUseCase {
6 | fun execute(description: String, errorMessage: String): ValidationResult {
7 | if (description.isEmpty()) {
8 | return ValidationResult(false, errorMessage)
9 | }
10 |
11 | return ValidationResult(true)
12 | }
13 | }
--------------------------------------------------------------------------------
/feature/addnote/domain/src/main/java/com/msoula/noteappclean/feature/addnote/domain/use_cases/ValidateTitleUseCase.kt:
--------------------------------------------------------------------------------
1 | package com.msoula.noteappclean.feature.addnote.domain.use_cases
2 |
3 | import com.msoula.noteappclean.core.common.ValidationResult
4 |
5 | class ValidateTitleUseCase {
6 | fun execute(title: String, errorMessage: String): ValidationResult {
7 | if (title.isEmpty()) {
8 | return ValidationResult(false, errorMessage)
9 | }
10 |
11 | return ValidationResult(true)
12 | }
13 | }
--------------------------------------------------------------------------------
/feature/addnote/presentation/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/feature/addnote/presentation/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | `android-library`
3 | `kotlin-android`
4 | id(Plugins.DAGGER_HILT)
5 | kotlin(Plugins.KAPT)
6 | }
7 |
8 | apply()
9 |
10 | android {
11 | namespace = "com.msoula.noteappclean.feature.addnote.presentation"
12 | }
13 |
14 | dependencies {
15 | // Compose
16 | implementation(libs.androidx.activity.compose)
17 | implementation(libs.material3)
18 | implementation(libs.androidx.ui.tooling)
19 |
20 | // Core
21 | implementation(libs.runtime)
22 |
23 | // Hilt
24 | implementation(libs.hilt.android)
25 | kapt(libs.hilt.compiler)
26 |
27 | // Modules
28 | implementation(project(Modules.ADD_NOTE_DOMAIN))
29 | implementation(project(Modules.COMMON))
30 | implementation(project(Modules.DI))
31 | implementation(project(Modules.NOTE_DOMAIN))
32 | implementation(project(Modules.NOTE_DATA))
33 | }
--------------------------------------------------------------------------------
/feature/addnote/presentation/src/main/java/com/msoula/noteappclean/feature/addnote/presentation/AddNoteFormScreen.kt:
--------------------------------------------------------------------------------
1 | package com.msoula.noteappclean.feature.addnote.presentation
2 |
3 | import androidx.compose.foundation.layout.Column
4 | import androidx.compose.foundation.layout.Spacer
5 | import androidx.compose.foundation.layout.fillMaxSize
6 | import androidx.compose.foundation.layout.fillMaxWidth
7 | import androidx.compose.foundation.layout.height
8 | import androidx.compose.foundation.layout.padding
9 | import androidx.compose.material3.Button
10 | import androidx.compose.material3.Scaffold
11 | import androidx.compose.material3.Text
12 | import androidx.compose.material3.TextField
13 | import androidx.compose.runtime.Composable
14 | import androidx.compose.ui.Modifier
15 | import androidx.compose.ui.text.style.TextAlign
16 | import androidx.compose.ui.unit.dp
17 | import com.msoula.noteappclean.feature.addnote.presentation.models.AddNoteFormEvent
18 | import com.msoula.noteappclean.feature.addnote.presentation.models.AddNoteFormUiState
19 |
20 | @Composable
21 | fun AddNoteFormScreen(
22 | modifier: Modifier = Modifier,
23 | state: AddNoteFormUiState,
24 | onUiEvent: (event: AddNoteFormEvent) -> Unit
25 | ) {
26 | Scaffold(modifier = modifier) { paddingValues ->
27 | Column(
28 | modifier = Modifier
29 | .padding(paddingValues)
30 | .fillMaxSize()
31 | .padding(16.dp)
32 | ) {
33 | TextField(
34 | value = state.noteTitle,
35 | onValueChange = { onUiEvent(AddNoteFormEvent.OnTitleChanged(it)) },
36 | placeholder = { Text(text = "Title") },
37 | modifier = Modifier.fillMaxWidth()
38 | )
39 |
40 | Spacer(modifier = Modifier.height(8.dp))
41 |
42 | TextField(
43 | value = state.noteDescription,
44 | onValueChange = { onUiEvent(AddNoteFormEvent.OnDescriptionChanged(it)) },
45 | placeholder = { Text(text = "Description") },
46 | modifier = Modifier.fillMaxWidth()
47 | )
48 |
49 | Spacer(modifier = Modifier.height(16.dp))
50 |
51 | Button(
52 | onClick = { onUiEvent(AddNoteFormEvent.OnSubmitNote) },
53 | enabled = state.enableSubmit
54 | ) {
55 | Text(
56 | text = "ADD NOTE",
57 | modifier = Modifier.fillMaxWidth(),
58 | textAlign = TextAlign.Center
59 | )
60 | }
61 | }
62 | }
63 | }
--------------------------------------------------------------------------------
/feature/addnote/presentation/src/main/java/com/msoula/noteappclean/feature/addnote/presentation/AddNoteViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.msoula.noteappclean.feature.addnote.presentation
2 |
3 | import android.util.Log
4 | import androidx.lifecycle.ViewModel
5 | import androidx.lifecycle.viewModelScope
6 | import com.msoula.noteappclean.core.common.Result
7 | import com.msoula.noteappclean.core.common.StringResourceProvider
8 | import com.msoula.noteappclean.core.di.navigation.AppScreenRoute
9 | import com.msoula.noteappclean.core.di.navigation.Navigator
10 | import com.msoula.noteappclean.feature.addnote.domain.use_cases.ValidateDescriptionUseCase
11 | import com.msoula.noteappclean.feature.addnote.domain.use_cases.ValidateTitleUseCase
12 | import com.msoula.noteappclean.feature.addnote.presentation.models.AddNoteFormEvent
13 | import com.msoula.noteappclean.feature.addnote.presentation.models.AddNoteFormUiState
14 | import com.msoula.noteappclean.feature.notes.domain.models.NoteDomainModel
15 | import com.msoula.noteappclean.feature.notes.domain.use_cases.InsertNoteUseCase
16 | import dagger.hilt.android.lifecycle.HiltViewModel
17 | import kotlinx.coroutines.Dispatchers
18 | import kotlinx.coroutines.flow.MutableStateFlow
19 | import kotlinx.coroutines.flow.asStateFlow
20 | import kotlinx.coroutines.flow.update
21 | import kotlinx.coroutines.launch
22 | import kotlinx.coroutines.withContext
23 | import javax.inject.Inject
24 |
25 | @HiltViewModel
26 | class AddNoteViewModel @Inject constructor(
27 | private val insertNoteUseCase: InsertNoteUseCase,
28 | private val validateTitleUseCase: ValidateTitleUseCase,
29 | private val validateDescriptionUseCase: ValidateDescriptionUseCase,
30 | private val resourceProvider: StringResourceProvider,
31 | private val navigator: Navigator
32 | ) : ViewModel() {
33 |
34 | private val _addNoteState = MutableStateFlow(AddNoteFormUiState())
35 | val addNoteState = _addNoteState.asStateFlow()
36 |
37 | fun onUiEvent(event: AddNoteFormEvent) {
38 | when (event) {
39 | is AddNoteFormEvent.OnTitleChanged -> {
40 | _addNoteState.update { it.copy(noteTitle = event.title) }
41 | validateInput()
42 | }
43 |
44 | is AddNoteFormEvent.OnDescriptionChanged -> {
45 | _addNoteState.update { it.copy(noteDescription = event.description) }
46 | validateInput()
47 | }
48 |
49 | AddNoteFormEvent.OnSubmitNote -> {
50 | saveNote()
51 | }
52 | }
53 | }
54 |
55 | private fun validateInput() {
56 | val titleResult =
57 | validateTitleUseCase.execute(
58 | addNoteState.value.noteTitle,
59 | resourceProvider.getString(R.string.title_error)
60 | )
61 | val descriptionResult =
62 | validateDescriptionUseCase.execute(
63 | addNoteState.value.noteDescription,
64 | resourceProvider.getString(R.string.description_error)
65 | )
66 |
67 | val error = listOf(titleResult, descriptionResult).any { !it.successful }
68 |
69 | _addNoteState.update { it.copy(enableSubmit = !error) }
70 | }
71 |
72 | private fun saveNote() {
73 | viewModelScope.launch(Dispatchers.IO) {
74 | when (val result = insertNoteUseCase(
75 | NoteDomainModel(
76 | 0,
77 | addNoteState.value.noteTitle,
78 | addNoteState.value.noteDescription
79 | )
80 | )) {
81 | is Result.Success -> {
82 | withContext(Dispatchers.Main) {
83 | navigator.navigate(AppScreenRoute)
84 | }
85 | }
86 |
87 | is Result.Failure -> Log.e("NotApp", result.error.message)
88 | }
89 | }
90 | }
91 | }
--------------------------------------------------------------------------------
/feature/addnote/presentation/src/main/java/com/msoula/noteappclean/feature/addnote/presentation/models/AddNoteFormEvent.kt:
--------------------------------------------------------------------------------
1 | package com.msoula.noteappclean.feature.addnote.presentation.models
2 |
3 | sealed interface AddNoteFormEvent {
4 | data class OnTitleChanged(val title: String) : AddNoteFormEvent
5 | data class OnDescriptionChanged(val description: String) : AddNoteFormEvent
6 | data object OnSubmitNote : AddNoteFormEvent
7 | }
--------------------------------------------------------------------------------
/feature/addnote/presentation/src/main/java/com/msoula/noteappclean/feature/addnote/presentation/models/AddNoteFormUiState.kt:
--------------------------------------------------------------------------------
1 | package com.msoula.noteappclean.feature.addnote.presentation.models
2 |
3 | data class AddNoteFormUiState(
4 | val noteId: Long? = null,
5 | val noteTitle: String = "",
6 | val noteTitleError: Int? = null,
7 | val noteDescription: String = "",
8 | val noteDescriptionError: Int? = null,
9 | val enableSubmit: Boolean = false
10 | )
11 |
--------------------------------------------------------------------------------
/feature/addnote/presentation/src/main/res/values-en-rUS/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Title should not be empty
4 | Description should not be empty
5 |
--------------------------------------------------------------------------------
/feature/addnote/presentation/src/main/res/values/values.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Le titre ne peut pas être vide
4 | La description ne peut pas être vide
5 |
--------------------------------------------------------------------------------
/feature/notedetail/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/feature/notedetail/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | id("java-library")
3 | id("org.jetbrains.kotlin.jvm")
4 | }
5 |
6 | java {
7 | sourceCompatibility = JavaVersion.VERSION_17
8 | targetCompatibility = JavaVersion.VERSION_17
9 | }
--------------------------------------------------------------------------------
/feature/notedetail/presentation/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/feature/notedetail/presentation/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | `android-library`
3 | `kotlin-android`
4 | id(Plugins.DAGGER_HILT)
5 | kotlin(Plugins.KAPT)
6 | }
7 |
8 | apply()
9 |
10 | android {
11 | namespace = "com.msoula.noteappclean.feature.notedetail.presentation"
12 | }
13 |
14 | dependencies {
15 | // Compose
16 | implementation(libs.androidx.activity.compose)
17 | implementation(libs.material3)
18 | implementation(libs.androidx.ui.tooling)
19 |
20 | // Core
21 | implementation(libs.runtime)
22 |
23 | // Hilt
24 | implementation(libs.hilt.android)
25 | kapt(libs.hilt.compiler)
26 |
27 | // Modules
28 | implementation(project(Modules.COMMON))
29 | implementation(project(Modules.DI))
30 | implementation(project(Modules.NOTE_DOMAIN))
31 | }
--------------------------------------------------------------------------------
/feature/notedetail/presentation/src/main/java/com/msoula/noteappclean/feature/notedetail/presentation/NoteDetailScreen.kt:
--------------------------------------------------------------------------------
1 | package com.msoula.noteappclean.feature.notedetail.presentation
2 |
3 | import androidx.compose.foundation.layout.Column
4 | import androidx.compose.foundation.layout.Spacer
5 | import androidx.compose.foundation.layout.height
6 | import androidx.compose.material3.Text
7 | import androidx.compose.runtime.Composable
8 | import androidx.compose.ui.Modifier
9 | import androidx.compose.ui.unit.dp
10 | import androidx.compose.ui.unit.sp
11 | import com.msoula.noteappclean.feature.notedetail.presentation.models.NoteDetailUiState
12 |
13 | @Composable
14 | fun NoteDetailScreen(modifier: Modifier = Modifier, state: NoteDetailUiState) {
15 | Column(modifier = modifier) {
16 | Text(text = state.title, fontSize = 40.sp)
17 | Spacer(modifier = Modifier.height(16.dp))
18 | Text(text = state.description, fontSize = 16.sp)
19 | }
20 | }
--------------------------------------------------------------------------------
/feature/notedetail/presentation/src/main/java/com/msoula/noteappclean/feature/notedetail/presentation/NoteDetailViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.msoula.noteappclean.feature.notedetail.presentation
2 |
3 | import android.util.Log
4 | import androidx.lifecycle.SavedStateHandle
5 | import androidx.lifecycle.ViewModel
6 | import androidx.lifecycle.viewModelScope
7 | import com.msoula.noteappclean.core.common.Result
8 | import com.msoula.noteappclean.core.di.navigation.NoteDetailScreenRoute
9 | import com.msoula.noteappclean.feature.notedetail.presentation.models.NoteDetailUiState
10 | import com.msoula.noteappclean.feature.notes.domain.use_cases.FetchNoteByIdUseCase
11 | import dagger.hilt.android.lifecycle.HiltViewModel
12 | import kotlinx.coroutines.Dispatchers
13 | import kotlinx.coroutines.flow.MutableStateFlow
14 | import kotlinx.coroutines.flow.asStateFlow
15 | import kotlinx.coroutines.flow.update
16 | import kotlinx.coroutines.launch
17 | import javax.inject.Inject
18 |
19 | @HiltViewModel
20 | class NoteDetailViewModel @Inject constructor(
21 | savedStateHandle: SavedStateHandle,
22 | private val fetchNoteByIdUseCase: FetchNoteByIdUseCase
23 | ) : ViewModel() {
24 |
25 | private val _noteDetailState = MutableStateFlow(NoteDetailUiState())
26 | val noteDetailState = _noteDetailState.asStateFlow()
27 |
28 | private val route = NoteDetailScreenRoute(savedStateHandle)
29 | private val savedId: Long = route.id.toLong()
30 |
31 | init {
32 | fetchNoteInDb()
33 | }
34 |
35 | private fun fetchNoteInDb() {
36 | viewModelScope.launch(Dispatchers.IO) {
37 | when (val note = fetchNoteByIdUseCase(savedId)) {
38 | is Result.Success -> {
39 | _noteDetailState.update { state ->
40 | state.copy(
41 | title = note.data.title,
42 | description = note.data.description
43 | )
44 | }
45 | }
46 |
47 | is Result.Failure -> {
48 | Log.e("NoteAppClean", note.error.message)
49 | }
50 | }
51 |
52 | }
53 | }
54 | }
--------------------------------------------------------------------------------
/feature/notedetail/presentation/src/main/java/com/msoula/noteappclean/feature/notedetail/presentation/models/NoteDetailUiState.kt:
--------------------------------------------------------------------------------
1 | package com.msoula.noteappclean.feature.notedetail.presentation.models
2 |
3 | data class NoteDetailUiState(
4 | val id: Long = 0L,
5 | val title: String = "",
6 | val description: String = ""
7 | )
--------------------------------------------------------------------------------
/feature/notes/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/feature/notes/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | `android-library`
3 | `kotlin-android`
4 | }
5 |
6 | apply()
7 |
8 | android {
9 | namespace = "com.msoula.noteappclean.feature.notes"
10 | }
11 |
12 | dependencies {
13 | // Core
14 | implementation(libs.runtime)
15 | }
--------------------------------------------------------------------------------
/feature/notes/data/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/feature/notes/data/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | `android-library`
3 | `kotlin-android`
4 | id(Plugins.DAGGER_HILT)
5 | kotlin(Plugins.KAPT)
6 | }
7 |
8 | apply()
9 |
10 | android {
11 | namespace = "com.msoula.noteappclean.feature.notes.data"
12 | }
13 |
14 | dependencies {
15 | // Core
16 | implementation(libs.androidx.core.ktx)
17 | implementation(libs.runtime)
18 |
19 | // Hilt
20 | implementation(libs.hilt.android)
21 | kapt(libs.hilt.compiler)
22 |
23 | // Modules
24 | implementation(project(Modules.COMMON))
25 | implementation(project(Modules.DAO))
26 | implementation(project(Modules.NOTE_DOMAIN))
27 | }
--------------------------------------------------------------------------------
/feature/notes/data/src/main/java/com/msoula/noteappclean/feature/notes/data/data_sources/local/NoteLocalDataSourceImpl.kt:
--------------------------------------------------------------------------------
1 | package com.msoula.noteappclean.feature.notes.data.data_sources.local
2 |
3 | import com.msoula.noteappclean.core.common.Result
4 | import com.msoula.noteappclean.core.database.dao.NoteDAO
5 | import com.msoula.noteappclean.feature.notes.data.data_sources.local.mappers.toNoteDomainModel
6 | import com.msoula.noteappclean.feature.notes.data.data_sources.local.mappers.toNoteEntityModel
7 | import com.msoula.noteappclean.feature.notes.domain.data_sources.NoteLocalDataSource
8 | import com.msoula.noteappclean.feature.notes.domain.errors.FetchNoteByIdError
9 | import com.msoula.noteappclean.feature.notes.domain.errors.InsertNoteError
10 | import com.msoula.noteappclean.feature.notes.domain.models.NoteDomainModel
11 | import kotlinx.coroutines.flow.Flow
12 | import kotlinx.coroutines.flow.map
13 | import kotlinx.coroutines.flow.onEmpty
14 |
15 | class NoteLocalDataSourceImpl(
16 | private val noteDAO: NoteDAO
17 | ) : NoteLocalDataSource {
18 |
19 | override fun observeNotes(): Flow> {
20 | return noteDAO.observeNotes()
21 | .map { list ->
22 | list.map { noteEntityModel -> noteEntityModel.toNoteDomainModel() }
23 | }
24 | .onEmpty {
25 | return@onEmpty
26 | }
27 | }
28 |
29 | override suspend fun insertNote(note: NoteDomainModel): Result {
30 | return try {
31 | noteDAO.upsertNote(note.toNoteEntityModel())
32 | Result.Success(true)
33 | } catch (exception: Exception) {
34 | exception.printStackTrace()
35 | Result.Failure(
36 | InsertNoteError(
37 | exception.message ?: "Error on upserting note: $exception"
38 | )
39 | )
40 | }
41 | }
42 |
43 | override suspend fun fetchNoteById(id: Long): Result {
44 | return try {
45 | val note = noteDAO.fetchNoteByNoteId(id)
46 | Result.Success(note.toNoteDomainModel())
47 | } catch (exception: Exception) {
48 | exception.printStackTrace()
49 | Result.Failure(
50 | FetchNoteByIdError(
51 | exception.message ?: "Error on fetching note with id $id - $exception"
52 | )
53 | )
54 | }
55 | }
56 | }
--------------------------------------------------------------------------------
/feature/notes/data/src/main/java/com/msoula/noteappclean/feature/notes/data/data_sources/local/mappers/LocalMappers.kt:
--------------------------------------------------------------------------------
1 | package com.msoula.noteappclean.feature.notes.data.data_sources.local.mappers
2 |
3 | import com.msoula.noteappclean.core.database.dao.models.NoteEntityModel
4 | import com.msoula.noteappclean.feature.notes.domain.models.NoteDomainModel
5 |
6 | fun NoteDomainModel.toNoteEntityModel(): NoteEntityModel {
7 | return NoteEntityModel(
8 | id = this.id,
9 | title = this.title,
10 | description = this.description
11 | )
12 | }
13 |
14 | fun NoteEntityModel.toNoteDomainModel(): NoteDomainModel {
15 | return NoteDomainModel(
16 | id = this.id,
17 | title = this.title,
18 | description = this.description
19 | )
20 | }
--------------------------------------------------------------------------------
/feature/notes/data/src/main/java/com/msoula/noteappclean/feature/notes/data/di/NoteDataSourceModule.kt:
--------------------------------------------------------------------------------
1 | package com.msoula.noteappclean.feature.notes.data.di
2 |
3 | import com.msoula.noteappclean.core.database.dao.NoteDAO
4 | import com.msoula.noteappclean.feature.notes.data.data_sources.local.NoteLocalDataSourceImpl
5 | import com.msoula.noteappclean.feature.notes.domain.data_sources.NoteLocalDataSource
6 | import dagger.Module
7 | import dagger.Provides
8 | import dagger.hilt.InstallIn
9 | import dagger.hilt.components.SingletonComponent
10 | import javax.inject.Singleton
11 |
12 | @Module
13 | @InstallIn(SingletonComponent::class)
14 | object NoteDataSourceModule {
15 |
16 | @Provides
17 | @Singleton
18 | fun provideNoteLocalDataSource(noteDAO: NoteDAO): NoteLocalDataSource =
19 | NoteLocalDataSourceImpl(noteDAO)
20 | }
--------------------------------------------------------------------------------
/feature/notes/domain/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/feature/notes/domain/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | `android-library`
3 | `kotlin-android`
4 | id(Plugins.DAGGER_HILT)
5 | kotlin(Plugins.KAPT)
6 | }
7 |
8 | apply()
9 |
10 | android {
11 | namespace = "com.msoula.noteappclean.feature.notes.domain"
12 | }
13 |
14 | dependencies {
15 | // Core
16 | implementation(libs.androidx.core.ktx)
17 | implementation(libs.runtime)
18 |
19 | // Hilt
20 | implementation(libs.hilt.android)
21 | kapt(libs.hilt.compiler)
22 |
23 | // Modules
24 | implementation(project(Modules.COMMON))
25 | }
--------------------------------------------------------------------------------
/feature/notes/domain/src/main/java/com/msoula/noteappclean/feature/notes/domain/data_sources/NoteLocalDataSource.kt:
--------------------------------------------------------------------------------
1 | package com.msoula.noteappclean.feature.notes.domain.data_sources
2 |
3 | import com.msoula.noteappclean.core.common.Result
4 | import com.msoula.noteappclean.feature.notes.domain.models.NoteDomainModel
5 | import kotlinx.coroutines.flow.Flow
6 |
7 | interface NoteLocalDataSource {
8 | fun observeNotes(): Flow>
9 | suspend fun insertNote(note: NoteDomainModel): Result
10 | suspend fun fetchNoteById(id: Long): Result
11 | }
--------------------------------------------------------------------------------
/feature/notes/domain/src/main/java/com/msoula/noteappclean/feature/notes/domain/di/NoteDomainModule.kt:
--------------------------------------------------------------------------------
1 | package com.msoula.noteappclean.feature.notes.domain.di
2 |
3 | import com.msoula.noteappclean.feature.notes.domain.data_sources.NoteLocalDataSource
4 | import com.msoula.noteappclean.feature.notes.domain.repositories.NoteRepository
5 | import com.msoula.noteappclean.feature.notes.domain.use_cases.FetchNoteByIdUseCase
6 | import com.msoula.noteappclean.feature.notes.domain.use_cases.InsertNoteUseCase
7 | import com.msoula.noteappclean.feature.notes.domain.use_cases.ObserveNotesUseCase
8 | import dagger.Module
9 | import dagger.Provides
10 | import dagger.hilt.InstallIn
11 | import dagger.hilt.components.SingletonComponent
12 | import javax.inject.Singleton
13 |
14 | @Module
15 | @InstallIn(SingletonComponent::class)
16 | object NoteDomainModule {
17 |
18 | @Provides
19 | @Singleton
20 | fun provideNoteRepository(
21 | noteLocalDataSource: NoteLocalDataSource
22 | ): NoteRepository {
23 | return NoteRepository(noteLocalDataSource)
24 | }
25 |
26 | @Provides
27 | fun provideInsertNoteUseCase(noteRepository: NoteRepository): InsertNoteUseCase {
28 | return InsertNoteUseCase(noteRepository)
29 | }
30 |
31 | @Provides
32 | fun provideObserveNotesUseCase(noteRepository: NoteRepository): ObserveNotesUseCase {
33 | return ObserveNotesUseCase(noteRepository)
34 | }
35 |
36 | @Provides
37 | fun provideFetchNoteByIdUseCase(noteRepository: NoteRepository): FetchNoteByIdUseCase {
38 | return FetchNoteByIdUseCase(noteRepository)
39 | }
40 | }
--------------------------------------------------------------------------------
/feature/notes/domain/src/main/java/com/msoula/noteappclean/feature/notes/domain/errors/InsertNoteError.kt:
--------------------------------------------------------------------------------
1 | package com.msoula.noteappclean.feature.notes.domain.errors
2 |
3 | import com.msoula.noteappclean.core.common.AppError
4 |
5 | class InsertNoteError(override val message: String) : AppError
6 | class FetchNoteByIdError(override val message: String) : AppError
--------------------------------------------------------------------------------
/feature/notes/domain/src/main/java/com/msoula/noteappclean/feature/notes/domain/models/NoteDomainModel.kt:
--------------------------------------------------------------------------------
1 | package com.msoula.noteappclean.feature.notes.domain.models
2 |
3 | data class NoteDomainModel(
4 | val id: Long,
5 | val title: String,
6 | val description: String
7 | ) {
8 | companion object {
9 | const val DEFAULT_ID: Long = -1L
10 | const val DEFAULT_TITLE: String = ""
11 | const val DEFAULT_DESCRIPTION: String = ""
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/feature/notes/domain/src/main/java/com/msoula/noteappclean/feature/notes/domain/repositories/NoteRepository.kt:
--------------------------------------------------------------------------------
1 | package com.msoula.noteappclean.feature.notes.domain.repositories
2 |
3 | import com.msoula.noteappclean.core.common.Result
4 | import com.msoula.noteappclean.feature.notes.domain.data_sources.NoteLocalDataSource
5 | import com.msoula.noteappclean.feature.notes.domain.models.NoteDomainModel
6 | import kotlinx.coroutines.flow.Flow
7 |
8 | class NoteRepository(
9 | private val noteLocalDataSource: NoteLocalDataSource
10 | ) {
11 |
12 | fun observeNotes(): Flow> {
13 | return noteLocalDataSource.observeNotes()
14 | }
15 |
16 | suspend fun insertNote(note: NoteDomainModel): Result {
17 | return noteLocalDataSource.insertNote(note)
18 | }
19 |
20 | suspend fun fetchNoteById(id: Long): Result {
21 | return noteLocalDataSource.fetchNoteById(id)
22 | }
23 | }
--------------------------------------------------------------------------------
/feature/notes/domain/src/main/java/com/msoula/noteappclean/feature/notes/domain/use_cases/FetchNoteByIdUseCase.kt:
--------------------------------------------------------------------------------
1 | package com.msoula.noteappclean.feature.notes.domain.use_cases
2 |
3 | import com.msoula.noteappclean.feature.notes.domain.repositories.NoteRepository
4 |
5 | class FetchNoteByIdUseCase(private val noteRepository: NoteRepository) {
6 |
7 | suspend operator fun invoke(id: Long) = noteRepository.fetchNoteById(id)
8 | }
--------------------------------------------------------------------------------
/feature/notes/domain/src/main/java/com/msoula/noteappclean/feature/notes/domain/use_cases/InsertNoteUseCase.kt:
--------------------------------------------------------------------------------
1 | package com.msoula.noteappclean.feature.notes.domain.use_cases
2 |
3 | import com.msoula.noteappclean.core.common.Result
4 | import com.msoula.noteappclean.feature.notes.domain.models.NoteDomainModel
5 | import com.msoula.noteappclean.feature.notes.domain.repositories.NoteRepository
6 |
7 | class InsertNoteUseCase(
8 | private val noteRepository: NoteRepository
9 | ) {
10 | suspend operator fun invoke(note: NoteDomainModel): Result {
11 | return noteRepository.insertNote(note)
12 | }
13 | }
--------------------------------------------------------------------------------
/feature/notes/domain/src/main/java/com/msoula/noteappclean/feature/notes/domain/use_cases/ObserveNotesUseCase.kt:
--------------------------------------------------------------------------------
1 | package com.msoula.noteappclean.feature.notes.domain.use_cases
2 |
3 | import com.msoula.noteappclean.feature.notes.domain.models.NoteDomainModel
4 | import com.msoula.noteappclean.feature.notes.domain.repositories.NoteRepository
5 | import kotlinx.coroutines.flow.Flow
6 |
7 | class ObserveNotesUseCase(
8 | private val noteRepository: NoteRepository
9 | ) {
10 | operator fun invoke(): Flow> {
11 | return noteRepository.observeNotes()
12 | }
13 | }
--------------------------------------------------------------------------------
/feature/notes/presentation/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/feature/notes/presentation/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | `android-library`
3 | `kotlin-android`
4 | id(Plugins.DAGGER_HILT)
5 | kotlin(Plugins.KAPT)
6 | }
7 |
8 | apply()
9 |
10 | android {
11 | namespace = "com.msoula.noteappclean.feature.notes.presentation"
12 | }
13 |
14 | dependencies {
15 | // AndroidX
16 | implementation(libs.lifecycle.runtime.compose)
17 | implementation(libs.lifecycle.viewmodel.compose)
18 | implementation(libs.kotlinx.collections.immutable)
19 |
20 | // Compose
21 | implementation(libs.androidx.activity.compose)
22 | implementation(libs.material3)
23 | implementation(libs.androidx.ui.tooling)
24 |
25 | // Core
26 | implementation(libs.core.ktx)
27 | implementation(libs.runtime)
28 |
29 | // Hilt
30 | implementation(libs.hilt.android)
31 | kapt(libs.hilt.compiler)
32 |
33 | // Modules
34 | implementation(project(Modules.NOTE_DOMAIN))
35 | }
--------------------------------------------------------------------------------
/feature/notes/presentation/src/main/java/com/msoula/noteappclean/feature/notes/presentation/NoteScreen.kt:
--------------------------------------------------------------------------------
1 | package com.msoula.noteappclean.feature.notes.presentation
2 |
3 | import androidx.compose.foundation.layout.Column
4 | import androidx.compose.foundation.layout.Spacer
5 | import androidx.compose.foundation.layout.fillMaxSize
6 | import androidx.compose.foundation.layout.fillMaxWidth
7 | import androidx.compose.foundation.layout.height
8 | import androidx.compose.foundation.lazy.LazyColumn
9 | import androidx.compose.foundation.lazy.items
10 | import androidx.compose.material3.Text
11 | import androidx.compose.runtime.Composable
12 | import androidx.compose.ui.Modifier
13 | import androidx.compose.ui.text.style.TextAlign
14 | import androidx.compose.ui.unit.dp
15 | import androidx.compose.ui.unit.sp
16 | import com.msoula.noteappclean.feature.notes.presentation.components.NoteItem
17 | import com.msoula.noteappclean.feature.notes.presentation.models.NoteUiModel
18 |
19 | @Composable
20 | fun NoteScreen(
21 | modifier: Modifier = Modifier,
22 | notes: List,
23 | openNoteDetail: (id: Long) -> Unit
24 | ) {
25 | Column(modifier.fillMaxSize()) {
26 | Text(
27 | text = "Welcome to NoteApp - Clean Version",
28 | modifier = Modifier
29 | .fillMaxWidth(),
30 | textAlign = TextAlign.Center,
31 | fontSize = 18.sp
32 | )
33 |
34 | Spacer(modifier = Modifier.height(24.dp))
35 |
36 | LazyColumn(modifier = Modifier.fillMaxSize()) {
37 | items(
38 | items = notes
39 | ) { note ->
40 | NoteItem(title = note.title, id = note.id, openNoteDetail = openNoteDetail)
41 | }
42 | }
43 | }
44 | }
45 |
46 | @Composable
47 | fun EmptyNoteScreen(modifier: Modifier = Modifier) {
48 | Text(modifier = modifier, text = "No data found")
49 | }
--------------------------------------------------------------------------------
/feature/notes/presentation/src/main/java/com/msoula/noteappclean/feature/notes/presentation/NoteViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.msoula.noteappclean.feature.notes.presentation
2 |
3 | import androidx.lifecycle.ViewModel
4 | import androidx.lifecycle.viewModelScope
5 | import com.msoula.noteappclean.feature.notes.domain.use_cases.ObserveNotesUseCase
6 | import com.msoula.noteappclean.feature.notes.presentation.mappers.toNoteUiModel
7 | import com.msoula.noteappclean.feature.notes.presentation.models.NoteUiStateModel
8 | import dagger.hilt.android.lifecycle.HiltViewModel
9 | import kotlinx.collections.immutable.toPersistentList
10 | import kotlinx.coroutines.Dispatchers
11 | import kotlinx.coroutines.ExperimentalCoroutinesApi
12 | import kotlinx.coroutines.flow.SharingStarted
13 | import kotlinx.coroutines.flow.StateFlow
14 | import kotlinx.coroutines.flow.flowOn
15 | import kotlinx.coroutines.flow.mapLatest
16 | import kotlinx.coroutines.flow.stateIn
17 | import javax.inject.Inject
18 |
19 | @OptIn(ExperimentalCoroutinesApi::class)
20 | @HiltViewModel
21 | class NoteViewModel @Inject constructor(
22 | private val observeNotesUseCase: ObserveNotesUseCase
23 | ) : ViewModel() {
24 |
25 | val noteState: StateFlow by lazy {
26 | observeNotesUseCase()
27 | .mapLatest { notes ->
28 | if (notes.isEmpty()) {
29 | NoteUiStateModel.Empty
30 | } else {
31 | NoteUiStateModel.Fetched(notes.map { it.toNoteUiModel() }.toPersistentList())
32 | }
33 | }
34 | .flowOn(Dispatchers.Main)
35 | .stateIn(
36 | viewModelScope,
37 | SharingStarted.WhileSubscribed(5000),
38 | NoteUiStateModel.Loading
39 | )
40 | }
41 | }
--------------------------------------------------------------------------------
/feature/notes/presentation/src/main/java/com/msoula/noteappclean/feature/notes/presentation/components/NoteItem.kt:
--------------------------------------------------------------------------------
1 | package com.msoula.noteappclean.feature.notes.presentation.components
2 |
3 | import androidx.compose.foundation.clickable
4 | import androidx.compose.foundation.layout.Spacer
5 | import androidx.compose.foundation.layout.fillMaxWidth
6 | import androidx.compose.foundation.layout.height
7 | import androidx.compose.foundation.layout.padding
8 | import androidx.compose.material3.Card
9 | import androidx.compose.material3.Text
10 | import androidx.compose.runtime.Composable
11 | import androidx.compose.ui.Modifier
12 | import androidx.compose.ui.unit.dp
13 |
14 | @Composable
15 | fun NoteItem(
16 | modifier: Modifier = Modifier,
17 | title: String,
18 | id: Long,
19 | openNoteDetail: (id: Long) -> Unit
20 | ) {
21 | Card(
22 | modifier
23 | .fillMaxWidth()
24 | .height(50.dp)
25 | .clickable {
26 | openNoteDetail(id)
27 | }
28 | ) {
29 | Text(
30 | text = title, modifier = Modifier
31 | .fillMaxWidth()
32 | .padding(start = 8.dp)
33 | )
34 | }
35 |
36 | Spacer(modifier = modifier.height(16.dp))
37 | }
--------------------------------------------------------------------------------
/feature/notes/presentation/src/main/java/com/msoula/noteappclean/feature/notes/presentation/mappers/Mappers.kt:
--------------------------------------------------------------------------------
1 | package com.msoula.noteappclean.feature.notes.presentation.mappers
2 |
3 | import com.msoula.noteappclean.feature.notes.domain.models.NoteDomainModel
4 | import com.msoula.noteappclean.feature.notes.presentation.models.NoteUiModel
5 |
6 | fun NoteDomainModel.toNoteUiModel(): NoteUiModel {
7 | return NoteUiModel(
8 | id = this.id,
9 | title = this.title,
10 | description = this.description
11 | )
12 | }
--------------------------------------------------------------------------------
/feature/notes/presentation/src/main/java/com/msoula/noteappclean/feature/notes/presentation/models/NoteUiModel.kt:
--------------------------------------------------------------------------------
1 | package com.msoula.noteappclean.feature.notes.presentation.models
2 |
3 | import androidx.compose.runtime.Immutable
4 |
5 | @Immutable
6 | data class NoteUiModel(
7 | val id: Long,
8 | val title: String,
9 | val description: String
10 | )
11 |
--------------------------------------------------------------------------------
/feature/notes/presentation/src/main/java/com/msoula/noteappclean/feature/notes/presentation/models/NoteUiStateModel.kt:
--------------------------------------------------------------------------------
1 | package com.msoula.noteappclean.feature.notes.presentation.models
2 |
3 | import androidx.compose.runtime.Immutable
4 | import kotlinx.collections.immutable.PersistentList
5 |
6 | sealed interface NoteUiStateModel {
7 | data object Loading : NoteUiStateModel
8 | data object Empty : NoteUiStateModel
9 | @Immutable
10 | data class Fetched(val list: PersistentList) : NoteUiStateModel
11 | }
12 |
--------------------------------------------------------------------------------
/feature/notes/src/main/java/com/msoula/noteappclean/feature/notes/MyClass.kt:
--------------------------------------------------------------------------------
1 | package com.msoula.noteappclean.feature.notes
2 |
3 | class MyClass {
4 | }
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. For more details, visit
12 | # https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app's APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Kotlin code style for this project: "official" or "obsolete":
19 | kotlin.code.style=official
20 | # Enables namespacing of each library's R class so that its R class includes only the
21 | # resources declared in the library itself and none from the library's dependencies,
22 | # thereby reducing the size of the R class for that library
23 | android.nonTransitiveRClass=true
--------------------------------------------------------------------------------
/gradle/libs.versions.toml:
--------------------------------------------------------------------------------
1 | [versions]
2 | agp = "8.3.2"
3 | kotlin = "1.9.22"
4 | coreKtx = "1.13.0"
5 | lifecycleRuntimeKtx = "2.7.0"
6 | lifecycleViewmodelCompose = "2.7.0"
7 | activityCompose = "1.9.0"
8 | composeBom = "2024.04.01"
9 | gradle = "8.3.1"
10 | hiltAndroid = "2.50"
11 | hiltCompiler = "2.50"
12 | hiltNavigationCompose = "1.2.0"
13 | javapoet = "1.13.0"
14 | kotlinxCollectionsImmutable = "0.3.7"
15 | kotlinXCoroutines = "1.8.0"
16 | navigationUiKtx = "2.7.7"
17 | room = "2.6.1"
18 | runtime = "1.6.6"
19 | runtimeCompose = "2.7.0"
20 | jetbrainsKotlinJvm = "1.9.22"
21 | uiTooling = "1.6.6"
22 | material3 = "1.2.1"
23 |
24 | [libraries]
25 | androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
26 | androidx-lifecycle-compose = { module = "androidx.lifecycle:lifecycle-runtime-compose", version.ref = "runtimeCompose" }
27 | androidx-lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycleRuntimeKtx" }
28 | androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activityCompose" }
29 | androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "composeBom" }
30 | androidx-hilt-navigation-compose = { module = "androidx.hilt:hilt-navigation-compose", version.ref = "hiltNavigationCompose" }
31 | androidx-ui = { group = "androidx.compose.ui", name = "ui" }
32 | androidx-ui-graphics = { group = "androidx.compose.ui", name = "ui-graphics" }
33 | androidx-ui-tooling = { module = "androidx.compose.ui:ui-tooling", version.ref = "uiTooling" }
34 | androidx-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" }
35 | androidx-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" }
36 | material3 = { module = "androidx.compose.material3:material3", version.ref = "material3" }
37 | core-ktx = { module = "androidx.core:core-ktx", version.ref = "coreKtx" }
38 | gradle = { module = "com.android.tools.build:gradle", version.ref = "gradle" }
39 | hilt-android = { module = "com.google.dagger:hilt-android", version.ref = "hiltAndroid" }
40 | hilt-android-gradle-plugin = { module = "com.google.dagger:hilt-android-gradle-plugin", version.ref = "hiltAndroid" }
41 | hilt-compiler = { module = "com.google.dagger:hilt-compiler", version.ref = "hiltCompiler" }
42 | javapoet = { module = "com.squareup:javapoet", version.ref = "javapoet" }
43 | kotlinx-collections-immutable = { module = "org.jetbrains.kotlinx:kotlinx-collections-immutable", version.ref = "kotlinxCollectionsImmutable" }
44 | kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinXCoroutines" }
45 | kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
46 | lifecycle-runtime-compose = { module = "androidx.lifecycle:lifecycle-runtime-compose", version.ref = "lifecycleViewmodelCompose" }
47 | lifecycle-viewmodel-compose = { module = "androidx.lifecycle:lifecycle-viewmodel-compose", version.ref = "lifecycleViewmodelCompose" }
48 | navigation = { module = "androidx.navigation:navigation-compose", version.ref = "navigationUiKtx" }
49 | navigation-ui-ktx = { module = "androidx.navigation:navigation-ui-ktx", version.ref = "navigationUiKtx" }
50 | room-runtime = { module = "androidx.room:room-runtime", version.ref = "room" }
51 | room-compiler = { module = "androidx.room:room-compiler", version.ref = "room" }
52 | room-ktx = { module = "androidx.room:room-ktx", version.ref = "room" }
53 | runtime = { module = "androidx.compose.runtime:runtime", version.ref = "runtime" }
54 |
55 | [plugins]
56 | androidApplication = { id = "com.android.application", version.ref = "agp" }
57 | jetbrainsKotlinAndroid = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
58 | jetbrainsKotlinJvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "jetbrainsKotlinJvm" }
59 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/morganesoula/NoteAppClean/3bc794640661fcdcdeb26c6ae1d8448abe338125/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Apr 12 15:45:22 CEST 2024
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
5 | zipStoreBase=GRADLE_USER_HOME
6 | zipStorePath=wrapper/dists
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | #
4 | # Copyright 2015 the original author or authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | ##############################################################################
20 | ##
21 | ## Gradle start up script for UN*X
22 | ##
23 | ##############################################################################
24 |
25 | # Attempt to set APP_HOME
26 | # Resolve links: $0 may be a link
27 | PRG="$0"
28 | # Need this for relative symlinks.
29 | while [ -h "$PRG" ] ; do
30 | ls=`ls -ld "$PRG"`
31 | link=`expr "$ls" : '.*-> \(.*\)$'`
32 | if expr "$link" : '/.*' > /dev/null; then
33 | PRG="$link"
34 | else
35 | PRG=`dirname "$PRG"`"/$link"
36 | fi
37 | done
38 | SAVED="`pwd`"
39 | cd "`dirname \"$PRG\"`/" >/dev/null
40 | APP_HOME="`pwd -P`"
41 | cd "$SAVED" >/dev/null
42 |
43 | APP_NAME="Gradle"
44 | APP_BASE_NAME=`basename "$0"`
45 |
46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
48 |
49 | # Use the maximum available, or set MAX_FD != -1 to use that value.
50 | MAX_FD="maximum"
51 |
52 | warn () {
53 | echo "$*"
54 | }
55 |
56 | die () {
57 | echo
58 | echo "$*"
59 | echo
60 | exit 1
61 | }
62 |
63 | # OS specific support (must be 'true' or 'false').
64 | cygwin=false
65 | msys=false
66 | darwin=false
67 | nonstop=false
68 | case "`uname`" in
69 | CYGWIN* )
70 | cygwin=true
71 | ;;
72 | Darwin* )
73 | darwin=true
74 | ;;
75 | MINGW* )
76 | msys=true
77 | ;;
78 | NONSTOP* )
79 | nonstop=true
80 | ;;
81 | esac
82 |
83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
84 |
85 |
86 | # Determine the Java command to use to start the JVM.
87 | if [ -n "$JAVA_HOME" ] ; then
88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
89 | # IBM's JDK on AIX uses strange locations for the executables
90 | JAVACMD="$JAVA_HOME/jre/sh/java"
91 | else
92 | JAVACMD="$JAVA_HOME/bin/java"
93 | fi
94 | if [ ! -x "$JAVACMD" ] ; then
95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
96 |
97 | Please set the JAVA_HOME variable in your environment to match the
98 | location of your Java installation."
99 | fi
100 | else
101 | JAVACMD="java"
102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
103 |
104 | Please set the JAVA_HOME variable in your environment to match the
105 | location of your Java installation."
106 | fi
107 |
108 | # Increase the maximum file descriptors if we can.
109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
110 | MAX_FD_LIMIT=`ulimit -H -n`
111 | if [ $? -eq 0 ] ; then
112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
113 | MAX_FD="$MAX_FD_LIMIT"
114 | fi
115 | ulimit -n $MAX_FD
116 | if [ $? -ne 0 ] ; then
117 | warn "Could not set maximum file descriptor limit: $MAX_FD"
118 | fi
119 | else
120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
121 | fi
122 | fi
123 |
124 | # For Darwin, add options to specify how the application appears in the dock
125 | if $darwin; then
126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
127 | fi
128 |
129 | # For Cygwin or MSYS, switch paths to Windows format before running java
130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
133 |
134 | JAVACMD=`cygpath --unix "$JAVACMD"`
135 |
136 | # We build the pattern for arguments to be converted via cygpath
137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
138 | SEP=""
139 | for dir in $ROOTDIRSRAW ; do
140 | ROOTDIRS="$ROOTDIRS$SEP$dir"
141 | SEP="|"
142 | done
143 | OURCYGPATTERN="(^($ROOTDIRS))"
144 | # Add a user-defined pattern to the cygpath arguments
145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
147 | fi
148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
149 | i=0
150 | for arg in "$@" ; do
151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
153 |
154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
156 | else
157 | eval `echo args$i`="\"$arg\""
158 | fi
159 | i=`expr $i + 1`
160 | done
161 | case $i in
162 | 0) set -- ;;
163 | 1) set -- "$args0" ;;
164 | 2) set -- "$args0" "$args1" ;;
165 | 3) set -- "$args0" "$args1" "$args2" ;;
166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
172 | esac
173 | fi
174 |
175 | # Escape application args
176 | save () {
177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
178 | echo " "
179 | }
180 | APP_ARGS=`save "$@"`
181 |
182 | # Collect all arguments for the java command, following the shell quoting and substitution rules
183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
184 |
185 | exec "$JAVACMD" "$@"
186 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if "%ERRORLEVEL%" == "0" goto execute
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto execute
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :execute
68 | @rem Setup the command line
69 |
70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71 |
72 |
73 | @rem Execute Gradle
74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75 |
76 | :end
77 | @rem End local scope for the variables with windows NT shell
78 | if "%ERRORLEVEL%"=="0" goto mainEnd
79 |
80 | :fail
81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82 | rem the _cmd.exe /c_ return code!
83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84 | exit /b 1
85 |
86 | :mainEnd
87 | if "%OS%"=="Windows_NT" endlocal
88 |
89 | :omega
90 |
--------------------------------------------------------------------------------
/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | pluginManagement {
2 | repositories {
3 | google {
4 | content {
5 | includeGroupByRegex("com\\.android.*")
6 | includeGroupByRegex("com\\.google.*")
7 | includeGroupByRegex("androidx.*")
8 | }
9 | }
10 | mavenCentral()
11 | gradlePluginPortal()
12 | }
13 | }
14 | dependencyResolutionManagement {
15 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
16 | repositories {
17 | google()
18 | mavenCentral()
19 | }
20 | }
21 |
22 | rootProject.name = "NoteAppClean"
23 | include(":app")
24 | include(":core")
25 | include(":core:database")
26 | include(":feature")
27 | include(":feature:notes")
28 | include(":feature:notes:data")
29 | include(":feature:notes:domain")
30 | include(":feature:notes:presentation")
31 | include(":core:database:dao")
32 | include(":core:di")
33 | include(":feature:addnote")
34 | include(":feature:addnote:presentation")
35 | include(":feature:addnote:domain")
36 | include(":core:common")
37 | include(":feature:notedetail")
38 | include(":feature:notedetail:presentation")
39 |
--------------------------------------------------------------------------------