Sfoglia il codice sorgente

chore: blocked thought v2

beautusg 7 anni fa
parent
commit
59345b472d

+ 5 - 2
app/src/main/java/com/sduduzog/slimlauncher/data/BaseDatabase.kt

@@ -68,8 +68,11 @@ abstract class BaseDatabase : RoomDatabase() {
 
         private val MIGRATION_4_5 = object : Migration(4, 5) {
             override fun migrate(database: SupportSQLiteDatabase) {
-                database.execSQL("ALTER TABLE `notes` ADD COLUMN `is_voice` INTEGER NOT NULL DEFAULT 0")
-                database.execSQL("ALTER TABLE `notes` ADD COLUMN `path` TEXT")
+                database.beginTransaction()
+                database.execSQL("ALTER TABLE `notes` RENAME TO `notes_old`")
+                database.execSQL("CREATE TABLE IF NOT EXISTS `notes` (`body` TEXT NOT NULL, `edited` INTEGER NOT NULL, `is_voice` INTEGER NOT NULL DEFAULT 0, `id` INTEGER PRIMARY KEY, `title` TEXT, `path` TEXT)")
+                database.execSQL("INSERT INTO `notes` (`body`, `edited`, `id`, `title`) SELECT `body`, `edited`, `id`, `title` FROM `notes_old`")
+                database.endTransaction()
             }
         }
     }

+ 7 - 2
app/src/main/java/com/sduduzog/slimlauncher/ui/main/NotesFragment.kt

