5 |
6 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/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 2023 Xero
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 | 
2 |
3 | ## Paper
4 | Paper — Note management done right.
5 | Manage all your important notes with ease
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | ## 📝Features
14 | - [x] Minimal and Aesthetic UI
15 | - [x] Light and Dark Theme
16 | - [x] Create and Edit Notes
17 | - [x] Search and Find Notes
18 | - [X] Save Notes for Later
19 | - [x] Delete Notes
20 |
21 | ## ✅ Downloads
22 | [](./LICENSE)
23 | [](https://github.com/dev-xero/paper-app/releases/tag/v1.0)
24 |
25 | **Runs on Android 7.0 and up**
26 |
27 | Installation Steps
28 |
29 | 1. [Download the app](https://github.com/dev-xero/paper-app/releases/tag/v1.0) by clicking the green button or this link.
30 | 2. Locate the file and install, you might get a warning, that's because the app isn't from the playstore, but it's safe to install.
31 | 3. After installing, you should be able to use the app.
32 |
33 |
34 | ### Donating
35 |
36 |
37 | Each donation is greatly appreciated, thanks in advance!
38 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'com.android.application'
3 | id 'org.jetbrains.kotlin.android'
4 | id 'kotlin-kapt'
5 | id 'com.google.dagger.hilt.android'
6 | }
7 |
8 | android {
9 | namespace 'dev.xero.paper'
10 | compileSdk 33
11 |
12 | defaultConfig {
13 | applicationId "dev.xero.paper"
14 | minSdk 24
15 | targetSdk 33
16 | versionCode 1
17 | versionName "1.0"
18 |
19 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
20 | vectorDrawables {
21 | useSupportLibrary true
22 | }
23 | }
24 |
25 | buildTypes {
26 | release {
27 | minifyEnabled false
28 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
29 | }
30 | }
31 | compileOptions {
32 | sourceCompatibility JavaVersion.VERSION_1_8
33 | targetCompatibility JavaVersion.VERSION_1_8
34 | }
35 | kotlinOptions {
36 | jvmTarget = '1.8'
37 | }
38 | buildFeatures {
39 | compose true
40 | }
41 | composeOptions {
42 | kotlinCompilerExtensionVersion '1.4.3'
43 | }
44 | packagingOptions {
45 | resources {
46 | excludes += '/META-INF/{AL2.0,LGPL2.1}'
47 | }
48 | }
49 | }
50 |
51 | kapt {
52 | correctErrorTypes true
53 | }
54 |
55 | dependencies {
56 | def composeBOM = platform("androidx.compose:compose-bom:2023.01.00")
57 | implementation composeBOM
58 | androidTestImplementation composeBOM
59 |
60 | implementation 'androidx.core:core-ktx:1.9.0'
61 | implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.0'
62 | implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
63 | implementation 'androidx.activity:activity-compose:1.6.1'
64 | implementation "androidx.compose.ui:ui"
65 | implementation "androidx.compose.ui:ui-tooling-preview"
66 | implementation 'androidx.compose.material:material'
67 | testImplementation 'junit:junit:4.13.2'
68 | androidTestImplementation 'androidx.test.ext:junit:1.1.5'
69 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
70 | androidTestImplementation "androidx.compose.ui:ui-test-junit4"
71 | debugImplementation "androidx.compose.ui:ui-tooling"
72 | debugImplementation "androidx.compose.ui:ui-test-manifest"
73 |
74 | // Splash API
75 | implementation "androidx.core:core-splashscreen:1.0.0"
76 |
77 | // Navigation
78 | def nav_version = "2.5.3"
79 | implementation "androidx.navigation:navigation-compose:$nav_version"
80 |
81 | // Accompanist - Status Bar
82 | implementation "com.google.accompanist:accompanist-systemuicontroller:0.27.0"
83 |
84 | // ViewModel
85 | implementation "androidx.lifecycle:lifecycle-viewmodel-compose:2.6.0"
86 |
87 | // Dagger Hilt
88 | def hilt_version = "2.45"
89 | implementation "com.google.dagger:hilt-android:$hilt_version"
90 | kapt "com.google.dagger:hilt-android-compiler:$hilt_version"
91 | implementation "androidx.hilt:hilt-navigation-compose:1.0.0"
92 |
93 | // Room DataBase
94 | def room_version = "2.5.0"
95 | implementation "androidx.room:room-runtime:$room_version"
96 | kapt "androidx.room:room-compiler:$room_version"
97 | implementation "androidx.room:room-ktx:$room_version"
98 |
99 | // Coroutines
100 | def coroutines_version = "1.6.4"
101 | implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
102 | implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"
103 |
104 | // Live Data
105 | def live_data_version = "2.6.0"
106 | implementation "androidx.lifecycle:lifecycle-livedata-ktx:$live_data_version"
107 | implementation "androidx.lifecycle:lifecycle-livedata:$live_data_version"
108 | implementation "androidx.compose.runtime:runtime-livedata:1.3.3"
109 |
110 | }
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/app/src/androidTest/java/dev/xero/paper/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package dev.xero.paper
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22 | assertEquals("dev.xero.paper", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
19 |
20 |
30 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/app/src/main/ic_launcher-playstore.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dev-xero/paper-app/f3c532473b6d5aae8afe8c9175c08cd6e90315de/app/src/main/ic_launcher-playstore.png
--------------------------------------------------------------------------------
/app/src/main/java/dev/xero/paper/app/PaperApplication.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2023 - Xero
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package dev.xero.paper.app
17 |
18 | import android.app.Application
19 | import dagger.hilt.android.HiltAndroidApp
20 |
21 | @HiltAndroidApp
22 | class PaperApplication : Application()
--------------------------------------------------------------------------------
/app/src/main/java/dev/xero/paper/core/di/AppModule.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2023 - Xero
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package dev.xero.paper.core.di
17 |
18 | import android.app.Application
19 | import androidx.room.Room
20 | import dagger.Module
21 | import dagger.Provides
22 | import dagger.hilt.InstallIn
23 | import dagger.hilt.components.SingletonComponent
24 | import dev.xero.paper.data.datasource.db.NoteDB
25 | import dev.xero.paper.data.repository.NoteRepositoryImpl
26 | import dev.xero.paper.domain.repository.NoteRepository
27 | import dev.xero.paper.domain.usecases.*
28 | import javax.inject.Singleton
29 |
30 | @Module
31 | @InstallIn(SingletonComponent::class)
32 | object AppModule {
33 |
34 | @Provides
35 | @Singleton
36 | fun providesNoteDatabase(app: Application): NoteDB {
37 | return Room.databaseBuilder(
38 | app.applicationContext,
39 | NoteDB::class.java,
40 | NoteDB.DATABASE_NAME
41 | ).build()
42 | }
43 |
44 | @Provides
45 | @Singleton
46 | fun providesNoteRepository(db: NoteDB): NoteRepository {
47 | return NoteRepositoryImpl(dao = db.noteDAO)
48 | }
49 |
50 | @Provides
51 | @Singleton
52 | fun providesNoteUseCases(repository: NoteRepository): NoteUseCases {
53 | return NoteUseCases(
54 | getNotesUseCase = GetNotesUseCase(repository),
55 | getNoteUseCase = GetNoteUseCase(repository),
56 | addNoteUseCase = AddNoteUseCase(repository),
57 | updateNoteUseCase = UpdateNoteUseCase(repository),
58 | deleteNoteUseCase = DeleteNoteUseCase(repository)
59 | )
60 | }
61 |
62 | }
--------------------------------------------------------------------------------
/app/src/main/java/dev/xero/paper/data/datasource/db/NoteDAO.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2023 - Xero
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package dev.xero.paper.data.datasource.db
18 |
19 | import androidx.room.*
20 | import dev.xero.paper.domain.model.NoteDBEntity
21 | import kotlinx.coroutines.flow.Flow
22 |
23 | @Dao
24 | interface NoteDAO {
25 | @Query("SELECT * FROM notes")
26 | fun getAllNotes(): Flow>
27 |
28 | @Query("SELECT * FROM notes WHERE id = :id")
29 | suspend fun getNoteById(id: Long): NoteDBEntity?
30 |
31 | @Insert(onConflict = OnConflictStrategy.REPLACE)
32 | suspend fun addNote(note: NoteDBEntity)
33 |
34 | @Update
35 | suspend fun updateNote(note: NoteDBEntity)
36 |
37 | @Delete
38 | suspend fun deleteNote(note: NoteDBEntity)
39 | }
--------------------------------------------------------------------------------
/app/src/main/java/dev/xero/paper/data/datasource/db/NoteDB.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2023 - Xero
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package dev.xero.paper.data.datasource.db
17 |
18 | import androidx.room.Database
19 | import androidx.room.RoomDatabase
20 | import dev.xero.paper.domain.model.NoteDBEntity
21 |
22 | @Database(
23 | entities = [NoteDBEntity::class],
24 | version = 1,
25 | exportSchema = false
26 | )
27 | abstract class NoteDB : RoomDatabase() {
28 | abstract val noteDAO: NoteDAO
29 |
30 | companion object {
31 | const val DATABASE_NAME = "notes_db"
32 | }
33 | }
--------------------------------------------------------------------------------
/app/src/main/java/dev/xero/paper/data/repository/NoteRepositoryImpl.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2023 - Xero
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package dev.xero.paper.data.repository
17 |
18 | import dev.xero.paper.data.datasource.db.NoteDAO
19 | import dev.xero.paper.domain.model.NoteDBEntity
20 | import dev.xero.paper.domain.repository.NoteRepository
21 | import kotlinx.coroutines.flow.Flow
22 | import javax.inject.Inject
23 |
24 | class NoteRepositoryImpl @Inject constructor (
25 | private val dao: NoteDAO
26 | ) : NoteRepository {
27 | override fun getAllNotes(): Flow> {
28 | return dao.getAllNotes()
29 | }
30 |
31 | override suspend fun getNoteById(id: Long): NoteDBEntity? {
32 | return dao.getNoteById(id)
33 | }
34 |
35 | override suspend fun addNote(note: NoteDBEntity) {
36 | return dao.addNote(note)
37 | }
38 |
39 | override suspend fun updateNote(note: NoteDBEntity) {
40 | return dao.updateNote(note)
41 | }
42 |
43 | override suspend fun deleteNote(note: NoteDBEntity) {
44 | return dao.deleteNote(note)
45 | }
46 | }
--------------------------------------------------------------------------------
/app/src/main/java/dev/xero/paper/domain/model/NoteDBEntity.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2023 - Xero
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package dev.xero.paper.domain.model
17 |
18 | import androidx.room.Entity
19 | import androidx.room.PrimaryKey
20 |
21 | @Entity(tableName = "notes")
22 | data class NoteDBEntity(
23 | @PrimaryKey(autoGenerate = true)
24 | val id: Long = 0L,
25 | val title: String,
26 | val content: String
27 | )
--------------------------------------------------------------------------------
/app/src/main/java/dev/xero/paper/domain/repository/NoteRepository.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2023 - Xero
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package dev.xero.paper.domain.repository
17 |
18 | import dev.xero.paper.domain.model.NoteDBEntity
19 | import kotlinx.coroutines.flow.Flow
20 |
21 | interface NoteRepository {
22 | fun getAllNotes()
23 | : Flow>
24 |
25 | suspend fun getNoteById(id: Long)
26 | : NoteDBEntity?
27 |
28 | suspend fun addNote(note: NoteDBEntity)
29 |
30 | suspend fun updateNote(note: NoteDBEntity)
31 |
32 | suspend fun deleteNote(note: NoteDBEntity)
33 | }
--------------------------------------------------------------------------------
/app/src/main/java/dev/xero/paper/domain/usecases/AddNoteUseCase.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2023 - Xero
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package dev.xero.paper.domain.usecases
17 |
18 | import dev.xero.paper.domain.model.NoteDBEntity
19 | import dev.xero.paper.domain.repository.NoteRepository
20 |
21 | class AddNoteUseCase(
22 | private val repository: NoteRepository
23 | ) {
24 |
25 | suspend operator fun invoke(note: NoteDBEntity) {
26 | return repository.addNote(note)
27 | }
28 | }
--------------------------------------------------------------------------------
/app/src/main/java/dev/xero/paper/domain/usecases/DeleteNoteUseCase.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2023 - Xero
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package dev.xero.paper.domain.usecases
17 |
18 | import dev.xero.paper.domain.model.NoteDBEntity
19 | import dev.xero.paper.domain.repository.NoteRepository
20 |
21 | class DeleteNoteUseCase(
22 | private val repository: NoteRepository
23 | ) {
24 |
25 | suspend operator fun invoke(note: NoteDBEntity) {
26 | return repository.deleteNote(note)
27 | }
28 | }
--------------------------------------------------------------------------------
/app/src/main/java/dev/xero/paper/domain/usecases/GetNoteUseCase.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2023 - Xero
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package dev.xero.paper.domain.usecases
17 |
18 | import dev.xero.paper.domain.model.NoteDBEntity
19 | import dev.xero.paper.domain.repository.NoteRepository
20 |
21 | class GetNoteUseCase(
22 | private val repository: NoteRepository
23 | ) {
24 |
25 | suspend operator fun invoke(id: Long): NoteDBEntity? {
26 | return repository.getNoteById(id)
27 | }
28 | }
--------------------------------------------------------------------------------
/app/src/main/java/dev/xero/paper/domain/usecases/GetNotesUseCase.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2023 - Xero
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package dev.xero.paper.domain.usecases
17 |
18 | import dev.xero.paper.domain.model.NoteDBEntity
19 | import dev.xero.paper.domain.repository.NoteRepository
20 | import kotlinx.coroutines.flow.Flow
21 |
22 | class GetNotesUseCase(
23 | private val repository: NoteRepository
24 | ) {
25 | operator fun invoke(): Flow> {
26 | return repository.getAllNotes()
27 | }
28 | }
--------------------------------------------------------------------------------
/app/src/main/java/dev/xero/paper/domain/usecases/NoteUseCases.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2023 - Xero
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package dev.xero.paper.domain.usecases
17 |
18 | data class NoteUseCases(
19 | val getNotesUseCase: GetNotesUseCase,
20 | val getNoteUseCase: GetNoteUseCase,
21 | val addNoteUseCase: AddNoteUseCase,
22 | val updateNoteUseCase: UpdateNoteUseCase,
23 | val deleteNoteUseCase: DeleteNoteUseCase
24 | )
--------------------------------------------------------------------------------
/app/src/main/java/dev/xero/paper/domain/usecases/UpdateNoteUseCase.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2023 - Xero
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package dev.xero.paper.domain.usecases
17 |
18 | import dev.xero.paper.domain.model.NoteDBEntity
19 | import dev.xero.paper.domain.repository.NoteRepository
20 |
21 | class UpdateNoteUseCase(
22 | private val repository: NoteRepository
23 | ) {
24 |
25 | suspend operator fun invoke(note: NoteDBEntity) {
26 | repository.updateNote(note)
27 | }
28 | }
--------------------------------------------------------------------------------
/app/src/main/java/dev/xero/paper/navigation/NavGraph.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2023 - Xero
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package dev.xero.paper.navigation
17 |
18 | import androidx.compose.runtime.Composable
19 | import androidx.hilt.navigation.compose.hiltViewModel
20 | import androidx.navigation.NavHostController
21 | import androidx.navigation.compose.NavHost
22 | import androidx.navigation.compose.composable
23 | import dev.xero.paper.domain.model.NoteDBEntity
24 | import dev.xero.paper.presentation.notes.edit_notes.EditNoteScreen
25 | import dev.xero.paper.presentation.notes.edit_notes.EditNoteScreenViewModel
26 | import dev.xero.paper.presentation.notes.notes_list.HomeScreen
27 | import dev.xero.paper.presentation.notes.notes_list.HomeScreenViewModel
28 |
29 | enum class Screens {
30 | Home,
31 | EditNote
32 | }
33 |
34 | @Composable
35 | fun SetupNavGraph(
36 | navHostController: NavHostController
37 | ) {
38 | NavHost(
39 | navController = navHostController,
40 | startDestination = Screens.Home.name
41 | ) {
42 | var noteContentState: NoteDBEntity? = null
43 |
44 | // ROUTE: Home
45 | composable(route = Screens.Home.name) {
46 | val viewModel = hiltViewModel()
47 | HomeScreen(
48 | viewModel = viewModel,
49 | onAddNoteButtonClicked = { navHostController.navigate(Screens.EditNote.name) },
50 | onEditNoteButtonClicked = {
51 | navHostController.navigate(Screens.EditNote.name)
52 | noteContentState = it
53 | }
54 | )
55 | }
56 |
57 | // ROUTE: Edit Note
58 | composable(route = Screens.EditNote.name) {
59 | val viewModel = hiltViewModel()
60 | EditNoteScreen(
61 | viewModel = viewModel,
62 | noteContentState = noteContentState,
63 | onBackButtonClicked = { navHostController.navigate(Screens.Home.name) },
64 | onSaveNoteButtonClicked = { navHostController.navigate(Screens.Home.name) },
65 | onSetContent = { noteContentState = null }
66 | )
67 | }
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/app/src/main/java/dev/xero/paper/presentation/MainActivity.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2023 - Xero
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package dev.xero.paper.presentation
17 |
18 | import android.os.Bundle
19 | import androidx.activity.ComponentActivity
20 | import androidx.activity.compose.setContent
21 | import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
22 | import androidx.navigation.NavHostController
23 | import androidx.navigation.compose.rememberNavController
24 | import dagger.hilt.android.AndroidEntryPoint
25 | import dev.xero.paper.navigation.SetupNavGraph
26 | import dev.xero.paper.presentation.ui.theme.PaperTheme
27 |
28 | @AndroidEntryPoint
29 | class MainActivity : ComponentActivity() {
30 | override fun onCreate(savedInstanceState: Bundle?) {
31 | super.onCreate(savedInstanceState)
32 | installSplashScreen()
33 | setContent {
34 | PaperTheme {
35 | // SETUP NAVIGATION
36 | val navController: NavHostController = rememberNavController()
37 | SetupNavGraph(navHostController = navController)
38 | }
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/app/src/main/java/dev/xero/paper/presentation/notes/edit_notes/EditNoteScreen.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2023 - Xero
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package dev.xero.paper.presentation.notes.edit_notes
17 |
18 | import androidx.compose.foundation.Canvas
19 | import androidx.compose.foundation.background
20 | import androidx.compose.foundation.isSystemInDarkTheme
21 | import androidx.compose.foundation.layout.*
22 | import androidx.compose.foundation.shape.RoundedCornerShape
23 | import androidx.compose.foundation.text.KeyboardActions
24 | import androidx.compose.foundation.text.KeyboardOptions
25 | import androidx.compose.material.FloatingActionButton
26 | import androidx.compose.material.FloatingActionButtonDefaults
27 | import androidx.compose.material.Scaffold
28 | import androidx.compose.runtime.Composable
29 | import androidx.compose.runtime.LaunchedEffect
30 | import androidx.compose.runtime.remember
31 | import androidx.compose.ui.Modifier
32 | import androidx.compose.ui.focus.FocusDirection
33 | import androidx.compose.ui.focus.FocusRequester
34 | import androidx.compose.ui.platform.LocalFocusManager
35 | import androidx.compose.ui.text.input.ImeAction
36 | import androidx.compose.ui.unit.dp
37 | import dev.xero.paper.domain.model.NoteDBEntity
38 | import dev.xero.paper.presentation.notes.edit_notes.edit_note_components.BackButton
39 | import dev.xero.paper.presentation.notes.edit_notes.edit_note_components.InputBox
40 | import dev.xero.paper.presentation.notes.edit_notes.edit_note_components.SaveNoteButton
41 | import dev.xero.paper.presentation.notes.edit_notes.utils.InputType
42 | import dev.xero.paper.presentation.ui.theme.Primary
43 | import dev.xero.paper.presentation.ui.theme.Secondary
44 | import dev.xero.paper.presentation.ui.theme.SurfaceDark
45 |
46 | @Composable
47 | fun EditNoteScreen(
48 | modifier: Modifier = Modifier,
49 | viewModel: EditNoteScreenViewModel,
50 | noteContentState: NoteDBEntity?,
51 | onBackButtonClicked: () -> Unit,
52 | onSaveNoteButtonClicked: () -> Unit,
53 | onSetContent: () -> Unit
54 | ) {
55 | val isDarkTheme = isSystemInDarkTheme()
56 | val title = viewModel.title
57 | val content = viewModel.content
58 | val focusManager = LocalFocusManager.current
59 | val focusRequester = remember { FocusRequester() }
60 |
61 | LaunchedEffect(Unit) {
62 | if (noteContentState != null) {
63 | viewModel.getNote(noteContentState.id)
64 | onSetContent()
65 | }
66 | }
67 |
68 | Scaffold(
69 | topBar = {
70 | Row(
71 | modifier = modifier
72 | .fillMaxWidth()
73 | .background(
74 | when (isDarkTheme) {
75 | true -> SurfaceDark
76 | else -> Secondary
77 | }
78 | )
79 | ) {
80 | BackButton(
81 | isDarkTheme = isDarkTheme,
82 | modifier = Modifier.padding(
83 | horizontal = 6.dp,
84 | vertical = 8.dp
85 | ),
86 | onButtonClick = onBackButtonClicked
87 | )
88 | }
89 | },
90 | floatingActionButton = {
91 | FloatingActionButton(
92 | onClick = {
93 | if (viewModel.currentNote != null)
94 | viewModel.updateNote()
95 | else
96 | viewModel.addNote()
97 | onSaveNoteButtonClicked()
98 | },
99 | backgroundColor = Primary,
100 | shape = RoundedCornerShape(4.dp),
101 | elevation = FloatingActionButtonDefaults.elevation(
102 | defaultElevation = 0.dp,
103 | pressedElevation = 0.dp,
104 | focusedElevation = 0.dp,
105 | hoveredElevation = 0.dp
106 | )
107 | ) {
108 | SaveNoteButton(
109 | isDarkTheme = isDarkTheme
110 | )
111 | }
112 | }
113 | ) {padding ->
114 | Column(
115 | verticalArrangement = Arrangement.spacedBy(4.dp)
116 | ) {
117 | InputBox(
118 | inputType = InputType.Title,
119 | isDarkTheme = isDarkTheme,
120 | value = title,
121 | onValueChange = {
122 | viewModel.updateTitle(it)
123 | },
124 | keyboardActions = KeyboardActions(
125 | onNext = { focusManager.moveFocus(FocusDirection.Down) }
126 | ),
127 | keyboardOptions = KeyboardOptions.Default.copy(
128 | imeAction = ImeAction.Next
129 | ),
130 | focusRequester = focusRequester
131 | )
132 |
133 | Canvas(
134 | modifier = Modifier
135 | .size(
136 | width = 100.dp,
137 | height = 2.dp
138 | )
139 | .padding(start = 12.dp)
140 | ) {
141 | drawRoundRect(
142 | color = Primary,
143 | size = size
144 | )
145 | }
146 |
147 | InputBox(
148 | inputType = InputType.Content,
149 | isDarkTheme = isDarkTheme,
150 | value = content,
151 | onValueChange = {
152 | viewModel.updateContent(it)
153 | },
154 | keyboardActions = KeyboardActions(
155 | onDone = { focusManager.clearFocus() }
156 | ),
157 | keyboardOptions = KeyboardOptions.Default.copy(
158 | imeAction = ImeAction.Done
159 | )
160 | )
161 | }
162 | }
163 | }
--------------------------------------------------------------------------------
/app/src/main/java/dev/xero/paper/presentation/notes/edit_notes/EditNoteScreenViewModel.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2023 - Xero
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package dev.xero.paper.presentation.notes.edit_notes
17 |
18 | import android.util.Log
19 | import androidx.compose.runtime.getValue
20 | import androidx.compose.runtime.mutableStateOf
21 | import androidx.compose.runtime.setValue
22 | import androidx.lifecycle.ViewModel
23 | import androidx.lifecycle.viewModelScope
24 | import dagger.hilt.android.lifecycle.HiltViewModel
25 | import dev.xero.paper.domain.model.NoteDBEntity
26 | import dev.xero.paper.domain.usecases.NoteUseCases
27 | import kotlinx.coroutines.launch
28 | import javax.inject.Inject
29 |
30 | @HiltViewModel
31 | class EditNoteScreenViewModel @Inject constructor (
32 | private val useCases: NoteUseCases,
33 | ) : ViewModel() {
34 |
35 | var title: String by mutableStateOf("")
36 | var content: String by mutableStateOf("")
37 | var currentNote: NoteDBEntity? = null
38 |
39 | fun updateTitle(value: String) {
40 | title = value
41 | }
42 |
43 | fun updateContent(value: String) {
44 | content = value
45 | }
46 |
47 | fun addNote() {
48 | val newNote = NoteDBEntity(
49 | title = title.ifBlank { "Title" },
50 | content = content
51 | )
52 | viewModelScope.launch {
53 | useCases.addNoteUseCase(newNote)
54 | }
55 | }
56 |
57 | fun getNote(id: Long) {
58 | viewModelScope.launch {
59 | currentNote = useCases.getNoteUseCase(id)
60 | if (currentNote != null) {
61 | title = currentNote!!.title
62 | content = currentNote!!.content
63 | }
64 | }
65 | }
66 |
67 | fun updateNote() {
68 | val updatedNote = NoteDBEntity(
69 | id = currentNote!!.id,
70 | title = title,
71 | content = content
72 | )
73 | Log.d("APP", currentNote.toString())
74 | viewModelScope.launch {
75 | useCases.updateNoteUseCase(updatedNote)
76 | }
77 | }
78 |
79 | }
--------------------------------------------------------------------------------
/app/src/main/java/dev/xero/paper/presentation/notes/edit_notes/edit_note_components/BackButton.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2023 - Xero
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package dev.xero.paper.presentation.notes.edit_notes.edit_note_components
17 |
18 | import androidx.compose.foundation.background
19 | import androidx.compose.foundation.shape.CircleShape
20 | import androidx.compose.material.Icon
21 | import androidx.compose.material.IconButton
22 | import androidx.compose.runtime.Composable
23 | import androidx.compose.ui.Modifier
24 | import androidx.compose.ui.res.painterResource
25 | import dev.xero.paper.R
26 | import dev.xero.paper.presentation.ui.theme.Primary
27 | import dev.xero.paper.presentation.ui.theme.Secondary
28 | import dev.xero.paper.presentation.ui.theme.SurfaceDark
29 |
30 | @Composable
31 | fun BackButton(
32 | modifier: Modifier = Modifier,
33 | isDarkTheme: Boolean,
34 | onButtonClick: () -> Unit
35 | ) {
36 | IconButton(
37 | onClick = onButtonClick,
38 | modifier = modifier
39 | .background(
40 | color = when(isDarkTheme) {
41 | true -> SurfaceDark
42 | else -> Secondary
43 | },
44 | shape = CircleShape
45 | )
46 | ) {
47 | Icon(
48 | painter = painterResource(id = R.drawable.back_icon_light),
49 | contentDescription = null,
50 | tint = Primary
51 | )
52 | }
53 | }
--------------------------------------------------------------------------------
/app/src/main/java/dev/xero/paper/presentation/notes/edit_notes/edit_note_components/InputBox.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2023 - Xero
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package dev.xero.paper.presentation.notes.edit_notes.edit_note_components
17 |
18 | import androidx.compose.foundation.layout.fillMaxWidth
19 | import androidx.compose.foundation.text.KeyboardActions
20 | import androidx.compose.foundation.text.KeyboardOptions
21 | import androidx.compose.material.MaterialTheme
22 | import androidx.compose.material.OutlinedTextField
23 | import androidx.compose.material.Text
24 | import androidx.compose.material.TextFieldDefaults
25 | import androidx.compose.runtime.Composable
26 | import androidx.compose.runtime.LaunchedEffect
27 | import androidx.compose.ui.Modifier
28 | import androidx.compose.ui.focus.FocusRequester
29 | import androidx.compose.ui.focus.focusRequester
30 | import androidx.compose.ui.graphics.Color
31 | import dev.xero.paper.presentation.notes.edit_notes.utils.InputType
32 | import dev.xero.paper.presentation.ui.theme.*
33 |
34 | @Composable
35 | fun InputBox(
36 | modifier: Modifier = Modifier,
37 | inputType: InputType,
38 | isDarkTheme: Boolean,
39 | value: String,
40 | onValueChange: (String) -> Unit,
41 | keyboardActions: KeyboardActions,
42 | keyboardOptions: KeyboardOptions,
43 | focusRequester: FocusRequester? = null
44 | ) {
45 | val colorMap: Map = mapOf(
46 | "main" to when(isDarkTheme) {
47 | true -> BgDark
48 | else -> OnSurface
49 | },
50 | "placeholder_title" to when(isDarkTheme) {
51 | true -> OnSurface
52 | else -> Grey500
53 | },
54 | "placeholder_content" to when(isDarkTheme) {
55 | true -> Grey100
56 | else -> Grey100
57 | }
58 | )
59 |
60 | OutlinedTextField(
61 | value = value,
62 | onValueChange = onValueChange,
63 | modifier = when(inputType) {
64 | InputType.Title -> {
65 | modifier
66 | .fillMaxWidth()
67 | .focusRequester(focusRequester!!)
68 | }
69 | else -> modifier.fillMaxWidth()
70 | },
71 | singleLine = inputType == InputType.Title,
72 | textStyle = if (inputType == InputType.Title) {
73 | MaterialTheme.typography.h3
74 | } else {
75 | MaterialTheme.typography.h4
76 | },
77 | placeholder = {
78 | Text(
79 | text = if (inputType == InputType.Title) "Title" else "content...",
80 | style = if (inputType == InputType.Title) {
81 | MaterialTheme.typography.h3
82 | } else {
83 | MaterialTheme.typography.h4
84 | }
85 | )
86 | },
87 | colors = TextFieldDefaults.outlinedTextFieldColors(
88 | backgroundColor = colorMap["main"]!!,
89 | focusedBorderColor = colorMap["main"]!!,
90 | unfocusedBorderColor = colorMap["main"]!!,
91 | placeholderColor = when(inputType) {
92 | InputType.Title -> colorMap["placeholder_title"]!!
93 | else -> colorMap["placeholder_content"]!!
94 | },
95 | cursorColor = Primary,
96 | textColor = when(inputType) {
97 | InputType.Title -> {
98 | if (isDarkTheme) OnSurface else Grey500
99 | }
100 | else -> {
101 | if (isDarkTheme) Grey100 else Grey300
102 | }
103 | }
104 | ),
105 | keyboardActions = keyboardActions,
106 | keyboardOptions = keyboardOptions
107 | )
108 |
109 | if (inputType == InputType.Title) {
110 | LaunchedEffect(Unit) {
111 | focusRequester!!.requestFocus()
112 | }
113 | }
114 | }
--------------------------------------------------------------------------------
/app/src/main/java/dev/xero/paper/presentation/notes/edit_notes/edit_note_components/SaveNoteButton.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2023 - Xero
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package dev.xero.paper.presentation.notes.edit_notes.edit_note_components
17 |
18 | import androidx.compose.foundation.layout.Arrangement
19 | import androidx.compose.foundation.layout.Row
20 | import androidx.compose.foundation.layout.padding
21 | import androidx.compose.foundation.layout.size
22 | import androidx.compose.material.*
23 | import androidx.compose.runtime.Composable
24 | import androidx.compose.ui.Alignment
25 | import androidx.compose.ui.Modifier
26 | import androidx.compose.ui.res.painterResource
27 | import androidx.compose.ui.res.stringResource
28 | import androidx.compose.ui.text.font.FontWeight
29 | import androidx.compose.ui.unit.dp
30 | import dev.xero.paper.R
31 | import dev.xero.paper.presentation.ui.theme.OnSurface
32 | import dev.xero.paper.presentation.ui.theme.SurfaceDark
33 |
34 | @Composable
35 | fun SaveNoteButton(
36 | modifier: Modifier = Modifier,
37 | isDarkTheme: Boolean,
38 | ) {
39 | Row(
40 | modifier = modifier.padding(horizontal = 24.dp),
41 | horizontalArrangement = Arrangement.spacedBy(8.dp),
42 | verticalAlignment = Alignment.CenterVertically
43 | ) {
44 | Icon(
45 | painter = painterResource(id = R.drawable.save_note_icon),
46 | contentDescription = null,
47 | modifier = modifier.size(24.dp),
48 | tint = if (isDarkTheme) SurfaceDark else OnSurface
49 | )
50 | Text(
51 | text = stringResource(id = R.string.save_note),
52 | style = MaterialTheme.typography.subtitle2,
53 | color = if (isDarkTheme) SurfaceDark else OnSurface,
54 | fontWeight = FontWeight.Bold,
55 | )
56 | }
57 | }
--------------------------------------------------------------------------------
/app/src/main/java/dev/xero/paper/presentation/notes/edit_notes/utils/NoteInputType.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2023 - Xero
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package dev.xero.paper.presentation.notes.edit_notes.utils
17 |
18 | enum class InputType {
19 | Title,
20 | Content
21 | }
22 |
--------------------------------------------------------------------------------
/app/src/main/java/dev/xero/paper/presentation/notes/notes_list/HomeScreen.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2023 - Xero
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package dev.xero.paper.presentation.notes.notes_list
17 |
18 | import androidx.compose.foundation.isSystemInDarkTheme
19 | import androidx.compose.foundation.layout.*
20 | import androidx.compose.foundation.lazy.LazyColumn
21 | import androidx.compose.foundation.shape.RoundedCornerShape
22 | import androidx.compose.material.*
23 | import androidx.compose.runtime.Composable
24 | import androidx.compose.runtime.livedata.observeAsState
25 | import androidx.compose.runtime.rememberCoroutineScope
26 | import androidx.compose.ui.Alignment
27 | import androidx.compose.ui.Modifier
28 | import androidx.compose.ui.graphics.Color
29 | import androidx.compose.ui.text.font.FontWeight
30 | import androidx.compose.ui.unit.dp
31 | import androidx.compose.ui.unit.sp
32 | import androidx.hilt.navigation.compose.hiltViewModel
33 | import dev.xero.paper.domain.model.NoteDBEntity
34 | import dev.xero.paper.presentation.notes.notes_list.components.*
35 | import dev.xero.paper.presentation.ui.theme.*
36 | import kotlinx.coroutines.launch
37 |
38 | @OptIn(ExperimentalMaterialApi::class)
39 | @Composable
40 | fun HomeScreen(
41 | modifier: Modifier = Modifier,
42 | viewModel: HomeScreenViewModel = hiltViewModel(),
43 | onAddNoteButtonClicked: () -> Unit,
44 | onEditNoteButtonClicked: (note: NoteDBEntity) -> Unit
45 | ) {
46 | val notes = viewModel.notes.observeAsState(initial = emptyList())
47 | val searchQuery = viewModel.searchQuery
48 | val isDarkTheme = isSystemInDarkTheme()
49 |
50 | val coroutineScope = rememberCoroutineScope()
51 | val modalSheetState = rememberModalBottomSheetState(
52 | initialValue = ModalBottomSheetValue.Hidden,
53 | confirmStateChange = { it != ModalBottomSheetValue.HalfExpanded },
54 | skipHalfExpanded = true
55 | )
56 |
57 | ModalBottomSheetLayout(
58 | sheetState = modalSheetState,
59 | sheetShape = RoundedCornerShape(topStart = 12.dp, topEnd = 12.dp),
60 | sheetContent = {
61 | Column {
62 | Text(
63 | text = "Do you want to delete this note?",
64 | style = MaterialTheme.typography.h3,
65 | fontSize = 20.sp,
66 | modifier = modifier.padding(
67 | top = 24.dp,
68 | start = 24.dp,
69 | end = 24.dp,
70 | bottom = 12.dp
71 | )
72 | )
73 | Text(
74 | text = "Deleting a note removes it permanently, it can't be undone.",
75 | style = MaterialTheme.typography.body1,
76 | fontSize = 16.sp,
77 | modifier = modifier.padding(
78 | start = 24.dp,
79 | end = 24.dp,
80 | bottom = 12.dp
81 | ),
82 | color = when(isDarkTheme) {
83 | true -> Grey100
84 | else -> Grey500
85 | }
86 | )
87 | Button(
88 | onClick = {
89 | coroutineScope.launch {
90 | viewModel.deleteNote()
91 | modalSheetState.hide()
92 | }
93 | },
94 | modifier = Modifier.padding(
95 | vertical = 12.dp,
96 | horizontal = 24.dp
97 | )
98 | ) {
99 | Text(
100 | text = "Delete Note",
101 | style = MaterialTheme.typography.subtitle2,
102 | fontWeight = FontWeight.Bold
103 | )
104 | }
105 | }
106 | },
107 | scrimColor = when(isDarkTheme) {
108 | true -> Color.Black.copy(alpha = 0.6f)
109 | else -> Color.Black.copy(alpha = 0.6f)
110 | },
111 | sheetBackgroundColor = when(isDarkTheme) {
112 | true -> BgDark
113 | else -> OnSurface
114 | }
115 | ) {
116 | Scaffold(
117 | topBar = {
118 | SearchBar(
119 | searchContent = searchQuery,
120 | onSearchContentChange = { viewModel.updateSearchQuery(it) },
121 | deviceThemeDark = isDarkTheme,
122 | )
123 | },
124 |
125 | floatingActionButton = {
126 | FloatingActionButton(
127 | onClick = onAddNoteButtonClicked,
128 | shape = RoundedCornerShape(4.dp),
129 | backgroundColor = Primary,
130 | elevation = FloatingActionButtonDefaults.elevation(
131 | defaultElevation = 0.dp,
132 | pressedElevation = 0.dp,
133 | focusedElevation = 0.dp,
134 | hoveredElevation = 0.dp
135 | ),
136 | ) {
137 | AddNoteButton(isDarkTheme = isDarkTheme)
138 | }
139 | }
140 | )
141 | { padding ->
142 | fun onTap(note: NoteDBEntity) {
143 | onEditNoteButtonClicked(note)
144 | }
145 |
146 | fun onDoubleTap(note: NoteDBEntity) {
147 | coroutineScope.launch {
148 | if (modalSheetState.isVisible)
149 | modalSheetState.hide()
150 | else
151 | modalSheetState.animateTo(ModalBottomSheetValue.Expanded)
152 | }
153 | viewModel.selectNote(note)
154 | }
155 |
156 | Column(
157 | modifier = Modifier.fillMaxWidth()
158 | ) {
159 | HomeDisplay(
160 | isDarkTheme = isDarkTheme,
161 | modifier = Modifier.padding(horizontal = 12.dp)
162 | )
163 |
164 | if (notes.value.isEmpty() && searchQuery.isEmpty()) {
165 | Box(contentAlignment = Alignment.Center) {
166 | LazyColumn(
167 | modifier = Modifier.fillMaxSize(),
168 | verticalArrangement = Arrangement.Center
169 | ) {
170 | item {
171 | EmptyNoteListDisplay(
172 | isDarkTheme = isDarkTheme,
173 | modifier = Modifier.padding(bottom = 64.dp)
174 | )
175 | }
176 | }
177 | }
178 | } else if (notes.value.isEmpty() && searchQuery.isNotEmpty()) {
179 | NoSearchResult(
180 | query = searchQuery,
181 | isDarkTheme = isDarkTheme
182 | )
183 | }
184 |
185 | NoteGrid(
186 | notes = notes,
187 | isDarkTheme = isDarkTheme,
188 | modifier = Modifier.padding(top = 12.dp),
189 | onDoubleTap = {
190 | onDoubleTap(it)
191 | },
192 | onTap = {
193 | onTap(it)
194 | }
195 | )
196 | }
197 | }
198 | }
199 | }
--------------------------------------------------------------------------------
/app/src/main/java/dev/xero/paper/presentation/notes/notes_list/HomeScreenViewModel.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2023 - Xero
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package dev.xero.paper.presentation.notes.notes_list
17 |
18 | import androidx.compose.runtime.getValue
19 | import androidx.compose.runtime.mutableStateOf
20 | import androidx.compose.runtime.setValue
21 | import androidx.lifecycle.LiveData
22 | import androidx.lifecycle.ViewModel
23 | import androidx.lifecycle.asLiveData
24 | import androidx.lifecycle.viewModelScope
25 | import dagger.hilt.android.lifecycle.HiltViewModel
26 | import dev.xero.paper.domain.model.NoteDBEntity
27 | import dev.xero.paper.domain.usecases.NoteUseCases
28 | import kotlinx.coroutines.flow.map
29 | import kotlinx.coroutines.launch
30 | import javax.inject.Inject
31 |
32 | @HiltViewModel
33 | class HomeScreenViewModel @Inject constructor(
34 | private val noteUseCases: NoteUseCases
35 | ) : ViewModel() {
36 | var notes: LiveData> = noteUseCases.getNotesUseCase().map {
37 | it.asReversed()
38 | }.asLiveData()
39 |
40 | private var selectedNote: NoteDBEntity? = null
41 | var searchQuery: String by mutableStateOf("")
42 |
43 | fun selectNote(note: NoteDBEntity) {
44 | selectedNote = note
45 | }
46 |
47 | fun updateSearchQuery(query: String) {
48 | searchQuery = query
49 | notes = if (searchQuery.isNotBlank()) {
50 | noteUseCases.getNotesUseCase().map {
51 | it.asReversed().filter { note ->
52 | note.title.lowercase().contains(searchQuery.lowercase())
53 | }
54 | }.asLiveData()
55 | } else {
56 | noteUseCases.getNotesUseCase().map {
57 | it.asReversed()
58 | }.asLiveData()
59 | }
60 | }
61 |
62 | fun deleteNote() {
63 | if (selectedNote != null) {
64 | viewModelScope.launch {
65 | noteUseCases.deleteNoteUseCase(selectedNote!!)
66 | }
67 | }
68 | }
69 |
70 | }
--------------------------------------------------------------------------------
/app/src/main/java/dev/xero/paper/presentation/notes/notes_list/components/AddNoteButton.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2023 - Xero
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package dev.xero.paper.presentation.notes.notes_list.components
17 |
18 | import androidx.compose.foundation.layout.Arrangement
19 | import androidx.compose.foundation.layout.Row
20 | import androidx.compose.foundation.layout.padding
21 | import androidx.compose.foundation.layout.size
22 | import androidx.compose.material.Icon
23 | import androidx.compose.material.MaterialTheme
24 | import androidx.compose.material.Text
25 | import androidx.compose.runtime.Composable
26 | import androidx.compose.ui.Alignment
27 | import androidx.compose.ui.Modifier
28 | import androidx.compose.ui.res.painterResource
29 | import androidx.compose.ui.text.font.FontWeight
30 | import androidx.compose.ui.unit.dp
31 | import dev.xero.paper.R
32 | import dev.xero.paper.presentation.ui.theme.OnSurface
33 | import dev.xero.paper.presentation.ui.theme.SurfaceDark
34 |
35 | @Composable
36 | fun AddNoteButton(
37 | modifier: Modifier = Modifier,
38 | isDarkTheme: Boolean
39 | ) {
40 | Row(
41 | modifier = modifier.padding(horizontal = 24.dp),
42 | horizontalArrangement = Arrangement.spacedBy(8.dp),
43 | verticalAlignment = Alignment.CenterVertically
44 | ) {
45 | Icon(
46 | painter = painterResource(id = R.drawable.app_icon_light),
47 | contentDescription = "add note",
48 | tint = if (isDarkTheme) SurfaceDark else OnSurface,
49 | modifier = Modifier.size(18.dp)
50 | )
51 |
52 | Text(
53 | text = "Add Note",
54 | style = MaterialTheme.typography.subtitle2,
55 | color = if (isDarkTheme) SurfaceDark else OnSurface,
56 | fontWeight = FontWeight.Bold,
57 | )
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/app/src/main/java/dev/xero/paper/presentation/notes/notes_list/components/EmptyNoteListDisplay.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2023 - Xero
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package dev.xero.paper.presentation.notes.notes_list.components
17 |
18 | import androidx.compose.foundation.Image
19 | import androidx.compose.foundation.layout.Arrangement
20 | import androidx.compose.foundation.layout.Column
21 | import androidx.compose.foundation.layout.fillMaxSize
22 | import androidx.compose.material.MaterialTheme
23 | import androidx.compose.material.Text
24 | import androidx.compose.runtime.Composable
25 | import androidx.compose.ui.Alignment
26 | import androidx.compose.ui.Modifier
27 | import androidx.compose.ui.res.painterResource
28 | import androidx.compose.ui.res.stringResource
29 | import androidx.compose.ui.unit.dp
30 | import dev.xero.paper.R
31 | import dev.xero.paper.presentation.ui.theme.Grey100
32 | import dev.xero.paper.presentation.ui.theme.Grey300
33 |
34 | @Composable
35 | fun EmptyNoteListDisplay(
36 | modifier: Modifier = Modifier,
37 | isDarkTheme: Boolean
38 | ) {
39 | Column(
40 | modifier = modifier.fillMaxSize(),
41 | verticalArrangement = Arrangement.spacedBy(24.dp, Alignment.CenterVertically),
42 | horizontalAlignment = Alignment.CenterHorizontally
43 | ) {
44 | val documentIconRes = when(isDarkTheme) {
45 | true -> R.drawable.document_icon_dark
46 | else -> R.drawable.document_icon_light
47 | }
48 |
49 | Image(
50 | painter = painterResource(id = documentIconRes),
51 | contentDescription = "no notes found",
52 | modifier = Modifier.align(Alignment.CenterHorizontally)
53 | )
54 |
55 | Text(
56 | text = stringResource(id = R.string.note_tip),
57 | style = MaterialTheme.typography.subtitle2,
58 | color = when(isDarkTheme) {
59 | true -> Grey100
60 | else -> Grey300
61 | }
62 | )
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/app/src/main/java/dev/xero/paper/presentation/notes/notes_list/components/HomeDisplay.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2023 - Xero
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package dev.xero.paper.presentation.notes.notes_list.components
17 |
18 | import androidx.compose.foundation.background
19 | import androidx.compose.foundation.layout.Column
20 | import androidx.compose.foundation.layout.fillMaxWidth
21 | import androidx.compose.foundation.layout.padding
22 | import androidx.compose.material.MaterialTheme
23 | import androidx.compose.material.Text
24 | import androidx.compose.runtime.Composable
25 | import androidx.compose.ui.Modifier
26 | import androidx.compose.ui.res.stringResource
27 | import androidx.compose.ui.unit.dp
28 | import dev.xero.paper.R
29 | import dev.xero.paper.presentation.ui.theme.*
30 |
31 | @Composable
32 | fun HomeDisplay(
33 | modifier: Modifier = Modifier,
34 | isDarkTheme: Boolean
35 | ) {
36 | Column(
37 | modifier = Modifier
38 | .fillMaxWidth()
39 | .background(
40 | color = if (isDarkTheme) BgDark else OnSurface
41 | )
42 | ) {
43 | Text(
44 | text = stringResource(id = R.string.home_text),
45 | modifier = modifier.padding(
46 | top = 12.dp
47 | ),
48 | style = MaterialTheme.typography.h3,
49 | color = when(isDarkTheme) {
50 | true -> OnSurface
51 | else -> Black
52 | }
53 | )
54 | Text(
55 | text = stringResource(id = R.string.efficiently),
56 | style = MaterialTheme.typography.h4,
57 | modifier = Modifier.padding(
58 | start = 40.dp,
59 | top = 8.dp
60 | ),
61 | color = when(isDarkTheme) {
62 | true -> Primary
63 | else -> Grey500
64 | }
65 | )
66 | }
67 | }
--------------------------------------------------------------------------------
/app/src/main/java/dev/xero/paper/presentation/notes/notes_list/components/NoSearchResults.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2023 - Xero
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package dev.xero.paper.presentation.notes.notes_list.components
17 |
18 | import androidx.compose.foundation.Image
19 | import androidx.compose.foundation.layout.*
20 | import androidx.compose.foundation.lazy.LazyColumn
21 | import androidx.compose.material.MaterialTheme
22 | import androidx.compose.material.Text
23 | import androidx.compose.runtime.Composable
24 | import androidx.compose.ui.Alignment
25 | import androidx.compose.ui.Modifier
26 | import androidx.compose.ui.res.painterResource
27 | import androidx.compose.ui.text.style.TextAlign
28 | import androidx.compose.ui.unit.dp
29 | import dev.xero.paper.R
30 |
31 |
32 | @Composable
33 | fun NoSearchResult(
34 | modifier: Modifier = Modifier,
35 | isDarkTheme: Boolean,
36 | query: String
37 | ) {
38 | Box(
39 | contentAlignment = Alignment.Center
40 | ) {
41 | LazyColumn(
42 | modifier = modifier
43 | .fillMaxSize()
44 | .padding(24.dp),
45 | verticalArrangement = Arrangement.spacedBy(12.dp, Alignment.CenterVertically),
46 | horizontalAlignment = Alignment.CenterHorizontally
47 | ) {
48 | item {
49 | val resID = when(isDarkTheme) {
50 | true -> R.drawable.document_blush_dark
51 | else -> R.drawable.document_blush_light
52 | }
53 |
54 | Image(
55 | painter = painterResource(id = resID),
56 | contentDescription = "no results found"
57 | )
58 |
59 | Text(
60 | text = "No Results for\n \"$query\"",
61 | style = MaterialTheme.typography.h3,
62 | textAlign = TextAlign.Center
63 | )
64 | }
65 | }
66 | }
67 | }
--------------------------------------------------------------------------------
/app/src/main/java/dev/xero/paper/presentation/notes/notes_list/components/NoteGrid.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2023 - Xero
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package dev.xero.paper.presentation.notes.notes_list.components
17 |
18 | import androidx.compose.foundation.ExperimentalFoundationApi
19 | import androidx.compose.foundation.layout.*
20 | import androidx.compose.foundation.lazy.staggeredgrid.LazyVerticalStaggeredGrid
21 | import androidx.compose.foundation.lazy.staggeredgrid.StaggeredGridCells
22 | import androidx.compose.foundation.lazy.staggeredgrid.items
23 | import androidx.compose.runtime.Composable
24 | import androidx.compose.runtime.State
25 | import androidx.compose.ui.Modifier
26 | import androidx.compose.ui.unit.dp
27 | import dev.xero.paper.domain.model.NoteDBEntity
28 |
29 | @OptIn(ExperimentalFoundationApi::class)
30 | @Composable
31 | fun NoteGrid(
32 | notes: State>,
33 | isDarkTheme: Boolean,
34 | onDoubleTap: (note: NoteDBEntity) -> Unit,
35 | onTap: (note: NoteDBEntity) -> Unit,
36 | modifier: Modifier = Modifier
37 | ) {
38 | LazyVerticalStaggeredGrid(
39 | columns = StaggeredGridCells.Adaptive(128.dp),
40 | modifier = modifier
41 | .fillMaxSize()
42 | .padding(horizontal = 12.dp),
43 | contentPadding = PaddingValues(12.dp),
44 | horizontalArrangement = Arrangement.spacedBy(8.dp),
45 | verticalArrangement = Arrangement.spacedBy(8.dp)
46 | ) {
47 | items(notes.value, key = { note -> note.id }) { note ->
48 | NoteItem(
49 | note = note,
50 | isDarkTheme = isDarkTheme,
51 | onDoubleTap = { onDoubleTap(note) },
52 | onTap = { onTap(note) }
53 | )
54 | }
55 | }
56 | }
--------------------------------------------------------------------------------
/app/src/main/java/dev/xero/paper/presentation/notes/notes_list/components/NoteItem.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2023 - Xero
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package dev.xero.paper.presentation.notes.notes_list.components
17 |
18 | import androidx.compose.foundation.gestures.detectTapGestures
19 | import androidx.compose.foundation.layout.Column
20 | import androidx.compose.foundation.layout.padding
21 | import androidx.compose.foundation.shape.RoundedCornerShape
22 | import androidx.compose.material.Card
23 | import androidx.compose.material.MaterialTheme
24 | import androidx.compose.material.Text
25 | import androidx.compose.runtime.*
26 | import androidx.compose.ui.Modifier
27 | import androidx.compose.ui.geometry.Offset
28 | import androidx.compose.ui.input.pointer.pointerInput
29 | import androidx.compose.ui.text.font.FontWeight
30 | import androidx.compose.ui.text.style.TextOverflow
31 | import androidx.compose.ui.unit.dp
32 | import androidx.compose.ui.unit.sp
33 | import dev.xero.paper.domain.model.NoteDBEntity
34 | import dev.xero.paper.presentation.ui.theme.*
35 |
36 | @Composable
37 | fun NoteItem(
38 | note: NoteDBEntity,
39 | isDarkTheme: Boolean,
40 | modifier: Modifier = Modifier,
41 | onDoubleTap: (note: NoteDBEntity) -> Unit,
42 | onTap: (note: NoteDBEntity) -> Unit
43 | ) {
44 | Card(
45 | shape = RoundedCornerShape(4.dp),
46 | elevation = 0.dp,
47 | backgroundColor = if (isDarkTheme) SurfaceDark else Secondary,
48 | modifier = modifier
49 | .pointerInput(Unit) {
50 | detectTapGestures (
51 | onDoubleTap = { onDoubleTap(note) },
52 | onTap = { onTap(note) }
53 | )
54 | }
55 | ) {
56 | Column(
57 | modifier = Modifier
58 | .padding(16.dp)
59 | ) {
60 | Text(
61 | text = note.title,
62 | style = MaterialTheme.typography.subtitle1,
63 | fontSize = 18.sp,
64 | color = if (isDarkTheme) Primary else Grey500,
65 | maxLines = 2,
66 | overflow = TextOverflow.Ellipsis,
67 | modifier = Modifier.padding(bottom = 8.dp),
68 | fontWeight = FontWeight.Black
69 | )
70 | Text(
71 | text = note.content,
72 | style = MaterialTheme.typography.body1,
73 | color = if (isDarkTheme) Grey100 else Grey300,
74 | maxLines = 6,
75 | fontSize = 14.sp,
76 | overflow = TextOverflow.Ellipsis
77 | )
78 | }
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/app/src/main/java/dev/xero/paper/presentation/notes/notes_list/components/SearchBar.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2023 - Xero
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package dev.xero.paper.presentation.notes.notes_list.components
17 |
18 | import androidx.compose.foundation.Image
19 | import androidx.compose.foundation.background
20 | import androidx.compose.foundation.layout.*
21 | import androidx.compose.foundation.shape.RoundedCornerShape
22 | import androidx.compose.material.MaterialTheme
23 | import androidx.compose.material.OutlinedTextField
24 | import androidx.compose.material.Text
25 | import androidx.compose.material.TextFieldDefaults
26 | import androidx.compose.runtime.Composable
27 | import androidx.compose.ui.Modifier
28 | import androidx.compose.ui.graphics.Color
29 | import androidx.compose.ui.res.painterResource
30 | import androidx.compose.ui.tooling.preview.Preview
31 | import androidx.compose.ui.unit.dp
32 | import dev.xero.paper.R
33 | import dev.xero.paper.presentation.ui.theme.*
34 |
35 | @Composable
36 | fun SearchBar(
37 | modifier: Modifier = Modifier,
38 | searchContent: String,
39 | onSearchContentChange: (String) -> Unit,
40 | deviceThemeDark: Boolean
41 | ) {
42 | val searchIcon = when(deviceThemeDark) {
43 | true -> R.drawable.search_icon_dark
44 | else -> R.drawable.search_icon_light
45 | }
46 |
47 | val colorMapping: Map = mapOf(
48 | "placeholder" to if (deviceThemeDark) Grey100 else Grey300,
49 | "background" to if (deviceThemeDark) SurfaceDark else Secondary
50 | )
51 |
52 | Row(
53 | modifier = modifier
54 | .fillMaxWidth()
55 | ) {
56 | OutlinedTextField(
57 | value = searchContent,
58 | onValueChange = onSearchContentChange,
59 | singleLine = true,
60 | maxLines = 1,
61 | placeholder = { Text(text = "search your notes") },
62 | leadingIcon = {
63 | Image(
64 | painter = painterResource(id = searchIcon),
65 | contentDescription = null
66 | )
67 | },
68 | colors = TextFieldDefaults.outlinedTextFieldColors(
69 | placeholderColor = colorMapping["placeholder"]!!,
70 | unfocusedBorderColor = colorMapping["background"]!!,
71 | focusedBorderColor = colorMapping["background"]!!,
72 | backgroundColor = colorMapping["background"]!!,
73 | cursorColor = Primary
74 | ),
75 | textStyle = MaterialTheme.typography.body2,
76 | shape = RoundedCornerShape(0.dp),
77 | modifier = Modifier.fillMaxWidth()
78 | )
79 | }
80 | }
81 |
82 | @Preview
83 | @Composable
84 | fun SearchBarDefaultPreview() {
85 | Box(
86 | modifier = Modifier
87 | .fillMaxSize()
88 | .background(OnSurface),
89 | ) {
90 | var searchContentFake = ""
91 | SearchBar(
92 | searchContent = searchContentFake,
93 | onSearchContentChange = { searchContentFake = it },
94 | deviceThemeDark = false
95 | )
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/app/src/main/java/dev/xero/paper/presentation/ui/theme/Color.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2023 - Xero
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package dev.xero.paper.presentation.ui.theme
17 |
18 | import androidx.compose.ui.graphics.Color
19 |
20 | val Primary = Color(0xFF3DDC84)
21 | val OnSurface = Color(0xFFEBF7EE)
22 | val Secondary = Color(0xFFCAF0D2)
23 | val Grey100 = Color(0xFF8A978D)
24 | val Grey300 = Color(0xFF66776A)
25 | val Grey500 = Color(0xFF445347)
26 | val Black = Color(0xFF070809)
27 | val BgDark = Color(0xFF080B0D)
28 | val SurfaceDark = Color(0xFF0C1013)
29 |
30 |
--------------------------------------------------------------------------------
/app/src/main/java/dev/xero/paper/presentation/ui/theme/Shape.kt:
--------------------------------------------------------------------------------
1 | package dev.xero.paper.presentation.ui.theme
2 |
3 | import androidx.compose.foundation.shape.RoundedCornerShape
4 | import androidx.compose.material.Shapes
5 | import androidx.compose.ui.unit.dp
6 |
7 | val Shapes = Shapes(
8 | small = RoundedCornerShape(4.dp),
9 | medium = RoundedCornerShape(4.dp),
10 | large = RoundedCornerShape(0.dp)
11 | )
--------------------------------------------------------------------------------
/app/src/main/java/dev/xero/paper/presentation/ui/theme/Theme.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2023 - Xero
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package dev.xero.paper.presentation.ui.theme
17 |
18 | import androidx.compose.foundation.isSystemInDarkTheme
19 | import androidx.compose.material.MaterialTheme
20 | import androidx.compose.material.darkColors
21 | import androidx.compose.material.lightColors
22 | import androidx.compose.runtime.Composable
23 | import com.google.accompanist.systemuicontroller.rememberSystemUiController
24 |
25 | private val DarkColorPalette = darkColors(
26 | primary = Primary,
27 | surface = SurfaceDark,
28 | background = BgDark,
29 | onSurface = Grey100
30 | )
31 |
32 | private val LightColorPalette = lightColors(
33 | primary = Primary,
34 | surface = Secondary,
35 | background = OnSurface,
36 | onSurface = Grey500
37 | )
38 |
39 | @Composable
40 | fun PaperTheme(darkTheme: Boolean = isSystemInDarkTheme(), content: @Composable () -> Unit) {
41 | val colors = if (darkTheme) {
42 | DarkColorPalette
43 | } else {
44 | LightColorPalette
45 | }
46 |
47 | val systemUiController = rememberSystemUiController()
48 | systemUiController.setStatusBarColor(
49 | darkIcons = !darkTheme,
50 | color = when(darkTheme) {
51 | true -> SurfaceDark
52 | else -> Secondary
53 | }
54 | )
55 |
56 | MaterialTheme(
57 | colors = colors,
58 | typography = Typography,
59 | shapes = Shapes,
60 | content = content
61 | )
62 | }
--------------------------------------------------------------------------------
/app/src/main/java/dev/xero/paper/presentation/ui/theme/Type.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2023 - Xero
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package dev.xero.paper.presentation.ui.theme
17 |
18 | import androidx.compose.material.Typography
19 | import androidx.compose.ui.text.TextStyle
20 | import androidx.compose.ui.text.font.Font
21 | import androidx.compose.ui.text.font.FontFamily
22 | import androidx.compose.ui.text.font.FontWeight
23 | import androidx.compose.ui.unit.sp
24 | import dev.xero.paper.R
25 |
26 | val AvenirLT = FontFamily(
27 | Font(
28 | resId = R.font.avenir_lt_book,
29 | weight = FontWeight.Normal
30 | ),
31 |
32 | Font(
33 | resId = R.font.avenir_lt_medium,
34 | weight = FontWeight.Medium
35 | ),
36 |
37 | Font(
38 | resId = R.font.avenir_lt_black,
39 | weight = FontWeight.Black
40 | )
41 | )
42 |
43 | val CoreSans = FontFamily(
44 | Font(
45 | resId = R.font.core_sans_regular,
46 | weight = FontWeight.Normal
47 | ),
48 |
49 | Font(
50 | resId = R.font.core_sans_bold,
51 | weight = FontWeight.Bold
52 | )
53 | )
54 |
55 | val OutFit = FontFamily(
56 | Font(
57 | resId = R.font.outfit_regular,
58 | weight = FontWeight.Normal
59 | )
60 | )
61 |
62 | val Typography = Typography(
63 | caption = TextStyle(
64 | fontFamily = CoreSans,
65 | fontWeight = FontWeight.Normal,
66 | fontSize = 16.sp
67 | ),
68 |
69 | h3 = TextStyle(
70 | fontFamily = CoreSans,
71 | fontWeight = FontWeight.Bold,
72 | fontSize = 22.sp
73 | ),
74 |
75 | h4 = TextStyle(
76 | fontFamily = CoreSans,
77 | fontWeight = FontWeight.Normal,
78 | fontSize = 20.sp
79 | ),
80 |
81 | subtitle1 = TextStyle(
82 | fontFamily = AvenirLT,
83 | fontWeight = FontWeight.Medium,
84 | fontSize = 16.sp
85 | ),
86 |
87 | subtitle2 = TextStyle(
88 | fontFamily = CoreSans,
89 | fontWeight = FontWeight.Normal,
90 | fontSize = 14.sp
91 | ),
92 |
93 | body1 = TextStyle(
94 | fontFamily = CoreSans,
95 | fontWeight = FontWeight.Normal,
96 | fontSize = 16.sp
97 | ),
98 |
99 | body2 = TextStyle(
100 | fontFamily = OutFit,
101 | fontWeight = FontWeight.Normal,
102 | fontSize = 16.sp
103 | ),
104 | )
--------------------------------------------------------------------------------
/app/src/main/res/drawable/app_icon_dark.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
9 |
12 |
15 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/app_icon_light.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
9 |
12 |
15 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/back_icon_light.xml:
--------------------------------------------------------------------------------
1 |
6 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/branding_dark.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/branding_light.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/document_blush_dark.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
9 |
15 |
21 |
24 |
27 |
30 |
33 |
36 |
39 |
42 |
45 |
51 |
57 |
63 |
69 |
75 |
81 |
82 |
83 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/document_blush_light.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
9 |
15 |
21 |
24 |
27 |
30 |
33 |
36 |
39 |
42 |
45 |
51 |
57 |
63 |
69 |
75 |
81 |
82 |
83 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/document_icon_dark.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
12 |
17 |
22 |
27 |
32 |
37 |
38 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/document_icon_light.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
12 |
17 |
22 |
27 |
32 |
37 |
38 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
6 |
10 |
13 |
16 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/save_note_icon.xml:
--------------------------------------------------------------------------------
1 |
6 |
13 |
20 |
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/search_icon_dark.xml:
--------------------------------------------------------------------------------
1 |
6 |
13 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/search_icon_light.xml:
--------------------------------------------------------------------------------
1 |
6 |
13 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/splash_icon_dark.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
9 |
12 |
15 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/splash_icon_light.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
9 |
12 |
15 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/res/font/avenir_lt_black.otf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dev-xero/paper-app/f3c532473b6d5aae8afe8c9175c08cd6e90315de/app/src/main/res/font/avenir_lt_black.otf
--------------------------------------------------------------------------------
/app/src/main/res/font/avenir_lt_book.otf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dev-xero/paper-app/f3c532473b6d5aae8afe8c9175c08cd6e90315de/app/src/main/res/font/avenir_lt_book.otf
--------------------------------------------------------------------------------
/app/src/main/res/font/avenir_lt_medium.otf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dev-xero/paper-app/f3c532473b6d5aae8afe8c9175c08cd6e90315de/app/src/main/res/font/avenir_lt_medium.otf
--------------------------------------------------------------------------------
/app/src/main/res/font/core_sans_bold.otf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dev-xero/paper-app/f3c532473b6d5aae8afe8c9175c08cd6e90315de/app/src/main/res/font/core_sans_bold.otf
--------------------------------------------------------------------------------
/app/src/main/res/font/core_sans_regular.otf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dev-xero/paper-app/f3c532473b6d5aae8afe8c9175c08cd6e90315de/app/src/main/res/font/core_sans_regular.otf
--------------------------------------------------------------------------------
/app/src/main/res/font/outfit_regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dev-xero/paper-app/f3c532473b6d5aae8afe8c9175c08cd6e90315de/app/src/main/res/font/outfit_regular.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/dev-xero/paper-app/f3c532473b6d5aae8afe8c9175c08cd6e90315de/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dev-xero/paper-app/f3c532473b6d5aae8afe8c9175c08cd6e90315de/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dev-xero/paper-app/f3c532473b6d5aae8afe8c9175c08cd6e90315de/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dev-xero/paper-app/f3c532473b6d5aae8afe8c9175c08cd6e90315de/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dev-xero/paper-app/f3c532473b6d5aae8afe8c9175c08cd6e90315de/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dev-xero/paper-app/f3c532473b6d5aae8afe8c9175c08cd6e90315de/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dev-xero/paper-app/f3c532473b6d5aae8afe8c9175c08cd6e90315de/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dev-xero/paper-app/f3c532473b6d5aae8afe8c9175c08cd6e90315de/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dev-xero/paper-app/f3c532473b6d5aae8afe8c9175c08cd6e90315de/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dev-xero/paper-app/f3c532473b6d5aae8afe8c9175c08cd6e90315de/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values-night-v31/SplashTheme.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
25 |
--------------------------------------------------------------------------------
/app/src/main/res/values-night/SplashTheme.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
23 |
--------------------------------------------------------------------------------
/app/src/main/res/values-night/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 | #FF080B0D
19 |
--------------------------------------------------------------------------------
/app/src/main/res/values-night/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
24 |
--------------------------------------------------------------------------------
/app/src/main/res/values-v31/SplashTheme.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
25 |
--------------------------------------------------------------------------------
/app/src/main/res/values/SplashTheme.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
23 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 | #FF5DE07A
19 | #FFCAF0D2
20 |
--------------------------------------------------------------------------------
/app/src/main/res/values/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3DDC84
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 | Paper
19 | — Paper, Organize your notes.
20 | Efficiently.
21 | To start creating notes, click on the note button
22 | Save Note
23 |
--------------------------------------------------------------------------------
/app/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
24 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/backup_rules.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/data_extraction_rules.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
12 |
13 |
19 |
--------------------------------------------------------------------------------
/app/src/test/java/dev/xero/paper/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package dev.xero.paper
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
--------------------------------------------------------------------------------
/assets/preview - 1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dev-xero/paper-app/f3c532473b6d5aae8afe8c9175c08cd6e90315de/assets/preview - 1.png
--------------------------------------------------------------------------------
/assets/preview - 2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dev-xero/paper-app/f3c532473b6d5aae8afe8c9175c08cd6e90315de/assets/preview - 2.png
--------------------------------------------------------------------------------
/assets/preview - 3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dev-xero/paper-app/f3c532473b6d5aae8afe8c9175c08cd6e90315de/assets/preview - 3.png
--------------------------------------------------------------------------------
/assets/preview - 4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dev-xero/paper-app/f3c532473b6d5aae8afe8c9175c08cd6e90315de/assets/preview - 4.png
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | ext {
3 | compose_ui_version = '1.3.3'
4 | }
5 | }// Top-level build file where you can add configuration options common to all sub-projects/modules.
6 | plugins {
7 | id 'com.android.application' version '7.4.1' apply false
8 | id 'com.android.library' version '7.4.1' apply false
9 | id 'org.jetbrains.kotlin.android' version '1.8.10' apply false
10 | id 'com.google.dagger.hilt.android' version '2.45' apply false
11 | }
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app's APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Kotlin code style for this project: "official" or "obsolete":
19 | kotlin.code.style=official
20 | # Enables namespacing of each library's R class so that its R class includes only the
21 | # resources declared in the library itself and none from the library's dependencies,
22 | # thereby reducing the size of the R class for that library
23 | android.nonTransitiveRClass=true
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dev-xero/paper-app/f3c532473b6d5aae8afe8c9175c08cd6e90315de/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Tue Mar 07 16:21:55 WAT 2023
2 | distributionBase=GRADLE_USER_HOME
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-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 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | pluginManagement {
2 | repositories {
3 | google()
4 | mavenCentral()
5 | gradlePluginPortal()
6 | }
7 | }
8 | dependencyResolutionManagement {
9 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
10 | repositories {
11 | google()
12 | mavenCentral()
13 | }
14 | }
15 | rootProject.name = "Paper"
16 | include ':app'
17 |
--------------------------------------------------------------------------------