feat: add pCloud model and mappers, add strings

This commit is contained in:
Manuel Jenny 2021-03-12 17:19:02 +01:00
parent 80dce5ec60
commit faaec7a922
No known key found for this signature in database
GPG Key ID: 1C80FE62B2BEAA18
7 changed files with 53 additions and 0 deletions

View File

@ -4,6 +4,7 @@ import org.cryptomator.data.db.entities.CloudEntity;
import org.cryptomator.domain.Cloud;
import org.cryptomator.domain.CloudType;
import org.cryptomator.domain.DropboxCloud;
import org.cryptomator.domain.PCloudCloud;
import org.cryptomator.domain.GoogleDriveCloud;
import org.cryptomator.domain.LocalStorageCloud;
import org.cryptomator.domain.OnedriveCloud;
@ -16,6 +17,7 @@ import static org.cryptomator.domain.DropboxCloud.aDropboxCloud;
import static org.cryptomator.domain.GoogleDriveCloud.aGoogleDriveCloud;
import static org.cryptomator.domain.LocalStorageCloud.aLocalStorage;
import static org.cryptomator.domain.OnedriveCloud.aOnedriveCloud;
import static org.cryptomator.domain.PCloudCloud.aPCloudCloud;
import static org.cryptomator.domain.WebDavCloud.aWebDavCloudCloud;
@Singleton
@ -47,6 +49,12 @@ public class CloudEntityMapper extends EntityMapper<CloudEntity, Cloud> {
.withAccessToken(entity.getAccessToken()) //
.withUsername(entity.getUsername()) //
.build();
case PCLOUD:
return aPCloudCloud() //
.withId(entity.getId()) //
.withAccessToken(entity.getAccessToken()) //
.withUsername(entity.getUsername()) //
.build();
case LOCAL:
return aLocalStorage() //
.withId(entity.getId()) //
@ -82,6 +90,11 @@ public class CloudEntityMapper extends EntityMapper<CloudEntity, Cloud> {
result.setAccessToken(((OnedriveCloud) domainObject).accessToken());
result.setUsername(((OnedriveCloud) domainObject).username());
break;
case PCLOUD:
result.setAccessToken(((PCloudCloud) domainObject).accessToken());
result.setWebdavUrl(((PCloudCloud) domainObject).url());
result.setUsername(((PCloudCloud) domainObject).username());
break;
case LOCAL:
result.setAccessToken(((LocalStorageCloud) domainObject).rootUri());
break;

View File

@ -5,6 +5,7 @@ import org.cryptomator.data.cloud.dropbox.DropboxCloudContentRepositoryFactory;
import org.cryptomator.data.cloud.googledrive.GoogleDriveCloudContentRepositoryFactory;
import org.cryptomator.data.cloud.local.LocalStorageContentRepositoryFactory;
import org.cryptomator.data.cloud.onedrive.OnedriveCloudContentRepositoryFactory;
import org.cryptomator.data.cloud.pcloud.PCloudCloudContentRepositoryFactory;
import org.cryptomator.data.cloud.webdav.WebDavCloudContentRepositoryFactory;
import org.cryptomator.data.repository.CloudContentRepositoryFactory;
import org.jetbrains.annotations.NotNull;
@ -25,6 +26,7 @@ public class CloudContentRepositoryFactories implements Iterable<CloudContentRep
public CloudContentRepositoryFactories(DropboxCloudContentRepositoryFactory dropboxFactory, //
GoogleDriveCloudContentRepositoryFactory googleDriveFactory, //
OnedriveCloudContentRepositoryFactory oneDriveFactory, //
PCloudCloudContentRepositoryFactory pCloudFactory, //
CryptoCloudContentRepositoryFactory cryptoFactory, //
LocalStorageContentRepositoryFactory localStorageFactory, //
WebDavCloudContentRepositoryFactory webDavFactory) {
@ -32,6 +34,7 @@ public class CloudContentRepositoryFactories implements Iterable<CloudContentRep
factories = asList(dropboxFactory, //
googleDriveFactory, //
oneDriveFactory, //
pCloudFactory, //
cryptoFactory, //
localStorageFactory, //
webDavFactory);

View File

@ -4,6 +4,7 @@ import org.cryptomator.domain.Cloud;
import org.cryptomator.domain.DropboxCloud;
import org.cryptomator.domain.GoogleDriveCloud;
import org.cryptomator.domain.OnedriveCloud;
import org.cryptomator.domain.PCloudCloud;
import org.cryptomator.domain.exception.BackendException;
import org.cryptomator.domain.repository.CloudContentRepository;
import org.cryptomator.domain.repository.CloudRepository;
@ -47,6 +48,12 @@ class LogoutCloud {
.withUsername(null) //
.withAccessToken(null) //
.build();
} else if (cloud instanceof PCloudCloud) {
return PCloudCloud //
.aCopyOf((PCloudCloud) cloud) //
.withUsername(null) //
.withAccessToken(null) //
.build();
}
throw new IllegalStateException("Logout not supported for cloud with type " + cloud.type());
}

View File

@ -18,6 +18,9 @@ enum class CloudTypeModel(builder: Builder) {
.withCloudImageResource(R.drawable.onedrive) //
.withVaultImageResource(R.drawable.onedrive_vault) //
.withVaultSelectedImageResource(R.drawable.onedrive_vault_selected)), //
PCLOUD(Builder("PCLOUD", R.string.cloud_names_dropbox) //
.withCloudImageResource(R.drawable.cloud_type_dropbox) //
.withCloudImageLargeResource(R.drawable.cloud_type_dropbox_large)), //
WEBDAV(Builder("WEBDAV", R.string.cloud_names_webdav) //
.withCloudImageResource(R.drawable.webdav) //
.withVaultImageResource(R.drawable.webdav_vault) //

View File

@ -0,0 +1,24 @@
package org.cryptomator.presentation.model
import org.cryptomator.domain.Cloud
import org.cryptomator.domain.PCloudCloud
import org.cryptomator.presentation.R
class PCloudCloudModel(cloud: Cloud) : CloudModel(cloud) {
override fun name(): Int {
return R.string.cloud_names_pcloud
}
override fun username(): String? {
return cloud().username()
}
private fun cloud(): PCloudCloud {
return toCloud() as PCloudCloud
}
override fun cloudType(): CloudTypeModel {
return CloudTypeModel.PCLOUD
}
}

View File

@ -9,6 +9,7 @@ import org.cryptomator.presentation.model.DropboxCloudModel
import org.cryptomator.presentation.model.GoogleDriveCloudModel
import org.cryptomator.presentation.model.LocalStorageModel
import org.cryptomator.presentation.model.OnedriveCloudModel
import org.cryptomator.presentation.model.PCloudCloudModel
import org.cryptomator.presentation.model.WebDavCloudModel
import javax.inject.Inject
@ -24,6 +25,7 @@ class CloudModelMapper @Inject constructor() : ModelMapper<CloudModel, Cloud>()
CloudTypeModel.DROPBOX -> DropboxCloudModel(domainObject)
CloudTypeModel.GOOGLE_DRIVE -> GoogleDriveCloudModel(domainObject)
CloudTypeModel.ONEDRIVE -> OnedriveCloudModel(domainObject)
CloudTypeModel.PCLOUD -> PCloudCloudModel(domainObject)
CloudTypeModel.CRYPTO -> CryptoCloudModel(domainObject)
CloudTypeModel.LOCAL -> LocalStorageModel(domainObject)
CloudTypeModel.WEBDAV -> WebDavCloudModel(domainObject)

View File

@ -39,6 +39,7 @@
<string name="cloud_names_dropbox" translatable="false">Dropbox</string>
<string name="cloud_names_google_drive" translatable="false">Google Drive</string>
<string name="cloud_names_onedrive" translatable="false">OneDrive</string>
<string name="cloud_names_pcloud" translatable="false">pCloud</string>
<string name="cloud_names_webdav" translatable="false">WebDAV</string>
<string name="cloud_names_local_storage">Local storage</string>