diff --git a/app/src/main/java/eu/faircode/email/DaoMessage.java b/app/src/main/java/eu/faircode/email/DaoMessage.java index 83aaeaea43..1602a6f742 100644 --- a/app/src/main/java/eu/faircode/email/DaoMessage.java +++ b/app/src/main/java/eu/faircode/email/DaoMessage.java @@ -593,8 +593,8 @@ public interface DaoMessage { " GROUP BY sender" + " ORDER BY sender, subject" + - " LIMIT 5") - Cursor getSuggestions(Long account, Long folder, String query); + " LIMIT :limit") + Cursor getSuggestions(Long account, Long folder, String query, int limit); @Query("SELECT language FROM message" + " WHERE (:account IS NULL OR message.account = :account)" + diff --git a/app/src/main/java/eu/faircode/email/FragmentDialogSearch.java b/app/src/main/java/eu/faircode/email/FragmentDialogSearch.java index e4c1198b06..055f7d09d9 100644 --- a/app/src/main/java/eu/faircode/email/FragmentDialogSearch.java +++ b/app/src/main/java/eu/faircode/email/FragmentDialogSearch.java @@ -57,6 +57,8 @@ import java.util.Calendar; import java.util.List; public class FragmentDialogSearch extends FragmentDialogBase { + private static final int MAX_SUGGESTIONS = 3; + @NonNull @Override public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { @@ -141,7 +143,8 @@ public class FragmentDialogSearch extends FragmentDialogBase { return db.message().getSuggestions( account < 0 ? null : account, folder < 0 ? null : folder, - "%" + query + "%"); + "%" + query + "%", + MAX_SUGGESTIONS); } });