فهرست منبع

chore: fits sstem windows was acting up when editing a note

beautusg 7 سال پیش
والد
کامیت
a2082d8035

+ 7 - 5
app/src/main/java/com/sduduzog/slimlauncher/MainActivity.kt

@@ -66,16 +66,16 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
         return theme
     }
 
-    override fun onBackPressed() { dispatchBack() }
+    override fun onBackPressed() {
+        dispatchBack()
+    }
 
     private fun showSystemUI() {
-        window.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_LAYOUT_STABLE
-                or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN)
+        window.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_LAYOUT_STABLE)
     }
 
     private fun hideSystemUI() {
         window.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_LAYOUT_STABLE
-                or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                 or View.SYSTEM_UI_FLAG_FULLSCREEN)
     }
 
@@ -112,5 +112,7 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
         }
     }
 
-    private fun completeBackAction(){ super.onBackPressed() }
+    private fun completeBackAction() {
+        super.onBackPressed()
+    }
 }

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

@@ -0,0 +1,18 @@
+package com.sduduzog.slimlauncher.ui.main
+
+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.edit_note_fragment.*
+
+class EditNoteFragment : BaseFragment() {
+
+    override fun getFragmentView(): ViewGroup = edit_note_fragment
+
+    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
+        return inflater.inflate(R.layout.edit_note_fragment, container, false)
+    }
+}

+ 52 - 50
app/src/main/java/com/sduduzog/slimlauncher/ui/main/NoteFragment.kt

@@ -1,21 +1,18 @@
 package com.sduduzog.slimlauncher.ui.main
 
 
-import android.content.Context
 import android.os.Bundle
 import android.view.LayoutInflater
 import android.view.View
 import android.view.ViewGroup
-import android.view.inputmethod.InputMethodManager
 import androidx.lifecycle.ViewModelProviders
+import androidx.navigation.Navigation
 import com.sduduzog.slimlauncher.R
 import com.sduduzog.slimlauncher.data.MainViewModel
 import com.sduduzog.slimlauncher.data.model.Note
 import com.sduduzog.slimlauncher.utils.BaseFragment
-import com.sduduzog.slimlauncher.utils.DoubleClickListener
 import kotlinx.android.synthetic.main.note_fragment.*
 import java.security.MessageDigest
