From ac9f51602724c35753e97c0b6b792bbf20541fbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Brey=20Vilas?= Date: Fri, 29 Oct 2021 11:09:59 +0200 Subject: [PATCH] Unified search: skip local file check for non-file results MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes https://github.com/nextcloud/android/issues/9171 Needs https://github.com/nextcloud/android-library/pull/739 Signed-off-by: Álvaro Brey Vilas --- .../android/ui/adapter/UnifiedSearchItemViewHolder.kt | 10 ++++------ .../android/ui/unifiedsearch/UnifiedSearchViewModel.kt | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/owncloud/android/ui/adapter/UnifiedSearchItemViewHolder.kt b/src/main/java/com/owncloud/android/ui/adapter/UnifiedSearchItemViewHolder.kt index c9f43a8cb2..134ef39aaa 100644 --- a/src/main/java/com/owncloud/android/ui/adapter/UnifiedSearchItemViewHolder.kt +++ b/src/main/java/com/owncloud/android/ui/adapter/UnifiedSearchItemViewHolder.kt @@ -59,12 +59,10 @@ class UnifiedSearchItemViewHolder( binding.title.text = entry.title binding.subline.text = entry.subline - storageManager.getFileByDecryptedRemotePath(entry.remotePath())?.let { - if (it.isDown) { - binding.localFileIndicator.visibility = View.VISIBLE - } else { - binding.localFileIndicator.visibility = View.GONE - } + if (entry.isFile && storageManager.getFileByDecryptedRemotePath(entry.remotePath()) != null) { + binding.localFileIndicator.visibility = View.VISIBLE + } else { + binding.localFileIndicator.visibility = View.GONE } val mimetype = MimeTypeUtil.getBestMimeTypeByFilename(entry.title) diff --git a/src/main/java/com/owncloud/android/ui/unifiedsearch/UnifiedSearchViewModel.kt b/src/main/java/com/owncloud/android/ui/unifiedsearch/UnifiedSearchViewModel.kt index 7fd0c1d713..9d42e1c410 100644 --- a/src/main/java/com/owncloud/android/ui/unifiedsearch/UnifiedSearchViewModel.kt +++ b/src/main/java/com/owncloud/android/ui/unifiedsearch/UnifiedSearchViewModel.kt @@ -144,7 +144,7 @@ class UnifiedSearchViewModel(application: Application) : AndroidViewModel(applic } override fun openResult(result: SearchResultEntry) { - if (result.fileId() != null) { + if (result.isFile) { openFile(result.remotePath()) } else { val uri = Uri.parse(result.resourceUrl)