瀏覽代碼

Local search/filter works again

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
tobiasKaminsky 1 年之前
父節點
當前提交
cd6fe1e26f

+ 23 - 0
app/src/androidTest/java/com/owncloud/android/ui/activity/UploadFilesActivityIT.kt

@@ -88,6 +88,29 @@ class UploadFilesActivityIT : AbstractIT() {
         screenshot(sut)
     }
 
+    @Test
+    @ScreenshotTest
+    fun search() {
+        val sut: UploadFilesActivity = activityRule.launchActivity(null)
+
+        sut.runOnUiThread {
+            sut.fileListFragment.setFiles(
+                directories +
+                    listOf(
+                        File("1.txt"),
+                        File("2.pdf"),
+                        File("3.mp3")
+                    )
+            )
+
+            sut.fileListFragment.performSearch("1.txt", arrayListOf(), false)
+        }
+
+        waitForIdleSync()
+        longSleep()
+
+        screenshot(sut.fileListFragment.binding.listRoot)
+    }
     fun fileSelected() {
         val sut: UploadFilesActivity = activityRule.launchActivity(null)
 

+ 9 - 1
app/src/main/java/com/owncloud/android/ui/fragment/ExtendedListFragment.java

@@ -246,6 +246,10 @@ public class ExtendedListFragment extends Fragment implements
             performSearch(query, listOfHiddenFiles, false);
             return true;
         }
+        if (adapter instanceof LocalFileListAdapter) {
+            performSearch(query, new ArrayList<>(), false);
+            return true;
+        }
         return false;
     }
 
@@ -287,7 +291,7 @@ public class ExtendedListFragment extends Fragment implements
             } else if (activity instanceof UploadFilesActivity) {
                 LocalFileListAdapter localFileListAdapter = (LocalFileListAdapter) adapter;
                 localFileListAdapter.filter(query);
-                ((UploadFilesActivity) activity).showToolbarSpinner();
+                ((UploadFilesActivity) activity).getFileListFragment().setLoading(false);
             } else if (activity instanceof FolderPickerActivity) {
                 ((FolderPickerActivity) activity).search(query);
             }
@@ -630,6 +634,10 @@ public class ExtendedListFragment extends Fragment implements
                     setMessageForEmptyList(R.string.file_list_empty_headline_server_search,
                                            R.string.file_list_empty_gallery,
                                            R.drawable.file_image);
+                } else if (searchType == SearchType.LOCAL_SEARCH) {
+                    setMessageForEmptyList(R.string.file_list_empty_headline_server_search,
+                                           R.string.file_list_empty_local_search,
+                                           R.drawable.ic_search_light_grey);
                 }
             }
         });

+ 1 - 1
app/src/main/java/com/owncloud/android/ui/fragment/LocalFileListFragment.java

@@ -374,7 +374,7 @@ public class LocalFileListFragment extends ExtendedListFragment implements
             new Handler().post(() -> {
                 mAdapter.notifyDataSetChanged();
                 if (mAdapter.getFilesCount() == 0) {
-                    setEmptyListMessage(SearchType.NO_SEARCH);
+                    setEmptyListMessage(SearchType.LOCAL_SEARCH);
                 }
             });
         }

+ 1 - 0
app/src/main/java/com/owncloud/android/ui/fragment/SearchType.kt

@@ -13,6 +13,7 @@ import kotlinx.parcelize.Parcelize
 @Parcelize
 enum class SearchType : Parcelable {
     NO_SEARCH,
+    LOCAL_SEARCH,
     REGULAR_FILTER,
     FILE_SEARCH,
     FAVORITE_SEARCH,

+ 1 - 1
app/src/main/res/values/setup.xml

@@ -7,7 +7,7 @@
 -->
 <resources>
     <!-- Beta indicator -->
-    <bool name="is_beta">false</bool>
+    <bool name="is_beta">true</bool>
     <bool name="dev_version_direct_download_enabled">false</bool>
 
     <!-- App name  and other strings-->

+ 1 - 2
app/src/main/res/values/strings.xml

@@ -1213,8 +1213,7 @@
     <string name="sub_folder_rule_day">Year/Month/Day</string>
     <string name="secure_share_not_set_up">Secure sharing is not set up for this user</string>
     <string name="share_not_allowed_when_file_drop">Resharing is not allowed during secure file drop</string>
-
-
+    <string name="file_list_empty_local_search">No file or folder matching your search</string>
     <string name="unified_search_fragment_calendar_event_not_found">Event not found, you can always sync to update. Redirecting to web…</string>
     <string name="unified_search_fragment_contact_not_found">Contact not found, you can always sync to update. Redirecting to web…</string>
     <string name="unified_search_fragment_permission_needed">Permissions are required to open search result otherwise it will redirected to web…</string>