diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/DynamicSessionManager.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/DynamicSessionManager.java
deleted file mode 100644
index 4a69fac4..00000000
--- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/DynamicSessionManager.java
+++ /dev/null
@@ -1,62 +0,0 @@
-package com.owncloud.android.lib.common;
-
-import android.accounts.AuthenticatorException;
-import android.accounts.OperationCanceledException;
-import android.content.Context;
-
-import com.owncloud.android.lib.common.accounts.AccountUtils;
-import com.owncloud.android.lib.resources.status.OwnCloudVersion;
-
-import java.io.IOException;
-
-/**
- * Dynamic implementation of {@link OwnCloudClientManager}.
- *
- * Wraps instances of {@link SingleSessionManager} and {@link SimpleFactoryManager} and delegates on one
- * or the other depending on the known version of the server corresponding to the {@link OwnCloudAccount}
- *
- * @author David A. Velasco
- */
-
-public class DynamicSessionManager implements OwnCloudClientManager {
-
- private SimpleFactoryManager mSimpleFactoryManager = new SimpleFactoryManager();
-
- private SingleSessionManager mSingleSessionManager = new SingleSessionManager();
-
- @Override
- public OwnCloudClient getClientFor(OwnCloudAccount account, Context context)
- throws OperationCanceledException, AuthenticatorException, IOException {
-
- OwnCloudVersion ownCloudVersion = null;
- if (account.getSavedAccount() != null) {
- ownCloudVersion = AccountUtils.getServerVersionForAccount(
- account.getSavedAccount(), context
- );
- }
-
- if (ownCloudVersion != null && ownCloudVersion.isSessionMonitoringSupported()) {
- return mSingleSessionManager.getClientFor(account, context);
- } else {
- return mSimpleFactoryManager.getClientFor(account, context);
- }
- }
-
- @Override
- public OwnCloudClient removeClientFor(OwnCloudAccount account) {
- OwnCloudClient clientRemovedFromFactoryManager = mSimpleFactoryManager.removeClientFor(account);
- OwnCloudClient clientRemovedFromSingleSessionManager = mSingleSessionManager.removeClientFor(account);
- if (clientRemovedFromSingleSessionManager != null) {
- return clientRemovedFromSingleSessionManager;
- } else {
- return clientRemovedFromFactoryManager;
- }
- // clientRemoved and clientRemoved2 should not be != null at the same time
- }
-
- @Override
- public void saveAllClients(Context context, String accountType) {
- mSimpleFactoryManager.saveAllClients(context, accountType);
- mSingleSessionManager.saveAllClients(context, accountType);
- }
-}
diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/OwnCloudClientManagerFactory.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/OwnCloudClientManagerFactory.java
index 14944a15..02304502 100644
--- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/OwnCloudClientManagerFactory.java
+++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/OwnCloudClientManagerFactory.java
@@ -29,17 +29,17 @@ public class OwnCloudClientManagerFactory {
private static OwnCloudClientManager sDefaultSingleton;
private static String sUserAgent;
- public static OwnCloudClientManager newDefaultOwnCloudClientManager() {
+ private static OwnCloudClientManager newDefaultOwnCloudClientManager() {
return newOwnCloudClientManager(sDefaultPolicy);
}
- public static OwnCloudClientManager newOwnCloudClientManager(Policy policy) {
+ private static OwnCloudClientManager newOwnCloudClientManager(Policy policy) {
switch (policy) {
case ALWAYS_NEW_CLIENT:
return new SimpleFactoryManager();
- case SINGLE_SESSION_PER_ACCOUNT_IF_SERVER_SUPPORTS_SERVER_MONITORING:
- return new DynamicSessionManager();
+ case SINGLE_SESSION_PER_ACCOUNT:
+ return new SingleSessionManager();
default:
throw new IllegalArgumentException("Unknown policy");
@@ -53,10 +53,6 @@ public class OwnCloudClientManagerFactory {
return sDefaultSingleton;
}
- public static Policy getDefaultPolicy() {
- return sDefaultPolicy;
- }
-
public static void setDefaultPolicy(Policy policy) {
if (policy == null) {
throw new IllegalArgumentException("Default policy cannot be NULL");
@@ -84,6 +80,6 @@ public class OwnCloudClientManagerFactory {
public enum Policy {
ALWAYS_NEW_CLIENT,
- SINGLE_SESSION_PER_ACCOUNT_IF_SERVER_SUPPORTS_SERVER_MONITORING
+ SINGLE_SESSION_PER_ACCOUNT
}
}
diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/accounts/AccountUtils.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/accounts/AccountUtils.java
index 0b5911b2..649fb630 100644
--- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/accounts/AccountUtils.java
+++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/accounts/AccountUtils.java
@@ -143,7 +143,6 @@ public class AccountUtils {
boolean isOauth2 = supportsOAuth2 != null && supportsOAuth2.equals("TRUE");
String username = AccountUtils.getUsernameForAccount(account);
- OwnCloudVersion version = new OwnCloudVersion(am.getUserData(account, Constants.KEY_OC_VERSION));
if (isOauth2) {
String accessToken = am.blockingGetAuthToken(
@@ -152,7 +151,6 @@ public class AccountUtils {
false);
credentials = OwnCloudCredentialsFactory.newBearerCredentials(username, accessToken);
-
} else {
String password = am.blockingGetAuthToken(
account,
@@ -161,8 +159,7 @@ public class AccountUtils {
credentials = OwnCloudCredentialsFactory.newBasicCredentials(
username,
- password,
- version.isPreemptiveAuthenticationPreferred()
+ password
);
}
@@ -201,9 +198,8 @@ public class AccountUtils {
if (url.contains("://")) {
url = url.substring(serverBaseUrl.toString().indexOf("://") + 3);
}
- String accountName = username + "@" + url;
- return accountName;
+ return username + "@" + url;
}
public static void saveClient(OwnCloudClient client, Account savedAccount, Context context) {
diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/OwnCloudCredentialsFactory.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/OwnCloudCredentialsFactory.java
index 822ef760..6e1172fa 100644
--- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/OwnCloudCredentialsFactory.java
+++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/OwnCloudCredentialsFactory.java
@@ -38,12 +38,6 @@ public class OwnCloudCredentialsFactory {
return new OwnCloudBasicCredentials(username, password);
}
- public static OwnCloudCredentials newBasicCredentials(
- String username, String password, boolean preemptiveMode
- ) {
- return new OwnCloudBasicCredentials(username, password, preemptiveMode);
- }
-
public static OwnCloudCredentials newBearerCredentials(String username, String authToken) {
return new OwnCloudBearerCredentials(username, authToken);
}
diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/CopyRemoteFileOperation.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/CopyRemoteFileOperation.java
index 79852444..f41c8220 100644
--- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/CopyRemoteFileOperation.java
+++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/CopyRemoteFileOperation.java
@@ -33,7 +33,6 @@ import com.owncloud.android.lib.common.network.WebdavUtils;
import com.owncloud.android.lib.common.operations.RemoteOperation;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
-import com.owncloud.android.lib.resources.status.OwnCloudVersion;
import java.net.URL;
import java.util.concurrent.TimeUnit;
@@ -41,11 +40,12 @@ import java.util.concurrent.TimeUnit;
/**
* Remote operation moving a remote file or folder in the ownCloud server to a different folder
* in the same account.
- *
+ *
* Allows renaming the moving file/folder at the same time.
*
* @author David A. Velasco
* @author Christian Schabesberger
+ * @author David González V.
*/
public class CopyRemoteFileOperation extends RemoteOperation {
@@ -81,14 +81,6 @@ public class CopyRemoteFileOperation extends RemoteOperation {
*/
@Override
protected RemoteOperationResult run(OwnCloudClient client) {
- OwnCloudVersion version = client.getOwnCloudVersion();
- boolean versionWithForbiddenChars =
- (version != null && version.isVersionWithForbiddenCharacters());
-
- /// check parameters
- if (!FileUtils.isValidPath(mTargetRemotePath, versionWithForbiddenChars)) {
- return new RemoteOperationResult<>(ResultCode.INVALID_CHARACTER_IN_NAME);
- }
if (mTargetRemotePath.equals(mSrcRemotePath)) {
// nothing to do!
@@ -100,7 +92,7 @@ public class CopyRemoteFileOperation extends RemoteOperation {
}
/// perform remote operation
- RemoteOperationResult result;
+ RemoteOperationResult result;
try {
CopyMethod copyMethod =
new CopyMethod(new URL(client.getUserFilesWebDavUri() + WebdavUtils.encodePath(mSrcRemotePath)),
diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/CreateRemoteFolderOperation.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/CreateRemoteFolderOperation.java
index 4e8ccd52..becb85e4 100644
--- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/CreateRemoteFolderOperation.java
+++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/CreateRemoteFolderOperation.java
@@ -1,5 +1,5 @@
/* ownCloud Android Library is available under MIT license
- * Copyright (C) 2016 ownCloud GmbH.
+ * 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
@@ -33,7 +33,6 @@ import com.owncloud.android.lib.common.network.WebdavUtils;
import com.owncloud.android.lib.common.operations.RemoteOperation;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
-import com.owncloud.android.lib.resources.status.OwnCloudVersion;
import timber.log.Timber;
import java.net.URL;
@@ -73,25 +72,7 @@ public class CreateRemoteFolderOperation extends RemoteOperation {
*/
@Override
protected RemoteOperationResult run(OwnCloudClient client) {
- RemoteOperationResult result;
- OwnCloudVersion version = client.getOwnCloudVersion();
- boolean versionWithForbiddenChars =
- (version != null && version.isVersionWithForbiddenCharacters());
- boolean noInvalidChars = FileUtils.isValidPath(mRemotePath, versionWithForbiddenChars);
- if (noInvalidChars) {
- result = createFolder(client);
- if (!result.isSuccess() && mCreateFullPath &&
- RemoteOperationResult.ResultCode.CONFLICT == result.getCode()) {
- result = createParentFolder(FileUtils.getParentPath(mRemotePath), client);
- if (result.isSuccess()) {
- result = createFolder(client); // second (and last) try
- }
- }
- } else {
- result = new RemoteOperationResult<>(ResultCode.INVALID_CHARACTER_IN_NAME);
- }
-
- return result;
+ return new RemoteOperationResult<>(ResultCode.INVALID_CHARACTER_IN_NAME);
}
private RemoteOperationResult createFolder(OwnCloudClient client) {
@@ -121,4 +102,4 @@ public class CreateRemoteFolderOperation extends RemoteOperation {
RemoteOperation operation = new CreateRemoteFolderOperation(parentPath, mCreateFullPath);
return operation.execute(client);
}
-}
\ No newline at end of file
+}
diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/MoveRemoteFileOperation.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/MoveRemoteFileOperation.java
index 2bebe540..d6275c1d 100644
--- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/MoveRemoteFileOperation.java
+++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/MoveRemoteFileOperation.java
@@ -34,7 +34,6 @@ import com.owncloud.android.lib.common.network.WebdavUtils;
import com.owncloud.android.lib.common.operations.RemoteOperation;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
-import com.owncloud.android.lib.resources.status.OwnCloudVersion;
import java.net.URL;
import java.util.concurrent.TimeUnit;
@@ -87,16 +86,6 @@ public class MoveRemoteFileOperation extends RemoteOperation {
*/
@Override
protected RemoteOperationResult run(OwnCloudClient client) {
-
- OwnCloudVersion version = client.getOwnCloudVersion();
- boolean versionWithForbiddenChars =
- (version != null && version.isVersionWithForbiddenCharacters());
-
- /// check parameters
- if (!FileUtils.isValidPath(mTargetRemotePath, versionWithForbiddenChars)) {
- return new RemoteOperationResult<>(ResultCode.INVALID_CHARACTER_IN_NAME);
- }
-
if (mTargetRemotePath.equals(mSrcRemotePath)) {
// nothing to do!
return new RemoteOperationResult<>(ResultCode.OK);
diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/RenameRemoteFileOperation.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/RenameRemoteFileOperation.java
index a1c289fa..221a133c 100644
--- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/RenameRemoteFileOperation.java
+++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/RenameRemoteFileOperation.java
@@ -1,5 +1,5 @@
/* ownCloud Android Library is available under MIT license
- * Copyright (C) 2016 ownCloud GmbH.
+ * 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
@@ -31,7 +31,6 @@ import com.owncloud.android.lib.common.network.WebdavUtils;
import com.owncloud.android.lib.common.operations.RemoteOperation;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
-import com.owncloud.android.lib.resources.status.OwnCloudVersion;
import timber.log.Timber;
import java.io.File;
@@ -84,15 +83,6 @@ public class RenameRemoteFileOperation extends RemoteOperation {
*/
@Override
protected RemoteOperationResult run(OwnCloudClient client) {
-
- final OwnCloudVersion version = client.getOwnCloudVersion();
- final boolean versionWithForbiddenChars =
- (version != null && version.isVersionWithForbiddenCharacters());
-
- if (!FileUtils.isValidPath(mNewRemotePath, versionWithForbiddenChars)) {
- return new RemoteOperationResult<>(ResultCode.INVALID_CHARACTER_IN_NAME);
- }
-
try {
if (mNewName.equals(mOldName)) {
return new RemoteOperationResult<>(ResultCode.OK);
diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/RemoteShare.kt b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/RemoteShare.kt
index a0a4afea..47184f4a 100644
--- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/RemoteShare.kt
+++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/RemoteShare.kt
@@ -66,16 +66,14 @@ data class RemoteShare(
const val MAXIMUM_PERMISSIONS_FOR_FOLDER = MAXIMUM_PERMISSIONS_FOR_FILE +
CREATE_PERMISSION_FLAG +
DELETE_PERMISSION_FLAG
- const val FEDERATED_PERMISSIONS_FOR_FILE_UP_TO_OC9 = READ_PERMISSION_FLAG + UPDATE_PERMISSION_FLAG
- const val FEDERATED_PERMISSIONS_FOR_FILE_AFTER_OC9 = READ_PERMISSION_FLAG +
+ const val FEDERATED_PERMISSIONS_FOR_FILE = READ_PERMISSION_FLAG +
UPDATE_PERMISSION_FLAG +
SHARE_PERMISSION_FLAG
- const val FEDERATED_PERMISSIONS_FOR_FOLDER_UP_TO_OC9 = READ_PERMISSION_FLAG +
+ const val FEDERATED_PERMISSIONS_FOR_FOLDER = READ_PERMISSION_FLAG +
UPDATE_PERMISSION_FLAG +
CREATE_PERMISSION_FLAG +
- DELETE_PERMISSION_FLAG
- const val FEDERATED_PERMISSIONS_FOR_FOLDER_AFTER_OC9 =
- FEDERATED_PERMISSIONS_FOR_FOLDER_UP_TO_OC9 + SHARE_PERMISSION_FLAG
+ DELETE_PERMISSION_FLAG +
+ SHARE_PERMISSION_FLAG
const val INIT_EXPIRATION_DATE_IN_MILLIS: Long = 0
const val INIT_SHARED_DATE: Long = 0
diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/ShareToRemoteOperationResultParser.kt b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/ShareToRemoteOperationResultParser.kt
index 490f9c2b..31fcff51 100644
--- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/ShareToRemoteOperationResultParser.kt
+++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/ShareToRemoteOperationResultParser.kt
@@ -72,7 +72,7 @@ class ShareToRemoteOperationResultParser(private var shareXmlParser: ShareXMLPar
}
if (serverBaseUri != null) {
- val sharingLinkPath = ShareUtils.getSharingLinkPath(ownCloudVersion)
+ val sharingLinkPath = ShareUtils.SHARING_LINK_PATH
share.shareLink = serverBaseUri.toString() + sharingLinkPath + share.token
} else {
Timber.e("Couldn't build link for public share :(")
diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/ShareUtils.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/ShareUtils.java
index 4d4b80ae..f09642de 100644
--- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/ShareUtils.java
+++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/ShareUtils.java
@@ -39,14 +39,5 @@ public class ShareUtils {
public static final String SHARING_API_PATH = "ocs/v2.php/apps/files_sharing/api/v1/shares";
// String to build the link with the token of a share:
- public static final String SHARING_LINK_PATH_BEFORE_VERSION_8 = "/public.php?service=files&t=";
- public static final String SHARING_LINK_PATH_AFTER_VERSION_8 = "/index.php/s/";
-
- public static String getSharingLinkPath(OwnCloudVersion version) {
- if (version != null && version.isAfter8Version()) {
- return SHARING_LINK_PATH_AFTER_VERSION_8;
- } else {
- return SHARING_LINK_PATH_BEFORE_VERSION_8;
- }
- }
-}
\ No newline at end of file
+ public static final String SHARING_LINK_PATH = "/index.php/s/";
+}
diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/status/OwnCloudVersion.kt b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/status/OwnCloudVersion.kt
index e395e5ab..d71114fb 100644
--- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/status/OwnCloudVersion.kt
+++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/status/OwnCloudVersion.kt
@@ -45,46 +45,9 @@ class OwnCloudVersion(version: String) : Comparable, Parcelable
INVALID_ZERO_VERSION
}
- val isChunkedUploadSupported: Boolean
- get() = mVersion >= MINIMUN_VERSION_FOR_CHUNKED_UPLOADS
-
- val isSharedSupported: Boolean
- get() = mVersion >= MINIMUM_VERSION_FOR_SHARING_API
-
- val isVersionWithForbiddenCharacters: Boolean
- get() = mVersion >= MINIMUM_VERSION_WITH_FORBIDDEN_CHARS
-
- val isAfter8Version: Boolean
- get() = mVersion >= VERSION_8
-
- val isSearchUsersSupported: Boolean
- get() = mVersion >= MINIMUM_VERSION_FOR_SEARCHING_USERS
-
- val isVersionWithCapabilitiesAPI: Boolean
- get() = mVersion >= MINIMUM_VERSION_CAPABILITIES_API
-
- val isNotReshareableFederatedSupported: Boolean
- get() = mVersion >= MINIMUM_VERSION_WITH_NOT_RESHAREABLE_FEDERATED
-
- val isSessionMonitoringSupported: Boolean
- get() = mVersion >= MINIMUM_VERSION_WITH_SESSION_MONITORING
-
- /**
- * From OC 9.1 session tracking is a feature, but to get it working in the OC app we need the preemptive
- * mode of basic authentication is disabled. This changes in OC 9.1.3, where preemptive mode is compatible
- * with session tracking again.
- *
- * @return True for every version before 9.1 and from 9.1.3, false otherwise
- */
- val isPreemptiveAuthenticationPreferred: Boolean
- get() = mVersion < MINIMUM_VERSION_WITH_SESSION_MONITORING || mVersion >= MINIMUM_VERSION_WITH_SESSION_MONITORING_WORKING_IN_PREEMPTIVE_MODE
-
val isVersionLowerThan10: Boolean
get() = mVersion < VERSION_10
- val isMultiplePublicSharingSupported: Boolean
- get() = mVersion >= MINIMUM_VERSION_WITH_MULTIPLE_PUBLIC_SHARING
-
val isPublicSharingWriteOnlySupported: Boolean
get() = mVersion >= MINIMUM_VERSION_WITH_WRITE_ONLY_PUBLIC_SHARING
@@ -94,17 +57,17 @@ class OwnCloudVersion(version: String) : Comparable, Parcelable
mVersion > MINIMUN_MICRO_VERSION_WITHOUT_PUBLIC_UPLOAD_PERMISSION)
init {
- var version = version
+ var versionToParse = version
mVersion = 0
isVersionValid = false
- val countDots = version.length - version.replace(".", "").length
+ val countDots = versionToParse.length - versionToParse.replace(".", "").length
// Complete the version. Version must have 3 dots
for (i in countDots until MAX_DOTS) {
- version = "$version.0"
+ versionToParse = "$versionToParse.0"
}
- parseVersion(version)
+ parseVersion(versionToParse)
}
@@ -122,10 +85,10 @@ class OwnCloudVersion(version: String) : Comparable, Parcelable
return versionToString
}
- override fun compareTo(another: OwnCloudVersion): Int {
- return if (another.mVersion == mVersion)
+ override fun compareTo(other: OwnCloudVersion): Int {
+ return if (other.mVersion == mVersion)
0
- else if (another.mVersion < mVersion) 1 else -1
+ else if (other.mVersion < mVersion) 1 else -1
}
private fun parseVersion(version: String) {
@@ -137,20 +100,18 @@ class OwnCloudVersion(version: String) : Comparable, Parcelable
isVersionValid = false
// if invalid, the instance will respond as if server is 8.1, minimum with capabilities API,
// and "dead" : https://github.com/owncloud/core/wiki/Maintenance-and-Release-Schedule
- mVersion = MINIMUM_VERSION_CAPABILITIES_API
}
-
}
@Throws(NumberFormatException::class)
private fun getParsedVersion(version: String): Int {
- var version = version
+ var versionToParse = version
var versionValue = 0
// get only numeric part
- version = version.replace("[^\\d.]".toRegex(), "")
+ versionToParse = versionToParse.replace("[^\\d.]".toRegex(), "")
- val nums = version.split("\\.".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
+ val nums = versionToParse.split("\\.".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
var i = 0
while (i < nums.size && i <= MAX_DOTS) {
versionValue += Integer.parseInt(nums[i])
@@ -163,10 +124,6 @@ class OwnCloudVersion(version: String) : Comparable, Parcelable
return versionValue
}
- fun supportsRemoteThumbnails(): Boolean {
- return mVersion >= MINIMUM_SERVER_VERSION_FOR_REMOTE_THUMBNAILS
- }
-
override fun describeContents(): Int {
return super.hashCode()
}
@@ -181,31 +138,8 @@ class OwnCloudVersion(version: String) : Comparable, Parcelable
private const val MINIMUN_MICRO_VERSION_WITHOUT_PUBLIC_UPLOAD_PERMISSION = 0x03000000 // 3.0.0
- const val MINIMUN_VERSION_FOR_CHUNKED_UPLOADS = 0x04050000 // 4.5
-
- const val MINIMUM_VERSION_FOR_SHARING_API = 0x05001B00 // 5.0.27
-
- const val MINIMUM_VERSION_WITH_FORBIDDEN_CHARS = 0x08010000 // 8.1
-
- const val MINIMUM_SERVER_VERSION_FOR_REMOTE_THUMBNAILS = 0x07080000 // 7.8.0
-
- const val MINIMUM_VERSION_FOR_SEARCHING_USERS = 0x08020000 //8.2
-
- const val VERSION_8 = 0x08000000 // 8.0
-
- const val MINIMUM_VERSION_CAPABILITIES_API = 0x08010000 // 8.1
-
- private const val MINIMUM_VERSION_WITH_NOT_RESHAREABLE_FEDERATED = 0x09010000 // 9.1
-
- private const val MINIMUM_VERSION_WITH_SESSION_MONITORING = 0x09010000 // 9.1
-
- private const val MINIMUM_VERSION_WITH_SESSION_MONITORING_WORKING_IN_PREEMPTIVE_MODE = 0x09010301
- // 9.1.3.1, final 9.1.3: https://github.com/owncloud/core/commit/f9a867b70c217463289a741d4d26079eb2a80dfd
-
private const val VERSION_10 = 0xA000000 // 10.0.0
- private const val MINIMUM_VERSION_WITH_MULTIPLE_PUBLIC_SHARING = 0xA000000 // 10.0.0
-
private const val MINIMUN_MAJOR_VERSION_WITHOUT_PUBLIC_UPLOAD_PERMISSION = 0xA000000 // 10.0.0
private const val MINIMUM_VERSION_WITH_WRITE_ONLY_PUBLIC_SHARING = 0xA000100 // 10.0.1