@@ -144,7 +144,9 @@ private void initializeArguments() {
144144 @ Override
145145 public void onStart () {
146146 super .onStart ();
147- UsersAndGroupsSearchConfig .INSTANCE .setSearchOnlyUsers (true );
147+
148+ // note cannot be encrypted - logic ported from files app
149+ UsersAndGroupsSearchConfig .INSTANCE .setSearchOnlyUsers (false );
148150 }
149151
150152 @ Override
@@ -202,43 +204,47 @@ public boolean onQueryTextSubmit(String query) {
202204
203205 @ Override
204206 public boolean onQueryTextChange (String newText ) {
205- binding .progressBar .setVisibility (View .VISIBLE );
206-
207- // Cancel the previous task if it's still running
208- if (future != null && !future .isDone ()) {
209- future .cancel (true );
210- }
207+ if (!newText .isEmpty ()) {
208+ binding .progressBar .setVisibility (View .VISIBLE );
211209
212- // Schedule a new task with a delay
213- future = executorService .schedule (() -> {
214- if (capabilities == null ) {
215- Log_OC .d (TAG , "Capabilities cannot be null" );
216- return ;
210+ // Cancel the previous task if it's still running
211+ if (future != null && !future .isDone ()) {
212+ future .cancel (true );
217213 }
218214
219- final var isFederationShareAllowed = capabilities .getFederationShare ();
220- try {
221- var cursor = provider .searchForUsersOrGroups (newText , isFederationShareAllowed );
222-
223- if (cursor == null || cursor .getCount () == 0 ) {
215+ // Schedule a new task with a delay
216+ future = executorService .schedule (() -> {
217+ if (capabilities == null ) {
218+ Log_OC .d (TAG , "Capabilities cannot be null" );
224219 return ;
225220 }
226221
227- runOnUiThread (() -> {
228- if (binding .searchView .getVisibility () == View .VISIBLE ) {
229- suggestionAdapter .swapCursor (cursor );
222+ final var isFederationShareAllowed = capabilities .getFederationShare ();
223+ try {
224+ var cursor = provider .searchForUsersOrGroups (newText , isFederationShareAllowed );
225+
226+ if (cursor == null || cursor .getCount () == 0 ) {
227+ return ;
230228 }
231229
232- binding .progressBar .setVisibility (View .GONE );
233- });
230+ runOnUiThread (() -> {
231+ if (binding .searchView .getVisibility () == View .VISIBLE ) {
232+ suggestionAdapter .swapCursor (cursor );
233+ }
234234
235- } catch (Exception e ) {
236- Log_OC .d (TAG , "Exception setupSearchView.onQueryTextChange: " + e );
237- runOnUiThread (() -> binding .progressBar .setVisibility (View .GONE ));
238- }
235+ binding .progressBar .setVisibility (View .GONE );
236+ });
239237
240- }, SEARCH_DELAY_MS , TimeUnit .MILLISECONDS );
238+ } catch (Exception e ) {
239+ Log_OC .d (TAG , "Exception setupSearchView.onQueryTextChange: " + e );
240+ runOnUiThread (() -> binding .progressBar .setVisibility (View .GONE ));
241+ }
241242
243+ }, SEARCH_DELAY_MS , TimeUnit .MILLISECONDS );
244+ } else {
245+ binding .progressBar .setVisibility (View .GONE );
246+ suggestionAdapter .swapCursor (null );
247+ }
242248 return false ;
243249 }
244250 });
0 commit comments