From b0ea112edaad634c8859f5281730b88fdea1e34d Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 14 Jun 2020 08:44:29 +0200 Subject: [PATCH] Show tab page title in settings search suggestions --- .../java/eu/faircode/email/FragmentOptions.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentOptions.java b/app/src/main/java/eu/faircode/email/FragmentOptions.java index d1bce634af..d0bbf5525c 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptions.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptions.java @@ -247,8 +247,10 @@ public class FragmentOptions extends FragmentBase { } int id = 0; - for (int tab = 0; tab < TAB_PAGES.length; tab++) - id = getSuggestions(query.toLowerCase(), id, tab, views[tab], cursor); + for (int tab = 0; tab < TAB_PAGES.length; tab++) { + String title = (String) adapter.getPageTitle(tab); + id = getSuggestions(query.toLowerCase(), id, tab, title, views[tab], cursor); + } } searchView.setSuggestionsAdapter(new SimpleCursorAdapter( @@ -261,19 +263,21 @@ public class FragmentOptions extends FragmentBase { )); } - private int getSuggestions(String query, int id, int tab, View view, MatrixCursor cursor) { + private int getSuggestions(String query, int id, int tab, String title, View view, MatrixCursor cursor) { if (view instanceof ViewGroup) { ViewGroup group = (ViewGroup) view; for (int i = 0; i <= group.getChildCount(); i++) - id = getSuggestions(query, id, tab, group.getChildAt(i), cursor); + id = getSuggestions(query, id, tab, title, group.getChildAt(i), cursor); } else if (view instanceof TextView) { - String text = ((TextView) view).getText().toString(); - if (text.toLowerCase().contains(query)) + String description = ((TextView) view).getText().toString(); + if (description.toLowerCase().contains(query)) { + String text = view.getContext().getString(R.string.title_title_description, title, description); cursor.newRow() .add(id++) .add(tab) .add(view.getId()) .add(text); + } } return id;