beautusg 7 лет назад
Родитель
Сommit
66c67eb047

+ 10 - 0
app/src/main/java/com/sduduzog/slimlauncher/ui/main/EditNoteFragment.kt

@@ -1,9 +1,11 @@
 package com.sduduzog.slimlauncher.ui.main
 package com.sduduzog.slimlauncher.ui.main
 
 
+import android.content.Context
 import android.os.Bundle
 import android.os.Bundle
 import android.view.LayoutInflater
 import android.view.LayoutInflater
 import android.view.View
 import android.view.View
 import android.view.ViewGroup
 import android.view.ViewGroup
+import android.view.inputmethod.InputMethodManager
 import com.sduduzog.slimlauncher.R
 import com.sduduzog.slimlauncher.R
 import com.sduduzog.slimlauncher.utils.BaseFragment
 import com.sduduzog.slimlauncher.utils.BaseFragment
 import kotlinx.android.synthetic.main.edit_note_fragment.*
 import kotlinx.android.synthetic.main.edit_note_fragment.*
@@ -15,4 +17,12 @@ class EditNoteFragment : BaseFragment() {
     override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
     override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
         return inflater.inflate(R.layout.edit_note_fragment, container, false)
         return inflater.inflate(R.layout.edit_note_fragment, container, false)
     }
     }
+
+    override fun onActivityCreated(savedInstanceState: Bundle?) {
+        super.onActivityCreated(savedInstanceState)
+        if (edit_note_fragment_body.requestFocus()) {
+            val imm = activity!!.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
+            imm.showSoftInput(edit_note_fragment_title, InputMethodManager.SHOW_IMPLICIT)
+        }
+    }
 }
 }

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

@@ -66,7 +66,7 @@ class NotesFragment : BaseFragment(), OnShitDoneToNotesListener {
         val itemTouchHelper = ItemTouchHelper(simpleItemTouchCallback)
         val itemTouchHelper = ItemTouchHelper(simpleItemTouchCallback)
         itemTouchHelper.attachToRecyclerView(notes_fragment_list)
         itemTouchHelper.attachToRecyclerView(notes_fragment_list)
 
 
-        notes_fragment_create_note.setOnClickListener(Navigation.createNavigateOnClickListener(R.id.action_notesFragment_to_noteFragment))
+        notes_fragment_create_note.setOnClickListener(Navigation.createNavigateOnClickListener(R.id.action_notesFragment_to_editNoteFragment))
     }
     }
 
 
 
 

+ 8 - 5
app/src/main/res/layout/edit_note_fragment.xml

@@ -21,11 +21,13 @@
             android:layout_marginTop="16dp"
             android:layout_marginTop="16dp"
             android:background="@android:color/transparent"
             android:background="@android:color/transparent"
             android:padding="12dp"
             android:padding="12dp"
-            android:text="Untitled"
+            android:hint="@string/edit_note_fragment_untitled"
             android:textSize="18sp"
             android:textSize="18sp"
             app:layout_constraintEnd_toStartOf="@+id/edit_note_fragment_save"
             app:layout_constraintEnd_toStartOf="@+id/edit_note_fragment_save"
             app:layout_constraintStart_toStartOf="parent"
             app:layout_constraintStart_toStartOf="parent"
-            app:layout_constraintTop_toTopOf="parent" />
+            android:singleLine="true"
+            app:layout_constraintTop_toTopOf="parent"
+            tools:ignore="Autofill,TextFields" />
 
 
         <TextView
         <TextView
             android:id="@+id/edit_note_fragment_save"
             android:id="@+id/edit_note_fragment_save"
@@ -35,13 +37,13 @@
             android:layout_marginEnd="16dp"
             android:layout_marginEnd="16dp"
             android:layout_marginRight="16dp"
             android:layout_marginRight="16dp"
             android:padding="12dp"
             android:padding="12dp"
-            android:text="SAVE"
+            android:text="@string/edit_note_fragment_save"
             android:textSize="18sp"
             android:textSize="18sp"
             app:layout_constraintEnd_toEndOf="parent"
             app:layout_constraintEnd_toEndOf="parent"
             app:layout_constraintTop_toTopOf="parent" />
             app:layout_constraintTop_toTopOf="parent" />
 
 
         <EditText
         <EditText