-import java.util.*
 
 
 class NoteFragment : BaseFragment() {
@@ -49,55 +46,60 @@ class NoteFragment : BaseFragment() {
 
     override fun onActivityCreated(savedInstanceState: Bundle?) {
         super.onActivityCreated(savedInstanceState)
-        if (note.edited == -1L) {
-            editBody()
-        } else {
-            bodyEditText.visibility = View.GONE
-            textBody.visibility = View.VISIBLE
-            textBody.text = note.body
-            titleEditText.setText(note.title.orEmpty())
-            bodyEditText.setText(note.body)
-            titleEditText.isEnabled = false
-        }
-        titleEditText.setOnEditorActionListener { _, _, _ ->
-            editBody()
-            true
-        }
-        textBody.setOnClickListener(object : DoubleClickListener() {
-            override fun onDoubleClick(v: View) {
-                titleEditText.isEnabled = true
-                editBody()
-            }
-
-            override fun onSingleClick(v: View) {
-                // Do nothing
-            }
-        })
+        note_fragment_edit.setOnClickListener(Navigation.createNavigateOnClickListener(R.id.action_noteFragment_to_editNoteFragment))
     }
 
-    private fun editBody() {
-        textBody.visibility = View.GONE
-        bodyEditText.visibility = View.VISIBLE
-        if (bodyEditText.requestFocus()) {
-            val imm = activity!!.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
-            imm.showSoftInput(bodyEditText, InputMethodManager.SHOW_IMPLICIT)
-            bodyEditText.setSelection(note.body.length)
-        }
-    }
+//    override fun onActivityCreated(savedInstanceState: Bundle?) {
+//        super.onActivityCreated(savedInstanceState)
+//        if (note.edited == -1L) {
+//            editBody()
+//        } else {
+//            bodyEditText.visibility = View.GONE
+//            textBody.visibility = View.VISIBLE
+//            textBody.text = note.body
+//            titleEditText.setText(note.title.orEmpty())
+//            bodyEditText.setText(note.body)
+//            titleEditText.isEnabled = false
+//        }
+//        titleEditText.setOnEditorActionListener { _, _, _ ->
+//            editBody()
+//            true
+//        }
+//        textBody.setOnClickListener(object : DoubleClickListener() {
+//            override fun onDoubleClick(v: View) {
+//                titleEditText.isEnabled = true
+//                editBody()
+//            }
+//
+//            override fun onSingleClick(v: View) {
+//            //     Do nothing
+//            }
+//        })
+//    }
 
-    private fun saveNote() {
-        val body = bodyEditText.text.toString()
-        val title = titleEditText.text.toString()
-        val newNote = Note(body, Date().time)
-        newNote.title = if (title.isEmpty()) null else title
-        newNote.body = body.trim()
-        newNote.id = note.id
-        val currentDigest = hash(newNote.title + newNote.body)
-        if (body.isEmpty()) return
-        if (initialDigest == currentDigest) return
-        if (note.id == null) viewModel.add(newNote) else viewModel.update(newNote)
+//    private fun editBody() {
+//        textBody.visibility = View.GONE
+//        bodyEditText.visibility = View.VISIBLE
+//        if (bodyEditText.requestFocus()) {
+//            val imm = activity!!.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
+//            imm.showSoftInput(bodyEditText, InputMethodManager.SHOW_IMPLICIT)
+//            bodyEditText.setSelection(note.body.length)
+//        }
+//    }
 
-    }
+//    private fun saveNote() {
+//        val body = bodyEditText.text.toString()
+//        val title = titleEditText.text.toString()
+//        val newNote = Note(body, Date().time)
+//        newNote.title = if (title.isEmpty()) null else title
+//        newNote.body = body.trim()
+//        newNote.id = note.id
+//        val currentDigest = hash(newNote.title + newNote.body)
+//        if (body.isEmpty()) return
+//        if (initialDigest == currentDigest) return
+//        if (note.id == null) viewModel.add(newNote) else viewModel.update(newNote)
+//
+//    }
 
     private fun hash(input: String): String {
         val bytes = input.toByteArray(charset("UTF-8"))
@@ -107,7 +109,7 @@ class NoteFragment : BaseFragment() {
     }
 
     override fun onBack(): Boolean {
-        saveNote()
+        //saveNote()
         return false
     }
 }

+ 6 - 6
app/src/main/res/layout/customise_apps_fragment.xml

@@ -11,9 +11,9 @@
         android:id="@+id/textView6"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
-        android:layout_marginStart="16dp"
-        android:layout_marginLeft="16dp"
-        android:layout_marginTop="@dimen/_32sdp"
+        android:layout_marginStart="@dimen/_16sdp"
+        android:layout_marginLeft="@dimen/_16sdp"
+        android:layout_marginTop="@dimen/_8sdp"
         android:text="@string/options_fragment_customise_apps"
         android:textAppearance="@style/TextAppearance.AppCompat"
         android:textSize="@dimen/_36ssp"
@@ -54,11 +54,11 @@
         android:id="@+id/customise_apps_fragment_counter"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
-        android:textSize="@dimen/_16ssp"
-        android:padding="@dimen/_12sdp"
-        android:layout_marginRight="8dp"
         android:layout_marginEnd="8dp"
+        android:layout_marginRight="8dp"
         android:layout_marginBottom="8dp"
+        android:padding="@dimen/_12sdp"
+        android:textSize="@dimen/_16ssp"
         app:layout_constraintBottom_toBottomOf="parent"
         app:layout_constraintEnd_toEndOf="parent" />
 </androidx.constraintlayout.widget.ConstraintLayout>

+ 54 - 0
app/src/main/res/layout/edit_note_fragment.xml

@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="utf-8"?>
+<ScrollView 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/edit_note_fragment"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:fitsSystemWindows="true"
+    android:scrollbarStyle="insideOverlay"
+    tools:context="com.sduduzog.slimlauncher.ui.main.EditNoteFragment">
+
+    <androidx.constraintlayout.widget.ConstraintLayout
+        android:id="@+id/edit_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:padding="12dp"
+            android:text="Untitled"
+            android:textSize="18sp"
+            app:layout_constraintEnd_toStartOf="@+id/edit_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="SAVE"
+            android:textSize="18sp"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintTop_toTopOf="parent" />
+
+        <EditText
+            android:id="@+id/textView4"
+            android:layout_width="0dp"
+            android:layout_height="wrap_content"
+            android:imeOptions="normal"
+            android:inputType="textMultiLine|textCapSentences"
+            android:padding="12dp"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintTop_toBottomOf="@id/edit_note_fragment_title" />
+    </androidx.constraintlayout.widget.ConstraintLayout>
+</ScrollView>

+ 30 - 51
app/src/main/res/layout/note_fragment.xml

@@ -4,70 +4,49 @@
     android:id="@+id/note_fragment"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    app:layout_constraintEnd_toEndOf="parent"
-    app:layout_constraintStart_toStartOf="parent"
-    app:layout_constraintTop_toTopOf="parent"
     tools:context="com.sduduzog.slimlauncher.ui.main.NoteFragment">
 
-    <LinearLayout
+    <androidx.constraintlayout.widget.ConstraintLayout
+        android:id="@+id/note_fragment_layout"
         android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:paddingTop="20dp"
-        android:orientation="vertical">
+        android:layout_height="wrap_content">
 
-        <EditText
-            android:id="@+id/titleEditText"
-            android:layout_width="match_parent"
+        <TextView
+            android:id="@+id/note_fragment_title"
+            android:layout_width="0dp"
             android:layout_height="wrap_content"
-            android:layout_marginStart="8dp"
-            android:layout_marginTop="8dp"
-            android:layout_marginEnd="8dp"
-            android:background="@android:color/transparent"
-            android:ems="10"
-            android:hint="@string/note_fragment_hint_title"
-            android:inputType="textPersonName"
-            android:padding="8dp"
-            android:textSize="24sp"
-            app:layout_constraintEnd_toEndOf="parent"
+            android:layout_marginTop="16dp"
+            android:padding="12dp"
+            android:text="Untitled"
+            android:textAppearance="@style/Base.TextAppearance.AppCompat"
+            android:textSize="18sp"
+            app:layout_constraintEnd_toStartOf="@+id/note_fragment_edit"
             app:layout_constraintStart_toStartOf="parent"
-            app:layout_constraintTop_toTopOf="parent"
-            tools:ignore="Autofill,LabelFor" />
+            app:layout_constraintTop_toTopOf="parent" />
 
-        <EditText
-            android:id="@+id/bodyEditText"
-            android:layout_width="match_parent"
+        <TextView
+            android:id="@+id/note_fragment_edit"
+            android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            android:layout_marginStart="8dp"
-            android:layout_marginTop="8dp"
-            android:layout_marginEnd="8dp"
-            android:background="@android:color/transparent"
-            android:ems="10"
-            android:gravity="top"
-            android:hint="@string/note_fragment_hint_body"
-            android:inputType="textCapSentences|textAutoCorrect|textAutoComplete|textMultiLine|textImeMultiLine"
-            android:minLines="2"
-            android:padding="8dp"
-            android:textSize="14sp"
+            android:layout_marginTop="16dp"
+            android:layout_marginEnd="16dp"
+            android:layout_marginRight="16dp"
+            android:padding="12dp"
+            android:text="EDIT"
+            android:textSize="18sp"
             app:layout_constraintEnd_toEndOf="parent"
-            app:layout_constraintStart_toStartOf="parent"
-            app:layout_constraintTop_toBottomOf="@+id/titleEditText"
-            tools:ignore="Autofill,LabelFor" />
+            app:layout_constraintTop_toTopOf="parent" />
 
         <TextView
-            android:id="@+id/textBody"
-            android:layout_width="match_parent"
+            android:id="@+id/textView4"
+            android:layout_width="0dp"
             android:layout_height="wrap_content"
-            android:layout_marginStart="8dp"
-            android:layout_marginTop="8dp"
-            android:layout_marginEnd="8dp"
-            android:padding="8dp"
-            android:text="@string/note_fragment_hint_body"
-            android:textSize="14sp"
-            android:visibility="gone"
+            android:padding="12dp"
+            android:text="@string/test_string"
+            android:textAppearance="@style/Base.TextAppearance.AppCompat"
             app:layout_constraintEnd_toEndOf="parent"
-            app:layout_constraintHorizontal_bias="1.0"
             app:layout_constraintStart_toStartOf="parent"
-            app:layout_constraintTop_toBottomOf="@+id/titleEditText" />
-    </LinearLayout>
+            app:layout_constraintTop_toBottomOf="@id/note_fragment_title" />
+    </androidx.constraintlayout.widget.ConstraintLayout>
 </ScrollView>
 

+ 6 - 2
app/src/main/res/layout/notes_fragment.xml

@@ -13,7 +13,7 @@
         android:layout_height="wrap_content"
         android:layout_marginStart="16dp"
         android:layout_marginLeft="16dp"
-        android:layout_marginTop="@dimen/_32sdp"
+        android:layout_marginTop="@dimen/_8sdp"
         android:text="@string/main_fragment_notes"
         android:textAppearance="@style/TextAppearance.AppCompat"
         android:textSize="@dimen/_36ssp"
@@ -24,8 +24,12 @@
         android:id="@+id/notes_fragment_create_note"
         android:layout_width="0dp"
         android:layout_height="wrap_content"
-        android:alpha="0.5"
+        android:layout_marginStart="@dimen/_8sdp"
+        android:layout_marginLeft="@dimen/_8sdp"
         android:layout_marginTop="@dimen/_8sdp"
+        android:layout_marginEnd="@dimen/_8sdp"
+        android:layout_marginRight="@dimen/_8sdp"
+        android:alpha="0.5"
         android:padding="@dimen/_12sdp"
         android:text="@string/notes_fragment_create_new_note"
         android:textAppearance="@style/TextAppearance.AppCompat"

+ 1 - 0
app/src/main/res/layout/notes_fragment_list_item.xml

@@ -16,6 +16,7 @@
         android:id="@+id/notes_fragment_list_item_snippet"
         android:layout_width="match_parent"
         android:ellipsize="end"
+        android:textAppearance="@style/TextAppearance.AppCompat"
         android:maxLines="5"
         android:layout_height="wrap_content" />
 </LinearLayout>

+ 1 - 1
app/src/main/res/layout/options_fragment.xml

@@ -13,7 +13,7 @@
         android:layout_height="wrap_content"
         android:layout_marginStart="@dimen/_16sdp"
         android:layout_marginLeft="@dimen/_16sdp"
-        android:layout_marginTop="@dimen/_32sdp"
+        android:layout_marginTop="@dimen/_8sdp"
         android:text="@string/main_fragment_options"
         android:textAppearance="@style/TextAppearance.AppCompat"
         android:textSize="@dimen/_36ssp"

+ 0 - 1
app/src/main/res/layout/tasks_fragment.xml

@@ -11,7 +11,6 @@
         android:id="@+id/tasks_fragment_input"
         android:layout_width="0dp"
         android:layout_height="wrap_content"
-        android:layout_marginTop="@dimen/_32sdp"
         android:ems="10"
         android:hint="@string/tasks_fragment_enter_a_new_task"
         android:inputType="textCapSentences"

+ 14 - 1
app/src/main/res/navigation/nav_graph.xml

@@ -47,7 +47,11 @@
         android:id="@+id/noteFragment"
         android:name="com.sduduzog.slimlauncher.ui.main.NoteFragment"
         android:label="note_fragment"
-        tools:layout="@layout/note_fragment" />
+        tools:layout="@layout/note_fragment">
+        <action
+            android:id="@+id/action_noteFragment_to_editNoteFragment"
+            app:destination="@id/editNoteFragment" />
+    </fragment>
     <fragment
         android:id="@+id/notesFragment"
         android:name="com.sduduzog.slimlauncher.ui.main.NotesFragment"
@@ -56,11 +60,20 @@
         <action
             android:id="@+id/action_notesFragment_to_noteFragment"
             app:destination="@id/noteFragment" />
+        <action
+            android:id="@+id/action_notesFragment_to_editNoteFragment"
+            app:destination="@id/editNoteFragment"
+            app:popUpTo="@+id/noteFragment" />
     </fragment>
     <fragment
         android:id="@+id/tasksFragment"
         android:name="com.sduduzog.slimlauncher.ui.main.TasksFragment"
         android:label="tasks_fragment"
         tools:layout="@layout/tasks_fragment" />
+    <fragment
+        android:id="@+id/editNoteFragment"
+        android:name="com.sduduzog.slimlauncher.ui.main.EditNoteFragment"
+        android:label="edit_note_fragment"
+        tools:layout="@layout/edit_note_fragment" />
 
 </navigation>

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

@@ -59,5 +59,53 @@
     <string name="tasks_fragment_clear_completed_tasks">Clear completed tasks</string>
     <string name="tasks_fragment_enter_a_new_task">Enter a new task</string>
 
+    <string name="test_string">"About Codeo
+Why do we do what we do?
+We love learning and solving challenging problems in an innovative way. We love that technology lets small teams solve big problems.
+We want to leverage what we love and what we are good at to make a positive impact on the way people live and work.
+Our Vision
+Our vision is to create an environment where world class people master their craft while creating remarkable products that change the world.
+Our Values
+To be effective together, we align around a shared set of values:
+Be Excellent We invest care in our work and hone our skills, because how you do anything reflects how you do everything.
+Value Human Experience We care deeply about how people experience our work, whether they are customers, suppliers or coworkers.
+Innovate We constantly push boundaries, moving forward by seeking change and challenging old ideas.
+Be Strategic We think big-picture and long-term so that our work can have the greatest impact.
+Take Ownership We take ownership of challenges. We\'re responsible. We don\'t pass the buck. Be Genuine We are genuine people.
+We are honest, authentic &amp; trustworthy. 
+In pursuing this vision together, adhering to these values, we believe that we will fulfill our purpose and make a significant contribution to the world. 
+More about our Core Values
+Be Excellent - We invest care in our work and hone our skills, because how you do anything reflects how you do everything.
+We care deeply about the work we do, no matter its form. We believe that how one does anything is a reflection of how one does everything.
+We enjoy the process and believe one can be creative in even the most simplest of tasks.
+We care about  detail and believe that this attention reflects the respect we have for others.
+We want to be proud of each deliverable, no matter what it is.
+Value Human Experience We care deeply about how people experience our work, whether they are customers, suppliers or coworkers.
+It\'s not all about the code. We care deeply about the presentation of our work and the human experience.
+We also care about the internals, and value the perspective that other engineers\/designers would have if they reviewed our work.
+We believe in a solid balance of engineering, user experience and the presentation of our work.
+We do not deliver anything that isn\'t underpinned with an investment in these three areas. This is what makes us unique.
+Innovate We constantly push boundaries because we love learning and transforming ideas into reality.
+We evolve through innovation. We value ideation and innovation and the impact it has on the evolution of our work.
+Innovation means a better way of doing something. Innovation means an opportunity to do something differently.
+Innovation means we are learning. We are constantly evolving through innovation. It's not something we do sometimes. 
+Be Strategic We think big-picture and long-term so that our work can have the greatest impact
+We believe in always thinking long term and about solving the right problems.
+We invest in ideas, people, processes and tools that deal with challenges in a sustainable way.
+We ask Why? before What? or How? because we want to invest in things that align with our values and purpose. 
+Take Ownership We take ownership of challenges. We're responsible. We don't pass the buck.
+We demonstrate ownership in everything we do. We take the initiative and don't wait for others to act.
+We care about the outcomes and take the lead, particularly when dealing with the results of our own actions.
+Taking ownership demonstrates to others that they can trust us to do the right thing.
+Because of this, outsiders describe us as responsible or trustworthy.
+Be Genuine We are genuine people. We are honest, authentic &amp; trustworthy. 
+We are genuine. We don't pretend to be something we are not. We demonstrate that we are genuine through our actions.
+We actively listen to others. We are honest. We are sincere. We care. When we express gratitude, it is genuine.
+When we present critiques, we do so in a positive manner.
+Other things we care deeply about:
+Efficacy We hone our skills and optimize our tools to make the best use of the time we have.
+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."
+</string>
 
 </resources>