Pārlūkot izejas kodu

Versioning, updated instruction resource, left out files, prepopulate note

sduduzog 7 gadi atpakaļ
vecāks
revīzija
e7ffc5882b

+ 2 - 2
app/build.gradle

@@ -12,8 +12,8 @@ android {
         applicationId "com.sduduzog.slimlauncher"
         minSdkVersion 21
         targetSdkVersion 28
-        versionCode 20
-        versionName "2.1.1"
+        versionCode 21
+        versionName "2.1.2"
         testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
         vectorDrawables.useSupportLibrary = true
     }

+ 8 - 0
app/src/main/java/com/sduduzog/slimlauncher/data/DataRoomDatabase.kt

@@ -25,6 +25,14 @@ abstract class DataRoomDatabase : RoomDatabase() {
                 if (INSTANCE == null) {
                     INSTANCE = Room.databaseBuilder(context.applicationContext,
                             DataRoomDatabase::class.java, "app_database")
+                            .addCallback(object : Callback(){
+                                override fun onCreate(db: SupportSQLiteDatabase) {
+                                    super.onCreate(db)
+                                    val _db = DataRoomDatabase.getDatabase(context)!!
+                                    val dao = _db.noteDao()
+                                    PopulateDatabaseTask(dao).execute()
+                                }
+                            })
                             .addMigrations(MIGRATION_1_2, MIGRATION_2_3)
                             .build()
                 }

+ 38 - 0
app/src/main/java/com/sduduzog/slimlauncher/data/PopulateDatabaseTask.kt

@@ -0,0 +1,38 @@
+package com.sduduzog.slimlauncher.data
+
+import android.os.AsyncTask
+import java.util.*
+
+class PopulateDatabaseTask(private val dao: NoteDao) : AsyncTask<Void, Void, Void>() {
+    override fun doInBackground(vararg p0: Void?): Void? {
+        val demoNote = Note("""
+            Dear reader.
+
+            This is a demo note. Also a short summary to help you get started in how to use create, edit
+            or delete note items.
+
+            1. Creating a note: Pretty easy actually. Just tap the button with the pen icon and type away.
+            To save your note, press back and exit the editing screen. And done! the note is saved :)
+
+            2. Editing a note: When you open a note, like this one, it is on reader mode, double tap on this text to enter editor mode, and make your changes.
+
+            3. Deleting a note: I think you know this one. Go back, swipe this note away, and its gone.
+
+            That's it! You're ready to go. Remember to give us feedback on the app and on changes you might wanna see in the future.
+            And don't forget to give us 5 stars ;)
+
+            ## TO COME ##
+            - Tasks : Like a todo list or whatever
+            - Voice recorder/ voice note : I'd like to integrate this nicely with text notes. Like taking text notes, record sound all in one note.
+            - Insights : See which apps you use the most, see which apps you haven't used in a long time,
+            probably to suggest clearing some, and some informative usage patterns, All while we're offline :)
+
+            Remember! All you need is less.
+
+            Thanks for the support
+        """.trimIndent(), Date().time)
+        dao.saveNote(demoNote)
+        return null
+    }
+
+}