From 834930981a1f7b474f025d090bf23187cc771378 Mon Sep 17 00:00:00 2001 From: stefan-niedermann Date: Thu, 23 Jan 2020 12:52:41 +0100 Subject: [PATCH] #550 In-note-search doesn't jump to occurrence of searchstring - Keep coloring and occurrences when switching between edit and preview mode --- .../notes/android/fragment/NoteEditFragment.java | 1 + .../notes/android/fragment/NotePreviewFragment.java | 1 + .../android/fragment/SearchableBaseNoteFragment.java | 10 ++++------ 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/it/niedermann/owncloud/notes/android/fragment/NoteEditFragment.java b/app/src/main/java/it/niedermann/owncloud/notes/android/fragment/NoteEditFragment.java index 2a1f37b0..216f6214 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/android/fragment/NoteEditFragment.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/android/fragment/NoteEditFragment.java @@ -114,6 +114,7 @@ public class NoteEditFragment extends SearchableBaseNoteFragment { @Override protected Layout getLayout() { + editContent.onPreDraw(); return editContent.getLayout(); } diff --git a/app/src/main/java/it/niedermann/owncloud/notes/android/fragment/NotePreviewFragment.java b/app/src/main/java/it/niedermann/owncloud/notes/android/fragment/NotePreviewFragment.java index 024abcb7..8e45c93a 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/android/fragment/NotePreviewFragment.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/android/fragment/NotePreviewFragment.java @@ -96,6 +96,7 @@ public class NotePreviewFragment extends SearchableBaseNoteFragment { @Override protected Layout getLayout() { + noteContent.onPreDraw(); return noteContent.getLayout(); } diff --git a/app/src/main/java/it/niedermann/owncloud/notes/android/fragment/SearchableBaseNoteFragment.java b/app/src/main/java/it/niedermann/owncloud/notes/android/fragment/SearchableBaseNoteFragment.java index 7a0b4da1..991d31c9 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/android/fragment/SearchableBaseNoteFragment.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/android/fragment/SearchableBaseNoteFragment.java @@ -34,11 +34,6 @@ public abstract class SearchableBaseNoteFragment extends BaseNoteFragment { if (savedInstanceState != null) { searchQuery = savedInstanceState.getString("searchQuery", ""); currentOccurrence = savedInstanceState.getInt("currentOccurrence", 1); - // TODO if search is open - if (searchView != null && !TextUtils.isEmpty(searchView.getQuery().toString())) { - colorWithText(searchQuery); - jumpToOccurrence(); - } } } @@ -74,6 +69,9 @@ public abstract class SearchableBaseNoteFragment extends BaseNoteFragment { searchQuery = ""; hideSearchFabs(); } else { + jumpToOccurrence(); + colorWithText(searchQuery); + occurrenceCount = countOccurrences(getContent(), searchQuery); showSearchFabs(); } @@ -111,7 +109,6 @@ public abstract class SearchableBaseNoteFragment extends BaseNoteFragment { @Override public boolean onQueryTextChange(String newText) { searchQuery = newText; - colorWithText(newText); occurrenceCount = countOccurrences(getContent(), searchQuery); if (occurrenceCount > 1) { showSearchFabs(); @@ -120,6 +117,7 @@ public abstract class SearchableBaseNoteFragment extends BaseNoteFragment { } currentOccurrence = 1; jumpToOccurrence(); + colorWithText(searchQuery); return true; } });