-            android:id="@+id/textView4"
+            android:id="@+id/edit_note_fragment_body"
             android:layout_width="0dp"
             android:layout_width="0dp"
             android:layout_height="wrap_content"
             android:layout_height="wrap_content"
             android:imeOptions="normal"
             android:imeOptions="normal"
@@ -49,6 +51,7 @@
             android:padding="12dp"
             android:padding="12dp"
             app:layout_constraintEnd_toEndOf="parent"
             app:layout_constraintEnd_toEndOf="parent"
             app:layout_constraintStart_toStartOf="parent"
             app:layout_constraintStart_toStartOf="parent"
-            app:layout_constraintTop_toBottomOf="@id/edit_note_fragment_title" />
+            app:layout_constraintTop_toBottomOf="@id/edit_note_fragment_title"
+            tools:ignore="Autofill,LabelFor" />
     </androidx.constraintlayout.widget.ConstraintLayout>
     </androidx.constraintlayout.widget.ConstraintLayout>
 </ScrollView>
 </ScrollView>

+ 2 - 3
app/src/main/res/layout/note_fragment.xml

@@ -17,7 +17,7 @@
             android:layout_height="wrap_content"
             android:layout_height="wrap_content"
             android:layout_marginTop="16dp"
             android:layout_marginTop="16dp"
             android:padding="12dp"
             android:padding="12dp"
-            android:text="Untitled"
+            android:text="@string/edit_note_fragment_untitled"
             android:textAppearance="@style/Base.TextAppearance.AppCompat"
             android:textAppearance="@style/Base.TextAppearance.AppCompat"
             android:textSize="18sp"
             android:textSize="18sp"
             app:layout_constraintEnd_toStartOf="@+id/note_fragment_edit"
             app:layout_constraintEnd_toStartOf="@+id/note_fragment_edit"
@@ -32,7 +32,7 @@
             android:layout_marginEnd="16dp"
             android:layout_marginEnd="16dp"
             android:layout_marginRight="16dp"
             android:layout_marginRight="16dp"
             android:padding="12dp"
             android:padding="12dp"
-            android:text="EDIT"
+            android:text="@string/note_fragment_edit"
             android:textSize="18sp"
             android:textSize="18sp"
             app:layout_constraintEnd_toEndOf="parent"
             app:layout_constraintEnd_toEndOf="parent"
             app:layout_constraintTop_toTopOf="parent" />
             app:layout_constraintTop_toTopOf="parent" />
@@ -42,7 +42,6 @@
             android:layout_width="0dp"
             android:layout_width="0dp"
             android:layout_height="wrap_content"
             android:layout_height="wrap_content"
             android:padding="12dp"
             android:padding="12dp"
-            android:text="@string/test_string"
             android:textAppearance="@style/Base.TextAppearance.AppCompat"
             android:textAppearance="@style/Base.TextAppearance.AppCompat"
             app:layout_constraintEnd_toEndOf="parent"
             app:layout_constraintEnd_toEndOf="parent"
             app:layout_constraintStart_toStartOf="parent"
             app:layout_constraintStart_toStartOf="parent"

+ 3 - 0
app/src/main/res/values/strings.xml

@@ -107,5 +107,8 @@ Efficacy We hone our skills and optimize our tools to make the best use of the t
 Being effective means more time can be invested in being creative. You cannot scale creativity or be effective at it.
 Being effective means more time can be invested in being creative. You cannot scale creativity or be effective at it.
 Because of this, we are ruthless at driving efficiency and automating the rote so we can spend more time on the problems that really challenge us."
 Because of this, we are ruthless at driving efficiency and automating the rote so we can spend more time on the problems that really challenge us."
 </string>
 </string>
+    <string name="edit_note_fragment_save">SAVE</string>
+    <string name="edit_note_fragment_untitled">Untitled</string>
+    <string name="note_fragment_edit">EDIT</string>
 
 
 </resources>
 </resources>