Merge pull request #7086 from nextcloud/hideEmptyRichWorkspacses

Do not show rich workspace if it only contains whitespaces
This commit is contained in:
Andy Scherzinger 2020-10-15 14:47:34 +02:00 committed by GitHub
commit a1832eb908
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 44 additions and 1 deletions

View file

@ -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())
}
}
}

View file

@ -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;