From 6585cf0b2fc4308681fa1d95dec53c707f12143f Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 8 Mar 2017 21:49:45 +0100 Subject: [PATCH] store the note value in db only if its not linked to a file --- .../notes/adapters/NotesPagerAdapter.kt | 2 +- .../notes/fragments/NoteFragment.kt | 26 ++++++++++++++----- app/src/main/res/values-de/strings.xml | 2 +- app/src/main/res/values-es/strings.xml | 2 +- app/src/main/res/values-fr/strings.xml | 2 +- app/src/main/res/values-hu/strings.xml | 2 +- app/src/main/res/values-it/strings.xml | 2 +- app/src/main/res/values-ja/strings.xml | 2 +- app/src/main/res/values-pt-rPT/strings.xml | 2 +- app/src/main/res/values-sv/strings.xml | 2 +- app/src/main/res/values/strings.xml | 2 +- 11 files changed, 29 insertions(+), 17 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/notes/adapters/NotesPagerAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/notes/adapters/NotesPagerAdapter.kt index e6ce7bce..c73a4908 100644 --- a/app/src/main/kotlin/com/simplemobiletools/notes/adapters/NotesPagerAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/notes/adapters/NotesPagerAdapter.kt @@ -30,7 +30,7 @@ class NotesPagerAdapter(fm: FragmentManager, private val notes: List) : Fr override fun getPageTitle(position: Int) = notes[position].title - fun getCurrentNoteText(position: Int) = fragments[position].getCurrentNoteText() + fun getCurrentNoteText(position: Int) = fragments[position].getCurrentNoteViewText() fun showKeyboard(position: Int) = fragments[position]?.showKeyboard() } diff --git a/app/src/main/kotlin/com/simplemobiletools/notes/fragments/NoteFragment.kt b/app/src/main/kotlin/com/simplemobiletools/notes/fragments/NoteFragment.kt index 43d2ad1a..99ae512d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/notes/fragments/NoteFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/notes/fragments/NoteFragment.kt @@ -56,16 +56,14 @@ class NoteFragment : Fragment() { return view } - fun getCurrentNoteText() = view.notes_view.text.toString() - fun saveText() { - val newText = getCurrentNoteText() - val oldText = note.value + val newText = getCurrentNoteViewText() + val oldText = getNoteStoredValue() if (newText != oldText) { note.value = newText - mDb.updateNoteValue(note) - context.updateWidget() + saveNoteValue(note) } + context.updateWidget() } fun showKeyboard() { @@ -74,12 +72,26 @@ class NoteFragment : Fragment() { imm.showSoftInput(view.notes_view, InputMethodManager.SHOW_IMPLICIT) } + private fun saveNoteValue(note: Note) { + if (note.path.isEmpty()) { + mDb.updateNoteValue(note) + } else { + + } + } + + fun getCurrentNoteViewText() = view.notes_view.text.toString() + + private fun getNoteStoredValue(): String { + return note.value + } + override fun onResume() { super.onResume() val config = context.config view.notes_view.apply { - setText(note.value) + setText(getNoteStoredValue()) setColors(config.textColor, config.primaryColor, config.backgroundColor) setTextSize(TypedValue.COMPLEX_UNIT_PX, context.getTextSize()) gravity = context.getTextGravity() diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 910ad135..58a604e5 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -18,7 +18,7 @@ Save as file File too large, the limit is 10MB Only import the file content - Update the file at updating the note + Update the file itself at updating the note This will delete the note only. Delete the file itself too diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index d3b6202f..ba21392b 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -18,7 +18,7 @@ Save as file File too large, the limit is 10MB Only import the file content - Update the file at updating the note + Update the file itself at updating the note This will delete the note only. Delete the file itself too diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index a3110942..a070adeb 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -18,7 +18,7 @@ Save as file File too large, the limit is 10MB Only import the file content - Update the file at updating the note + Update the file itself at updating the note This will delete the note only. Delete the file itself too diff --git a/app/src/main/res/values-hu/strings.xml b/app/src/main/res/values-hu/strings.xml index f65233c7..1b0203e3 100644 --- a/app/src/main/res/values-hu/strings.xml +++ b/app/src/main/res/values-hu/strings.xml @@ -18,7 +18,7 @@ Save as file File too large, the limit is 10MB Only import the file content - Update the file at updating the note + Update the file itself at updating the note This will delete the note only. Delete the file itself too diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 7b443645..67983d4c 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -18,7 +18,7 @@ Save as file File too large, the limit is 10MB Only import the file content - Update the file at updating the note + Update the file itself at updating the note This will delete the note only. Delete the file itself too diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index 1b36cb19..74a0c00e 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -18,7 +18,7 @@ Save as file File too large, the limit is 10MB Only import the file content - Update the file at updating the note + Update the file itself at updating the note This will delete the note only. Delete the file itself too diff --git a/app/src/main/res/values-pt-rPT/strings.xml b/app/src/main/res/values-pt-rPT/strings.xml index 9cf350a4..8f4b4f72 100644 --- a/app/src/main/res/values-pt-rPT/strings.xml +++ b/app/src/main/res/values-pt-rPT/strings.xml @@ -18,7 +18,7 @@ Save as file File too large, the limit is 10MB Only import the file content - Update the file at updating the note + Update the file itself at updating the note This will delete the note only. Delete the file itself too diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index f2244a44..69362988 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -18,7 +18,7 @@ Save as file File too large, the limit is 10MB Only import the file content - Update the file at updating the note + Update the file itself at updating the note This will delete the note only. Delete the file itself too diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 51f434fa..103dd67e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -18,7 +18,7 @@ Save as file File too large, the limit is 10MB Only import the file content - Update the file at updating the note + Update the file itself at updating the note This will delete the note only. Delete the file itself too