@@ -115,8 +115,13 @@ class NotesFragment : BaseFragment(), OnShitDoneToNotesListener {
 
     override fun onView(note: Note) {
         val bundle = Bundle()
-        bundle.putSerializable("note", note)
-        Navigation.findNavController(notes_fragment).navigate(R.id.action_notesFragment_to_noteFragment, bundle)
+        bundle.putInt(getString(R.string.nav_key_note), note.id!!)
+        if (note.is_voice)
+            Navigation.findNavController(notes_fragment)
+                    .navigate(R.id.action_notesFragment_to_voiceNoteFragment, bundle)
+        else
+            Navigation.findNavController(notes_fragment)
+                    .navigate(R.id.action_notesFragment_to_noteFragment, bundle)
     }
 
     override fun onDelete(note: Note) {

+ 17 - 0
app/src/main/java/com/sduduzog/slimlauncher/ui/notes/VoiceNoteFragment.kt

@@ -0,0 +1,17 @@
+package com.sduduzog.slimlauncher.ui.notes
+
+import android.os.Bundle
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import com.sduduzog.slimlauncher.R
+import com.sduduzog.slimlauncher.utils.BaseFragment
+import kotlinx.android.synthetic.main.voice_note_fragment.*
+
+class VoiceNoteFragment : BaseFragment() {
+    override fun getFragmentView(): ViewGroup = voice_note_fragment
+
+    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
+        return inflater.inflate(R.layout.voice_note_fragment, container, false)
+    }
+}

+ 62 - 49
app/src/main/res/layout/voice_note_fragment.xml

@@ -1,59 +1,72 @@
 <?xml version="1.0" encoding="utf-8"?>
-<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:app="http://schemas.android.com/apk/res-auto"
     xmlns:tools="http://schemas.android.com/tools"
     android:id="@+id/voice_note_fragment"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    android:fitsSystemWindows="true"
-    android:scrollbarStyle="insideOverlay"
-    tools:context="com.sduduzog.slimlauncher.ui.notes.EditNoteFragment">
+    tools:context="com.sduduzog.slimlauncher.ui.notes.VoiceNoteFragment">
 
-    <androidx.constraintlayout.widget.ConstraintLayout
-        android:id="@+id/voice_note_fragment_layout"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content">
 
-        <EditText
-            android:id="@+id/edit_note_fragment_title"
-            android:layout_width="0dp"
-            android:layout_height="wrap_content"
-            android:layout_marginTop="16dp"
-            android:background="@android:color/transparent"
-            android:hint="@string/edit_note_fragment_untitled"
-            android:inputType="textCapSentences"
-            android:padding="12dp"
-            android:singleLine="true"
-            android:textSize="18sp"
-            app:layout_constraintEnd_toStartOf="@+id/edit_note_fragment_save"
-            app:layout_constraintStart_toStartOf="parent"
-            app:layout_constraintTop_toTopOf="parent"
-            tools:ignore="Autofill,TextFields" />
+    <TextView
+        android:id="@+id/voice_note_fragment_title"
+        android:layout_width="0dp"
+        android:layout_height="wrap_content"
+        android:layout_marginTop="16dp"
+        android:background="@android:color/transparent"
+        android:hint="@string/edit_note_fragment_untitled"
+        android:padding="12dp"
+        android:textSize="18sp"
+        app:layout_constraintEnd_toStartOf="@+id/voice_note_fragment_save"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintTop_toTopOf="parent" />
 
-        <TextView
-            android:id="@+id/edit_note_fragment_save"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_marginTop="16dp"
-            android:layout_marginEnd="16dp"
-            android:layout_marginRight="16dp"
-            android:padding="12dp"
-            android:text="@string/edit_note_fragment_save"
-            android:textSize="18sp"
-            app:layout_constraintEnd_toEndOf="parent"
-            app:layout_constraintTop_toTopOf="parent" />
+    <TextView
+        android:id="@+id/voice_note_fragment_save"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginTop="16dp"
+        android:layout_marginEnd="16dp"
+        android:layout_marginRight="16dp"
+        android:padding="12dp"
+        android:text="SHARE"
+        android:textSize="18sp"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintTop_toTopOf="parent" />
 
-        <EditText
-            android:id="@+id/edit_note_fragment_body"
-            android:layout_width="0dp"
-            android:layout_height="wrap_content"
-            android:imeOptions="normal"
-            android:inputType="textMultiLine|textCapSentences"
-            android:padding="12dp"
-            android:textSize="14sp"
-            app:layout_constraintEnd_toEndOf="parent"
-            app:layout_constraintStart_toStartOf="parent"
-            app:layout_constraintTop_toBottomOf="@id/edit_note_fragment_title"
-            tools:ignore="Autofill,LabelFor" />
-    </androidx.constraintlayout.widget.ConstraintLayout>
-</ScrollView>
+    <TextView
+        android:id="@+id/voice_note_fragment_body"
+        android:layout_width="0dp"
+        android:layout_height="wrap_content"
+        android:padding="12dp"
+        android:textSize="14sp"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintTop_toBottomOf="@id/voice_note_fragment_title" />
+
+    <TextView
+        android:id="@+id/textView"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="00:00"
+        android:textSize="38sp"
+        app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintTop_toTopOf="parent" />
+
+    <SeekBar
+        android:id="@+id/seekBar"
+        android:layout_width="0dp"
+        android:layout_height="wrap_content"
+        android:layout_marginStart="8dp"
+        android:layout_marginLeft="8dp"
+        android:layout_marginEnd="8dp"
+        android:layout_marginRight="8dp"
+        android:layout_marginBottom="64dp"
+        android:max="100"
+        android:progress="13"
+        app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintStart_toStartOf="parent" />
+</androidx.constraintlayout.widget.ConstraintLayout>

+ 8 - 0
app/src/main/res/navigation/nav_graph.xml

@@ -63,6 +63,9 @@
         <action
             android:id="@+id/action_notesFragment_to_editNoteFragment"
             app:destination="@id/editNoteFragment" />
+        <action
+            android:id="@+id/action_notesFragment_to_voiceNoteFragment"
+            app:destination="@id/voiceNoteFragment" />
     </fragment>
     <fragment
         android:id="@+id/tasksFragment"
@@ -79,5 +82,10 @@
             app:destination="@id/noteFragment"
             app:popUpTo="@+id/notesFragment" />
     </fragment>
+    <fragment
+        android:id="@+id/voiceNoteFragment"
+        android:name="com.sduduzog.slimlauncher.ui.notes.VoiceNoteFragment"
+        android:label="voice_note_fragment"
+        tools:layout="@layout/voice_note_fragment" />
 
 </navigation>