diff --git a/app/screenshots/gplay/debug/com.owncloud.android.ui.activity.UploadFilesActivityIT_search.png b/app/screenshots/gplay/debug/com.owncloud.android.ui.activity.UploadFilesActivityIT_search.png new file mode 100644 index 000000000000..a8960fa7d89a Binary files /dev/null and b/app/screenshots/gplay/debug/com.owncloud.android.ui.activity.UploadFilesActivityIT_search.png differ diff --git a/app/src/androidTest/java/com/owncloud/android/ui/activity/UploadFilesActivityIT.kt b/app/src/androidTest/java/com/owncloud/android/ui/activity/UploadFilesActivityIT.kt index 0b598e3efc53..71aa4009f89b 100644 --- a/app/src/androidTest/java/com/owncloud/android/ui/activity/UploadFilesActivityIT.kt +++ b/app/src/androidTest/java/com/owncloud/android/ui/activity/UploadFilesActivityIT.kt @@ -8,9 +8,16 @@ package com.owncloud.android.ui.activity import android.content.Intent +import androidx.annotation.UiThread +import androidx.test.espresso.Espresso.onView +import androidx.test.espresso.IdlingRegistry +import androidx.test.espresso.assertion.ViewAssertions.matches import androidx.test.espresso.intent.rule.IntentsTestRule +import androidx.test.espresso.matcher.ViewMatchers.isDisplayed +import androidx.test.espresso.matcher.ViewMatchers.isRoot import com.nextcloud.test.GrantStoragePermissionRule import com.owncloud.android.AbstractIT +import com.owncloud.android.utils.EspressoIdlingResource import com.owncloud.android.utils.FileStorageUtils import com.owncloud.android.utils.ScreenshotTest import org.junit.After @@ -20,6 +27,8 @@ import org.junit.Test import java.io.File class UploadFilesActivityIT : AbstractIT() { + private val testClassName = "com.owncloud.android.ui.activity.UploadFilesActivityIT" + @get:Rule var activityRule = IntentsTestRule(UploadFilesActivity::class.java, true, false) @@ -39,6 +48,16 @@ class UploadFilesActivityIT : AbstractIT() { directories.forEach { it.deleteRecursively() } } + @Before + fun registerIdlingResource() { + IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource) + } + + @After + fun unregisterIdlingResource() { + IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource) + } + @Test @ScreenshotTest fun noneSelected() { @@ -88,6 +107,33 @@ class UploadFilesActivityIT : AbstractIT() { screenshot(sut) } + @Test + @UiThread + @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") + ) + ) + + onIdleSync { + EspressoIdlingResource.increment() + sut.fileListFragment.performSearch("1.txt", arrayListOf(), false) + EspressoIdlingResource.decrement() + val screenShotName = createName(testClassName + "_" + "search", "") + onView(isRoot()).check(matches(isDisplayed())) + screenshotViaName(sut, screenShotName) + } + } + } + fun fileSelected() { val sut: UploadFilesActivity = activityRule.launchActivity(null) diff --git a/app/src/main/java/com/nextcloud/client/etm/pages/EtmBackgroundJobsFragment.kt b/app/src/main/java/com/nextcloud/client/etm/pages/EtmBackgroundJobsFragment.kt index 4f7ff91c1381..d14686854c41 100644 --- a/app/src/main/java/com/nextcloud/client/etm/pages/EtmBackgroundJobsFragment.kt +++ b/app/src/main/java/com/nextcloud/client/etm/pages/EtmBackgroundJobsFragment.kt @@ -80,6 +80,7 @@ class EtmBackgroundJobsFragment : EtmBaseFragment(), Injectable { private val dateFormat = SimpleDateFormat("yyyy-MM-dd HH:MM:ssZ", Locale.getDefault()) var backgroundJobs: List = emptyList() + @SuppressLint("NotifyDataSetChanged") set(value) { field = value notifyDataSetChanged() diff --git a/app/src/main/java/com/owncloud/android/ui/fragment/ExtendedListFragment.java b/app/src/main/java/com/owncloud/android/ui/fragment/ExtendedListFragment.java index 52d0d78672de..90d5ff624628 100644 --- a/app/src/main/java/com/owncloud/android/ui/fragment/ExtendedListFragment.java +++ b/app/src/main/java/com/owncloud/android/ui/fragment/ExtendedListFragment.java @@ -246,6 +246,10 @@ public boolean onQueryTextSubmit(String query) { performSearch(query, listOfHiddenFiles, false); return true; } + if (adapter instanceof LocalFileListAdapter) { + performSearch(query, new ArrayList<>(), false); + return true; + } return false; } @@ -253,6 +257,7 @@ public void performSearch(final String query, final ArrayList listOfHidd handler.removeCallbacksAndMessages(null); RecyclerView.Adapter adapter = getRecyclerView().getAdapter(); Activity activity = getActivity(); + if (activity != null) { if (activity instanceof FileDisplayActivity) { if (isBackPressed && TextUtils.isEmpty(query)) { @@ -274,8 +279,7 @@ public void performSearch(final String query, final ArrayList listOfHidd new SearchEvent(query, SearchRemoteOperation.SearchType.FILE_SEARCH) ); } - } else if (adapter instanceof LocalFileListAdapter) { - LocalFileListAdapter localFileListAdapter = (LocalFileListAdapter) adapter; + } else if (adapter instanceof LocalFileListAdapter localFileListAdapter) { localFileListAdapter.filter(query); } }); @@ -284,10 +288,12 @@ public void performSearch(final String query, final ArrayList listOfHidd searchView.clearFocus(); } } - } else if (activity instanceof UploadFilesActivity) { + } else if (activity instanceof UploadFilesActivity uploadFilesActivity) { LocalFileListAdapter localFileListAdapter = (LocalFileListAdapter) adapter; - localFileListAdapter.filter(query); - ((UploadFilesActivity) activity).showToolbarSpinner(); + if (localFileListAdapter != null) { + localFileListAdapter.filter(query); + uploadFilesActivity.getFileListFragment().setLoading(false); + } } else if (activity instanceof FolderPickerActivity) { ((FolderPickerActivity) activity).search(query); } @@ -630,6 +636,10 @@ public void run() { 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); } } }); diff --git a/app/src/main/java/com/owncloud/android/ui/fragment/LocalFileListFragment.java b/app/src/main/java/com/owncloud/android/ui/fragment/LocalFileListFragment.java index 1e2875566b76..e82f04e04129 100644 --- a/app/src/main/java/com/owncloud/android/ui/fragment/LocalFileListFragment.java +++ b/app/src/main/java/com/owncloud/android/ui/fragment/LocalFileListFragment.java @@ -374,7 +374,7 @@ public void setLoading(boolean enabled) { new Handler().post(() -> { mAdapter.notifyDataSetChanged(); if (mAdapter.getFilesCount() == 0) { - setEmptyListMessage(SearchType.NO_SEARCH); + setEmptyListMessage(SearchType.LOCAL_SEARCH); } }); } diff --git a/app/src/main/java/com/owncloud/android/ui/fragment/SearchType.kt b/app/src/main/java/com/owncloud/android/ui/fragment/SearchType.kt index 1b7e39215d55..c28fdb366922 100644 --- a/app/src/main/java/com/owncloud/android/ui/fragment/SearchType.kt +++ b/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, diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d937ddf1e3fd..5c06a52d4527 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1213,8 +1213,7 @@ Year/Month/Day Secure sharing is not set up for this user Resharing is not allowed during secure file drop - - + No file or folder matching your search Event not found, you can always sync to update. Redirecting to web… Contact not found, you can always sync to update. Redirecting to web… Permissions are required to open search result otherwise it will redirected to web…