store the note value in db only if its not linked to a file

This commit is contained in:
tibbi 2017-03-08 21:49:45 +01:00
parent c0617d518a
commit 6585cf0b2f
11 changed files with 29 additions and 17 deletions

View File

@ -30,7 +30,7 @@ class NotesPagerAdapter(fm: FragmentManager, private val notes: List<Note>) : 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()
}

View File

@ -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()

View File

@ -18,7 +18,7 @@
<string name="save_as_file">Save as file</string>
<string name="file_too_large">File too large, the limit is 10MB</string>
<string name="only_import_file_content">Only import the file content</string>
<string name="update_file_at_note">Update the file at updating the note</string>
<string name="update_file_at_note">Update the file itself at updating the note</string>
<string name="delete_note_only">This will delete the note only.</string>
<string name="delete_file_itself">Delete the file itself too</string>

View File

@ -18,7 +18,7 @@
<string name="save_as_file">Save as file</string>
<string name="file_too_large">File too large, the limit is 10MB</string>
<string name="only_import_file_content">Only import the file content</string>
<string name="update_file_at_note">Update the file at updating the note</string>
<string name="update_file_at_note">Update the file itself at updating the note</string>
<string name="delete_note_only">This will delete the note only.</string>
<string name="delete_file_itself">Delete the file itself too</string>

View File

@ -18,7 +18,7 @@
<string name="save_as_file">Save as file</string>
<string name="file_too_large">File too large, the limit is 10MB</string>
<string name="only_import_file_content">Only import the file content</string>
<string name="update_file_at_note">Update the file at updating the note</string>
<string name="update_file_at_note">Update the file itself at updating the note</string>
<string name="delete_note_only">This will delete the note only.</string>
<string name="delete_file_itself">Delete the file itself too</string>

View File

@ -18,7 +18,7 @@
<string name="save_as_file">Save as file</string>
<string name="file_too_large">File too large, the limit is 10MB</string>
<string name="only_import_file_content">Only import the file content</string>
<string name="update_file_at_note">Update the file at updating the note</string>
<string name="update_file_at_note">Update the file itself at updating the note</string>
<string name="delete_note_only">This will delete the note only.</string>
<string name="delete_file_itself">Delete the file itself too</string>

View File

@ -18,7 +18,7 @@
<string name="save_as_file">Save as file</string>
<string name="file_too_large">File too large, the limit is 10MB</string>
<string name="only_import_file_content">Only import the file content</string>
<string name="update_file_at_note">Update the file at updating the note</string>
<string name="update_file_at_note">Update the file itself at updating the note</string>
<string name="delete_note_only">This will delete the note only.</string>
<string name="delete_file_itself">Delete the file itself too</string>

View File

@ -18,7 +18,7 @@
<string name="save_as_file">Save as file</string>
<string name="file_too_large">File too large, the limit is 10MB</string>
<string name="only_import_file_content">Only import the file content</string>
<string name="update_file_at_note">Update the file at updating the note</string>
<string name="update_file_at_note">Update the file itself at updating the note</string>
<string name="delete_note_only">This will delete the note only.</string>
<string name="delete_file_itself">Delete the file itself too</string>

View File

@ -18,7 +18,7 @@
<string name="save_as_file">Save as file</string>
<string name="file_too_large">File too large, the limit is 10MB</string>
<string name="only_import_file_content">Only import the file content</string>
<string name="update_file_at_note">Update the file at updating the note</string>
<string name="update_file_at_note">Update the file itself at updating the note</string>
<string name="delete_note_only">This will delete the note only.</string>
<string name="delete_file_itself">Delete the file itself too</string>

View File

@ -18,7 +18,7 @@
<string name="save_as_file">Save as file</string>
<string name="file_too_large">File too large, the limit is 10MB</string>
<string name="only_import_file_content">Only import the file content</string>
<string name="update_file_at_note">Update the file at updating the note</string>
<string name="update_file_at_note">Update the file itself at updating the note</string>
<string name="delete_note_only">This will delete the note only.</string>
<string name="delete_file_itself">Delete the file itself too</string>

View File

@ -18,7 +18,7 @@
<string name="save_as_file">Save as file</string>
<string name="file_too_large">File too large, the limit is 10MB</string>
<string name="only_import_file_content">Only import the file content</string>
<string name="update_file_at_note">Update the file at updating the note</string>
<string name="update_file_at_note">Update the file itself at updating the note</string>
<string name="delete_note_only">This will delete the note only.</string>
<string name="delete_file_itself">Delete the file itself too</string>