├── .editorconfig
├── .github
└── workflows
│ └── check.yml
├── .gitignore
├── LICENSE
├── README.md
├── app
├── .gitignore
├── build.gradle.kts
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── kotlin
│ │ └── com
│ │ └── task
│ │ └── noteapp
│ │ ├── HiltTestRunner.kt
│ │ ├── NoteAppTest.kt
│ │ └── TestAppModule.kt
│ ├── main
│ ├── AndroidManifest.xml
│ ├── ic_launcher-playstore.png
│ ├── kotlin
│ │ └── com
│ │ │ └── task
│ │ │ └── noteapp
│ │ │ ├── Application.kt
│ │ │ ├── data
│ │ │ ├── repository
│ │ │ │ └── NoteRepositoryImpl.kt
│ │ │ └── source
│ │ │ │ ├── NoteDao.kt
│ │ │ │ └── NoteDatabase.kt
│ │ │ ├── di
│ │ │ └── AppModule.kt
│ │ │ ├── domain
│ │ │ ├── interactor
│ │ │ │ ├── DeleteNote.kt
│ │ │ │ ├── GetNote.kt
│ │ │ │ ├── GetNotes.kt
│ │ │ │ └── InsertNote.kt
│ │ │ ├── model
│ │ │ │ └── Note.kt
│ │ │ └── repository
│ │ │ │ └── NoteRepository.kt
│ │ │ ├── presentation
│ │ │ ├── MainActivity.kt
│ │ │ ├── core
│ │ │ │ └── BaseViewModel.kt
│ │ │ ├── features
│ │ │ │ ├── home
│ │ │ │ │ ├── HomeScreen.kt
│ │ │ │ │ ├── HomeViewModel.kt
│ │ │ │ │ └── components
│ │ │ │ │ │ ├── HomeTopAppBar.kt
│ │ │ │ │ │ └── NoteCard.kt
│ │ │ │ └── note
│ │ │ │ │ ├── NoteScreen.kt
│ │ │ │ │ └── NoteViewModel.kt
│ │ │ ├── navigation
│ │ │ │ ├── Navigator.kt
│ │ │ │ └── Screen.kt
│ │ │ └── theme
│ │ │ │ ├── Color.kt
│ │ │ │ ├── Dimens.kt
│ │ │ │ ├── Shape.kt
│ │ │ │ ├── Theme.kt
│ │ │ │ └── Typography.kt
│ │ │ └── utils
│ │ │ └── TestTags.kt
│ └── res
│ │ ├── drawable-nodpi
│ │ └── img_placeholder.png
│ │ ├── drawable
│ │ ├── ic_edit.xml
│ │ └── ic_launcher_foreground.xml
│ │ ├── font
│ │ ├── domine_bold.ttf
│ │ ├── domine_regular.ttf
│ │ ├── montserrat_medium.ttf
│ │ ├── montserrat_regular.ttf
│ │ └── montserrat_semibold.ttf
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ └── values
│ │ ├── colors.xml
│ │ ├── ic_launcher_background.xml
│ │ ├── strings.xml
│ │ └── themes.xml
│ └── test
│ └── kotlin
│ └── com
│ └── task
│ └── noteapp
│ ├── FakeRepository.kt
│ └── GetNotesTest.kt
├── build.gradle.kts
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── screenshots
├── detail.png
├── detail_dark.png
├── home.png
├── home_dark.png
├── selection.png
└── selection_dark.png
└── settings.gradle.kts
/.editorconfig:
--------------------------------------------------------------------------------
1 | # EditorConfig: http://editorconfig.org
2 | root = true
3 |
4 | [*]
5 | insert_final_newline = true
6 |
7 | [*.{graphql, graphqls}]
8 | insert_final_newline = false
9 |
10 | [*.{yml, json}]
11 | indent_style = space
12 | indent_size = 2
13 |
14 | [*.{kt, kts, java}]
15 | indent_size = 4
16 | max_line_length = 100
17 |
--------------------------------------------------------------------------------
/.github/workflows/check.yml:
--------------------------------------------------------------------------------
1 | name: Code Analysis & Unit Tests
2 |
3 | on:
4 | push:
5 | branches: [ main ]
6 | pull_request:
7 | branches: [ main ]
8 |
9 | jobs:
10 | build:
11 | runs-on: ubuntu-latest
12 | steps:
13 | - uses: actions/checkout@v3
14 |
15 | - name: Set up JDK 1.8
16 | uses: actions/setup-java@v3
17 | with:
18 | distribution: "zulu"
19 | java-version: 11
20 |
21 | - name: Ktlint Check
22 | run: ./gradlew ktlintCheck
23 |
24 | - name: Unit Tests
25 | run: ./gradlew test
26 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Created by https://www.toptal.com/developers/gitignore/api/kotlin,android,androidstudio,macos
2 | # Edit at https://www.toptal.com/developers/gitignore?templates=kotlin,android,androidstudio,macos
3 |
4 | ### Android ###
5 | # Gradle files
6 | .gradle/
7 | build/
8 |
9 | # Local configuration file (sdk path, etc)
10 | local.properties
11 |
12 | # Log/OS Files
13 | *.log
14 |
15 | # Android Studio generated files and folders
16 | captures/
17 | .externalNativeBuild/
18 | .cxx/
19 | *.apk
20 | output.json
21 |
22 | # IntelliJ
23 | *.iml
24 | .idea/
25 | misc.xml
26 | deploymentTargetDropDown.xml
27 | render.experimental.xml
28 |
29 | # Keystore files
30 | *.jks
31 | *.keystore
32 |
33 | # Google Services (e.g. APIs or Firebase)
34 | google-services.json
35 |
36 | # Android Profiling
37 | *.hprof
38 |
39 | ### Android Patch ###
40 | gen-external-apklibs
41 |
42 | # Replacement of .externalNativeBuild directories introduced
43 | # with Android Studio 3.5.
44 |
45 | ### Kotlin ###
46 | # Compiled class file
47 | *.class
48 |
49 | # Log file
50 |
51 | # BlueJ files
52 | *.ctxt
53 |
54 | # Mobile Tools for Java (J2ME)
55 | .mtj.tmp/
56 |
57 | # Package Files #
58 | *.jar
59 | *.war
60 | *.nar
61 | *.ear
62 | *.zip
63 | *.tar.gz
64 | *.rar
65 |
66 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
67 | hs_err_pid*
68 | replay_pid*
69 |
70 | ### macOS ###
71 | # General
72 | .DS_Store
73 | .AppleDouble
74 | .LSOverride
75 |
76 | # Icon must end with two \r
77 | Icon
78 |
79 |
80 | # Thumbnails
81 | ._*
82 |
83 | # Files that might appear in the root of a volume
84 | .DocumentRevisions-V100
85 | .fseventsd
86 | .Spotlight-V100
87 | .TemporaryItems
88 | .Trashes
89 | .VolumeIcon.icns
90 | .com.apple.timemachine.donotpresent
91 |
92 | # Directories potentially created on remote AFP share
93 | .AppleDB
94 | .AppleDesktop
95 | Network Trash Folder
96 | Temporary Items
97 | .apdisk
98 |
99 | ### AndroidStudio ###
100 | # Covers files to be ignored for android development using Android Studio.
101 |
102 | # Built application files
103 | *.ap_
104 | *.aab
105 |
106 | # Files for the ART/Dalvik VM
107 | *.dex
108 |
109 | # Java class files
110 |
111 | # Generated files
112 | bin/
113 | gen/
114 | out/
115 |
116 | # Gradle files
117 | .gradle
118 |
119 | # Signing files
120 | .signing/
121 |
122 | # Local configuration file (sdk path, etc)
123 |
124 | # Proguard folder generated by Eclipse
125 | proguard/
126 |
127 | # Log Files
128 |
129 | # Android Studio
130 | /*/build/
131 | /*/local.properties
132 | /*/out
133 | /*/*/build
134 | /*/*/production
135 | .navigation/
136 | *.ipr
137 | *~
138 | *.swp
139 |
140 | # Keystore files
141 |
142 | # Google Services (e.g. APIs or Firebase)
143 | # google-services.json
144 |
145 | # Android Patch
146 |
147 | # External native build folder generated in Android Studio 2.2 and later
148 | .externalNativeBuild
149 |
150 | # NDK
151 | obj/
152 |
153 | # IntelliJ IDEA
154 | *.iws
155 | /out/
156 |
157 | # User-specific configurations
158 | .idea/caches/
159 | .idea/libraries/
160 | .idea/shelf/
161 | .idea/workspace.xml
162 | .idea/tasks.xml
163 | .idea/.name
164 | .idea/compiler.xml
165 | .idea/copyright/profiles_settings.xml
166 | .idea/encodings.xml
167 | .idea/misc.xml
168 | .idea/modules.xml
169 | .idea/scopes/scope_settings.xml
170 | .idea/dictionaries
171 | .idea/vcs.xml
172 | .idea/jsLibraryMappings.xml
173 | .idea/datasources.xml
174 | .idea/dataSources.ids
175 | .idea/sqlDataSources.xml
176 | .idea/dynamic.xml
177 | .idea/uiDesigner.xml
178 | .idea/assetWizardSettings.xml
179 | .idea/gradle.xml
180 | .idea/jarRepositories.xml
181 | .idea/navEditor.xml
182 |
183 | # Legacy Eclipse project files
184 | .classpath
185 | .project
186 | .cproject
187 | .settings/
188 |
189 | # Mobile Tools for Java (J2ME)
190 |
191 | # Package Files #
192 |
193 | # virtual machine crash logs (Reference: http://www.java.com/en/download/help/error_hotspot.xml)
194 |
195 | ## Plugin-specific files:
196 |
197 | # mpeltonen/sbt-idea plugin
198 | .idea_modules/
199 |
200 | # JIRA plugin
201 | atlassian-ide-plugin.xml
202 |
203 | # Mongo Explorer plugin
204 | .idea/mongoSettings.xml
205 |
206 | # Crashlytics plugin (for Android Studio and IntelliJ)
207 | com_crashlytics_export_strings.xml
208 | crashlytics.properties
209 | crashlytics-build.properties
210 | fabric.properties
211 |
212 | ### AndroidStudio Patch ###
213 |
214 | !/gradle/wrapper/gradle-wrapper.jar
215 |
216 | # End of https://www.toptal.com/developers/gitignore/api/kotlin,android,androidstudio,macos
217 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
NoteApp
2 |
3 | 
4 | 
5 | 
6 |
7 | A note taking app illustrating Android best practices with Jetpack Compose.
8 |
9 | ## Screenshots
10 |
11 |
12 |
13 | ## Tech stack
14 |
15 | * Written in [Kotlin](https://kotlinlang.org/)
16 | * Built entirely using [Jetpack Compose](https://developer.android.com/jetpack/compose)
17 | * Dependency injection done by [Dagger Hilt](https://dagger.dev/hilt/)
18 | * [Room](https://developer.android.com/training/data-storage/room) for persistence
19 | * [Coroutines](https://kotlinlang.org/docs/coroutines-overview.html) with [Flow](https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/) for asynchronous operations
20 | * Tests with [JUnit](https://developer.android.com/training/testing/local-tests)
21 |
22 | ## License
23 |
24 | Copyright 2022 Omer Karaca
25 |
26 | Licensed under the Apache License, Version 2.0 (the "License");
27 | you may not use this file except in compliance with the License.
28 | You may obtain a copy of the License at
29 |
30 | https://www.apache.org/licenses/LICENSE-2.0
31 |
32 | Unless required by applicable law or agreed to in writing, software
33 | distributed under the License is distributed on an "AS IS" BASIS,
34 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
35 | See the License for the specific language governing permissions and
36 | limitations under the License.
37 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle.kts:
--------------------------------------------------------------------------------
1 | @file:Suppress("SpellCheckingInspection")
2 |
3 | plugins {
4 | id("com.android.application")
5 | kotlin("android")
6 | kotlin("kapt")
7 | id("dagger.hilt.android.plugin")
8 | }
9 |
10 | android {
11 | compileSdk = 32
12 | defaultConfig {
13 | applicationId = "com.task.noteapp"
14 | minSdk = 21
15 | targetSdk = 32
16 | versionCode = 1
17 | versionName = "1.0"
18 | testInstrumentationRunner = "com.task.noteapp.HiltTestRunner"
19 | vectorDrawables {
20 | useSupportLibrary = true
21 | }
22 | }
23 |
24 | buildTypes {
25 | getByName("release") {
26 | isMinifyEnabled = false
27 | }
28 | }
29 |
30 | compileOptions {
31 | sourceCompatibility = JavaVersion.VERSION_1_8
32 | targetCompatibility = JavaVersion.VERSION_1_8
33 | }
34 |
35 | kotlinOptions {
36 | jvmTarget = "1.8"
37 | }
38 |
39 | buildFeatures {
40 | compose = true
41 | }
42 |
43 | composeOptions {
44 | kotlinCompilerExtensionVersion = rootProject.extra.get("composeVersion") as String
45 | }
46 |
47 | packagingOptions {
48 | resources {
49 | excludes.add("/META-INF/{AL2.0,LGPL2.1}")
50 | }
51 | }
52 |
53 | sourceSets {
54 | getByName("main") {
55 | java.srcDir("src/main/kotlin")
56 | }
57 |
58 | getByName("test") {
59 | java.srcDir("src/test/kotlin")
60 | }
61 |
62 | getByName("androidTest") {
63 | java.srcDir("src/androidTest/kotlin")
64 | }
65 | }
66 | }
67 |
68 | dependencies {
69 | implementation("androidx.core:core-ktx:1.7.0")
70 | implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.4.1")
71 | implementation("androidx.activity:activity-compose:1.4.0")
72 | implementation("androidx.hilt:hilt-navigation-compose:1.0.0")
73 |
74 | implementation("androidx.room:room-runtime:2.4.2")
75 | implementation("androidx.room:room-ktx:2.4.2")
76 | kapt("androidx.room:room-compiler:2.4.2")
77 |
78 | val composeVersion = rootProject.extra.get("composeVersion")
79 | implementation("androidx.compose.ui:ui:$composeVersion")
80 | implementation("androidx.compose.material:material:$composeVersion")
81 | implementation("androidx.compose.ui:ui-tooling-preview:$composeVersion")
82 | debugImplementation("androidx.compose.ui:ui-tooling:$composeVersion")
83 |
84 | val daggerVersion = rootProject.extra.get("daggerVersion")
85 | implementation("com.google.dagger:hilt-android:$daggerVersion")
86 | kapt("com.google.dagger:hilt-compiler:$daggerVersion")
87 |
88 | implementation("com.google.android.material:material:1.5.0")
89 | implementation("io.coil-kt:coil-compose:2.0.0-rc01")
90 |
91 | testImplementation("androidx.test:core:1.4.0")
92 | testImplementation("junit:junit:4.13.2")
93 | testImplementation("androidx.arch.core:core-testing:2.1.0")
94 | testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.5.1")
95 | testImplementation("com.google.truth:truth:1.1.3")
96 |
97 | androidTestImplementation("com.google.dagger:hilt-android-testing:$daggerVersion")
98 | kaptAndroidTest("com.google.dagger:hilt-android-compiler:$daggerVersion")
99 | androidTestImplementation("junit:junit:4.13.2")
100 | androidTestImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.5.1")
101 | androidTestImplementation("androidx.arch.core:core-testing:2.1.0")
102 | androidTestImplementation("com.google.truth:truth:1.1.3")
103 | androidTestImplementation("androidx.test.ext:junit:1.1.3")
104 | androidTestImplementation("androidx.test:core-ktx:1.4.0")
105 | androidTestImplementation("androidx.test:runner:1.4.0")
106 | androidTestImplementation("androidx.test.ext:junit:1.1.3")
107 | androidTestImplementation("androidx.test.espresso:espresso-core:3.4.0")
108 | androidTestImplementation("androidx.compose.ui:ui-test-junit4:$composeVersion")
109 | }
110 |
111 | kapt {
112 | correctErrorTypes = true
113 | }
114 |
--------------------------------------------------------------------------------
/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.kts.
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
22 |
--------------------------------------------------------------------------------
/app/src/androidTest/kotlin/com/task/noteapp/HiltTestRunner.kt:
--------------------------------------------------------------------------------
1 | package com.task.noteapp
2 |
3 | import android.app.Application
4 | import android.content.Context
5 | import androidx.test.runner.AndroidJUnitRunner
6 | import dagger.hilt.android.testing.HiltTestApplication
7 |
8 | /**
9 | * @author karacca
10 | * @date 14.03.2022
11 | */
12 |
13 | class HiltTestRunner : AndroidJUnitRunner() {
14 |
15 | override fun newApplication(
16 | cl: ClassLoader?,
17 | className: String?,
18 | context: Context?
19 | ): Application {
20 | return super.newApplication(cl, HiltTestApplication::class.java.name, context)
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/app/src/androidTest/kotlin/com/task/noteapp/NoteAppTest.kt:
--------------------------------------------------------------------------------
1 | package com.task.noteapp
2 |
3 | import androidx.compose.foundation.ExperimentalFoundationApi
4 | import androidx.compose.ui.test.*
5 | import androidx.compose.ui.test.junit4.createAndroidComposeRule
6 | import com.task.noteapp.di.AppModule
7 | import com.task.noteapp.presentation.MainActivity
8 | import com.task.noteapp.presentation.navigation.Navigator
9 | import com.task.noteapp.presentation.theme.NoteAppTheme
10 | import com.task.noteapp.utils.TestTags
11 | import dagger.hilt.android.testing.HiltAndroidRule
12 | import dagger.hilt.android.testing.HiltAndroidTest
13 | import dagger.hilt.android.testing.UninstallModules
14 | import org.junit.Before
15 | import org.junit.Rule
16 | import org.junit.Test
17 |
18 | /**
19 | * @author karacca
20 | * @date 14.03.2022
21 | */
22 |
23 | @ExperimentalFoundationApi
24 | @HiltAndroidTest
25 | @UninstallModules(AppModule::class)
26 | class NoteAppTest {
27 |
28 | @get:Rule(order = 0)
29 | val hiltRule = HiltAndroidRule(this)
30 |
31 | @get:Rule(order = 1)
32 | val composeRule = createAndroidComposeRule()
33 |
34 | @Before
35 | fun setup() {
36 | hiltRule.inject()
37 | composeRule.setContent {
38 | NoteAppTheme { Navigator() }
39 | }
40 | }
41 |
42 | @Test
43 | fun saveNewNote_displayAfter() {
44 | // Click FAB
45 | composeRule.onNodeWithTag(TestTags.ADD_NOTE).performClick()
46 |
47 | // Perform text inputs
48 | composeRule.onNodeWithTag(TestTags.NOTE_TITLE).performTextInput("Title")
49 | composeRule.onNodeWithTag(TestTags.NOTE_IMAGE_URL)
50 | .performTextInput("https://picsum.photos/600")
51 | composeRule.onNodeWithTag(TestTags.NOTE_DESCRIPTION).performTextInput("Description")
52 | composeRule.onNodeWithTag(TestTags.SAVE_NOTE).performClick()
53 |
54 | // Assert
55 | composeRule.onNodeWithText("Title").assertIsDisplayed()
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/app/src/androidTest/kotlin/com/task/noteapp/TestAppModule.kt:
--------------------------------------------------------------------------------
1 | package com.task.noteapp
2 |
3 | import android.app.Application
4 | import androidx.room.Room
5 | import com.task.noteapp.data.repository.NoteRepositoryImpl
6 | import com.task.noteapp.data.source.NoteDatabase
7 | import com.task.noteapp.domain.interactor.DeleteNote
8 | import com.task.noteapp.domain.interactor.GetNote
9 | import com.task.noteapp.domain.interactor.GetNotes
10 | import com.task.noteapp.domain.interactor.InsertNote
11 | import com.task.noteapp.domain.repository.NoteRepository
12 | import dagger.Module
13 | import dagger.Provides
14 | import dagger.hilt.InstallIn
15 | import dagger.hilt.components.SingletonComponent
16 | import javax.inject.Singleton
17 |
18 | /**
19 | * @author karacca
20 | * @date 14.03.2022
21 | */
22 |
23 | @Module
24 | @InstallIn(SingletonComponent::class)
25 | class TestAppModule {
26 |
27 | @Provides
28 | @Singleton
29 | fun provideNoteDatabase(app: Application): NoteDatabase {
30 | return Room.inMemoryDatabaseBuilder(
31 | app,
32 | NoteDatabase::class.java
33 | ).build()
34 | }
35 |
36 | @Provides
37 | @Singleton
38 | fun provideNoteRepository(database: NoteDatabase): NoteRepository {
39 | return NoteRepositoryImpl(database.dao)
40 | }
41 |
42 | @Provides
43 | @Singleton
44 | fun provideGetNotes(repository: NoteRepository) = GetNotes(repository)
45 |
46 | @Provides
47 | @Singleton
48 | fun provideGetNote(repository: NoteRepository) = GetNote(repository)
49 |
50 | @Provides
51 | @Singleton
52 | fun provideInsertNote(repository: NoteRepository) = InsertNote(repository)
53 |
54 | @Provides
55 | @Singleton
56 | fun provideDeleteNote(repository: NoteRepository) = DeleteNote(repository)
57 | }
58 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
15 |
16 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/app/src/main/ic_launcher-playstore.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karacca/NoteApp/f248fb169efeba3b09e66873fb0910b4c93d9b73/app/src/main/ic_launcher-playstore.png
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/task/noteapp/Application.kt:
--------------------------------------------------------------------------------
1 | package com.task.noteapp
2 |
3 | import android.app.Application
4 | import dagger.hilt.android.HiltAndroidApp
5 |
6 | /**
7 | * @author karacca
8 | * @date 12.03.2022
9 | */
10 |
11 | @HiltAndroidApp
12 | class Application : Application()
13 |
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/task/noteapp/data/repository/NoteRepositoryImpl.kt:
--------------------------------------------------------------------------------
1 | package com.task.noteapp.data.repository
2 |
3 | import com.task.noteapp.data.source.NoteDao
4 | import com.task.noteapp.domain.model.Note
5 | import com.task.noteapp.domain.repository.NoteRepository
6 | import kotlinx.coroutines.flow.Flow
7 |
8 | /**
9 | * @author karacca
10 | * @date 13.03.2022
11 | */
12 |
13 | class NoteRepositoryImpl(private val noteDao: NoteDao) : NoteRepository {
14 |
15 | override fun getNotes(): Flow> {
16 | return noteDao.getNotes()
17 | }
18 |
19 | override suspend fun getNote(id: Int): Note? {
20 | return noteDao.getNote(id)
21 | }
22 |
23 | override suspend fun insertNote(note: Note) {
24 | noteDao.insertNote(note)
25 | }
26 |
27 | override suspend fun deleteNote(note: Note) {
28 | noteDao.deleteNote(note)
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/task/noteapp/data/source/NoteDao.kt:
--------------------------------------------------------------------------------
1 | package com.task.noteapp.data.source
2 |
3 | import androidx.room.Dao
4 | import androidx.room.Delete
5 | import androidx.room.Insert
6 | import androidx.room.OnConflictStrategy.REPLACE
7 | import androidx.room.Query
8 | import com.task.noteapp.domain.model.Note
9 | import kotlinx.coroutines.flow.Flow
10 |
11 | /**
12 | * @author karacca
13 | * @date 13.03.2022
14 | */
15 |
16 | @Dao
17 | interface NoteDao {
18 |
19 | @Query("SELECT * FROM note")
20 | fun getNotes(): Flow>
21 |
22 | @Query("SELECT * FROM note WHERE id = :id")
23 | suspend fun getNote(id: Int): Note?
24 |
25 | @Insert(onConflict = REPLACE)
26 | suspend fun insertNote(note: Note)
27 |
28 | @Delete
29 | suspend fun deleteNote(note: Note)
30 | }
31 |
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/task/noteapp/data/source/NoteDatabase.kt:
--------------------------------------------------------------------------------
1 | package com.task.noteapp.data.source
2 |
3 | import androidx.room.Database
4 | import androidx.room.RoomDatabase
5 | import com.task.noteapp.domain.model.Note
6 |
7 | /**
8 | * @author karacca
9 | * @date 13.03.2022
10 | */
11 |
12 | @Database(entities = [Note::class], version = 1, exportSchema = false)
13 | abstract class NoteDatabase : RoomDatabase() {
14 |
15 | abstract val dao: NoteDao
16 |
17 | companion object {
18 | const val DATABASE_NAME = "notes_db"
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/task/noteapp/di/AppModule.kt:
--------------------------------------------------------------------------------
1 | package com.task.noteapp.di
2 |
3 | import android.app.Application
4 | import androidx.room.Room
5 | import com.task.noteapp.data.repository.NoteRepositoryImpl
6 | import com.task.noteapp.data.source.NoteDatabase
7 | import com.task.noteapp.domain.interactor.DeleteNote
8 | import com.task.noteapp.domain.interactor.GetNote
9 | import com.task.noteapp.domain.interactor.GetNotes
10 | import com.task.noteapp.domain.interactor.InsertNote
11 | import com.task.noteapp.domain.repository.NoteRepository
12 | import dagger.Module
13 | import dagger.Provides
14 | import dagger.hilt.InstallIn
15 | import dagger.hilt.components.SingletonComponent
16 | import javax.inject.Singleton
17 |
18 | /**
19 | * @author karacca
20 | * @date 13.03.2022
21 | */
22 |
23 | @Module
24 | @InstallIn(SingletonComponent::class)
25 | object AppModule {
26 |
27 | @Provides
28 | @Singleton
29 | fun provideNoteDatabase(app: Application): NoteDatabase {
30 | return Room.databaseBuilder(
31 | app,
32 | NoteDatabase::class.java,
33 | NoteDatabase.DATABASE_NAME
34 | ).build()
35 | }
36 |
37 | @Provides
38 | @Singleton
39 | fun provideNoteRepository(database: NoteDatabase): NoteRepository {
40 | return NoteRepositoryImpl(database.dao)
41 | }
42 |
43 | @Provides
44 | @Singleton
45 | fun provideGetNotes(repository: NoteRepository) = GetNotes(repository)
46 |
47 | @Provides
48 | @Singleton
49 | fun provideGetNote(repository: NoteRepository) = GetNote(repository)
50 |
51 | @Provides
52 | @Singleton
53 | fun provideInsertNote(repository: NoteRepository) = InsertNote(repository)
54 |
55 | @Provides
56 | @Singleton
57 | fun provideDeleteNote(repository: NoteRepository) = DeleteNote(repository)
58 | }
59 |
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/task/noteapp/domain/interactor/DeleteNote.kt:
--------------------------------------------------------------------------------
1 | package com.task.noteapp.domain.interactor
2 |
3 | import com.task.noteapp.domain.model.Note
4 | import com.task.noteapp.domain.repository.NoteRepository
5 |
6 | /**
7 | * @author karacca
8 | * @date 14.03.2022
9 | */
10 |
11 | class DeleteNote(private val repository: NoteRepository) {
12 |
13 | suspend operator fun invoke(note: Note) = repository.deleteNote(note)
14 | }
15 |
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/task/noteapp/domain/interactor/GetNote.kt:
--------------------------------------------------------------------------------
1 | package com.task.noteapp.domain.interactor
2 |
3 | import com.task.noteapp.domain.repository.NoteRepository
4 |
5 | /**
6 | * @author karacca
7 | * @date 14.03.2022
8 | */
9 |
10 | class GetNote(private val repository: NoteRepository) {
11 |
12 | suspend operator fun invoke(id: Int) = repository.getNote(id)
13 | }
14 |
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/task/noteapp/domain/interactor/GetNotes.kt:
--------------------------------------------------------------------------------
1 | package com.task.noteapp.domain.interactor
2 |
3 | import com.task.noteapp.domain.model.Note
4 | import com.task.noteapp.domain.repository.NoteRepository
5 | import kotlinx.coroutines.flow.Flow
6 | import kotlinx.coroutines.flow.map
7 |
8 | /**
9 | * @author karacca
10 | * @date 14.03.2022
11 | */
12 |
13 | class GetNotes(private val repository: NoteRepository) {
14 |
15 | operator fun invoke(): Flow> {
16 | return repository.getNotes().map {
17 | it.sortedByDescending { n -> n.createdDate }
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/task/noteapp/domain/interactor/InsertNote.kt:
--------------------------------------------------------------------------------
1 | package com.task.noteapp.domain.interactor
2 |
3 | import com.task.noteapp.domain.model.Note
4 | import com.task.noteapp.domain.repository.NoteRepository
5 |
6 | /**
7 | * @author karacca
8 | * @date 14.03.2022
9 | */
10 |
11 | class InsertNote(private val repository: NoteRepository) {
12 |
13 | suspend operator fun invoke(note: Note) = repository.insertNote(note)
14 | }
15 |
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/task/noteapp/domain/model/Note.kt:
--------------------------------------------------------------------------------
1 | package com.task.noteapp.domain.model
2 |
3 | import androidx.room.Entity
4 | import androidx.room.PrimaryKey
5 | import java.text.SimpleDateFormat
6 | import java.util.*
7 |
8 | /**
9 | * @author karacca
10 | * @date 13.03.2022
11 | */
12 |
13 | @Entity
14 | data class Note(
15 | @PrimaryKey val id: Int? = null,
16 | val title: String,
17 | val description: String,
18 | val imageUrl: String? = null,
19 | val createdDate: Long,
20 | var modifiedDate: Long? = null
21 | ) {
22 |
23 | val prettyCreatedDate: String
24 | get() = SimpleDateFormat(
25 | "dd/MM/yyyy",
26 | Locale.getDefault()
27 | ).format(
28 | Date(createdDate)
29 | )
30 |
31 | companion object {
32 |
33 | val Mock = Note(
34 | title = "Title ${System.currentTimeMillis()}",
35 | description = "Lorem Ipsum is simply dummy text of the printing and " +
36 | "typesetting industry. Lorem Ipsum has been the industry's " +
37 | "standard dummy text ever since the 1500s, when an unknown " +
38 | "printer took a galley of type and scrambled it to make a type specimen book",
39 | imageUrl = "https://picsum.photos/600",
40 | createdDate = System.currentTimeMillis(),
41 | modifiedDate = System.currentTimeMillis()
42 | )
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/task/noteapp/domain/repository/NoteRepository.kt:
--------------------------------------------------------------------------------
1 | package com.task.noteapp.domain.repository
2 |
3 | import com.task.noteapp.domain.model.Note
4 | import kotlinx.coroutines.flow.Flow
5 |
6 | /**
7 | * @author karacca
8 | * @date 13.03.2022
9 | */
10 |
11 | interface NoteRepository {
12 |
13 | fun getNotes(): Flow>
14 |
15 | suspend fun getNote(id: Int): Note?
16 |
17 | suspend fun insertNote(note: Note)
18 |
19 | suspend fun deleteNote(note: Note)
20 | }
21 |
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/task/noteapp/presentation/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.task.noteapp.presentation
2 |
3 | import android.os.Bundle
4 | import androidx.activity.ComponentActivity
5 | import androidx.activity.compose.setContent
6 | import androidx.compose.foundation.ExperimentalFoundationApi
7 | import androidx.compose.foundation.layout.fillMaxSize
8 | import androidx.compose.material.MaterialTheme
9 | import androidx.compose.material.Surface
10 | import androidx.compose.ui.Modifier
11 | import com.task.noteapp.presentation.navigation.Navigator
12 | import com.task.noteapp.presentation.theme.NoteAppTheme
13 | import dagger.hilt.android.AndroidEntryPoint
14 |
15 | /**
16 | * @author karacca
17 | * @date 11.03.2022
18 | */
19 |
20 | @AndroidEntryPoint
21 | @ExperimentalFoundationApi
22 | class MainActivity : ComponentActivity() {
23 | override fun onCreate(savedInstanceState: Bundle?) {
24 | super.onCreate(savedInstanceState)
25 | setContent {
26 | NoteAppTheme {
27 | Surface(
28 | modifier = Modifier.fillMaxSize(),
29 | color = MaterialTheme.colors.background
30 | ) {
31 | Navigator()
32 | }
33 | }
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/task/noteapp/presentation/core/BaseViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.task.noteapp.presentation.core
2 |
3 | import androidx.compose.runtime.State
4 | import androidx.compose.runtime.mutableStateOf
5 | import androidx.lifecycle.ViewModel
6 | import androidx.lifecycle.viewModelScope
7 | import kotlinx.coroutines.flow.MutableSharedFlow
8 | import kotlinx.coroutines.flow.asSharedFlow
9 | import kotlinx.coroutines.launch
10 |
11 | /**
12 | * @author karacca
13 | * @date 13.03.2022
14 | */
15 |
16 | interface ViewState
17 | interface ViewAction
18 | interface SideEffect
19 |
20 | abstract class BaseViewModel(
21 | initialState: S
22 | ) : ViewModel() {
23 |
24 | private val _state = mutableStateOf(initialState)
25 | val state: State = _state
26 |
27 | private val _sideEffect = MutableSharedFlow()
28 | val sideEffect = _sideEffect.asSharedFlow()
29 |
30 | abstract fun dispatch(action: A)
31 |
32 | fun updateState(newState: S) {
33 | if (newState != _state.value) {
34 | _state.value = newState
35 | }
36 | }
37 |
38 | fun updateSideEffect(effect: E) {
39 | viewModelScope.launch { _sideEffect.emit(effect) }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/task/noteapp/presentation/features/home/HomeScreen.kt:
--------------------------------------------------------------------------------
1 | package com.task.noteapp.presentation.features.home
2 |
3 | import androidx.compose.foundation.ExperimentalFoundationApi
4 | import androidx.compose.foundation.layout.*
5 | import androidx.compose.foundation.lazy.LazyColumn
6 | import androidx.compose.foundation.lazy.items
7 | import androidx.compose.material.*
8 | import androidx.compose.material.icons.Icons
9 | import androidx.compose.material.icons.filled.Add
10 | import androidx.compose.runtime.Composable
11 | import androidx.compose.runtime.LaunchedEffect
12 | import androidx.compose.ui.Alignment
13 | import androidx.compose.ui.Modifier
14 | import androidx.compose.ui.platform.testTag
15 | import androidx.compose.ui.res.stringResource
16 | import androidx.hilt.navigation.compose.hiltViewModel
17 | import androidx.navigation.NavController
18 | import com.task.noteapp.R
19 | import com.task.noteapp.presentation.features.home.components.HomeTopAppBar
20 | import com.task.noteapp.presentation.features.home.components.NoteCard
21 | import com.task.noteapp.presentation.navigation.Screen
22 | import com.task.noteapp.presentation.theme.Dimens
23 | import com.task.noteapp.utils.TestTags
24 |
25 | /**
26 | * @author karacca
27 | * @date 13.03.2022
28 | */
29 |
30 | @Composable
31 | @ExperimentalFoundationApi
32 | fun HomeScreen(
33 | viewModel: HomeViewModel = hiltViewModel(),
34 | navController: NavController
35 | ) {
36 | val scaffoldState = rememberScaffoldState()
37 | val viewState = viewModel.state.value
38 |
39 | val message = stringResource(id = R.string.long_press_message)
40 | LaunchedEffect(scaffoldState.snackbarHostState) {
41 | scaffoldState.snackbarHostState.showSnackbar(
42 | message = message
43 | )
44 | }
45 |
46 | Scaffold(
47 | topBar = {
48 | HomeTopAppBar(
49 | homeState = viewState,
50 | onDeleteClick = { viewModel.dispatch(HomeViewModel.Action.DeleteNotes) }
51 | )
52 | },
53 | floatingActionButton = {
54 | FloatingActionButton(
55 | modifier = Modifier.testTag(TestTags.ADD_NOTE),
56 | onClick = { navController.navigate(Screen.Note.route) },
57 | backgroundColor = MaterialTheme.colors.primary
58 | ) {
59 | Icon(
60 | imageVector = Icons.Default.Add,
61 | contentDescription = stringResource(R.string.content_description)
62 | )
63 | }
64 | },
65 | scaffoldState = scaffoldState
66 | ) {
67 | when {
68 | viewState.loading -> {
69 | Box(
70 | contentAlignment = Alignment.Center,
71 | modifier = Modifier.fillMaxSize()
72 | ) {
73 | CircularProgressIndicator()
74 | }
75 | }
76 |
77 | viewState.notes.isNotEmpty() -> {
78 | LazyColumn(contentPadding = PaddingValues(top = Dimens.Large)) {
79 | items(viewState.notes) {
80 | NoteCard(
81 | modifier = Modifier.padding(horizontal = Dimens.Large),
82 | note = it,
83 | selected = viewState.selectedNotes.contains(it),
84 | onClick = {
85 | if (viewState.selectedNotes.isNotEmpty()) {
86 | viewModel.dispatch(HomeViewModel.Action.SelectNote(it))
87 | } else {
88 | navController.navigate(Screen.Note.route + "?noteId=${it.id}")
89 | }
90 | },
91 | onLongClick = {
92 | viewModel.dispatch(HomeViewModel.Action.SelectNote(it))
93 | }
94 | )
95 | Spacer(modifier = Modifier.height(Dimens.Large))
96 | }
97 | }
98 | }
99 | }
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/task/noteapp/presentation/features/home/HomeViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.task.noteapp.presentation.features.home
2 |
3 | import androidx.lifecycle.viewModelScope
4 | import com.task.noteapp.domain.interactor.DeleteNote
5 | import com.task.noteapp.domain.interactor.GetNotes
6 | import com.task.noteapp.domain.model.Note
7 | import com.task.noteapp.presentation.core.BaseViewModel
8 | import com.task.noteapp.presentation.core.SideEffect
9 | import com.task.noteapp.presentation.core.ViewAction
10 | import com.task.noteapp.presentation.core.ViewState
11 | import dagger.hilt.android.lifecycle.HiltViewModel
12 | import kotlinx.coroutines.flow.launchIn
13 | import kotlinx.coroutines.flow.onEach
14 | import kotlinx.coroutines.launch
15 | import javax.inject.Inject
16 |
17 | /**
18 | * @author karacca
19 | * @date 13.03.2022
20 | */
21 |
22 | @HiltViewModel
23 | class HomeViewModel @Inject constructor(
24 | private val getNotes: GetNotes,
25 | private val deleteNote: DeleteNote
26 | ) : BaseViewModel(
27 | initialState = State()
28 | ) {
29 |
30 | init {
31 | fetchNotes()
32 | }
33 |
34 | override fun dispatch(action: Action) {
35 | when (action) {
36 | is Action.SelectNote -> {
37 | val selectedNotes = state.value.selectedNotes.toMutableList()
38 | val noteSelected = selectedNotes.contains(action.note)
39 | if (noteSelected) {
40 | selectedNotes.remove(action.note)
41 | } else {
42 | selectedNotes.add(action.note)
43 | }
44 | updateState(state.value.copy(selectedNotes = selectedNotes))
45 | }
46 |
47 | Action.DeleteNotes -> viewModelScope.launch {
48 | updateState(state.value.copy(loading = true))
49 | val notes = state.value.selectedNotes
50 | val remaining = notes.toMutableList()
51 | notes.forEach {
52 | deleteNote.invoke(it)
53 | remaining.remove(it)
54 | }
55 | updateState(
56 | state.value.copy(
57 | loading = false,
58 | notes = remaining,
59 | selectedNotes = arrayListOf()
60 | )
61 | )
62 | }
63 |
64 | is Action.Data -> {
65 | updateState(
66 | state.value.copy(
67 | loading = false,
68 | notes = action.notes
69 | )
70 | )
71 | }
72 | }
73 | }
74 |
75 | private fun fetchNotes() {
76 | updateState(state.value.copy(loading = true))
77 | getNotes().onEach {
78 | dispatch(Action.Data(it))
79 | }.launchIn(viewModelScope)
80 | }
81 |
82 | data class State(
83 | val loading: Boolean = false,
84 | val notes: List = emptyList(),
85 | val selectedNotes: List = emptyList()
86 | ) : ViewState
87 |
88 | sealed class Action : ViewAction {
89 | data class Data(val notes: List) : Action()
90 | data class SelectNote(val note: Note) : Action()
91 | object DeleteNotes : Action()
92 | }
93 |
94 | sealed class Effect : SideEffect
95 | }
96 |
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/task/noteapp/presentation/features/home/components/HomeTopAppBar.kt:
--------------------------------------------------------------------------------
1 | package com.task.noteapp.presentation.features.home.components
2 |
3 | import androidx.compose.foundation.clickable
4 | import androidx.compose.foundation.layout.padding
5 | import androidx.compose.material.Icon
6 | import androidx.compose.material.MaterialTheme
7 | import androidx.compose.material.Text
8 | import androidx.compose.material.TopAppBar
9 | import androidx.compose.material.icons.Icons
10 | import androidx.compose.material.icons.filled.Delete
11 | import androidx.compose.runtime.Composable
12 | import androidx.compose.ui.Modifier
13 | import androidx.compose.ui.res.stringResource
14 | import com.task.noteapp.R
15 | import com.task.noteapp.presentation.features.home.HomeViewModel
16 | import com.task.noteapp.presentation.theme.Dimens
17 |
18 | /**
19 | * @author karacca
20 | * @date 14.03.2022
21 | */
22 |
23 | @Composable
24 | fun HomeTopAppBar(
25 | modifier: Modifier = Modifier,
26 | homeState: HomeViewModel.State,
27 | onDeleteClick: (() -> Unit)? = null
28 | ) {
29 | TopAppBar(
30 | modifier = modifier,
31 | backgroundColor = MaterialTheme.colors.primary,
32 | title = {
33 | Text(
34 | text = when {
35 | homeState.loading -> {
36 | stringResource(id = R.string.title_home_loading)
37 | }
38 |
39 | homeState.notes.isEmpty() -> {
40 | stringResource(id = R.string.title_home_empty)
41 | }
42 |
43 | homeState.selectedNotes.isNotEmpty() -> {
44 | stringResource(
45 | id = R.string.title_home_selection,
46 | homeState.selectedNotes.size
47 | )
48 | }
49 |
50 | else -> {
51 | stringResource(
52 | id = R.string.title_home,
53 | homeState.notes.size
54 | )
55 | }
56 | }
57 | )
58 | },
59 | actions = {
60 | if (homeState.selectedNotes.isNotEmpty()) {
61 | Icon(
62 | modifier = Modifier
63 | .padding(horizontal = Dimens.Medium)
64 | .clickable { onDeleteClick?.invoke() },
65 | imageVector = Icons.Default.Delete,
66 | tint = MaterialTheme.colors.onPrimary,
67 | contentDescription = stringResource(
68 | id = R.string.content_description
69 | )
70 | )
71 | }
72 | }
73 | )
74 | }
75 |
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/task/noteapp/presentation/features/home/components/NoteCard.kt:
--------------------------------------------------------------------------------
1 | package com.task.noteapp.presentation.features.home.components
2 |
3 | import android.content.res.Configuration.UI_MODE_NIGHT_YES
4 | import androidx.compose.foundation.ExperimentalFoundationApi
5 | import androidx.compose.foundation.combinedClickable
6 | import androidx.compose.foundation.layout.*
7 | import androidx.compose.material.Card
8 | import androidx.compose.material.Icon
9 | import androidx.compose.material.MaterialTheme
10 | import androidx.compose.material.Text
11 | import androidx.compose.material.icons.Icons
12 | import androidx.compose.material.icons.rounded.Edit
13 | import androidx.compose.runtime.Composable
14 | import androidx.compose.ui.Alignment
15 | import androidx.compose.ui.Modifier
16 | import androidx.compose.ui.layout.ContentScale
17 | import androidx.compose.ui.platform.LocalContext
18 | import androidx.compose.ui.res.painterResource
19 | import androidx.compose.ui.res.stringResource
20 | import androidx.compose.ui.tooling.preview.Preview
21 | import androidx.compose.ui.unit.dp
22 | import coil.compose.AsyncImage
23 | import coil.request.ImageRequest
24 | import com.task.noteapp.R
25 | import com.task.noteapp.domain.model.Note
26 | import com.task.noteapp.presentation.theme.Dimens
27 | import com.task.noteapp.presentation.theme.NoteAppTheme
28 |
29 | /**
30 | * @author karacca
31 | * @date 13.03.2022
32 | */
33 |
34 | @ExperimentalFoundationApi
35 | @Composable
36 | fun NoteCard(
37 | modifier: Modifier = Modifier,
38 | note: Note,
39 | selected: Boolean = false,
40 | onClick: (() -> Unit)? = null,
41 | onLongClick: (() -> Unit)? = null
42 | ) {
43 | Card(
44 | modifier = modifier.combinedClickable(
45 | onClick = { onClick?.invoke() },
46 | onLongClick = { onLongClick?.invoke() }
47 | ),
48 | backgroundColor = if (selected) {
49 | MaterialTheme.colors.primary
50 | } else {
51 | MaterialTheme.colors.background
52 | }
53 | ) {
54 | Row(modifier = Modifier.height(IntrinsicSize.Min)) {
55 | Column(
56 | modifier = Modifier
57 | .weight(1f)
58 | .padding(Dimens.Large)
59 | ) {
60 | Row(verticalAlignment = Alignment.CenterVertically) {
61 | Text(
62 | text = note.prettyCreatedDate,
63 | style = MaterialTheme.typography.overline
64 | )
65 | if (note.modifiedDate != null) {
66 | Spacer(modifier = Modifier.size(Dimens.Small))
67 | Icon(
68 | modifier = Modifier.size(Dimens.Medium),
69 | imageVector = Icons.Rounded.Edit,
70 | contentDescription = stringResource(R.string.content_description)
71 | )
72 | }
73 | }
74 | Spacer(modifier = Modifier.height(Dimens.Small))
75 | Text(
76 | text = note.title,
77 | style = MaterialTheme.typography.body1
78 | )
79 | Text(
80 | text = note.description,
81 | style = MaterialTheme.typography.caption,
82 | maxLines = 2
83 | )
84 | }
85 | if (note.imageUrl != null) {
86 | AsyncImage(
87 | modifier = Modifier
88 | .width(128.dp)
89 | .fillMaxHeight(),
90 | model = ImageRequest.Builder(LocalContext.current)
91 | .data(note.imageUrl)
92 | .crossfade(true)
93 | .build(),
94 | placeholder = painterResource(R.drawable.img_placeholder),
95 | contentDescription = stringResource(R.string.content_description),
96 | contentScale = ContentScale.Crop
97 | )
98 | }
99 | }
100 | }
101 | }
102 |
103 | @Preview(showBackground = true)
104 | @Composable
105 | @ExperimentalFoundationApi
106 | fun NoteCardLightPreview() {
107 | NoteAppTheme {
108 | NoteCard(note = Note.Mock)
109 | }
110 | }
111 |
112 | @Preview(showBackground = true, uiMode = UI_MODE_NIGHT_YES)
113 | @Composable
114 | @ExperimentalFoundationApi
115 | fun NoteCardDarkPreview() {
116 | NoteAppTheme {
117 | NoteCard(note = Note.Mock)
118 | }
119 | }
120 |
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/task/noteapp/presentation/features/note/NoteScreen.kt:
--------------------------------------------------------------------------------
1 | package com.task.noteapp.presentation.features.note
2 |
3 | import androidx.compose.foundation.layout.*
4 | import androidx.compose.material.*
5 | import androidx.compose.material.icons.Icons
6 | import androidx.compose.material.icons.filled.ArrowBack
7 | import androidx.compose.runtime.Composable
8 | import androidx.compose.runtime.LaunchedEffect
9 | import androidx.compose.ui.Modifier
10 | import androidx.compose.ui.platform.testTag
11 | import androidx.compose.ui.res.stringResource
12 | import androidx.hilt.navigation.compose.hiltViewModel
13 | import androidx.navigation.NavController
14 | import com.task.noteapp.R
15 | import com.task.noteapp.presentation.theme.Dimens
16 | import com.task.noteapp.utils.TestTags
17 | import kotlinx.coroutines.flow.collectLatest
18 |
19 | /**
20 | * @author karacca
21 | * @date 13.03.2022
22 | */
23 |
24 | @Composable
25 | fun NoteScreen(
26 | viewModel: NoteViewModel = hiltViewModel(),
27 | navController: NavController
28 | ) {
29 | val scaffoldState = rememberScaffoldState()
30 | val viewState = viewModel.state.value
31 |
32 | LaunchedEffect(key1 = "") {
33 | viewModel.sideEffect.collectLatest {
34 | when (it) {
35 | NoteViewModel.Effect.PopBackStack -> {
36 | navController.popBackStack()
37 | }
38 | }
39 | }
40 | }
41 |
42 | Scaffold(
43 | topBar = {
44 | TopAppBar(
45 | backgroundColor = MaterialTheme.colors.primary,
46 | title = { Text(text = stringResource(id = R.string.title_note_detail)) },
47 | navigationIcon = {
48 | IconButton(onClick = { navController.popBackStack() }) {
49 | Icon(
50 | imageVector = Icons.Filled.ArrowBack,
51 | contentDescription = stringResource(
52 | id = R.string.content_description
53 | ),
54 | )
55 | }
56 | }
57 | )
58 | },
59 | scaffoldState = scaffoldState
60 | ) {
61 | Column(
62 | modifier = Modifier.padding(Dimens.Large),
63 | verticalArrangement = Arrangement.spacedBy(Dimens.Large)
64 | ) {
65 | OutlinedTextField(
66 | modifier = Modifier.fillMaxWidth().testTag(TestTags.NOTE_TITLE),
67 | label = { Text(text = stringResource(id = R.string.hint_note_title)) },
68 | singleLine = true,
69 | value = viewState.note.title,
70 | onValueChange = { viewModel.dispatch(NoteViewModel.Action.UpdateTitle(it)) }
71 | )
72 |
73 | OutlinedTextField(
74 | modifier = Modifier.fillMaxWidth().testTag(TestTags.NOTE_IMAGE_URL),
75 | label = { Text(text = stringResource(id = R.string.hint_note_image_url)) },
76 | singleLine = true,
77 | value = viewState.note.imageUrl ?: "",
78 | onValueChange = { viewModel.dispatch(NoteViewModel.Action.UpdateImageUrl(it)) }
79 | )
80 |
81 | OutlinedTextField(
82 | modifier = Modifier.fillMaxWidth().testTag(TestTags.NOTE_DESCRIPTION),
83 | label = { Text(text = stringResource(id = R.string.hint_note_description)) },
84 | value = viewState.note.description,
85 | onValueChange = { viewModel.dispatch(NoteViewModel.Action.UpdateDescription(it)) }
86 | )
87 |
88 | Button(
89 | modifier = Modifier.fillMaxWidth().testTag(TestTags.SAVE_NOTE),
90 | enabled = viewState.isNoteValid,
91 | onClick = { viewModel.dispatch(NoteViewModel.Action.SaveNote) }
92 | ) {
93 | Text(text = stringResource(id = R.string.action_save_note))
94 | }
95 | }
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/task/noteapp/presentation/features/note/NoteViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.task.noteapp.presentation.features.note
2 |
3 | import androidx.lifecycle.SavedStateHandle
4 | import androidx.lifecycle.viewModelScope
5 | import com.task.noteapp.domain.interactor.GetNote
6 | import com.task.noteapp.domain.interactor.InsertNote
7 | import com.task.noteapp.domain.model.Note
8 | import com.task.noteapp.presentation.core.BaseViewModel
9 | import com.task.noteapp.presentation.core.SideEffect
10 | import com.task.noteapp.presentation.core.ViewAction
11 | import com.task.noteapp.presentation.core.ViewState
12 | import dagger.hilt.android.lifecycle.HiltViewModel
13 | import kotlinx.coroutines.launch
14 | import javax.inject.Inject
15 |
16 | /**
17 | * @author karacca
18 | * @date 13.03.2022
19 | */
20 |
21 | @HiltViewModel
22 | class NoteViewModel @Inject constructor(
23 | private val getNote: GetNote,
24 | private val insertNote: InsertNote,
25 | savedStateHandle: SavedStateHandle
26 | ) : BaseViewModel(
27 | initialState = State(
28 | note = Note(
29 | title = "",
30 | description = "",
31 | imageUrl = "",
32 | createdDate = System.currentTimeMillis()
33 | )
34 | )
35 | ) {
36 |
37 | init {
38 | val noteId = savedStateHandle.get("noteId")
39 | if (noteId != null) {
40 | fetchNote(noteId)
41 | }
42 | }
43 |
44 | override fun dispatch(action: Action) {
45 | when (action) {
46 | is Action.Data -> {
47 | updateState(
48 | state.value.copy(
49 | note = action.note.copy(
50 | modifiedDate = System.currentTimeMillis()
51 | )
52 | )
53 | )
54 | }
55 |
56 | is Action.SaveNote -> {
57 | viewModelScope.launch {
58 | updateState(state.value.copy(loading = true))
59 | val note = state.value.note
60 | insertNote.invoke(note)
61 | updateState(state.value.copy(loading = false))
62 | updateSideEffect(Effect.PopBackStack)
63 | }
64 | }
65 |
66 | is Action.UpdateTitle -> {
67 | val note = state.value.note.copy(title = action.content)
68 | updateState(state.value.copy(note = note))
69 | }
70 |
71 | is Action.UpdateDescription -> {
72 | val note = state.value.note.copy(description = action.content)
73 | updateState(state.value.copy(note = note))
74 | }
75 |
76 | is Action.UpdateImageUrl -> {
77 | val note = state.value.note.copy(imageUrl = action.content)
78 | updateState(state.value.copy(note = note))
79 | }
80 | }
81 | }
82 |
83 | private fun fetchNote(id: Int) {
84 | viewModelScope.launch {
85 | updateState(state.value.copy(loading = true))
86 | val note = getNote(id)
87 | if (note != null) {
88 | dispatch(Action.Data(note))
89 | } else {
90 | updateState(state.value.copy(loading = false))
91 | }
92 | }
93 | }
94 |
95 | data class State(
96 | val loading: Boolean = false,
97 | val note: Note
98 | ) : ViewState {
99 |
100 | val isNoteValid: Boolean
101 | get() = note.title.isNotEmpty() && note.description.isNotEmpty()
102 | }
103 |
104 | sealed class Action : ViewAction {
105 | data class Data(val note: Note) : Action()
106 | object SaveNote : Action()
107 | data class UpdateTitle(val content: String) : Action()
108 | data class UpdateImageUrl(val content: String) : Action()
109 | data class UpdateDescription(val content: String) : Action()
110 | }
111 |
112 | sealed class Effect : SideEffect {
113 | object PopBackStack : Effect()
114 | }
115 | }
116 |
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/task/noteapp/presentation/navigation/Navigator.kt:
--------------------------------------------------------------------------------
1 | package com.task.noteapp.presentation.navigation
2 |
3 | import androidx.compose.foundation.ExperimentalFoundationApi
4 | import androidx.compose.runtime.Composable
5 | import androidx.navigation.NavType
6 | import androidx.navigation.compose.NavHost
7 | import androidx.navigation.compose.composable
8 | import androidx.navigation.compose.rememberNavController
9 | import androidx.navigation.navArgument
10 | import com.task.noteapp.presentation.features.home.HomeScreen
11 | import com.task.noteapp.presentation.features.note.NoteScreen
12 |
13 | /**
14 | * @author karacca
15 | * @date 14.03.2022
16 | */
17 |
18 | @ExperimentalFoundationApi
19 | @Composable
20 | fun Navigator() {
21 | val navController = rememberNavController()
22 | NavHost(
23 | navController = navController,
24 | startDestination = Screen.Home.route
25 | ) {
26 | composable(Screen.Home.route) {
27 | HomeScreen(navController = navController)
28 | }
29 |
30 | composable(Screen.Note.route) {
31 | NoteScreen(navController = navController)
32 | }
33 |
34 | composable(
35 | route = "${Screen.Note.route}?noteId={noteId}",
36 | arguments = listOf(
37 | navArgument(name = "noteId") {
38 | type = NavType.IntType
39 | }
40 | )
41 | ) {
42 | NoteScreen(navController = navController)
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/task/noteapp/presentation/navigation/Screen.kt:
--------------------------------------------------------------------------------
1 | package com.task.noteapp.presentation.navigation
2 |
3 | /**
4 | * @author karacca
5 | * @date 14.03.2022
6 | */
7 |
8 | sealed class Screen(val route: String) {
9 | object Home : Screen("home")
10 | object Note : Screen("note")
11 | }
12 |
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/task/noteapp/presentation/theme/Color.kt:
--------------------------------------------------------------------------------
1 | package com.task.noteapp.presentation.theme
2 |
3 | import androidx.compose.ui.graphics.Color
4 |
5 | /**
6 | * @author karacca
7 | * @date 11.03.2022
8 | */
9 |
10 | val Red200 = Color(0xfff297a2)
11 | val Red300 = Color(0xffea6d7e)
12 | val Red700 = Color(0xffdd0d3c)
13 | val Red800 = Color(0xffd00036)
14 | val Red900 = Color(0xffc20029)
15 |
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/task/noteapp/presentation/theme/Dimens.kt:
--------------------------------------------------------------------------------
1 | package com.task.noteapp.presentation.theme
2 |
3 | import androidx.compose.ui.unit.dp
4 |
5 | /**
6 | * @author karacca
7 | * @date 13.03.2022
8 | */
9 |
10 | object Dimens {
11 | val Small = 4.dp
12 | val Medium = 8.dp
13 | val Large = 16.dp
14 | }
15 |
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/task/noteapp/presentation/theme/Shape.kt:
--------------------------------------------------------------------------------
1 | package com.task.noteapp.presentation.theme
2 |
3 | import androidx.compose.foundation.shape.RoundedCornerShape
4 | import androidx.compose.material.Shapes
5 |
6 | /**
7 | * @author karacca
8 | * @date 11.03.2022
9 | */
10 |
11 | val Shapes = Shapes(
12 | small = RoundedCornerShape(Dimens.Small),
13 | medium = RoundedCornerShape(Dimens.Medium),
14 | large = RoundedCornerShape(Dimens.Large)
15 | )
16 |
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/task/noteapp/presentation/theme/Theme.kt:
--------------------------------------------------------------------------------
1 | package com.task.noteapp.presentation.theme
2 |
3 | import androidx.compose.foundation.isSystemInDarkTheme
4 | import androidx.compose.material.MaterialTheme
5 | import androidx.compose.material.darkColors
6 | import androidx.compose.material.lightColors
7 | import androidx.compose.runtime.Composable
8 | import androidx.compose.ui.graphics.Color
9 |
10 | /**
11 | * @author karacca
12 | * @date 11.03.2022
13 | */
14 |
15 | private val LightThemeColors = lightColors(
16 | primary = Red700,
17 | primaryVariant = Red900,
18 | onPrimary = Color.White,
19 | secondary = Red700,
20 | secondaryVariant = Red900,
21 | onSecondary = Color.White,
22 | error = Red800,
23 | onBackground = Color.Black
24 | )
25 |
26 | private val DarkThemeColors = darkColors(
27 | primary = Red300,
28 | primaryVariant = Red700,
29 | onPrimary = Color.Black,
30 | secondary = Red300,
31 | onSecondary = Color.Black,
32 | error = Red200,
33 | onBackground = Color.White
34 | )
35 |
36 | @Composable
37 | fun NoteAppTheme(
38 | darkTheme: Boolean = isSystemInDarkTheme(),
39 | content: @Composable () -> Unit
40 | ) {
41 | MaterialTheme(
42 | colors = if (darkTheme) DarkThemeColors else LightThemeColors,
43 | typography = NotesAppTypography,
44 | shapes = Shapes,
45 | content = content
46 | )
47 | }
48 |
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/task/noteapp/presentation/theme/Typography.kt:
--------------------------------------------------------------------------------
1 | package com.task.noteapp.presentation.theme
2 |
3 | import androidx.compose.material.Typography
4 | import androidx.compose.ui.text.TextStyle
5 | import androidx.compose.ui.text.font.Font
6 | import androidx.compose.ui.text.font.FontFamily
7 | import androidx.compose.ui.text.font.FontWeight
8 | import androidx.compose.ui.unit.sp
9 | import com.task.noteapp.R
10 |
11 | /**
12 | * @author karacca
13 | * @date 11.03.2022
14 | */
15 |
16 | private val Montserrat = FontFamily(
17 | Font(R.font.montserrat_regular),
18 | Font(R.font.montserrat_medium, FontWeight.W500),
19 | Font(R.font.montserrat_semibold, FontWeight.W600)
20 | )
21 |
22 | @Suppress("SpellCheckingInspection")
23 | private val Domine = FontFamily(
24 | Font(R.font.domine_regular),
25 | Font(R.font.domine_bold, FontWeight.Bold)
26 | )
27 |
28 | val NotesAppTypography = Typography(
29 | defaultFontFamily = Montserrat,
30 | h4 = TextStyle(
31 | fontWeight = FontWeight.SemiBold,
32 | fontSize = 30.sp,
33 | letterSpacing = 0.sp
34 | ),
35 | h5 = TextStyle(
36 | fontWeight = FontWeight.SemiBold,
37 | fontSize = 24.sp,
38 | letterSpacing = 0.sp
39 | ),
40 | h6 = TextStyle(
41 | fontWeight = FontWeight.SemiBold,
42 | fontSize = 20.sp,
43 | letterSpacing = 0.sp
44 | ),
45 | subtitle1 = TextStyle(
46 | fontWeight = FontWeight.SemiBold,
47 | fontSize = 16.sp,
48 | letterSpacing = 0.15.sp
49 | ),
50 | subtitle2 = TextStyle(
51 | fontWeight = FontWeight.Medium,
52 | fontSize = 14.sp,
53 | letterSpacing = 0.1.sp
54 | ),
55 | body1 = TextStyle(
56 | fontFamily = Domine,
57 | fontWeight = FontWeight.Normal,
58 | fontSize = 16.sp,
59 | letterSpacing = 0.5.sp
60 | ),
61 | body2 = TextStyle(
62 | fontWeight = FontWeight.Medium,
63 | fontSize = 14.sp,
64 | letterSpacing = 0.25.sp
65 | ),
66 | button = TextStyle(
67 | fontWeight = FontWeight.SemiBold,
68 | fontSize = 14.sp,
69 | letterSpacing = 1.25.sp
70 | ),
71 | caption = TextStyle(
72 | fontWeight = FontWeight.Medium,
73 | fontSize = 12.sp,
74 | letterSpacing = 0.4.sp
75 | ),
76 | overline = TextStyle(
77 | fontWeight = FontWeight.SemiBold,
78 | fontSize = 12.sp,
79 | letterSpacing = 1.sp
80 | )
81 | )
82 |
--------------------------------------------------------------------------------
/app/src/main/kotlin/com/task/noteapp/utils/TestTags.kt:
--------------------------------------------------------------------------------
1 | package com.task.noteapp.utils
2 |
3 | /**
4 | * @author karacca
5 | * @date 14.03.2022
6 | */
7 |
8 | object TestTags {
9 | const val ADD_NOTE = "add_note"
10 | const val NOTE_TITLE = "note_title"
11 | const val NOTE_IMAGE_URL = "note_image_url"
12 | const val NOTE_DESCRIPTION = "note_description"
13 | const val SAVE_NOTE = "save_note"
14 | }
15 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-nodpi/img_placeholder.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karacca/NoteApp/f248fb169efeba3b09e66873fb0910b4c93d9b73/app/src/main/res/drawable-nodpi/img_placeholder.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_edit.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
11 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/font/domine_bold.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karacca/NoteApp/f248fb169efeba3b09e66873fb0910b4c93d9b73/app/src/main/res/font/domine_bold.ttf
--------------------------------------------------------------------------------
/app/src/main/res/font/domine_regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karacca/NoteApp/f248fb169efeba3b09e66873fb0910b4c93d9b73/app/src/main/res/font/domine_regular.ttf
--------------------------------------------------------------------------------
/app/src/main/res/font/montserrat_medium.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karacca/NoteApp/f248fb169efeba3b09e66873fb0910b4c93d9b73/app/src/main/res/font/montserrat_medium.ttf
--------------------------------------------------------------------------------
/app/src/main/res/font/montserrat_regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karacca/NoteApp/f248fb169efeba3b09e66873fb0910b4c93d9b73/app/src/main/res/font/montserrat_regular.ttf
--------------------------------------------------------------------------------
/app/src/main/res/font/montserrat_semibold.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karacca/NoteApp/f248fb169efeba3b09e66873fb0910b4c93d9b73/app/src/main/res/font/montserrat_semibold.ttf
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karacca/NoteApp/f248fb169efeba3b09e66873fb0910b4c93d9b73/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karacca/NoteApp/f248fb169efeba3b09e66873fb0910b4c93d9b73/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karacca/NoteApp/f248fb169efeba3b09e66873fb0910b4c93d9b73/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karacca/NoteApp/f248fb169efeba3b09e66873fb0910b4c93d9b73/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karacca/NoteApp/f248fb169efeba3b09e66873fb0910b4c93d9b73/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karacca/NoteApp/f248fb169efeba3b09e66873fb0910b4c93d9b73/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karacca/NoteApp/f248fb169efeba3b09e66873fb0910b4c93d9b73/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karacca/NoteApp/f248fb169efeba3b09e66873fb0910b4c93d9b73/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karacca/NoteApp/f248fb169efeba3b09e66873fb0910b4c93d9b73/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karacca/NoteApp/f248fb169efeba3b09e66873fb0910b4c93d9b73/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #0e0e0e
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/values/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #DD0D3C
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | NoteApp
3 | Loading…
4 | Dummy Content Description
5 | You have %1$s notes!
6 | You don\'t have any notes!
7 | %1$s notes selected
8 | Note Detail
9 | Title
10 | Description
11 | Image URL
12 | Save Note
13 | You can delete messages by long pressing
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
--------------------------------------------------------------------------------
/app/src/test/kotlin/com/task/noteapp/FakeRepository.kt:
--------------------------------------------------------------------------------
1 | package com.task.noteapp
2 |
3 | import com.task.noteapp.domain.model.Note
4 | import com.task.noteapp.domain.repository.NoteRepository
5 | import kotlinx.coroutines.flow.flow
6 |
7 | /**
8 | * @author karacca
9 | * @date 14.03.2022
10 | */
11 |
12 | class FakeRepository : NoteRepository {
13 |
14 | private val notes = arrayListOf()
15 |
16 | override fun getNotes() = flow { emit(notes) }
17 |
18 | override suspend fun getNote(id: Int) = notes.find { it.id == id }
19 |
20 | override suspend fun insertNote(note: Note) {
21 | notes.add(note)
22 | }
23 |
24 | override suspend fun deleteNote(note: Note) {
25 | notes.remove(note)
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/app/src/test/kotlin/com/task/noteapp/GetNotesTest.kt:
--------------------------------------------------------------------------------
1 | package com.task.noteapp
2 |
3 | import com.task.noteapp.domain.interactor.GetNotes
4 | import com.task.noteapp.domain.interactor.InsertNote
5 | import com.task.noteapp.domain.model.Note
6 | import com.task.noteapp.domain.repository.NoteRepository
7 | import kotlinx.coroutines.flow.first
8 | import kotlinx.coroutines.runBlocking
9 | import org.junit.Assert.assertEquals
10 | import org.junit.Before
11 | import org.junit.Test
12 | import java.util.*
13 |
14 | /**
15 | * @author karacca
16 | * @date 14.03.2022
17 | */
18 |
19 | class GetNotesTest {
20 |
21 | private lateinit var getNotes: GetNotes
22 | private lateinit var insertNote: InsertNote
23 |
24 | private lateinit var repository: NoteRepository
25 |
26 | @Before
27 | fun setup() {
28 | repository = FakeRepository()
29 | getNotes = GetNotes(repository)
30 | insertNote = InsertNote(repository)
31 |
32 | val notes = arrayListOf()
33 | for (i in 0..100) {
34 | notes.add(
35 | Note(
36 | title = "",
37 | description = "",
38 | imageUrl = "",
39 | createdDate = Random().nextLong()
40 | )
41 | )
42 | }
43 |
44 | runBlocking { notes.forEach { insertNote(it) } }
45 | }
46 |
47 | @Test
48 | fun `Get notes with correct order`() {
49 | runBlocking {
50 | val notes = getNotes().first()
51 | val correctlySorted = notes.sortedByDescending { it.createdDate }
52 | assertEquals(notes, correctlySorted)
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/build.gradle.kts:
--------------------------------------------------------------------------------
1 | @file:Suppress("SpellCheckingInspection")
2 |
3 | import org.jlleitschuh.gradle.ktlint.KtlintExtension
4 |
5 | buildscript {
6 | extra.apply {
7 | set("composeVersion", "1.1.1")
8 | set("daggerVersion", "2.41")
9 | }
10 |
11 | repositories {
12 | gradlePluginPortal()
13 | google()
14 | mavenCentral()
15 | }
16 |
17 | dependencies {
18 | classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10")
19 | classpath("com.android.tools.build:gradle:7.1.2")
20 | classpath("org.jlleitschuh.gradle:ktlint-gradle:10.2.1")
21 | val daggerVersion = rootProject.extra.get("daggerVersion")
22 | classpath("com.google.dagger:hilt-android-gradle-plugin:$daggerVersion")
23 | }
24 | }
25 |
26 | allprojects {
27 | repositories {
28 | google()
29 | mavenCentral()
30 | }
31 |
32 | apply(plugin = "org.jlleitschuh.gradle.ktlint")
33 | configure {
34 | version.set("0.44.0")
35 | disabledRules.add("no-wildcard-imports")
36 | }
37 | }
38 |
39 | tasks.register("clean", Delete::class) {
40 | delete(rootProject.buildDir)
41 | }
42 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
2 | android.useAndroidX=true
3 | kotlin.code.style=official
4 | android.nonTransitiveRClass=true
5 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karacca/NoteApp/f248fb169efeba3b09e66873fb0910b4c93d9b73/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Mar 11 21:29:46 TRT 2022
2 | distributionBase=GRADLE_USER_HOME
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
4 | distributionPath=wrapper/dists
5 | zipStorePath=wrapper/dists
6 | zipStoreBase=GRADLE_USER_HOME
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 |
--------------------------------------------------------------------------------
/screenshots/detail.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karacca/NoteApp/f248fb169efeba3b09e66873fb0910b4c93d9b73/screenshots/detail.png
--------------------------------------------------------------------------------
/screenshots/detail_dark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karacca/NoteApp/f248fb169efeba3b09e66873fb0910b4c93d9b73/screenshots/detail_dark.png
--------------------------------------------------------------------------------
/screenshots/home.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karacca/NoteApp/f248fb169efeba3b09e66873fb0910b4c93d9b73/screenshots/home.png
--------------------------------------------------------------------------------
/screenshots/home_dark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karacca/NoteApp/f248fb169efeba3b09e66873fb0910b4c93d9b73/screenshots/home_dark.png
--------------------------------------------------------------------------------
/screenshots/selection.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karacca/NoteApp/f248fb169efeba3b09e66873fb0910b4c93d9b73/screenshots/selection.png
--------------------------------------------------------------------------------
/screenshots/selection_dark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karacca/NoteApp/f248fb169efeba3b09e66873fb0910b4c93d9b73/screenshots/selection_dark.png
--------------------------------------------------------------------------------
/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | pluginManagement {
2 | repositories {
3 | gradlePluginPortal()
4 | google()
5 | mavenCentral()
6 | }
7 | }
8 |
9 | rootProject.name = "NoteApp"
10 | include(":app")
11 |
--------------------------------------------------------------------------------