From 86048f1d576e3e0689de69f667a425e851d21cec Mon Sep 17 00:00:00 2001 From: Noah Watson Date: Sun, 7 Nov 2021 23:10:07 -0600 Subject: [PATCH 1/2] attempt fixing launch from widget bug --- .../it/niedermann/owncloud/notes/edit/BaseNoteFragment.java | 3 ++- .../it/niedermann/owncloud/notes/edit/NoteEditFragment.java | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/it/niedermann/owncloud/notes/edit/BaseNoteFragment.java b/app/src/main/java/it/niedermann/owncloud/notes/edit/BaseNoteFragment.java index b7011fbb9..9b7531cfe 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/edit/BaseNoteFragment.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/edit/BaseNoteFragment.java @@ -82,6 +82,7 @@ public abstract class BaseNoteFragment extends BrandedFragment implements Catego private boolean titleModified = false; protected boolean isNew = true; + protected boolean contentLoaded = false; @Override public void onAttach(@NonNull Context context) { @@ -314,7 +315,7 @@ public void onCloseNote() { protected void saveNote(@Nullable ISyncCallback callback) { Log.d(TAG, "saveData()"); if (note != null) { - final var newContent = getContent(); + final var newContent = contentLoaded ? getContent() : note.getContent(); if (note.getContent().equals(newContent)) { if (note.getScrollY() != originalScrollY) { Log.v(TAG, "... only saving new scroll state, since content did not change"); diff --git a/app/src/main/java/it/niedermann/owncloud/notes/edit/NoteEditFragment.java b/app/src/main/java/it/niedermann/owncloud/notes/edit/NoteEditFragment.java index 7c56c1e17..6c8893935 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/edit/NoteEditFragment.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/edit/NoteEditFragment.java @@ -167,6 +167,7 @@ protected void onNoteLoaded(Note note) { binding.editContent.setMarkdownString(note.getContent()); binding.editContent.setEnabled(true); + contentLoaded = true; final var sp = PreferenceManager.getDefaultSharedPreferences(requireContext().getApplicationContext()); binding.editContent.setTextSize(TypedValue.COMPLEX_UNIT_PX, getFontSizeFromPreferences(requireContext(), sp)); From 50fccda8267762f17bf8a70d7d1d892032a7dcd2 Mon Sep 17 00:00:00 2001 From: Noah Watson Date: Thu, 11 Nov 2021 17:26:03 -0600 Subject: [PATCH 2/2] fix contentLoaded not updated for preview mode --- .../it/niedermann/owncloud/notes/edit/NotePreviewFragment.java | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/java/it/niedermann/owncloud/notes/edit/NotePreviewFragment.java b/app/src/main/java/it/niedermann/owncloud/notes/edit/NotePreviewFragment.java index 21f8a7c70..1cdfd677b 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/edit/NotePreviewFragment.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/edit/NotePreviewFragment.java @@ -132,6 +132,7 @@ protected void onNoteLoaded(Note note) { changedText = newContent.toString(); saveNote(null); }); + contentLoaded = true; } protected void registerInternalNoteLinkHandler() {