mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-04-13 15:02:05 +02:00
store the note value in db only if its not linked to a file
This commit is contained in:
parent
c0617d518a
commit
6585cf0b2f
@ -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()
|
||||
}
|
||||
|
@ -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()
|
||||
|
@ -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>
|
||||
|
||||
|
@ -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>
|
||||
|
||||
|
@ -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>
|
||||
|
||||
|
@ -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>
|
||||
|
||||
|
@ -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>
|
||||
|
||||
|
@ -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>
|
||||
|
||||
|
@ -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>
|
||||
|
||||
|
@ -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>
|
||||
|
||||
|
@ -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>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user