├── .gitignore
├── .idea
├── .name
├── codeStyles
│ ├── Project.xml
│ └── codeStyleConfig.xml
├── gradle.xml
├── misc.xml
├── runConfigurations.xml
└── vcs.xml
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
├── schemas
│ └── com.languagexx.simplenotes.persistence.NoteDatabase
│ │ └── 1.json
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── languagexx
│ │ └── simplenotes
│ │ ├── BaseApplication.kt
│ │ ├── di
│ │ ├── ActivityBuildersModule.kt
│ │ ├── AppComponent.kt
│ │ ├── AppModule.kt
│ │ ├── FragmentBuildersModule.kt
│ │ ├── ViewModelFactoryModule.kt
│ │ ├── ViewModelKey.kt
│ │ └── ViewModelModule.kt
│ │ ├── persistence
│ │ ├── Note.kt
│ │ ├── NoteDao.kt
│ │ └── NoteDatabase.kt
│ │ ├── repository
│ │ └── NoteRepository.kt
│ │ ├── ui
│ │ ├── AddFragment.kt
│ │ ├── EditFragment.kt
│ │ ├── ListFragment.kt
│ │ ├── MainActivity.kt
│ │ ├── NoteViewModel.kt
│ │ └── adapter
│ │ │ ├── DiffCallback.kt
│ │ │ └── NoteLAdapter.kt
│ │ └── util
│ │ └── ViewModelProviderFactory.kt
│ └── res
│ ├── drawable-v24
│ └── ic_launcher_foreground.xml
│ ├── drawable
│ ├── add.gif
│ ├── add.xml
│ ├── arc.png
│ ├── delete.gif
│ ├── edit.gif
│ ├── edit2.gif
│ ├── ic_add.xml
│ ├── ic_launcher_background.xml
│ └── tag_style.xml
│ ├── layout
│ ├── activity_add.xml
│ ├── activity_edit.xml
│ ├── activity_main.xml
│ ├── empty.xml
│ ├── fragment_add.xml
│ ├── fragment_edit.xml
│ ├── fragment_list.xml
│ └── note_items.xml
│ ├── mipmap-anydpi-v26
│ ├── ic_launcher.xml
│ └── ic_launcher_round.xml
│ ├── mipmap-hdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-mdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xxhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xxxhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── navigation
│ └── nav_graph.xml
│ └── values
│ ├── colors.xml
│ ├── strings.xml
│ └── styles.xml
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | /.idea/navEditor.xml
9 | /.idea/assetWizardSettings.xml
10 | .DS_Store
11 | /build
12 | /captures
13 | .externalNativeBuild
14 | .cxx
15 |
--------------------------------------------------------------------------------
/.idea/.name:
--------------------------------------------------------------------------------
1 | Simple Notes
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | xmlns:android
20 |
21 | ^$
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 | xmlns:.*
31 |
32 | ^$
33 |
34 |
35 | BY_NAME
36 |
37 |
38 |
39 |
40 |
41 |
42 | .*:id
43 |
44 | http://schemas.android.com/apk/res/android
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 | .*:name
54 |
55 | http://schemas.android.com/apk/res/android
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 | name
65 |
66 | ^$
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 | style
76 |
77 | ^$
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 | .*
87 |
88 | ^$
89 |
90 |
91 | BY_NAME
92 |
93 |
94 |
95 |
96 |
97 |
98 | .*
99 |
100 | http://schemas.android.com/apk/res/android
101 |
102 |
103 | ANDROID_ATTRIBUTE_ORDER
104 |
105 |
106 |
107 |
108 |
109 |
110 | .*
111 |
112 | .*
113 |
114 |
115 | BY_NAME
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
--------------------------------------------------------------------------------
/.idea/codeStyles/codeStyleConfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Introduction
2 |
3 |
4 |
5 | 🗒️ Simple Note App helps to to create your notes. You can 📝 edit and ❌ delete notes too.
6 | App respects its Mvvm architecture. Android Architecture Components
7 | Part of Android Jetpack. Android architecture components are a collection of libraries that help
8 | you design robust, testable, and maintainable apps.
9 |
10 | Proudly 💪 made in Kotlin
11 |
12 |
Features
13 |
14 | Add Note
15 | Delete Note
16 | Edit Note
17 |
18 |
19 |
20 | Screenshots
21 |
22 |
23 |
24 | Add Notes
25 | Edit Notes
26 | Delete Notes
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 | Architecture
40 |
41 | MVVM is one of the architectural patterns which enhances separation of concerns, it allows
42 | separating the user interface logic from the business (or the back-end) logic. Its target
43 | (with other MVC patterns goal) is to achieve the following principle “Keeping UI code simple
44 | and free of app logic in order to make it easier to manage”.
45 |
46 |
47 | Lifecycles: It manages activity and fragment lifecycles of our app, survives configuration changes,
48 | avoids memory leaks and easily loads data into our UI.
49 | LiveData: It notifies views of any database changes. Use LiveData to build data objects that notify views when
50 | the underlying database changes.
51 | Room: It is a SQLite object mapping library. Use it to Avoid boilerplate code and easily
52 | convert SQLite table data to Java objects. Room provides compile time checks of SQLite statements
53 | and can return RxJava, Flowable and LiveData observables.
54 | ViewModel: It manages UI-related data in a lifecycle-conscious way. It stores UI-related data
55 | that isn't destroyed on app rotations.
56 | Repository: The repository depends on a persistent data model and a remote backend data source.
57 |
58 |
59 |
60 |
61 |
62 | Library used
63 |
77 |
78 |
79 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | apply plugin: 'kotlin-android'
4 |
5 | apply plugin: 'kotlin-android-extensions'
6 |
7 | apply plugin: 'kotlin-kapt'
8 |
9 | apply plugin: "androidx.navigation.safeargs.kotlin"
10 |
11 |
12 | android {
13 | compileSdkVersion 29
14 | defaultConfig {
15 | applicationId "com.languagexx.simplenotes"
16 | minSdkVersion 15
17 | targetSdkVersion 29
18 | versionCode 1
19 | versionName "1.0"
20 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
21 |
22 | javaCompileOptions {
23 | annotationProcessorOptions {
24 | arguments = ["room.schemaLocation": "$projectDir/schemas".toString()]
25 | }
26 | }
27 | }
28 | buildTypes {
29 | release {
30 | minifyEnabled false
31 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
32 | }
33 | }
34 |
35 | compileOptions {
36 | sourceCompatibility JavaVersion.VERSION_1_8
37 | targetCompatibility JavaVersion.VERSION_1_8
38 | }
39 |
40 | kotlinOptions {
41 | jvmTarget = JavaVersion.VERSION_1_8.toString()
42 | }
43 | }
44 |
45 | dependencies {
46 |
47 | def room_version = "2.2.3"
48 | def lifecycle_version = "2.2.0"
49 | def dagger_version = "2.24"
50 | def recycler_view = "1.1.0"
51 | def nav_version = "2.2.1"
52 |
53 | implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
54 | implementation 'androidx.appcompat:appcompat:1.1.0'
55 | implementation 'androidx.core:core-ktx:1.2.0'
56 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
57 |
58 | //Room library
59 | implementation "androidx.room:room-runtime:$room_version"
60 | kapt "androidx.room:room-compiler:$room_version"
61 |
62 | //ViewModel and LiveData
63 | implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
64 |
65 | //Dagger
66 | api "com.google.dagger:dagger:$dagger_version"
67 | kapt "com.google.dagger:dagger-compiler:$dagger_version"
68 |
69 | //Dagger Android
70 | api "com.google.dagger:dagger-android:$dagger_version"
71 | api "com.google.dagger:dagger-android-support:$dagger_version"
72 | kapt "com.google.dagger:dagger-android-processor:$dagger_version"
73 |
74 | //Kotlin
75 | implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.3"
76 |
77 | //Coroutines LiveData Scope
78 | implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.2.0"
79 |
80 | //RecyclerView
81 | implementation "androidx.recyclerview:recyclerview:$recycler_view"
82 |
83 | //Material library
84 | implementation 'com.google.android.material:material:1.1.0'
85 |
86 | //Navigation Component
87 | implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
88 | implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
89 |
90 | }
91 |
92 |
--------------------------------------------------------------------------------
/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
22 |
--------------------------------------------------------------------------------
/app/schemas/com.languagexx.simplenotes.persistence.NoteDatabase/1.json:
--------------------------------------------------------------------------------
1 | {
2 | "formatVersion": 1,
3 | "database": {
4 | "version": 1,
5 | "identityHash": "f19ff8713df894fd5330d1f67d5041f5",
6 | "entities": [
7 | {
8 | "tableName": "tbl_note",
9 | "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `title` TEXT, `description` TEXT, `tag` TEXT)",
10 | "fields": [
11 | {
12 | "fieldPath": "id",
13 | "columnName": "id",
14 | "affinity": "INTEGER",
15 | "notNull": true
16 | },
17 | {
18 | "fieldPath": "title",
19 | "columnName": "title",
20 | "affinity": "TEXT",
21 | "notNull": false
22 | },
23 | {
24 | "fieldPath": "description",
25 | "columnName": "description",
26 | "affinity": "TEXT",
27 | "notNull": false
28 | },
29 | {
30 | "fieldPath": "tag",
31 | "columnName": "tag",
32 | "affinity": "TEXT",
33 | "notNull": false
34 | }
35 | ],
36 | "primaryKey": {
37 | "columnNames": [
38 | "id"
39 | ],
40 | "autoGenerate": true
41 | },
42 | "indices": [],
43 | "foreignKeys": []
44 | }
45 | ],
46 | "views": [],
47 | "setupQueries": [
48 | "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
49 | "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'f19ff8713df894fd5330d1f67d5041f5')"
50 | ]
51 | }
52 | }
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/app/src/main/java/com/languagexx/simplenotes/BaseApplication.kt:
--------------------------------------------------------------------------------
1 | package com.languagexx.simplenotes
2 |
3 | import com.languagexx.simplenotes.di.DaggerAppComponent
4 | import dagger.android.AndroidInjector
5 | import dagger.android.DaggerApplication
6 |
7 | class BaseApplication : DaggerApplication() {
8 |
9 | // Method #1
10 | override fun applicationInjector(): AndroidInjector {
11 | return DaggerAppComponent.builder().application(this).build()
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/app/src/main/java/com/languagexx/simplenotes/di/ActivityBuildersModule.kt:
--------------------------------------------------------------------------------
1 | package com.languagexx.simplenotes.di
2 |
3 | import com.languagexx.simplenotes.ui.MainActivity
4 | import dagger.Module
5 | import dagger.android.ContributesAndroidInjector
6 |
7 |
8 | // declare all the activity here , dependency of activity are provided by this module
9 |
10 | @Module
11 | abstract class ActivityBuildersModule {
12 |
13 | // Method #1
14 | @ContributesAndroidInjector(modules = [ViewModelModule::class,FragmentBuildersModule::class])
15 | abstract fun contributeMainActivity(): MainActivity
16 |
17 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/languagexx/simplenotes/di/AppComponent.kt:
--------------------------------------------------------------------------------
1 | package com.languagexx.simplenotes.di
2 |
3 | import android.app.Application
4 | import com.languagexx.simplenotes.BaseApplication
5 | import dagger.BindsInstance
6 | import dagger.Component
7 | import dagger.android.AndroidInjectionModule
8 | import dagger.android.AndroidInjector
9 | import javax.inject.Singleton
10 |
11 | @Singleton
12 | @Component(
13 | modules = [
14 | AndroidInjectionModule::class,
15 | AppModule::class,
16 | ActivityBuildersModule::class
17 | ]
18 | )
19 | interface AppComponent : AndroidInjector {
20 |
21 | //We have to instruct the component how to build itself. We do this with the @Component.Builder annotation.
22 |
23 | @Component.Builder
24 | interface Builder {
25 |
26 | // Method #1
27 | fun build(): AppComponent
28 |
29 | // Method #2
30 | @BindsInstance
31 | fun application(application: Application): Builder
32 | }
33 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/languagexx/simplenotes/di/AppModule.kt:
--------------------------------------------------------------------------------
1 | package com.languagexx.simplenotes.di
2 |
3 | import android.app.Application
4 | import androidx.room.Room
5 | import com.languagexx.simplenotes.persistence.NoteDao
6 | import com.languagexx.simplenotes.persistence.NoteDatabase
7 | import com.languagexx.simplenotes.repository.NoteRepository
8 | import dagger.Module
9 | import dagger.Provides
10 | import javax.inject.Singleton
11 |
12 |
13 | //Provide all the app level dependency here
14 | @Module
15 | class AppModule {
16 |
17 |
18 | // Method #1
19 | @Singleton
20 | @Provides
21 | fun providesAppDatabase(app:Application):NoteDatabase{
22 | return Room.databaseBuilder(app,NoteDatabase::class.java,"note_database").build()
23 | }
24 |
25 | // Method #2
26 | @Singleton
27 | @Provides
28 | fun providesNoteDao(db: NoteDatabase): NoteDao {
29 | return db.noteDao()
30 | }
31 |
32 | // Method #3
33 | @Provides
34 | fun providesRepository(noteDao: NoteDao):NoteRepository{
35 | return NoteRepository(noteDao)
36 | }
37 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/languagexx/simplenotes/di/FragmentBuildersModule.kt:
--------------------------------------------------------------------------------
1 | package com.languagexx.simplenotes.di
2 |
3 |
4 | import com.languagexx.simplenotes.ui.AddFragment
5 | import com.languagexx.simplenotes.ui.EditFragment
6 | import com.languagexx.simplenotes.ui.ListFragment
7 | import dagger.Module
8 | import dagger.android.ContributesAndroidInjector
9 |
10 |
11 | // declare all the fragments here , dependency of fragments are provided by this module
12 |
13 | @Module
14 | abstract class FragmentBuildersModule {
15 |
16 | // Method #1
17 | @ContributesAndroidInjector
18 | abstract fun contributeListFragment(): ListFragment
19 |
20 | // Method #2
21 | @ContributesAndroidInjector
22 | abstract fun contributeAddFragment(): AddFragment
23 |
24 | // Method #3
25 | @ContributesAndroidInjector
26 | abstract fun contributeEditFragment(): EditFragment
27 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/languagexx/simplenotes/di/ViewModelFactoryModule.kt:
--------------------------------------------------------------------------------
1 | package com.languagexx.simplenotes.di
2 |
3 | import androidx.lifecycle.ViewModelProvider
4 | import com.languagexx.simplenotes.util.ViewModelProviderFactory
5 | import dagger.Binds
6 | import dagger.Module
7 |
8 |
9 | @Module
10 | abstract class ViewModelFactoryModule {
11 |
12 | // Method #2
13 | @Binds
14 | abstract fun bindViewModelFactory(viewModelProvideFactory: ViewModelProviderFactory): ViewModelProvider.Factory
15 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/languagexx/simplenotes/di/ViewModelKey.kt:
--------------------------------------------------------------------------------
1 | package com.languagexx.simplenotes.di
2 |
3 | import androidx.lifecycle.ViewModel
4 | import dagger.MapKey
5 | import kotlin.reflect.KClass
6 |
7 | @MustBeDocumented
8 | @Target(
9 | AnnotationTarget.FUNCTION,
10 | AnnotationTarget.PROPERTY_GETTER,
11 | AnnotationTarget.PROPERTY_SETTER
12 | )
13 | @Retention(AnnotationRetention.RUNTIME)
14 | @MapKey
15 | annotation class ViewModelKey(val value: KClass)
--------------------------------------------------------------------------------
/app/src/main/java/com/languagexx/simplenotes/di/ViewModelModule.kt:
--------------------------------------------------------------------------------
1 | package com.languagexx.simplenotes.di
2 |
3 | import androidx.lifecycle.ViewModel
4 | import com.languagexx.simplenotes.ui.NoteViewModel
5 | import dagger.Binds
6 | import dagger.Module
7 | import dagger.multibindings.IntoMap
8 |
9 |
10 | @Module
11 | abstract class ViewModelModule {
12 |
13 | // Method #1
14 | @Binds
15 | @IntoMap
16 | @ViewModelKey(NoteViewModel::class)
17 | abstract fun bindMainViewModel(notesViewModel: NoteViewModel): ViewModel
18 | }
19 |
--------------------------------------------------------------------------------
/app/src/main/java/com/languagexx/simplenotes/persistence/Note.kt:
--------------------------------------------------------------------------------
1 | package com.languagexx.simplenotes.persistence
2 |
3 | import android.os.Parcel
4 | import android.os.Parcelable
5 | import androidx.room.Entity
6 | import androidx.room.PrimaryKey
7 |
8 |
9 | // - Entity class for note table
10 | // - A Parcelable is the Android implementation of the Java Serializable
11 | // - It is used to transfer data between activities or fragments
12 |
13 | @Entity(tableName = "tbl_note")
14 | class Note(@PrimaryKey(autoGenerate = true)
15 | var id: Int,
16 | var title: String?,
17 | var description: String?,
18 | var tag:String?) :Parcelable{
19 |
20 |
21 | constructor(parcel: Parcel) : this(
22 | parcel.readInt(),
23 | parcel.readString(),
24 | parcel.readString(),
25 | parcel.readString())
26 |
27 |
28 | // Method #1
29 | override fun equals(other: Any?): Boolean {
30 | return super.equals(other)
31 | }
32 |
33 | // Method #2
34 | override fun writeToParcel(parcel: Parcel, flags: Int) {
35 | parcel.writeInt(id)
36 | parcel.writeString(title)
37 | parcel.writeString(description)
38 | parcel.writeString(tag)
39 | }
40 |
41 | // Method #3
42 | override fun describeContents(): Int {
43 | return 0
44 | }
45 |
46 | companion object CREATOR : Parcelable.Creator {
47 | // Method #4
48 | override fun createFromParcel(parcel: Parcel): Note {
49 | return Note(parcel)
50 | }
51 |
52 | // Method #5
53 | override fun newArray(size: Int): Array {
54 | return arrayOfNulls(size)
55 | }
56 | }
57 |
58 | // Method #6
59 | override fun hashCode(): Int {
60 | var result = id
61 | result = 31 * result + (title?.hashCode() ?: 0)
62 | result = 31 * result + (description?.hashCode() ?: 0)
63 | result = 31 * result + (tag?.hashCode() ?: 0)
64 | return result
65 | }
66 |
67 |
68 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/languagexx/simplenotes/persistence/NoteDao.kt:
--------------------------------------------------------------------------------
1 | package com.languagexx.simplenotes.persistence
2 | import androidx.lifecycle.LiveData
3 | import androidx.room.*
4 |
5 |
6 | // - Interface Dao for Note table sql operations
7 |
8 | @Dao
9 | interface NoteDao {
10 |
11 | // Method #1
12 | @Insert(onConflict = OnConflictStrategy.REPLACE)
13 | fun insert(note: Note): Long
14 |
15 | // Method #2
16 | @Update
17 | fun update(note: Note)
18 |
19 | // Method #3
20 | @Query("delete from tbl_note where id = :id")
21 | fun deleteById(id: Int)
22 |
23 | // Method #4
24 | @Delete
25 | fun delete(note: Note)
26 |
27 | // Method #5
28 | @Query("select * from tbl_note")
29 | fun getAllNotes():LiveData>
30 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/languagexx/simplenotes/persistence/NoteDatabase.kt:
--------------------------------------------------------------------------------
1 | package com.languagexx.simplenotes.persistence
2 |
3 | import androidx.room.Database
4 | import androidx.room.RoomDatabase
5 |
6 |
7 | // - Database Class
8 | @Database(entities = [Note::class],version = 1)
9 | abstract class NoteDatabase: RoomDatabase() {
10 | abstract fun noteDao(): NoteDao
11 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/languagexx/simplenotes/repository/NoteRepository.kt:
--------------------------------------------------------------------------------
1 | package com.languagexx.simplenotes.repository
2 |
3 | import android.util.Log
4 | import androidx.lifecycle.LiveData
5 | import com.languagexx.simplenotes.persistence.NoteDao
6 | import com.languagexx.simplenotes.persistence.Note
7 | import kotlinx.coroutines.*
8 | import javax.inject.Inject
9 |
10 | class NoteRepository @Inject constructor(val noteDao: NoteDao) {
11 |
12 | // Method #1
13 | //function to insert note in database
14 | fun insert(note: Note) {
15 | CoroutineScope(Dispatchers.IO).launch {
16 | noteDao.insert(note)
17 | }
18 | }
19 |
20 | // Method #2
21 | //function to delete note in database
22 | fun delete(note: Note) {
23 | CoroutineScope(Dispatchers.IO).launch {
24 | noteDao.delete(note)
25 | }
26 | }
27 |
28 | // Method #3
29 | //function to delete note by Id in database
30 | fun deleteById(id: Int) {
31 | CoroutineScope(Dispatchers.IO).launch {
32 | noteDao.deleteById(id)
33 | }
34 | }
35 |
36 | // Method #4
37 | //function to update note in database
38 | fun update(note: Note) {
39 | CoroutineScope(Dispatchers.IO).launch {
40 | noteDao.update(note)
41 | Log.e("DEBUG", "update is called in repo")
42 |
43 | }
44 | }
45 |
46 | // Method #5
47 | //function to get all notes in database
48 | fun getAllNotes(): LiveData>{
49 | return noteDao.getAllNotes()
50 | }
51 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/languagexx/simplenotes/ui/AddFragment.kt:
--------------------------------------------------------------------------------
1 | package com.languagexx.simplenotes.ui
2 |
3 | import android.os.Bundle
4 | import android.view.LayoutInflater
5 | import android.view.View
6 | import android.view.ViewGroup
7 | import android.widget.Toast
8 | import androidx.lifecycle.ViewModelProvider
9 | import androidx.navigation.Navigation
10 | import com.languagexx.simplenotes.R
11 | import com.languagexx.simplenotes.persistence.Note
12 | import com.languagexx.simplenotes.util.ViewModelProviderFactory
13 | import dagger.android.support.DaggerFragment
14 | import kotlinx.android.synthetic.main.fragment_add.*
15 | import javax.inject.Inject
16 |
17 |
18 | class AddFragment : DaggerFragment() {
19 |
20 | @Inject
21 | lateinit var viewmodelProviderFactory: ViewModelProviderFactory
22 |
23 | lateinit var noteViewModel: NoteViewModel
24 |
25 |
26 | // Method #1
27 | override fun onCreateView(
28 | inflater: LayoutInflater,
29 | container: ViewGroup?,
30 | savedInstanceState: Bundle?
31 | ): View? {
32 | return inflater.inflate(R.layout.fragment_add, container, false)
33 | }
34 |
35 | // Method #2
36 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
37 | super.onViewCreated(view, savedInstanceState)
38 |
39 | setupViewModel()
40 |
41 | btnAdd.setOnClickListener {
42 | Navigation.findNavController(requireActivity(),R.id.container).popBackStack()
43 | }
44 | }
45 |
46 | // Method #3
47 | private fun saveNoteToDatabase() {
48 |
49 | //Save Notes WHEN app is minimized or back button is clicked [#onPause method will be called]
50 | //Save Notes WHEN save button is cliked
51 |
52 |
53 | /* VALIDATIONS FOR SAVING NOTES
54 |
55 | 1) if TITLE IS NULL -- Title = "Empty Title"
56 |
57 | 2) if all the property of notes is null i.e title , description , color and tag
58 | then note will note will saved
59 | show toast "Note is discarded"
60 |
61 | */
62 |
63 | (activity as MainActivity?)?.showFloatingButton()
64 |
65 | if (validations()) {
66 | Toast.makeText(activity, "Note is saved", Toast.LENGTH_SHORT).show()
67 | saveNote()
68 | } else
69 | Toast.makeText(activity, "Note is Discarded", Toast.LENGTH_SHORT).show()
70 |
71 | }
72 |
73 | // Method #4
74 | override fun onDestroyView() {
75 | super.onDestroyView()
76 | saveNoteToDatabase()
77 | }
78 |
79 |
80 | // Method #5
81 | private fun saveNote() {
82 | val note = Note(0,addTitle.text.toString(),addDescription.text.toString(),addTag.text.toString())
83 |
84 | //If title is null set Empty Title
85 | if (addTitle.text.isNullOrEmpty()) {
86 | note.title = "Empty Title"
87 |
88 | //Call viewmodel to save the data
89 | noteViewModel.insert(note)
90 |
91 | }else{
92 | //Call viewmodel to save the data
93 | noteViewModel.insert(note)
94 | }
95 | }
96 |
97 | // Method #6
98 | fun validations(): Boolean {
99 | return !(addTitle.text.isNullOrEmpty()
100 | && addDescription.text.isNullOrEmpty()
101 | && addTag.text.isNullOrEmpty())
102 | }
103 |
104 |
105 | // Method #7
106 | private fun setupViewModel() {
107 | noteViewModel = ViewModelProvider(this,viewmodelProviderFactory).get(NoteViewModel::class.java)
108 | }
109 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/languagexx/simplenotes/ui/EditFragment.kt:
--------------------------------------------------------------------------------
1 | package com.languagexx.simplenotes.ui
2 |
3 | import android.os.Bundle
4 | import android.util.Log
5 | import android.view.LayoutInflater
6 | import android.view.View
7 | import android.view.ViewGroup
8 | import android.widget.Toast
9 | import androidx.lifecycle.ViewModelProvider
10 | import androidx.navigation.Navigation
11 | import com.languagexx.simplenotes.R
12 | import com.languagexx.simplenotes.persistence.Note
13 | import com.languagexx.simplenotes.util.ViewModelProviderFactory
14 | import dagger.android.support.DaggerFragment
15 | import kotlinx.android.synthetic.main.activity_edit.*
16 | import javax.inject.Inject
17 |
18 |
19 | class EditFragment : DaggerFragment() {
20 |
21 | @Inject
22 | lateinit var viewmodelProviderFactory: ViewModelProviderFactory
23 |
24 | lateinit var noteViewModel: NoteViewModel
25 |
26 |
27 | override fun onCreateView(
28 | inflater: LayoutInflater,
29 | container: ViewGroup?,
30 | savedInstanceState: Bundle?
31 | ): View? {
32 | return inflater.inflate(R.layout.fragment_edit, container, false)
33 | }
34 |
35 | // Method #1
36 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
37 | super.onViewCreated(view, savedInstanceState)
38 |
39 |
40 |
41 | prepareNoteForEditing()
42 | setupViewModel()
43 |
44 | btnEdit.setOnClickListener {
45 | Navigation.findNavController(requireActivity(),R.id.container).popBackStack()
46 | }
47 | }
48 |
49 | // Method #2
50 | private fun saveNoteToDatabase() {
51 |
52 | //Save Notes WHEN app is minimized or back button is clicked [#onPause method will be called]
53 | //Save Notes WHEN save button is cliked
54 |
55 |
56 | /* VALIDATIONS FOR SAVING NOTES
57 |
58 | 1) if TITLE IS NULL -- Title = "Empty Title"
59 |
60 | 2) if all the property of notes is null i.e title , description , color and tag
61 | then note will note will saved
62 | show toast "Note is discarded"
63 |
64 | */
65 |
66 | (activity as MainActivity?)?.showFloatingButton()
67 |
68 | if (validations()) {
69 | Toast.makeText(activity, "Note is saved", Toast.LENGTH_SHORT).show()
70 | saveNote()
71 | val id:Int = EditFragmentArgs.fromBundle(arguments!!).note?.id!!
72 | Log.e("DEBUG","saving note $id")
73 |
74 | } else {
75 | Toast.makeText(activity, "Note is Discarded", Toast.LENGTH_SHORT).show()
76 | //Delete the note if all fields are empty (this is done by user)
77 | val id: Int = EditFragmentArgs.fromBundle(arguments!!).note?.id!!
78 | noteViewModel.deleteById(id)
79 | Log.e("DEBUG", "deleting note")
80 | }
81 | }
82 |
83 | // Method #3
84 | override fun onDestroyView() {
85 | super.onDestroyView()
86 | saveNoteToDatabase()
87 | }
88 |
89 | // Method #4
90 | private fun saveNote() {
91 |
92 | //getting the id from bundle , we are using that id to update/edit the note
93 | val id:Int? = EditFragmentArgs.fromBundle(arguments!!).note?.id
94 |
95 | val note = Note(id!!,editTitle.text.toString(),editDescription.text.toString(),editTag.text.toString())
96 |
97 | //If title is null set Empty Title
98 | if (editTitle.text.isNullOrEmpty()) {
99 | note.title = "Empty Title"
100 |
101 | //Call viewmodel to save the data
102 | noteViewModel.update(note)
103 |
104 | }else{
105 | //Call viewmodel to save the data
106 | Log.e("DEBUG","saving note update is called")
107 | noteViewModel.update(note)
108 | }
109 | }
110 |
111 | // Method #5
112 | fun validations(): Boolean {
113 | return !(editTitle.text.isNullOrEmpty()
114 | && editDescription.text.isNullOrEmpty()
115 | && editTag.text.isNullOrEmpty())
116 | }
117 |
118 |
119 | // Method #6
120 | private fun setupViewModel() {
121 | noteViewModel = ViewModelProvider(this,viewmodelProviderFactory).get(NoteViewModel::class.java)
122 | }
123 |
124 |
125 | // Method #7
126 | private fun prepareNoteForEditing() {
127 | // Getting the note from the bundle
128 | //Save args plugin is used as i believe bundle is not good for sending large data
129 | arguments?.let {
130 | val safeArgs = EditFragmentArgs.fromBundle(it)
131 | val note = safeArgs.note
132 | editTitle.setText(note?.title.toString())
133 | editDescription.setText(note?.description.toString())
134 | editTag.setText(note?.tag.toString())
135 | }
136 |
137 | }
138 | }
139 |
140 |
--------------------------------------------------------------------------------
/app/src/main/java/com/languagexx/simplenotes/ui/ListFragment.kt:
--------------------------------------------------------------------------------
1 | package com.languagexx.simplenotes.ui
2 |
3 | import android.os.Bundle
4 | import android.view.LayoutInflater
5 | import android.view.View
6 | import android.view.ViewGroup
7 | import android.widget.Toast
8 | import androidx.lifecycle.Observer
9 | import androidx.lifecycle.ViewModelProvider
10 | import androidx.navigation.fragment.findNavController
11 | import androidx.recyclerview.widget.ItemTouchHelper
12 | import androidx.recyclerview.widget.LinearLayoutManager
13 | import androidx.recyclerview.widget.RecyclerView
14 | import com.languagexx.simplenotes.R
15 | import com.languagexx.simplenotes.persistence.Note
16 | import com.languagexx.simplenotes.ui.adapter.NoteAdapter
17 | import com.languagexx.simplenotes.util.ViewModelProviderFactory
18 | import dagger.android.support.DaggerFragment
19 | import kotlinx.android.synthetic.main.fragment_list.*
20 | import javax.inject.Inject
21 |
22 | class ListFragment : DaggerFragment(),
23 | NoteAdapter.Interaction {
24 |
25 | private lateinit var noteAdapter: NoteAdapter
26 |
27 | private lateinit var noteViewModel: NoteViewModel
28 |
29 | @Inject
30 | lateinit var viewmodelProviderFactory: ViewModelProviderFactory
31 |
32 | lateinit var allNotes: List
33 |
34 |
35 | // Method #1
36 | override fun onCreateView(
37 | inflater: LayoutInflater,
38 | container: ViewGroup?,
39 | savedInstanceState: Bundle?
40 | ): View? {
41 | allNotes = mutableListOf()
42 | return inflater.inflate(R.layout.fragment_list, container, false)
43 | }
44 |
45 | // Method #2
46 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
47 | super.onViewCreated(view, savedInstanceState)
48 |
49 | setupViewModel() // Step 1
50 | initRecyclerView() // Step 2
51 | observerLiveData() // Step 3
52 | }
53 |
54 | // Method #3
55 | private fun observerLiveData() {
56 | noteViewModel.getAllNotes().observe(viewLifecycleOwner, Observer { lisOfNotes ->
57 | lisOfNotes?.let {
58 | allNotes = it
59 | noteAdapter.swap(it)
60 | }
61 | })
62 | }
63 |
64 | // Method #4
65 | private fun initRecyclerView() {
66 | recyclerView.apply {
67 | noteAdapter = NoteAdapter(
68 | allNotes,
69 | this@ListFragment
70 | )
71 | layoutManager = LinearLayoutManager(this@ListFragment.context)
72 | adapter = noteAdapter
73 | val swipe = ItemTouchHelper(initSwipeToDelete())
74 | swipe.attachToRecyclerView(recyclerView)
75 | }
76 | }
77 |
78 | // Method #5
79 | private fun setupViewModel() {
80 | noteViewModel =
81 | ViewModelProvider(this, viewmodelProviderFactory).get(NoteViewModel::class.java)
82 | }
83 |
84 | // Method #6
85 | private fun initSwipeToDelete(): ItemTouchHelper.SimpleCallback {
86 | //Swipe recycler view items on RIGHT
87 | return object : ItemTouchHelper.SimpleCallback(
88 | 0, ItemTouchHelper.RIGHT
89 | ) {
90 | override fun onMove(
91 | recyclerView: RecyclerView,
92 | viewHolder: RecyclerView.ViewHolder,
93 | target: RecyclerView.ViewHolder
94 | ): Boolean {
95 | return true
96 | }
97 |
98 | override fun onSwiped(viewHolder: RecyclerView.ViewHolder, direction: Int) {
99 | val position = viewHolder.adapterPosition
100 | noteViewModel.delete(allNotes.get(position))
101 | val note = allNotes.get(position)
102 | Toast.makeText(activity, "Note Deleted", Toast.LENGTH_SHORT).show()
103 | }
104 | }
105 | }
106 |
107 | // Method #7
108 | override fun onItemSelected(position: Int, item: Note) {
109 | val navDirection = ListFragmentDirections.actionListFragmentToEditFragment(item)
110 | findNavController().navigate(navDirection)
111 | }
112 | }
113 |
114 |
115 |
--------------------------------------------------------------------------------
/app/src/main/java/com/languagexx/simplenotes/ui/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.languagexx.simplenotes.ui
2 |
3 | import android.os.Bundle
4 | import android.view.View
5 | import androidx.navigation.NavController
6 | import androidx.navigation.findNavController
7 | import com.languagexx.simplenotes.R
8 | import dagger.android.support.DaggerAppCompatActivity
9 | import kotlinx.android.synthetic.main.activity_main.*
10 |
11 | class MainActivity : DaggerAppCompatActivity() {
12 |
13 | lateinit var navController: NavController
14 |
15 | // Method #1
16 | override fun onCreate(savedInstanceState: Bundle?) {
17 | super.onCreate(savedInstanceState)
18 | setContentView(R.layout.activity_main)
19 | navController = findNavController(R.id.container)
20 |
21 |
22 | //Floating action button will redirect to Add New Notes Fragment #AddFragment
23 | fab.setOnClickListener {
24 | onFloatingClicked()
25 | }
26 | }
27 |
28 | // Method #2
29 | private fun onFloatingClicked() {
30 | navController.navigate(R.id.action_listFragment_to_addFragment)
31 | fab.hide()
32 | }
33 |
34 | // Method #3
35 | fun showFloatingButton(){
36 | fab.show()
37 | fab.visibility = View.VISIBLE
38 | }
39 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/languagexx/simplenotes/ui/NoteViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.languagexx.simplenotes.ui
2 |
3 | import android.util.Log
4 | import androidx.lifecycle.LiveData
5 | import androidx.lifecycle.ViewModel
6 | import com.languagexx.simplenotes.persistence.Note
7 | import com.languagexx.simplenotes.repository.NoteRepository
8 | import javax.inject.Inject
9 |
10 | class NoteViewModel @Inject constructor(
11 | val noteRepository: NoteRepository
12 | ) : ViewModel() {
13 |
14 |
15 | //Database Operations in view model
16 |
17 |
18 | // Method #1
19 | fun insert(note: Note) {
20 | return noteRepository.insert(note)
21 | }
22 |
23 | // Method #2
24 | fun delete(note: Note) {
25 | noteRepository.delete(note)
26 | }
27 |
28 | // Method #3
29 | fun deleteById(id:Int){
30 | noteRepository.deleteById(id)
31 | }
32 |
33 | // Method #4
34 | fun update(note: Note) {
35 | Log.e("DEBUG","update is called in viewmodel")
36 | noteRepository.update(note)
37 | }
38 |
39 | // Method #5
40 | fun getAllNotes(): LiveData> {
41 | Log.e("DEBUG", "View model getallnotes")
42 | return noteRepository.getAllNotes()
43 | }
44 |
45 |
46 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/languagexx/simplenotes/ui/adapter/DiffCallback.kt:
--------------------------------------------------------------------------------
1 | package com.languagexx.simplenotes.ui.adapter
2 |
3 | import androidx.recyclerview.widget.DiffUtil
4 | import com.languagexx.simplenotes.persistence.Note
5 |
6 |
7 | class DiffCallback(
8 | private val oldList: List,
9 | private val newList: List
10 | ) : DiffUtil.Callback() {
11 |
12 | // Method #1
13 | override fun getOldListSize() = oldList.size
14 |
15 | // Method #2
16 | override fun getNewListSize() = newList.size
17 |
18 | // Method #3
19 | override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean {
20 | return oldList[oldItemPosition].id == newList[newItemPosition].id
21 | }
22 |
23 | // Method #4
24 | override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean {
25 | return oldList[oldItemPosition].id == newList[newItemPosition].id
26 | && oldList[oldItemPosition].title == newList[newItemPosition].title
27 | && oldList[oldItemPosition].description == newList[newItemPosition].description
28 | && oldList[oldItemPosition].tag == newList[newItemPosition].tag
29 | }
30 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/languagexx/simplenotes/ui/adapter/NoteLAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.languagexx.simplenotes.ui.adapter
2 |
3 | import android.view.LayoutInflater
4 | import android.view.View
5 | import android.view.ViewGroup
6 | import androidx.recyclerview.widget.*
7 | import com.languagexx.simplenotes.R
8 | import com.languagexx.simplenotes.persistence.Note
9 | import kotlinx.android.synthetic.main.note_items.view.*
10 |
11 |
12 |
13 | class NoteAdapter(
14 | noteList: List,
15 | private val interaction: Interaction? = null
16 | ) : RecyclerView.Adapter() {
17 |
18 | private val notes = mutableListOf()
19 |
20 | init {
21 | notes.addAll(noteList)
22 | }
23 |
24 | // Method #1
25 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
26 | val inflater = LayoutInflater.from(parent.context)
27 | val view = inflater.inflate(R.layout.note_items, parent, false)
28 | return ViewHolder(
29 | view,
30 | interaction
31 | )
32 | }
33 |
34 | // Method #2
35 | override fun getItemCount() = notes.size
36 |
37 |
38 | // Method #3
39 | override fun onBindViewHolder(holder: ViewHolder, position: Int) {
40 | holder.bind(item = notes[position])
41 | }
42 |
43 |
44 | // Method #4
45 | fun swap(notes: List) {
46 | val diffCallback = DiffCallback(this.notes, notes)
47 | val diffResult = DiffUtil.calculateDiff(diffCallback)
48 |
49 | this.notes.clear()
50 | this.notes.addAll(notes)
51 | diffResult.dispatchUpdatesTo(this)
52 | }
53 |
54 |
55 | // Method #5
56 | class ViewHolder(
57 | itemView: View,
58 | private val interaction: Interaction?
59 | ) : RecyclerView.ViewHolder(itemView) {
60 |
61 | // Method #6
62 | fun bind(item: Note) {
63 | itemView.txtTitle.text = item.title
64 | itemView.txtDescription.text = item.description
65 | itemView.txtTag.text = item.tag
66 |
67 | //Handle item click
68 | itemView.setOnClickListener {
69 | interaction?.onItemSelected(adapterPosition,item)
70 | }
71 | }
72 |
73 | }
74 |
75 | // Method #7
76 | interface Interaction {
77 | fun onItemSelected(position: Int, item: Note)
78 | }
79 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/languagexx/simplenotes/util/ViewModelProviderFactory.kt:
--------------------------------------------------------------------------------
1 | package com.languagexx.simplenotes.util
2 |
3 | import androidx.lifecycle.ViewModel
4 | import androidx.lifecycle.ViewModelProvider
5 | import javax.inject.Inject
6 | import javax.inject.Provider
7 |
8 |
9 | class ViewModelProviderFactory
10 | @Inject
11 | constructor(
12 | private val creators: Map, @JvmSuppressWildcards Provider>
13 | ) : ViewModelProvider.Factory {
14 |
15 | override fun create(modelClass: Class): T {
16 | val creator = creators[modelClass] ?: creators.entries.firstOrNull {
17 | modelClass.isAssignableFrom(it.key)
18 | }?.value ?: throw IllegalArgumentException("unknown model class $modelClass")
19 | try {
20 | @Suppress("UNCHECKED_CAST")
21 | return creator.get() as T
22 | } catch (e: Exception) {
23 | throw RuntimeException(e)
24 | }
25 | }
26 | }
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/add.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/prakashshuklahub/Simple-Notes-Kotlin-App/db091f01cbe84866cb6ca634f626da25e6538f77/app/src/main/res/drawable/add.gif
--------------------------------------------------------------------------------
/app/src/main/res/drawable/add.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/arc.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/prakashshuklahub/Simple-Notes-Kotlin-App/db091f01cbe84866cb6ca634f626da25e6538f77/app/src/main/res/drawable/arc.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/delete.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/prakashshuklahub/Simple-Notes-Kotlin-App/db091f01cbe84866cb6ca634f626da25e6538f77/app/src/main/res/drawable/delete.gif
--------------------------------------------------------------------------------
/app/src/main/res/drawable/edit.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/prakashshuklahub/Simple-Notes-Kotlin-App/db091f01cbe84866cb6ca634f626da25e6538f77/app/src/main/res/drawable/edit.gif
--------------------------------------------------------------------------------
/app/src/main/res/drawable/edit2.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/prakashshuklahub/Simple-Notes-Kotlin-App/db091f01cbe84866cb6ca634f626da25e6538f77/app/src/main/res/drawable/edit2.gif
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_add.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/tag_style.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_add.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
18 |
19 |
28 |
29 |
38 |
39 |
48 |
49 |
53 |
54 |
62 |
63 |
71 |
72 |
79 |
80 |
87 |
88 |
95 |
96 |
103 |
104 |
105 |
106 |
114 |
115 |
116 |
117 |
118 |
119 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_edit.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
18 |
19 |
29 |
30 |
39 |
40 |
50 |
51 |
56 |
57 |
65 |
66 |
74 |
75 |
82 |
83 |
90 |
91 |
98 |
99 |
106 |
107 |
108 |
109 |
117 |
118 |
119 |
120 |
121 |
122 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
15 |
22 |
23 |
24 |
32 |
33 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/empty.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_add.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
18 |
19 |
28 |
29 |
38 |
39 |
48 |
49 |
50 |
58 |
59 |
60 |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_edit.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
18 |
19 |
26 |
27 |
34 |
35 |
42 |
43 |
51 |
52 |
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
17 |
18 |
26 |
27 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/note_items.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
17 |
18 |
23 |
24 |
31 |
32 |
39 |
40 |
55 |
56 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/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/prakashshuklahub/Simple-Notes-Kotlin-App/db091f01cbe84866cb6ca634f626da25e6538f77/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/prakashshuklahub/Simple-Notes-Kotlin-App/db091f01cbe84866cb6ca634f626da25e6538f77/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/prakashshuklahub/Simple-Notes-Kotlin-App/db091f01cbe84866cb6ca634f626da25e6538f77/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/prakashshuklahub/Simple-Notes-Kotlin-App/db091f01cbe84866cb6ca634f626da25e6538f77/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/prakashshuklahub/Simple-Notes-Kotlin-App/db091f01cbe84866cb6ca634f626da25e6538f77/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/prakashshuklahub/Simple-Notes-Kotlin-App/db091f01cbe84866cb6ca634f626da25e6538f77/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/prakashshuklahub/Simple-Notes-Kotlin-App/db091f01cbe84866cb6ca634f626da25e6538f77/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/prakashshuklahub/Simple-Notes-Kotlin-App/db091f01cbe84866cb6ca634f626da25e6538f77/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/prakashshuklahub/Simple-Notes-Kotlin-App/db091f01cbe84866cb6ca634f626da25e6538f77/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/prakashshuklahub/Simple-Notes-Kotlin-App/db091f01cbe84866cb6ca634f626da25e6538f77/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/navigation/nav_graph.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
14 |
17 |
18 |
19 |
20 |
24 |
28 |
32 |
33 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #008577
4 | #00574B
5 | #D81B60
6 |
7 |
8 | #E880FC
9 | #64FFDA
10 | #BBDEFB
11 | #FFC400
12 | #A1887F
13 |
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Simple Notes
3 | Add description for your note ..
4 | work
5 | Save Note
6 | Title
7 | Color
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | ext.kotlin_version = '1.3.61'
5 | repositories {
6 | google()
7 | jcenter()
8 |
9 | }
10 | dependencies {
11 | classpath 'com.android.tools.build:gradle:3.5.3'
12 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
13 | def nav_version = "2.3.0-alpha01"
14 | classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
15 | // NOTE: Do not place your application dependencies here; they belong
16 | // in the individual module build.gradle files
17 | }
18 | }
19 |
20 | allprojects {
21 | repositories {
22 | google()
23 | jcenter()
24 |
25 | }
26 | }
27 |
28 | task clean(type: Delete) {
29 | delete rootProject.buildDir
30 | }
31 |
--------------------------------------------------------------------------------
/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=-Xmx1536m
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 | # Automatically convert third-party libraries to use AndroidX
19 | android.enableJetifier=true
20 | # Kotlin code style for this project: "official" or "obsolete":
21 | kotlin.code.style=official
22 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/prakashshuklahub/Simple-Notes-Kotlin-App/db091f01cbe84866cb6ca634f626da25e6538f77/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sat Oct 19 18:41:03 IST 2019
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 | rootProject.name='Simple Notes'
3 |
--------------------------------------------------------------------------------