1
0
mirror of https://github.com/owncloud/android-library.git synced 2025-06-07 16:06:08 +00:00

Get rid of conditions for <10 servers

This commit is contained in:
davigonz 2019-08-29 10:55:48 +02:00
parent 285306e1bc
commit bcc5a06335
12 changed files with 31 additions and 232 deletions

View File

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

View File

@ -29,17 +29,17 @@ public class OwnCloudClientManagerFactory {
private static OwnCloudClientManager sDefaultSingleton; private static OwnCloudClientManager sDefaultSingleton;
private static String sUserAgent; private static String sUserAgent;
public static OwnCloudClientManager newDefaultOwnCloudClientManager() { private static OwnCloudClientManager newDefaultOwnCloudClientManager() {
return newOwnCloudClientManager(sDefaultPolicy); return newOwnCloudClientManager(sDefaultPolicy);
} }
public static OwnCloudClientManager newOwnCloudClientManager(Policy policy) { private static OwnCloudClientManager newOwnCloudClientManager(Policy policy) {
switch (policy) { switch (policy) {
case ALWAYS_NEW_CLIENT: case ALWAYS_NEW_CLIENT:
return new SimpleFactoryManager(); return new SimpleFactoryManager();
case SINGLE_SESSION_PER_ACCOUNT_IF_SERVER_SUPPORTS_SERVER_MONITORING: case SINGLE_SESSION_PER_ACCOUNT:
return new DynamicSessionManager(); return new SingleSessionManager();
default: default:
throw new IllegalArgumentException("Unknown policy"); throw new IllegalArgumentException("Unknown policy");
@ -53,10 +53,6 @@ public class OwnCloudClientManagerFactory {
return sDefaultSingleton; return sDefaultSingleton;
} }
public static Policy getDefaultPolicy() {
return sDefaultPolicy;
}
public static void setDefaultPolicy(Policy policy) { public static void setDefaultPolicy(Policy policy) {
if (policy == null) { if (policy == null) {
throw new IllegalArgumentException("Default policy cannot be NULL"); throw new IllegalArgumentException("Default policy cannot be NULL");
@ -84,6 +80,6 @@ public class OwnCloudClientManagerFactory {
public enum Policy { public enum Policy {
ALWAYS_NEW_CLIENT, ALWAYS_NEW_CLIENT,
SINGLE_SESSION_PER_ACCOUNT_IF_SERVER_SUPPORTS_SERVER_MONITORING SINGLE_SESSION_PER_ACCOUNT
} }
} }

View File

@ -143,7 +143,6 @@ public class AccountUtils {
boolean isOauth2 = supportsOAuth2 != null && supportsOAuth2.equals("TRUE"); boolean isOauth2 = supportsOAuth2 != null && supportsOAuth2.equals("TRUE");
String username = AccountUtils.getUsernameForAccount(account); String username = AccountUtils.getUsernameForAccount(account);
OwnCloudVersion version = new OwnCloudVersion(am.getUserData(account, Constants.KEY_OC_VERSION));
if (isOauth2) { if (isOauth2) {
String accessToken = am.blockingGetAuthToken( String accessToken = am.blockingGetAuthToken(
@ -152,7 +151,6 @@ public class AccountUtils {
false); false);
credentials = OwnCloudCredentialsFactory.newBearerCredentials(username, accessToken); credentials = OwnCloudCredentialsFactory.newBearerCredentials(username, accessToken);
} else { } else {
String password = am.blockingGetAuthToken( String password = am.blockingGetAuthToken(
account, account,
@ -161,8 +159,7 @@ public class AccountUtils {
credentials = OwnCloudCredentialsFactory.newBasicCredentials( credentials = OwnCloudCredentialsFactory.newBasicCredentials(
username, username,
password, password
version.isPreemptiveAuthenticationPreferred()
); );
} }
@ -201,9 +198,8 @@ public class AccountUtils {
if (url.contains("://")) { if (url.contains("://")) {
url = url.substring(serverBaseUrl.toString().indexOf("://") + 3); 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) { public static void saveClient(OwnCloudClient client, Account savedAccount, Context context) {

View File

@ -38,12 +38,6 @@ public class OwnCloudCredentialsFactory {
return new OwnCloudBasicCredentials(username, password); 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) { public static OwnCloudCredentials newBearerCredentials(String username, String authToken) {
return new OwnCloudBearerCredentials(username, authToken); return new OwnCloudBearerCredentials(username, authToken);
} }

View File

@ -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.RemoteOperation;
import com.owncloud.android.lib.common.operations.RemoteOperationResult; import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode; import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
import com.owncloud.android.lib.resources.status.OwnCloudVersion;
import java.net.URL; import java.net.URL;
import java.util.concurrent.TimeUnit; 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 * Remote operation moving a remote file or folder in the ownCloud server to a different folder
* in the same account. * in the same account.
* <p> *
* Allows renaming the moving file/folder at the same time. * Allows renaming the moving file/folder at the same time.
* *
* @author David A. Velasco * @author David A. Velasco
* @author Christian Schabesberger * @author Christian Schabesberger
* @author David González V.
*/ */
public class CopyRemoteFileOperation extends RemoteOperation<String> { public class CopyRemoteFileOperation extends RemoteOperation<String> {
@ -81,14 +81,6 @@ public class CopyRemoteFileOperation extends RemoteOperation<String> {
*/ */
@Override @Override
protected RemoteOperationResult<String> run(OwnCloudClient client) { protected RemoteOperationResult<String> 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)) { if (mTargetRemotePath.equals(mSrcRemotePath)) {
// nothing to do! // nothing to do!
@ -100,7 +92,7 @@ public class CopyRemoteFileOperation extends RemoteOperation<String> {
} }
/// perform remote operation /// perform remote operation
RemoteOperationResult<String> result; RemoteOperationResult result;
try { try {
CopyMethod copyMethod = CopyMethod copyMethod =
new CopyMethod(new URL(client.getUserFilesWebDavUri() + WebdavUtils.encodePath(mSrcRemotePath)), new CopyMethod(new URL(client.getUserFilesWebDavUri() + WebdavUtils.encodePath(mSrcRemotePath)),

View File

@ -1,5 +1,5 @@
/* ownCloud Android Library is available under MIT license /* 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 * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * 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.RemoteOperation;
import com.owncloud.android.lib.common.operations.RemoteOperationResult; import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode; import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
import com.owncloud.android.lib.resources.status.OwnCloudVersion;
import timber.log.Timber; import timber.log.Timber;
import java.net.URL; import java.net.URL;
@ -73,25 +72,7 @@ public class CreateRemoteFolderOperation extends RemoteOperation {
*/ */
@Override @Override
protected RemoteOperationResult run(OwnCloudClient client) { protected RemoteOperationResult run(OwnCloudClient client) {
RemoteOperationResult result; return new RemoteOperationResult<>(ResultCode.INVALID_CHARACTER_IN_NAME);
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;
} }
private RemoteOperationResult createFolder(OwnCloudClient client) { private RemoteOperationResult createFolder(OwnCloudClient client) {
@ -121,4 +102,4 @@ public class CreateRemoteFolderOperation extends RemoteOperation {
RemoteOperation operation = new CreateRemoteFolderOperation(parentPath, mCreateFullPath); RemoteOperation operation = new CreateRemoteFolderOperation(parentPath, mCreateFullPath);
return operation.execute(client); return operation.execute(client);
} }
} }

View File

@ -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.RemoteOperation;
import com.owncloud.android.lib.common.operations.RemoteOperationResult; import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode; import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
import com.owncloud.android.lib.resources.status.OwnCloudVersion;
import java.net.URL; import java.net.URL;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -87,16 +86,6 @@ public class MoveRemoteFileOperation extends RemoteOperation {
*/ */
@Override @Override
protected RemoteOperationResult run(OwnCloudClient client) { 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)) { if (mTargetRemotePath.equals(mSrcRemotePath)) {
// nothing to do! // nothing to do!
return new RemoteOperationResult<>(ResultCode.OK); return new RemoteOperationResult<>(ResultCode.OK);

View File

@ -1,5 +1,5 @@
/* ownCloud Android Library is available under MIT license /* 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 * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * 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.RemoteOperation;
import com.owncloud.android.lib.common.operations.RemoteOperationResult; import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode; import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
import com.owncloud.android.lib.resources.status.OwnCloudVersion;
import timber.log.Timber; import timber.log.Timber;
import java.io.File; import java.io.File;
@ -84,15 +83,6 @@ public class RenameRemoteFileOperation extends RemoteOperation {
*/ */
@Override @Override
protected RemoteOperationResult run(OwnCloudClient client) { 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 { try {
if (mNewName.equals(mOldName)) { if (mNewName.equals(mOldName)) {
return new RemoteOperationResult<>(ResultCode.OK); return new RemoteOperationResult<>(ResultCode.OK);

View File

@ -66,16 +66,14 @@ data class RemoteShare(
const val MAXIMUM_PERMISSIONS_FOR_FOLDER = MAXIMUM_PERMISSIONS_FOR_FILE + const val MAXIMUM_PERMISSIONS_FOR_FOLDER = MAXIMUM_PERMISSIONS_FOR_FILE +
CREATE_PERMISSION_FLAG + CREATE_PERMISSION_FLAG +
DELETE_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 = READ_PERMISSION_FLAG +
const val FEDERATED_PERMISSIONS_FOR_FILE_AFTER_OC9 = READ_PERMISSION_FLAG +
UPDATE_PERMISSION_FLAG + UPDATE_PERMISSION_FLAG +
SHARE_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 + UPDATE_PERMISSION_FLAG +
CREATE_PERMISSION_FLAG + CREATE_PERMISSION_FLAG +
DELETE_PERMISSION_FLAG DELETE_PERMISSION_FLAG +
const val FEDERATED_PERMISSIONS_FOR_FOLDER_AFTER_OC9 = SHARE_PERMISSION_FLAG
FEDERATED_PERMISSIONS_FOR_FOLDER_UP_TO_OC9 + SHARE_PERMISSION_FLAG
const val INIT_EXPIRATION_DATE_IN_MILLIS: Long = 0 const val INIT_EXPIRATION_DATE_IN_MILLIS: Long = 0
const val INIT_SHARED_DATE: Long = 0 const val INIT_SHARED_DATE: Long = 0

View File

@ -72,7 +72,7 @@ class ShareToRemoteOperationResultParser(private var shareXmlParser: ShareXMLPar
} }
if (serverBaseUri != null) { if (serverBaseUri != null) {
val sharingLinkPath = ShareUtils.getSharingLinkPath(ownCloudVersion) val sharingLinkPath = ShareUtils.SHARING_LINK_PATH
share.shareLink = serverBaseUri.toString() + sharingLinkPath + share.token share.shareLink = serverBaseUri.toString() + sharingLinkPath + share.token
} else { } else {
Timber.e("Couldn't build link for public share :(") Timber.e("Couldn't build link for public share :(")

View File

@ -39,14 +39,5 @@ public class ShareUtils {
public static final String SHARING_API_PATH = "ocs/v2.php/apps/files_sharing/api/v1/shares"; 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: // 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 = "/index.php/s/";
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;
}
}
}

View File

@ -45,46 +45,9 @@ class OwnCloudVersion(version: String) : Comparable<OwnCloudVersion>, Parcelable
INVALID_ZERO_VERSION 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 val isVersionLowerThan10: Boolean
get() = mVersion < VERSION_10 get() = mVersion < VERSION_10
val isMultiplePublicSharingSupported: Boolean
get() = mVersion >= MINIMUM_VERSION_WITH_MULTIPLE_PUBLIC_SHARING
val isPublicSharingWriteOnlySupported: Boolean val isPublicSharingWriteOnlySupported: Boolean
get() = mVersion >= MINIMUM_VERSION_WITH_WRITE_ONLY_PUBLIC_SHARING get() = mVersion >= MINIMUM_VERSION_WITH_WRITE_ONLY_PUBLIC_SHARING
@ -94,17 +57,17 @@ class OwnCloudVersion(version: String) : Comparable<OwnCloudVersion>, Parcelable
mVersion > MINIMUN_MICRO_VERSION_WITHOUT_PUBLIC_UPLOAD_PERMISSION) mVersion > MINIMUN_MICRO_VERSION_WITHOUT_PUBLIC_UPLOAD_PERMISSION)
init { init {
var version = version var versionToParse = version
mVersion = 0 mVersion = 0
isVersionValid = false isVersionValid = false
val countDots = version.length - version.replace(".", "").length val countDots = versionToParse.length - versionToParse.replace(".", "").length
// Complete the version. Version must have 3 dots // Complete the version. Version must have 3 dots
for (i in countDots until MAX_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<OwnCloudVersion>, Parcelable
return versionToString return versionToString
} }
override fun compareTo(another: OwnCloudVersion): Int { override fun compareTo(other: OwnCloudVersion): Int {
return if (another.mVersion == mVersion) return if (other.mVersion == mVersion)
0 0
else if (another.mVersion < mVersion) 1 else -1 else if (other.mVersion < mVersion) 1 else -1
} }
private fun parseVersion(version: String) { private fun parseVersion(version: String) {
@ -137,20 +100,18 @@ class OwnCloudVersion(version: String) : Comparable<OwnCloudVersion>, Parcelable
isVersionValid = false isVersionValid = false
// if invalid, the instance will respond as if server is 8.1, minimum with capabilities API, // 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 // and "dead" : https://github.com/owncloud/core/wiki/Maintenance-and-Release-Schedule
mVersion = MINIMUM_VERSION_CAPABILITIES_API
} }
} }
@Throws(NumberFormatException::class) @Throws(NumberFormatException::class)
private fun getParsedVersion(version: String): Int { private fun getParsedVersion(version: String): Int {
var version = version var versionToParse = version
var versionValue = 0 var versionValue = 0
// get only numeric part // 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 var i = 0
while (i < nums.size && i <= MAX_DOTS) { while (i < nums.size && i <= MAX_DOTS) {
versionValue += Integer.parseInt(nums[i]) versionValue += Integer.parseInt(nums[i])
@ -163,10 +124,6 @@ class OwnCloudVersion(version: String) : Comparable<OwnCloudVersion>, Parcelable
return versionValue return versionValue
} }
fun supportsRemoteThumbnails(): Boolean {
return mVersion >= MINIMUM_SERVER_VERSION_FOR_REMOTE_THUMBNAILS
}
override fun describeContents(): Int { override fun describeContents(): Int {
return super.hashCode() return super.hashCode()
} }
@ -181,31 +138,8 @@ class OwnCloudVersion(version: String) : Comparable<OwnCloudVersion>, Parcelable
private const val MINIMUN_MICRO_VERSION_WITHOUT_PUBLIC_UPLOAD_PERMISSION = 0x03000000 // 3.0.0 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 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 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 private const val MINIMUM_VERSION_WITH_WRITE_ONLY_PUBLIC_SHARING = 0xA000100 // 10.0.1