Skip to content

Commit 3e31c59

Browse files
committed
fix: empty folder appearance
Signed-off-by: alperozturk <alper_ozturk@proton.me>
1 parent c6b22a4 commit 3e31c59

File tree

3 files changed

+23
-6
lines changed

3 files changed

+23
-6
lines changed

app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1604,7 +1604,9 @@ class FileDisplayActivity :
16041604
MainApp.isOnlyOnDevice() -> {
16051605
ocFileListFragment.setEmptyListMessage(EmptyListState.ONLY_ON_DEVICE)
16061606
}
1607-
result == true -> ocFileListFragment.setEmptyListMessage(EmptyListState.IDLE)
1607+
result == true -> {
1608+
ocFileListFragment.setEmptyListStateToIdleOrNoSearch()
1609+
}
16081610
else -> ocFileListFragment.setEmptyListMessage(EmptyListState.OFFLINE_MODE)
16091611
}
16101612
}

app/src/main/java/com/owncloud/android/ui/activity/FolderPickerActivity.kt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import android.view.View
2323
import androidx.activity.OnBackPressedCallback
2424
import androidx.lifecycle.lifecycleScope
2525
import androidx.localbroadcastmanager.content.LocalBroadcastManager
26+
import com.nextcloud.client.account.User
2627
import com.nextcloud.client.di.Injectable
2728
import com.nextcloud.utils.fileNameValidator.FileNameValidator
2829
import com.owncloud.android.R
@@ -247,7 +248,13 @@ open class FolderPickerActivity :
247248
}
248249

249250
private fun startSyncFolderOperation(folder: OCFile?, ignoreETag: Boolean) {
251+
val optionalUser = user ?: return
252+
if (optionalUser.isEmpty) {
253+
return
254+
}
255+
val user: User = optionalUser.get()
250256
listOfFilesFragment?.setEmptyListMessage(EmptyListState.LOADING)
257+
251258
lifecycleScope.launch(Dispatchers.IO) {
252259
val currentSyncTime = System.currentTimeMillis()
253260
val operation = RefreshFolderOperation(
@@ -256,14 +263,14 @@ open class FolderPickerActivity :
256263
false,
257264
ignoreETag,
258265
storageManager,
259-
user.orElseThrow { RuntimeException("User not set") },
266+
user,
260267
applicationContext
261268
)
262269
operation.execute(
263270
account,
264271
this@FolderPickerActivity,
265272
{ _, _ ->
266-
listOfFilesFragment?.setEmptyListMessage(EmptyListState.IDLE)
273+
listOfFilesFragment?.setEmptyListStateToIdleOrNoSearch()
267274
},
268275
null
269276
)
@@ -574,7 +581,7 @@ open class FolderPickerActivity :
574581
// in owncloud library with broadcast notifications pending to process
575582
DataHolderUtil.getInstance().delete(intent.getStringExtra(FileSyncAdapter.EXTRA_RESULT))
576583
} finally {
577-
listOfFilesFragment?.setEmptyListMessage(EmptyListState.IDLE)
584+
listOfFilesFragment?.setEmptyListStateToIdleOrNoSearch()
578585
}
579586
}
580587

app/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1806,11 +1806,11 @@ protected void setEmptyView(SearchEvent event) {
18061806
break;
18071807

18081808
default:
1809-
setEmptyListMessage(EmptyListState.IDLE);
1809+
setEmptyListStateToIdleOrNoSearch();
18101810
break;
18111811
}
18121812
} else {
1813-
setEmptyListMessage(EmptyListState.IDLE);
1813+
setEmptyListStateToIdleOrNoSearch();
18141814
}
18151815
}
18161816

@@ -2330,4 +2330,12 @@ public boolean isSearchEventFavorite() {
23302330
public boolean shouldNavigateBackToAllFiles() {
23312331
return ((this instanceof GalleryFragment) || isSearchEventFavorite() || DrawerActivity.menuItemId == R.id.nav_favorites);
23322332
}
2333+
2334+
public void setEmptyListStateToIdleOrNoSearch() {
2335+
if (isEmpty()) {
2336+
setEmptyListMessage(NO_SEARCH);
2337+
} else {
2338+
setEmptyListMessage(EmptyListState.IDLE);
2339+
}
2340+
}
23332341
}

0 commit comments

Comments
 (0)