mirror of
https://github.com/nextcloud/android.git
synced 2024-11-23 05:35:39 +03:00
Merge pull request #7086 from nextcloud/hideEmptyRichWorkspacses
Do not show rich workspace if it only contains whitespaces
This commit is contained in:
commit
a1832eb908
2 changed files with 44 additions and 1 deletions
|
@ -32,6 +32,7 @@ import com.owncloud.android.lib.resources.shares.ShareType
|
|||
import com.owncloud.android.lib.resources.shares.ShareeUser
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
import org.junit.Assert
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
|
||||
|
@ -200,4 +201,37 @@ class OCFileListFragmentStaticServerIT : AbstractIT() {
|
|||
|
||||
screenshot(sut)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun shouldShowHeader() {
|
||||
val activity = testActivityRule.launchActivity(null)
|
||||
val sut = OCFileListFragment()
|
||||
|
||||
val folder = OCFile("/test/", "00001")
|
||||
folder.setFolder()
|
||||
activity.storageManager.saveFile(folder)
|
||||
|
||||
activity.addFragment(sut)
|
||||
val testFolder: OCFile = activity.storageManager.getFileByEncryptedRemotePath("/test/")
|
||||
|
||||
activity.runOnUiThread {
|
||||
// richWorkspace is not set
|
||||
Assert.assertFalse(sut.adapter.shouldShowHeader())
|
||||
|
||||
testFolder.richWorkspace = " "
|
||||
activity.storageManager.saveFile(testFolder)
|
||||
sut.adapter.swapDirectory(user, testFolder, activity.storageManager, false, "")
|
||||
Assert.assertFalse(sut.adapter.shouldShowHeader())
|
||||
|
||||
testFolder.richWorkspace = null
|
||||
activity.storageManager.saveFile(testFolder)
|
||||
sut.adapter.swapDirectory(user, testFolder, activity.storageManager, false, "")
|
||||
Assert.assertFalse(sut.adapter.shouldShowHeader())
|
||||
|
||||
testFolder.richWorkspace = "1"
|
||||
activity.storageManager.saveFile(testFolder)
|
||||
sut.adapter.setCurrentDirectory(testFolder)
|
||||
Assert.assertTrue(sut.adapter.shouldShowHeader())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -851,7 +851,11 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|||
return false;
|
||||
}
|
||||
|
||||
return !TextUtils.isEmpty(currentDirectory.getRichWorkspace());
|
||||
if (currentDirectory.getRichWorkspace() == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !TextUtils.isEmpty(currentDirectory.getRichWorkspace().trim());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1291,6 +1295,11 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|||
showShareAvatar = bool;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public void setCurrentDirectory(OCFile folder) {
|
||||
currentDirectory = folder;
|
||||
}
|
||||
|
||||
static class OCFileListItemViewHolder extends OCFileListGridItemViewHolder {
|
||||
@BindView(R.id.file_size)
|
||||
public TextView fileSize;
|
||||
|
|
Loading…
Reference in a new issue