diff --git a/app/src/main/java/org/thoughtcrime/securesms/components/SearchToolbar.java b/app/src/main/java/org/thoughtcrime/securesms/components/SearchToolbar.java index e9af37b05d..0648f609c6 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/components/SearchToolbar.java +++ b/app/src/main/java/org/thoughtcrime/securesms/components/SearchToolbar.java @@ -69,12 +69,7 @@ public class SearchToolbar extends LinearLayout { } @Override - public boolean onQueryTextChange(String newText) { - - Log.d("[ACL]", "IT'S NOT THIS ONE - Search text changed to: " + newText); - - return onQueryTextSubmit(newText); - } + public boolean onQueryTextChange(String newText) { return onQueryTextSubmit(newText); } }); searchItem.setOnActionExpandListener(new MenuItem.OnActionExpandListener() { diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt index 401901607a..8c566c060b 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt @@ -2066,11 +2066,8 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe } fun onSearchQueryUpdated(query: String) { - Log.d("[ACL]", "1") searchViewModel.onQueryUpdated(query, viewModel.threadId) - Log.d("[ACL]", "2") binding?.searchBottomBar?.showLoading() - Log.d("[ACL]", "3") adapter.onSearchQueryUpdated(query) } diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationAdapter.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationAdapter.kt index 1ac7419d9a..160388865b 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationAdapter.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationAdapter.kt @@ -269,9 +269,7 @@ class ConversationAdapter( } fun onSearchQueryUpdated(query: String?) { - Log.d("[ACL]", "4") this.searchQuery = query - Log.d("[ACL]", "5") notifyDataSetChanged() } diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/menus/ConversationMenuHelper.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/menus/ConversationMenuHelper.kt index 744dc579a6..989bea39be 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/menus/ConversationMenuHelper.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/menus/ConversationMenuHelper.kt @@ -125,10 +125,6 @@ object ConversationMenuHelper { } override fun onQueryTextChange(query: String): Boolean { - - // *** Crashes when searching for non-alphanumeric first char *** - Log.d("[ACL]", "[ConversationMenuHelper] Query text changed to: $query") - context.onSearchQueryUpdated(query) return true } diff --git a/app/src/main/java/org/thoughtcrime/securesms/database/SearchDatabase.java b/app/src/main/java/org/thoughtcrime/securesms/database/SearchDatabase.java index 92b0bed9a0..93c163f632 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/database/SearchDatabase.java +++ b/app/src/main/java/org/thoughtcrime/securesms/database/SearchDatabase.java @@ -116,11 +116,7 @@ public class SearchDatabase extends Database { public Cursor queryMessages(@NonNull String query) { SQLiteDatabase db = databaseHelper.getReadableDatabase(); String prefixQuery = adjustQuery(query); - int queryLimit = Math.min(query.length()*50,500); - - Log.d("[ACL]", "[SearchDatabase] Query is:\n" + MESSAGES_QUERY); - Cursor cursor = db.rawQuery(MESSAGES_QUERY, new String[] { prefixQuery, prefixQuery, String.valueOf(queryLimit) }); setNotifyConverationListListeners(cursor); return cursor; diff --git a/app/src/main/java/org/thoughtcrime/securesms/home/HomeActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/home/HomeActivity.kt index d0713860f2..ecb8ee60c6 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/home/HomeActivity.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/home/HomeActivity.kt @@ -293,10 +293,6 @@ class HomeActivity : PassphraseRequiredActionBarActivity(), } val newData = contactResults + messageResults - - - Log.d("[ACL]", "THIS IS THE GLOBAL SEARCH - Result query is: ${result.query}") - globalSearchAdapter.setNewData(result.query, newData) } } diff --git a/app/src/main/java/org/thoughtcrime/securesms/search/SearchRepository.java b/app/src/main/java/org/thoughtcrime/securesms/search/SearchRepository.java index 737322d2cb..3641b39c62 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/search/SearchRepository.java +++ b/app/src/main/java/org/thoughtcrime/securesms/search/SearchRepository.java @@ -124,28 +124,15 @@ public class SearchRepository { public void query(@NonNull String query, long threadId, @NonNull Callback> callback) { if (TextUtils.isEmpty(query)) { - Log.d("[ACL]", "Recognised empty query!"); - callback.onResult(CursorList.emptyList()); return; } - else { - Log.d("[ACL]", "Non-empty query is: " + query); - } executor.execute(() -> { - - Log.d("[ACL]", "Hit query.execute!"); - - // If the search is for a single character and it was stripped by `sanitizeQuery` then abort - // the search for an empty string to avoid SQLite error. + // If the sanitized search query is empty or just contains a single space (" ") then abort + // the search to prevent SQLite errors. String cleanQuery = sanitizeQuery(query); - Log.d("[ACL]", "clean query is: \"" + cleanQuery + "\""); - if (cleanQuery.isEmpty() || cleanQuery.equalsIgnoreCase(" ")) - { - Log.d("[ACL]", "Aborting empty search query."); - return; - } + if (cleanQuery.equalsIgnoreCase(" ") || cleanQuery.isEmpty()) { return; } CursorList messages = queryMessages(cleanQuery, threadId); callback.onResult(messages); @@ -211,19 +198,12 @@ public class SearchRepository { } private CursorList queryMessages(@NonNull String query) { - - Log.d("[ACL]", "[SearchRepository] Query is:\n" + query); - - Cursor messages = searchDatabase.queryMessages(query); return messages != null ? new CursorList<>(messages, new MessageModelBuilder(context)) : CursorList.emptyList(); } private CursorList queryMessages(@NonNull String query, long threadId) { - - Log.d("[ACL]", "[SearchRepository] 6 - query is: " + query); - Cursor messages = searchDatabase.queryMessages(query, threadId); return messages != null ? new CursorList<>(messages, new MessageModelBuilder(context)) : CursorList.emptyList(); @@ -237,11 +217,7 @@ public class SearchRepository { * However, if we replace the apostrophe with a space, then the query will find the match. */ private String sanitizeQuery(@NonNull String query) { - - Log.d("[ACL]", "[SearchRepository] Hit sanitizeQuery - initial query is: " + query); - StringBuilder out = new StringBuilder(); - for (int i = 0; i < query.length(); i++) { char c = query.charAt(i); if (!BANNED_CHARACTERS.contains(c)) { @@ -250,11 +226,7 @@ public class SearchRepository { out.append(' '); } } - - Log.d("[ACL]", "[SearchRepository] Hit sanitizeQuery - sanitized query is: " + out.toString()); - - // Querying for an empty string causes a crash so we'll que - if (out.toString().length() > 0) { return out.toString(); } else { return " "; } + return out.toString(); } private static class ContactModelBuilder implements CursorList.ModelBuilder {