mirror of
				https://github.com/owncloud/android-library.git
				synced 2025-10-30 18:07:38 +00:00 
			
		
		
		
	Keep decoupling shares and capabilities, start to use mappers
This commit is contained in:
		
							parent
							
								
									d73ee43e3d
								
							
						
					
					
						commit
						9230937a44
					
				| @ -4,6 +4,8 @@ apply plugin: 'kotlin-kapt' | ||||
| apply plugin: 'kotlin-allopen' | ||||
| 
 | ||||
| dependencies { | ||||
|     implementation project(':owncloudDomain') | ||||
| 
 | ||||
|     api 'com.squareup.okhttp3:okhttp:3.12.0' | ||||
|     implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion" | ||||
|     api 'com.gitlab.ownclouders:dav4android:oc_support_1.0.1' | ||||
|  | ||||
| @ -149,5 +149,4 @@ public class OwnCloudAccount { | ||||
|             return null; | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| @ -27,6 +27,7 @@ | ||||
| 
 | ||||
| package com.owncloud.android.lib.resources.shares | ||||
| 
 | ||||
| import com.owncloud.android.domain.sharing.shares.model.ShareType | ||||
| import com.owncloud.android.lib.common.OwnCloudClient | ||||
| import com.owncloud.android.lib.common.http.HttpConstants | ||||
| import com.owncloud.android.lib.common.http.methods.nonwebdav.PostMethod | ||||
|  | ||||
| @ -26,6 +26,7 @@ package com.owncloud.android.lib.resources.shares | ||||
| 
 | ||||
| import android.os.Parcel | ||||
| import android.os.Parcelable | ||||
| import com.owncloud.android.domain.sharing.shares.model.ShareType | ||||
| import com.owncloud.android.lib.common.utils.Log_OC | ||||
| import com.owncloud.android.lib.resources.files.FileUtils | ||||
| import java.io.Serializable | ||||
|  | ||||
| @ -0,0 +1,51 @@ | ||||
| /** | ||||
|  * ownCloud Android client application | ||||
|  * | ||||
|  * @author David González Verdugo | ||||
|  * Copyright (C) 2019 ownCloud GmbH. | ||||
|  * | ||||
|  * This program is free software: you can redistribute it and/or modify | ||||
|  * it under the terms of the GNU General Public License version 2, | ||||
|  * as published by the Free Software Foundation. | ||||
|  * | ||||
|  * This program is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
|  * GNU General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU General Public License | ||||
|  * along with this program.  If not, see <http://www.gnu.org/licenses/>. | ||||
|  */ | ||||
| 
 | ||||
| package com.owncloud.android.lib.resources.shares | ||||
| 
 | ||||
| import com.owncloud.android.domain.mapper.RemoteMapper | ||||
| import com.owncloud.android.domain.sharing.shares.model.OCShare | ||||
| 
 | ||||
| class RemoteShareMapper : RemoteMapper<OCShare, RemoteShare> { | ||||
|     override fun toModel(remote: RemoteShare?): OCShare? = | ||||
|         remote?.let { | ||||
|             OCShare( | ||||
|                 fileSource = remote.fileSource, | ||||
|                 itemSource = remote.itemSource, | ||||
|                 shareType = remote.shareType!!, | ||||
|                 shareWith = remote.shareWith, | ||||
|                 path = remote.path, | ||||
|                 permissions = remote.permissions, | ||||
|                 sharedDate = remote.sharedDate, | ||||
|                 expirationDate = remote.expirationDate, | ||||
|                 token = remote.token, | ||||
|                 sharedWithDisplayName = remote.sharedWithDisplayName, | ||||
|                 sharedWithAdditionalInfo = remote.sharedWithAdditionalInfo, | ||||
|                 isFolder = remote.isFolder, | ||||
|                 userId = remote.userId, | ||||
|                 remoteId = remote.id, | ||||
|                 name = remote.name, | ||||
|                 shareLink = remote.shareLink | ||||
|             ) | ||||
|         } | ||||
| 
 | ||||
|     override fun toRemote(model: OCShare?): RemoteShare? { | ||||
|         TODO("not implemented") //To change body of created functions use File | Settings | File Templates. | ||||
|     } | ||||
| } | ||||
| @ -28,6 +28,7 @@ | ||||
| package com.owncloud.android.lib.resources.shares | ||||
| 
 | ||||
| import android.net.Uri | ||||
| import com.owncloud.android.domain.sharing.shares.model.ShareType | ||||
| import com.owncloud.android.lib.common.operations.RemoteOperationResult | ||||
| import com.owncloud.android.lib.common.utils.Log_OC | ||||
| import com.owncloud.android.lib.resources.status.OwnCloudVersion | ||||
|  | ||||
| @ -1,63 +0,0 @@ | ||||
| /* ownCloud Android Library is available under MIT license | ||||
|  *   Copyright (C) 2019 ownCloud GmbH. | ||||
|  * | ||||
|  *   Permission is hereby granted, free of charge, to any person obtaining a copy | ||||
|  *   of this software and associated documentation files (the "Software"), to deal | ||||
|  *   in the Software without restriction, including without limitation the rights | ||||
|  *   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||||
|  *   copies of the Software, and to permit persons to whom the Software is | ||||
|  *   furnished to do so, subject to the following conditions: | ||||
|  * | ||||
|  *   The above copyright notice and this permission notice shall be included in | ||||
|  *   all copies or substantial portions of the Software. | ||||
|  * | ||||
|  *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||||
|  *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||||
|  *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||||
|  *   NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||||
|  *   BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||||
|  *   ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||||
|  *   CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||||
|  *   THE SOFTWARE. | ||||
|  * | ||||
|  */ | ||||
| 
 | ||||
| package com.owncloud.android.lib.resources.shares | ||||
| 
 | ||||
| /** | ||||
|  * Enum for Share Type, with values: | ||||
|  * -1 - No shared | ||||
|  * 0 - Shared by user | ||||
|  * 1 - Shared by group | ||||
|  * 3 - Shared by public link | ||||
|  * 4 - Shared by e-mail | ||||
|  * 5 - Shared by contact | ||||
|  * 6 - Federated | ||||
|  * | ||||
|  * @author masensio | ||||
|  */ | ||||
| 
 | ||||
| enum class ShareType constructor(val value: Int) { | ||||
|     NO_SHARED(-1), | ||||
|     USER(0), | ||||
|     GROUP(1), | ||||
|     PUBLIC_LINK(3), | ||||
|     EMAIL(4), | ||||
|     CONTACT(5), | ||||
|     FEDERATED(6); | ||||
| 
 | ||||
|     companion object { | ||||
|         fun fromValue(value: Int): ShareType? { | ||||
|             return when (value) { | ||||
|                 -1 -> NO_SHARED | ||||
|                 0 -> USER | ||||
|                 1 -> GROUP | ||||
|                 3 -> PUBLIC_LINK | ||||
|                 4 -> EMAIL | ||||
|                 5 -> CONTACT | ||||
|                 6 -> FEDERATED | ||||
|                 else -> null | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @ -25,6 +25,7 @@ | ||||
| package com.owncloud.android.lib.resources.shares | ||||
| 
 | ||||
| import android.util.Xml | ||||
| import com.owncloud.android.domain.sharing.shares.model.ShareType | ||||
| 
 | ||||
| import com.owncloud.android.lib.common.network.WebdavUtils | ||||
| import com.owncloud.android.lib.resources.files.FileUtils | ||||
|  | ||||
| @ -1,65 +0,0 @@ | ||||
| /* ownCloud Android Library is available under MIT license | ||||
|  *   Copyright (C) 2019 ownCloud GmbH. | ||||
|  *   @author masensio | ||||
|  * | ||||
|  *   Permission is hereby granted, free of charge, to any person obtaining a copy | ||||
|  *   of this software and associated documentation files (the "Software"), to deal | ||||
|  *   in the Software without restriction, including without limitation the rights | ||||
|  *   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||||
|  *   copies of the Software, and to permit persons to whom the Software is | ||||
|  *   furnished to do so, subject to the following conditions: | ||||
|  * | ||||
|  *   The above copyright notice and this permission notice shall be included in | ||||
|  *   all copies or substantial portions of the Software. | ||||
|  * | ||||
|  *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||||
|  *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||||
|  *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||||
|  *   NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||||
|  *   BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||||
|  *   ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||||
|  *   CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||||
|  *   THE SOFTWARE. | ||||
|  * | ||||
|  */ | ||||
| package com.owncloud.android.lib.resources.status | ||||
| 
 | ||||
| /** | ||||
|  * Enum for Boolean Type in RemoteCapability parameters, with values: | ||||
|  * -1 - Unknown | ||||
|  * 0 - False | ||||
|  * 1 - True | ||||
|  */ | ||||
| enum class CapabilityBooleanType private constructor(val value: Int) { | ||||
|     UNKNOWN(-1), | ||||
|     FALSE(0), | ||||
|     TRUE(1); | ||||
| 
 | ||||
|     val isUnknown: Boolean | ||||
|         get() = value == -1 | ||||
| 
 | ||||
|     val isFalse: Boolean | ||||
|         get() = value == 0 | ||||
| 
 | ||||
|     val isTrue: Boolean | ||||
|         get() = value == 1 | ||||
| 
 | ||||
|     companion object { | ||||
|         fun fromValue(value: Int): CapabilityBooleanType? { | ||||
|             return when (value) { | ||||
|                 -1 -> UNKNOWN | ||||
|                 0 -> FALSE | ||||
|                 1 -> TRUE | ||||
|                 else -> null | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         fun fromBooleanValue(boolValue: Boolean): CapabilityBooleanType { | ||||
|             return if (boolValue) { | ||||
|                 TRUE | ||||
|             } else { | ||||
|                 FALSE | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @ -27,6 +27,7 @@ | ||||
| 
 | ||||
| package com.owncloud.android.lib.resources.status | ||||
| 
 | ||||
| import com.owncloud.android.domain.capabilities.model.CapabilityBooleanType | ||||
| import com.owncloud.android.lib.common.OwnCloudClient | ||||
| import com.owncloud.android.lib.common.http.HttpConstants | ||||
| import com.owncloud.android.lib.common.http.methods.nonwebdav.GetMethod | ||||
|  | ||||
| @ -26,6 +26,8 @@ | ||||
|  */ | ||||
| package com.owncloud.android.lib.resources.status | ||||
| 
 | ||||
| import com.owncloud.android.domain.capabilities.model.CapabilityBooleanType | ||||
| 
 | ||||
| /** | ||||
|  * Contains data of the Capabilities for an account, from the Capabilities API | ||||
|  */ | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user