├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── ic_launcher_background.xml │ │ │ │ ├── colors.xml │ │ │ │ └── themes.xml │ │ │ ├── drawable │ │ │ │ └── notepad_icon.png │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ ├── ic_launcher_round.png │ │ │ │ └── ic_launcher_foreground.png │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ ├── ic_launcher_round.png │ │ │ │ └── ic_launcher_foreground.png │ │ │ ├── font │ │ │ │ └── varela_round_regular.ttf │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ ├── ic_launcher_round.png │ │ │ │ └── ic_launcher_foreground.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ ├── ic_launcher_round.png │ │ │ │ └── ic_launcher_foreground.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ ├── ic_launcher_round.png │ │ │ │ └── ic_launcher_foreground.png │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ ├── ic_launcher.xml │ │ │ │ └── ic_launcher_round.xml │ │ │ ├── values-night │ │ │ │ └── themes.xml │ │ │ └── drawable-v24 │ │ │ │ └── ic_launcher_foreground.xml │ │ ├── ic_launcher-playstore.png │ │ ├── java │ │ │ └── com │ │ │ │ └── akshayashokcode │ │ │ │ └── notepad │ │ │ │ ├── NoteApp.kt │ │ │ │ ├── feature_note │ │ │ │ ├── domain │ │ │ │ │ ├── util │ │ │ │ │ │ ├── OrderType.kt │ │ │ │ │ │ └── NoteOrder.kt │ │ │ │ │ ├── use_case │ │ │ │ │ │ ├── NoteUseCases.kt │ │ │ │ │ │ ├── DeleteNote.kt │ │ │ │ │ │ ├── GetNote.kt │ │ │ │ │ │ ├── AddNote.kt │ │ │ │ │ │ └── GetNotes.kt │ │ │ │ │ ├── repository │ │ │ │ │ │ └── NoteRepository.kt │ │ │ │ │ └── model │ │ │ │ │ │ └── Note.kt │ │ │ │ ├── presentation │ │ │ │ │ ├── add_edit_note │ │ │ │ │ │ ├── NoteTextFieldState.kt │ │ │ │ │ │ ├── AddEditNoteEvent.kt │ │ │ │ │ │ ├── components │ │ │ │ │ │ │ ├── AppKeyboardFocusManager.kt │ │ │ │ │ │ │ └── TransparentHintTextField.kt │ │ │ │ │ │ ├── AddEditNoteViewModel.kt │ │ │ │ │ │ └── AddEditNoteScreen.kt │ │ │ │ │ ├── util │ │ │ │ │ │ ├── Screen.kt │ │ │ │ │ │ └── KeyBoardManager.kt │ │ │ │ │ ├── notes │ │ │ │ │ │ ├── NotesState.kt │ │ │ │ │ │ ├── NotesEvent.kt │ │ │ │ │ │ ├── components │ │ │ │ │ │ │ ├── DefaultRadioButton.kt │ │ │ │ │ │ │ ├── EmptyScreenText.kt │ │ │ │ │ │ │ ├── OrderSection.kt │ │ │ │ │ │ │ └── NoteItem.kt │ │ │ │ │ │ ├── NotesViewModel.kt │ │ │ │ │ │ └── NotesScreen.kt │ │ │ │ │ └── MainActivity.kt │ │ │ │ └── data │ │ │ │ │ ├── data_source │ │ │ │ │ ├── NoteDataBase.kt │ │ │ │ │ └── NoteDao.kt │ │ │ │ │ └── repository │ │ │ │ │ └── NoteRepositoryImpl.kt │ │ │ │ ├── core │ │ │ │ └── util │ │ │ │ │ └── TestTags.kt │ │ │ │ ├── ui │ │ │ │ └── theme │ │ │ │ │ ├── Shape.kt │ │ │ │ │ ├── Color.kt │ │ │ │ │ ├── Type.kt │ │ │ │ │ └── Theme.kt │ │ │ │ └── di │ │ │ │ └── AppModule.kt │ │ └── AndroidManifest.xml │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── akshayashokcode │ │ │ └── notepad │ │ │ ├── feature_note │ │ │ ├── domain │ │ │ │ └── use_case │ │ │ │ │ ├── AddNoteTest.kt │ │ │ │ │ └── GetNotesTest.kt │ │ │ └── data │ │ │ │ └── repository │ │ │ │ └── FakeNoteRepository.kt │ │ │ └── ExampleUnitTest.kt │ └── androidTest │ │ └── java │ │ └── com │ │ └── akshayashokcode │ │ └── notepad │ │ ├── HiltTestRunner.kt │ │ ├── ExampleInstrumentedTest.kt │ │ ├── di │ │ └── TestAppModule.kt │ │ └── feature_note │ │ └── presentation │ │ ├── notes │ │ └── NotesScreenTest.kt │ │ └── NotesEndToEndTest.kt ├── proguard-rules.pro └── build.gradle ├── screenshots ├── screenshot1.png ├── screenshot2.png ├── screenshot3.png ├── screenshot4.png └── screenshot5.png ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── settings.gradle ├── gradle.properties ├── README.md ├── gradlew.bat └── gradlew /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | NotePad 3 | -------------------------------------------------------------------------------- /screenshots/screenshot1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkshayAshokCode/NotePad/HEAD/screenshots/screenshot1.png -------------------------------------------------------------------------------- /screenshots/screenshot2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkshayAshokCode/NotePad/HEAD/screenshots/screenshot2.png -------------------------------------------------------------------------------- /screenshots/screenshot3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkshayAshokCode/NotePad/HEAD/screenshots/screenshot3.png -------------------------------------------------------------------------------- /screenshots/screenshot4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkshayAshokCode/NotePad/HEAD/screenshots/screenshot4.png -------------------------------------------------------------------------------- /screenshots/screenshot5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkshayAshokCode/NotePad/HEAD/screenshots/screenshot5.png -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkshayAshokCode/NotePad/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/ic_launcher-playstore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkshayAshokCode/NotePad/HEAD/app/src/main/ic_launcher-playstore.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/notepad_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkshayAshokCode/NotePad/HEAD/app/src/main/res/drawable/notepad_icon.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkshayAshokCode/NotePad/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkshayAshokCode/NotePad/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/font/varela_round_regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkshayAshokCode/NotePad/HEAD/app/src/main/res/font/varela_round_regular.ttf -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkshayAshokCode/NotePad/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkshayAshokCode/NotePad/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkshayAshokCode/NotePad/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkshayAshokCode/NotePad/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkshayAshokCode/NotePad/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkshayAshokCode/NotePad/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkshayAshokCode/NotePad/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkshayAshokCode/NotePad/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkshayAshokCode/NotePad/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkshayAshokCode/NotePad/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkshayAshokCode/NotePad/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkshayAshokCode/NotePad/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkshayAshokCode/NotePad/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/values/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3DDC84 4 | -------------------------------------------------------------------------------- /app/src/test/java/com/akshayashokcode/notepad/feature_note/domain/use_case/AddNoteTest.kt: -------------------------------------------------------------------------------- 1 | package com.akshayashokcode.notepad.feature_note.domain.use_case 2 | 3 | import org.junit.Assert.* 4 | 5 | class AddNoteTest -------------------------------------------------------------------------------- /app/src/main/java/com/akshayashokcode/notepad/NoteApp.kt: -------------------------------------------------------------------------------- 1 | package com.akshayashokcode.notepad 2 | 3 | import android.app.Application 4 | import dagger.hilt.android.HiltAndroidApp 5 | 6 | @HiltAndroidApp 7 | class NoteApp:Application() -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /app/src/main/java/com/akshayashokcode/notepad/feature_note/domain/util/OrderType.kt: -------------------------------------------------------------------------------- 1 | package com.akshayashokcode.notepad.feature_note.domain.util 2 | 3 | sealed class OrderType{ 4 | data object Ascending:OrderType() 5 | data object Descending:OrderType() 6 | } 7 | -------------------------------------------------------------------------------- /app/src/main/java/com/akshayashokcode/notepad/feature_note/domain/use_case/NoteUseCases.kt: -------------------------------------------------------------------------------- 1 | package com.akshayashokcode.notepad.feature_note.domain.use_case 2 | 3 | data class NoteUseCases( 4 | val getNotes: GetNotes, 5 | val deleteNote: DeleteNote, 6 | val addNote: AddNote, 7 | val getNote:GetNote 8 | ) 9 | -------------------------------------------------------------------------------- /app/src/main/java/com/akshayashokcode/notepad/feature_note/presentation/add_edit_note/NoteTextFieldState.kt: -------------------------------------------------------------------------------- 1 | package com.akshayashokcode.notepad.feature_note.presentation.add_edit_note 2 | 3 | data class NoteTextFieldState( 4 | val text:String="", 5 | val hint:String="", 6 | val isHintVisible:Boolean=true 7 | ) 8 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/java/com/akshayashokcode/notepad/feature_note/presentation/util/Screen.kt: -------------------------------------------------------------------------------- 1 | package com.akshayashokcode.notepad.feature_note.presentation.util 2 | 3 | sealed class Screen(val route:String){ 4 | data object NotesScreen:Screen("notes_screen") 5 | data object AddEditNoteScreen:Screen("add_edit_note_screen") 6 | } 7 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/java/com/akshayashokcode/notepad/core/util/TestTags.kt: -------------------------------------------------------------------------------- 1 | package com.akshayashokcode.notepad.core.util 2 | 3 | object TestTags { 4 | const val ORDER_SECTION = "ORDER_SECTION" 5 | const val TITLE_TEXT_FIELD = "TITLE_TEXT_FIELD" 6 | const val CONTENT_TEXT_FIELD = "CONTENT_TEXT_FIELD" 7 | const val NOTE_ITEM = "NOTE_ITEM" 8 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | /.idea/navEditor.xml 9 | /.idea/assetWizardSettings.xml 10 | /.idea/inspectionProfiles/Project_Default.xml 11 | .DS_Store 12 | /build 13 | /captures 14 | .externalNativeBuild 15 | .cxx 16 | local.properties 17 | -------------------------------------------------------------------------------- /app/src/main/java/com/akshayashokcode/notepad/ui/theme/Shape.kt: -------------------------------------------------------------------------------- 1 | package com.akshayashokcode.notepad.ui.theme 2 | 3 | import androidx.compose.foundation.shape.RoundedCornerShape 4 | import androidx.compose.material3.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/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FFBB86FC 4 | #FF202020 5 | #FF202020 6 | #FF03DAC5 7 | #FF018786 8 | #FF000000 9 | #FFFFFFFF 10 | -------------------------------------------------------------------------------- /app/src/test/java/com/akshayashokcode/notepad/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | package com.akshayashokcode.notepad 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 | } -------------------------------------------------------------------------------- /app/src/main/java/com/akshayashokcode/notepad/feature_note/domain/use_case/DeleteNote.kt: -------------------------------------------------------------------------------- 1 | package com.akshayashokcode.notepad.feature_note.domain.use_case 2 | 3 | import com.akshayashokcode.notepad.feature_note.domain.model.Note 4 | import com.akshayashokcode.notepad.feature_note.domain.repository.NoteRepository 5 | 6 | class DeleteNote( 7 | private val repository: NoteRepository 8 | ) { 9 | suspend operator fun invoke(note: Note){ 10 | repository.deleteNote(note) 11 | } 12 | } -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | gradlePluginPortal() 4 | google() 5 | mavenCentral() 6 | } 7 | } 8 | 9 | dependencyResolutionManagement { 10 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) 11 | repositories { 12 | google() 13 | mavenCentral() 14 | // jcenter() // Warning: this repository is going to shut down soon 15 | } 16 | } 17 | 18 | rootProject.name = "NotePad" 19 | include ':app' 20 | -------------------------------------------------------------------------------- /app/src/main/java/com/akshayashokcode/notepad/feature_note/domain/use_case/GetNote.kt: -------------------------------------------------------------------------------- 1 | package com.akshayashokcode.notepad.feature_note.domain.use_case 2 | 3 | import com.akshayashokcode.notepad.feature_note.domain.model.Note 4 | import com.akshayashokcode.notepad.feature_note.domain.repository.NoteRepository 5 | 6 | class GetNote( 7 | private val repository: NoteRepository 8 | ) { 9 | 10 | suspend operator fun invoke(id:Int): Note?{ 11 | return repository.getNoteById(id) 12 | } 13 | } -------------------------------------------------------------------------------- /app/src/main/java/com/akshayashokcode/notepad/feature_note/domain/repository/NoteRepository.kt: -------------------------------------------------------------------------------- 1 | package com.akshayashokcode.notepad.feature_note.domain.repository 2 | 3 | import com.akshayashokcode.notepad.feature_note.domain.model.Note 4 | import kotlinx.coroutines.flow.Flow 5 | 6 | interface NoteRepository { 7 | 8 | fun getNotes(): Flow> 9 | 10 | suspend fun getNoteById(id: Int): Note? 11 | 12 | suspend fun insertNote(note: Note) 13 | 14 | suspend fun deleteNote(note: Note) 15 | } -------------------------------------------------------------------------------- /app/src/main/java/com/akshayashokcode/notepad/feature_note/data/data_source/NoteDataBase.kt: -------------------------------------------------------------------------------- 1 | package com.akshayashokcode.notepad.feature_note.data.data_source 2 | 3 | import androidx.room.Database 4 | import androidx.room.RoomDatabase 5 | import com.akshayashokcode.notepad.feature_note.domain.model.Note 6 | 7 | @Database(entities = [Note::class], version = 1) 8 | abstract class NoteDataBase : RoomDatabase() { 9 | 10 | abstract val noteDao:NoteDao 11 | companion object{ 12 | const val DATABASE_NAME="notes_db" 13 | } 14 | } -------------------------------------------------------------------------------- /app/src/main/java/com/akshayashokcode/notepad/feature_note/presentation/notes/NotesState.kt: -------------------------------------------------------------------------------- 1 | package com.akshayashokcode.notepad.feature_note.presentation.notes 2 | 3 | import com.akshayashokcode.notepad.feature_note.domain.model.Note 4 | import com.akshayashokcode.notepad.feature_note.domain.util.NoteOrder 5 | import com.akshayashokcode.notepad.feature_note.domain.util.OrderType 6 | 7 | data class NotesState( 8 | val notes:List = emptyList(), 9 | val noteOrder: NoteOrder=NoteOrder.Date(OrderType.Descending), 10 | val isOrderSectionVisible:Boolean=false 11 | ) 12 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/akshayashokcode/notepad/HiltTestRunner.kt: -------------------------------------------------------------------------------- 1 | package com.akshayashokcode.notepad 2 | 3 | import android.app.Application 4 | import android.content.Context 5 | import androidx.test.runner.AndroidJUnitRunner 6 | import dagger.hilt.android.testing.HiltTestApplication 7 | 8 | class HiltTestRunner : AndroidJUnitRunner() { 9 | 10 | override fun newApplication( 11 | cl: ClassLoader?, 12 | className: String?, 13 | context: Context? 14 | ): Application { 15 | return super.newApplication(cl, HiltTestApplication::class.java.name, context) 16 | } 17 | } -------------------------------------------------------------------------------- /app/src/main/java/com/akshayashokcode/notepad/feature_note/presentation/notes/NotesEvent.kt: -------------------------------------------------------------------------------- 1 | package com.akshayashokcode.notepad.feature_note.presentation.notes 2 | 3 | import com.akshayashokcode.notepad.feature_note.domain.model.Note 4 | import com.akshayashokcode.notepad.feature_note.domain.util.NoteOrder 5 | 6 | sealed class NotesEvent { 7 | data class Order(val noteOrder: NoteOrder) : NotesEvent() 8 | data class DeleteNote(val note: Note) : NotesEvent() 9 | data object RestoreNote : NotesEvent() 10 | data object ToggleOrderSection : NotesEvent() 11 | data object CloseOrderSection : NotesEvent() 12 | } 13 | -------------------------------------------------------------------------------- /app/src/main/java/com/akshayashokcode/notepad/feature_note/domain/util/NoteOrder.kt: -------------------------------------------------------------------------------- 1 | package com.akshayashokcode.notepad.feature_note.domain.util 2 | 3 | sealed class NoteOrder(val orderType: OrderType){ 4 | class Title(orderType: OrderType):NoteOrder(orderType) 5 | class Date(orderType: OrderType):NoteOrder(orderType) 6 | class Color(orderType: OrderType):NoteOrder(orderType) 7 | 8 | fun copy(orderType: OrderType):NoteOrder{ 9 | return when(this){ 10 | is Title->Title(orderType) 11 | is Date->Date(orderType) 12 | is Color->Color(orderType) 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /app/src/main/java/com/akshayashokcode/notepad/feature_note/data/data_source/NoteDao.kt: -------------------------------------------------------------------------------- 1 | package com.akshayashokcode.notepad.feature_note.data.data_source 2 | 3 | import androidx.room.* 4 | import com.akshayashokcode.notepad.feature_note.domain.model.Note 5 | import kotlinx.coroutines.flow.Flow 6 | 7 | @Dao 8 | interface NoteDao { 9 | 10 | @Query("SELECT * FROM note") 11 | fun getNotes(): Flow> 12 | 13 | @Query("SELECT * FROM note WHERE id= :id") 14 | suspend fun getNoteById(id: Int): Note? 15 | 16 | @Insert(onConflict = OnConflictStrategy.REPLACE) 17 | suspend fun insertNote(note: Note) 18 | 19 | @Delete 20 | suspend fun deleteNote(note: Note) 21 | } -------------------------------------------------------------------------------- /app/src/main/java/com/akshayashokcode/notepad/feature_note/presentation/add_edit_note/AddEditNoteEvent.kt: -------------------------------------------------------------------------------- 1 | package com.akshayashokcode.notepad.feature_note.presentation.add_edit_note 2 | 3 | import androidx.compose.ui.focus.FocusState 4 | 5 | sealed class AddEditNoteEvent{ 6 | data class EnteredTitle(val value:String):AddEditNoteEvent() 7 | data class ChangeTitleFocus(val focusState: FocusState):AddEditNoteEvent() 8 | data class EnteredContent(val value:String):AddEditNoteEvent() 9 | data class ChangeContentFocus(val focusState: FocusState):AddEditNoteEvent() 10 | data class ChangeColor(val color:Int):AddEditNoteEvent() 11 | data object SaveNote:AddEditNoteEvent() 12 | } 13 | -------------------------------------------------------------------------------- /app/src/main/java/com/akshayashokcode/notepad/ui/theme/Color.kt: -------------------------------------------------------------------------------- 1 | package com.akshayashokcode.notepad.ui.theme 2 | 3 | import androidx.compose.ui.graphics.Color 4 | 5 | val DarkGray = Color(0xFF202020) 6 | val LightGray = Color(0xFF444040) 7 | val LightBlue = Color(0xFFD7E8DE) 8 | 9 | val RedOrange = Color(0xffffab91) 10 | val RedPink = Color(0xfff48fb1) 11 | val BabyBlue = Color(0xff81deea) 12 | val Violet = Color(0xffcf94da) 13 | val LightGreen = Color(0xffe7ed9b) 14 | 15 | val LightYellow = Color(0xFFFFE082) 16 | val LightOrange = Color(0xFFFFCC80) 17 | val MintGreen = Color(0xFFC8E6C9) 18 | val LightPurple = Color(0xFFD1C4E9) 19 | val Lavender = Color(0xFFB39DDB) 20 | val LightPink = Color(0xFFFFCDD2) 21 | val PaleGreen = Color(0xFFDCEDC8) 22 | val Cream = Color(0xFFFFF9C4) 23 | 24 | 25 | -------------------------------------------------------------------------------- /app/src/main/java/com/akshayashokcode/notepad/feature_note/domain/use_case/AddNote.kt: -------------------------------------------------------------------------------- 1 | package com.akshayashokcode.notepad.feature_note.domain.use_case 2 | 3 | import com.akshayashokcode.notepad.feature_note.domain.model.Note 4 | import com.akshayashokcode.notepad.feature_note.domain.repository.NoteRepository 5 | import kotlin.jvm.Throws 6 | 7 | class AddNote( 8 | private val repository:NoteRepository 9 | ) { 10 | 11 | @Throws(Note.InvalidNoteException::class) 12 | suspend operator fun invoke(note: Note){ 13 | if(note.title.isBlank()){ 14 | throw Note.InvalidNoteException("The title of the note can't be empty.") 15 | } 16 | // Content can be empty - user might want title-only notes or quick saves 17 | repository.insertNote(note) 18 | } 19 | } -------------------------------------------------------------------------------- /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/com/akshayashokcode/notepad/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.akshayashokcode.notepad 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("com.akshayashokcode.notepad", appContext.packageName) 23 | } 24 | } -------------------------------------------------------------------------------- /app/src/main/res/values-night/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | -------------------------------------------------------------------------------- /app/src/test/java/com/akshayashokcode/notepad/feature_note/data/repository/FakeNoteRepository.kt: -------------------------------------------------------------------------------- 1 | package com.akshayashokcode.notepad.feature_note.data.repository 2 | 3 | import com.akshayashokcode.notepad.feature_note.domain.model.Note 4 | import com.akshayashokcode.notepad.feature_note.domain.repository.NoteRepository 5 | import kotlinx.coroutines.flow.Flow 6 | import kotlinx.coroutines.flow.flow 7 | 8 | class FakeNoteRepository : NoteRepository { 9 | 10 | private val notes = mutableListOf() 11 | 12 | override fun getNotes(): Flow> { 13 | return flow { emit(notes) } 14 | } 15 | 16 | override suspend fun getNoteById(id: Int): Note? { 17 | return notes.find { it.id == id } 18 | } 19 | 20 | override suspend fun insertNote(note: Note) { 21 | notes.add(note) 22 | } 23 | 24 | override suspend fun deleteNote(note: Note) { 25 | notes.remove(note) 26 | } 27 | } -------------------------------------------------------------------------------- /app/src/main/java/com/akshayashokcode/notepad/feature_note/data/repository/NoteRepositoryImpl.kt: -------------------------------------------------------------------------------- 1 | package com.akshayashokcode.notepad.feature_note.data.repository 2 | 3 | import com.akshayashokcode.notepad.feature_note.data.data_source.NoteDao 4 | import com.akshayashokcode.notepad.feature_note.domain.model.Note 5 | import com.akshayashokcode.notepad.feature_note.domain.repository.NoteRepository 6 | import kotlinx.coroutines.flow.Flow 7 | 8 | class NoteRepositoryImpl( 9 | private val dao:NoteDao 10 | ): NoteRepository { 11 | override fun getNotes(): Flow> { 12 | return dao.getNotes() 13 | } 14 | 15 | override suspend fun getNoteById(id: Int): Note? { 16 | return dao.getNoteById(id) 17 | } 18 | 19 | override suspend fun insertNote(note: Note) { 20 | return dao.insertNote(note) 21 | } 22 | 23 | override suspend fun deleteNote(note: Note) { 24 | return dao.deleteNote(note) 25 | } 26 | } -------------------------------------------------------------------------------- /app/src/main/java/com/akshayashokcode/notepad/feature_note/presentation/add_edit_note/components/AppKeyboardFocusManager.kt: -------------------------------------------------------------------------------- 1 | package com.akshayashokcode.notepad.feature_note.presentation.add_edit_note.components 2 | 3 | import androidx.compose.runtime.Composable 4 | import androidx.compose.runtime.DisposableEffect 5 | import androidx.compose.ui.platform.LocalContext 6 | import androidx.compose.ui.platform.LocalFocusManager 7 | import com.akshayashokcode.notepad.feature_note.presentation.util.KeyBoardManager 8 | 9 | @Composable 10 | fun AppKeyboardFocusManager() { 11 | val context = LocalContext.current 12 | val focusManager = LocalFocusManager.current 13 | DisposableEffect(key1 = context) { 14 | val keyboardManager = KeyBoardManager(context) 15 | keyboardManager.attachKeyboardDismissListener { 16 | focusManager.clearFocus() 17 | } 18 | onDispose { 19 | keyboardManager.release() 20 | } 21 | } 22 | 23 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 12 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/res/values/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | 17 | 21 | 22 |