diff --git a/src/androidTest/java/com/owncloud/android/UploadIT.java b/src/androidTest/java/com/owncloud/android/UploadIT.java
index 7b32334b7f..07278eb19e 100644
--- a/src/androidTest/java/com/owncloud/android/UploadIT.java
+++ b/src/androidTest/java/com/owncloud/android/UploadIT.java
@@ -27,7 +27,6 @@ public class UploadIT extends AbstractIT {
null,
ocUpload,
false,
- false,
FileUploader.LOCAL_BEHAVIOUR_COPY,
context,
false,
@@ -52,7 +51,6 @@ public class UploadIT extends AbstractIT {
null,
ocUpload,
false,
- false,
FileUploader.LOCAL_BEHAVIOUR_COPY,
context,
false,
diff --git a/src/main/java/com/owncloud/android/MainApp.java b/src/main/java/com/owncloud/android/MainApp.java
index c7cfc42939..9dcbc15dbf 100644
--- a/src/main/java/com/owncloud/android/MainApp.java
+++ b/src/main/java/com/owncloud/android/MainApp.java
@@ -35,6 +35,7 @@ import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.StrictMode;
+import android.support.annotation.RequiresApi;
import android.support.annotation.StringRes;
import android.support.multidex.MultiDexApplication;
import android.support.v4.util.Pair;
@@ -341,6 +342,7 @@ public class MainApp extends MultiDexApplication {
}
}
+ @RequiresApi(api = Build.VERSION_CODES.N)
private static void createChannel(NotificationManager notificationManager,
String channelId, int channelName,
int channelDescription, Context context) {
diff --git a/src/main/java/com/owncloud/android/authentication/AccountUtils.java b/src/main/java/com/owncloud/android/authentication/AccountUtils.java
index 63bdc5798b..11db8afb4c 100644
--- a/src/main/java/com/owncloud/android/authentication/AccountUtils.java
+++ b/src/main/java/com/owncloud/android/authentication/AccountUtils.java
@@ -1,221 +1,217 @@
-/*
- * ownCloud Android client application
- *
- * Copyright (C) 2012 Bartek Przybylski
- * Copyright (C) 2016 ownCloud Inc.
- *
- * 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 .
- *
- */
-
-package com.owncloud.android.authentication;
-
-import android.accounts.Account;
-import android.accounts.AccountManager;
-import android.content.Context;
-import android.content.SharedPreferences;
-import android.preference.PreferenceManager;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-
-import com.owncloud.android.MainApp;
-import com.owncloud.android.datamodel.ArbitraryDataProvider;
-import com.owncloud.android.datamodel.FileDataStorageManager;
-import com.owncloud.android.lib.common.accounts.AccountUtils.Constants;
-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;
-import com.owncloud.android.operations.GetCapabilitiesOperarion;
-import com.owncloud.android.ui.activity.ManageAccountsActivity;
-
-
-public class AccountUtils {
- private static final String TAG = AccountUtils.class.getSimpleName();
- private static final String PREF_SELECT_OC_ACCOUNT = "select_oc_account";
-
- public static final int ACCOUNT_VERSION = 1;
- public static final int ACCOUNT_VERSION_WITH_PROPER_ID = 2;
- public static final String ACCOUNT_USES_STANDARD_PASSWORD = "ACCOUNT_USES_STANDARD_PASSWORD";
-
- private AccountUtils() {
- // Required empty constructor
- }
-
- /**
- * Can be used to get the currently selected ownCloud {@link Account} in the
- * application preferences.
- *
- * @param context The current application {@link Context}
- * @return The ownCloud {@link Account} currently saved in preferences, or the first
- * {@link Account} available, if valid (still registered in the system as ownCloud
- * account). If none is available and valid, returns null.
- */
- public static @Nullable Account getCurrentOwnCloudAccount(Context context) {
- Account[] ocAccounts = getAccounts(context);
- Account defaultAccount = null;
-
- ArbitraryDataProvider arbitraryDataProvider = new ArbitraryDataProvider(context.getContentResolver());
-
- SharedPreferences appPreferences = PreferenceManager.getDefaultSharedPreferences(context);
- String accountName = appPreferences.getString(PREF_SELECT_OC_ACCOUNT, null);
-
- // account validation: the saved account MUST be in the list of ownCloud Accounts known by the AccountManager
- if (accountName != null) {
- for (Account account : ocAccounts) {
- if (account.name.equals(accountName)) {
- defaultAccount = account;
- break;
- }
- }
- }
-
- if (defaultAccount == null && ocAccounts.length > 0) {
- // take first which is not pending for removal account as fallback
- for (Account account: ocAccounts) {
- boolean pendingForRemoval = arbitraryDataProvider.getBooleanValue(account,
- ManageAccountsActivity.PENDING_FOR_REMOVAL);
-
- if (!pendingForRemoval) {
- defaultAccount = account;
- break;
- }
- }
- }
-
- return defaultAccount;
- }
-
- public static Account[] getAccounts(Context context) {
- AccountManager accountManager = AccountManager.get(context);
- return accountManager.getAccountsByType(MainApp.getAccountType(context));
- }
-
-
- public static boolean exists(Account account, Context context) {
- Account[] ocAccounts = getAccounts(context);
-
- if (account != null && account.name != null) {
- int lastAtPos = account.name.lastIndexOf('@');
- String hostAndPort = account.name.substring(lastAtPos + 1);
- String username = account.name.substring(0, lastAtPos);
- String otherHostAndPort;
- String otherUsername;
- for (Account otherAccount : ocAccounts) {
- lastAtPos = otherAccount.name.lastIndexOf('@');
- otherHostAndPort = otherAccount.name.substring(lastAtPos + 1);
- otherUsername = otherAccount.name.substring(0, lastAtPos);
- if (otherHostAndPort.equals(hostAndPort) &&
- otherUsername.equalsIgnoreCase(username)) {
- return true;
- }
- }
- }
- return false;
- }
-
- /**
- * returns the user's name based on the account name.
- *
- * @param accountName the account name
- * @return the user's name
- */
- public static String getAccountUsername(String accountName) {
- if (accountName != null) {
- return accountName.substring(0, accountName.lastIndexOf('@'));
- } else {
- return null;
- }
- }
-
- /**
- * Returns owncloud account identified by accountName or null if it does not exist.
- * @param context the context
- * @param accountName name of account to be returned
- * @return owncloud account named accountName
- */
- public static Account getOwnCloudAccountByName(Context context, String accountName) {
- Account[] ocAccounts = AccountManager.get(context).getAccountsByType(MainApp.getAccountType(context));
- for (Account account : ocAccounts) {
- if(account.name.equals(accountName)) {
- return account;
- }
- }
- return null;
- }
-
-
- public static boolean setCurrentOwnCloudAccount(final Context context, String accountName) {
- boolean result = false;
- if (accountName != null) {
- boolean found;
- for (final Account account : getAccounts(context)) {
- found = (account.name.equals(accountName));
- if (found) {
- SharedPreferences.Editor appPrefs = PreferenceManager.getDefaultSharedPreferences(context).edit();
- appPrefs.putString(PREF_SELECT_OC_ACCOUNT, accountName);
-
- // update credentials
- Thread t = new Thread(() -> {
- FileDataStorageManager storageManager = new FileDataStorageManager(account,
- context.getContentResolver());
- GetCapabilitiesOperarion getCapabilities = new GetCapabilitiesOperarion();
- RemoteOperationResult updateResult = getCapabilities.execute(storageManager, context);
- Log_OC.w(TAG, "Update Capabilities: " + updateResult.isSuccess());
- });
-
- t.start();
-
- appPrefs.apply();
- result = true;
- break;
- }
- }
- }
- return result;
- }
-
- public static void resetOwnCloudAccount(Context context) {
- SharedPreferences.Editor appPrefs = PreferenceManager.getDefaultSharedPreferences(context).edit();
- appPrefs.putString(PREF_SELECT_OC_ACCOUNT, null);
-
- appPrefs.apply();
- }
-
- /**
- * Access the version of the OC server corresponding to an account SAVED IN THE ACCOUNTMANAGER
- *
- * @param account ownCloud account
- * @return Version of the OC server corresponding to account, according to the data saved
- * in the system AccountManager
- */
- public static @NonNull
- OwnCloudVersion getServerVersion(Account account) {
- OwnCloudVersion serverVersion = OwnCloudVersion.nextcloud_10;
- if (account != null) {
- AccountManager accountMgr = AccountManager.get(MainApp.getAppContext());
- String serverVersionStr = accountMgr.getUserData(account, Constants.KEY_OC_VERSION);
- if (serverVersionStr != null) {
- serverVersion = new OwnCloudVersion(serverVersionStr);
- }
- }
- return serverVersion;
- }
-
- public static boolean hasSearchUsersSupport(Account account) {
- return getServerVersion(account).isSearchUsersSupported();
- }
-
- public static boolean hasSearchSupport(Account account) {
- return getServerVersion(account).isSearchSupported();
- }
-}
+/*
+ * ownCloud Android client application
+ *
+ * Copyright (C) 2012 Bartek Przybylski
+ * Copyright (C) 2016 ownCloud Inc.
+ *
+ * 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 .
+ *
+ */
+
+package com.owncloud.android.authentication;
+
+import android.accounts.Account;
+import android.accounts.AccountManager;
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.preference.PreferenceManager;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+
+import com.owncloud.android.MainApp;
+import com.owncloud.android.datamodel.ArbitraryDataProvider;
+import com.owncloud.android.datamodel.FileDataStorageManager;
+import com.owncloud.android.lib.common.accounts.AccountUtils.Constants;
+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;
+import com.owncloud.android.operations.GetCapabilitiesOperarion;
+import com.owncloud.android.ui.activity.ManageAccountsActivity;
+
+
+public class AccountUtils {
+ private static final String TAG = AccountUtils.class.getSimpleName();
+ private static final String PREF_SELECT_OC_ACCOUNT = "select_oc_account";
+
+ public static final int ACCOUNT_VERSION = 1;
+ public static final int ACCOUNT_VERSION_WITH_PROPER_ID = 2;
+ public static final String ACCOUNT_USES_STANDARD_PASSWORD = "ACCOUNT_USES_STANDARD_PASSWORD";
+
+ private AccountUtils() {
+ // Required empty constructor
+ }
+
+ /**
+ * Can be used to get the currently selected ownCloud {@link Account} in the
+ * application preferences.
+ *
+ * @param context The current application {@link Context}
+ * @return The ownCloud {@link Account} currently saved in preferences, or the first
+ * {@link Account} available, if valid (still registered in the system as ownCloud
+ * account). If none is available and valid, returns null.
+ */
+ public static @Nullable Account getCurrentOwnCloudAccount(Context context) {
+ Account[] ocAccounts = getAccounts(context);
+ Account defaultAccount = null;
+
+ ArbitraryDataProvider arbitraryDataProvider = new ArbitraryDataProvider(context.getContentResolver());
+
+ SharedPreferences appPreferences = PreferenceManager.getDefaultSharedPreferences(context);
+ String accountName = appPreferences.getString(PREF_SELECT_OC_ACCOUNT, null);
+
+ // account validation: the saved account MUST be in the list of ownCloud Accounts known by the AccountManager
+ if (accountName != null) {
+ for (Account account : ocAccounts) {
+ if (account.name.equals(accountName)) {
+ defaultAccount = account;
+ break;
+ }
+ }
+ }
+
+ if (defaultAccount == null && ocAccounts.length > 0) {
+ // take first which is not pending for removal account as fallback
+ for (Account account: ocAccounts) {
+ boolean pendingForRemoval = arbitraryDataProvider.getBooleanValue(account,
+ ManageAccountsActivity.PENDING_FOR_REMOVAL);
+
+ if (!pendingForRemoval) {
+ defaultAccount = account;
+ break;
+ }
+ }
+ }
+
+ return defaultAccount;
+ }
+
+ public static Account[] getAccounts(Context context) {
+ AccountManager accountManager = AccountManager.get(context);
+ return accountManager.getAccountsByType(MainApp.getAccountType(context));
+ }
+
+
+ public static boolean exists(Account account, Context context) {
+ Account[] ocAccounts = getAccounts(context);
+
+ if (account != null && account.name != null) {
+ int lastAtPos = account.name.lastIndexOf('@');
+ String hostAndPort = account.name.substring(lastAtPos + 1);
+ String username = account.name.substring(0, lastAtPos);
+ String otherHostAndPort;
+ String otherUsername;
+ for (Account otherAccount : ocAccounts) {
+ lastAtPos = otherAccount.name.lastIndexOf('@');
+ otherHostAndPort = otherAccount.name.substring(lastAtPos + 1);
+ otherUsername = otherAccount.name.substring(0, lastAtPos);
+ if (otherHostAndPort.equals(hostAndPort) &&
+ otherUsername.equalsIgnoreCase(username)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * returns the user's name based on the account name.
+ *
+ * @param accountName the account name
+ * @return the user's name
+ */
+ public static String getAccountUsername(String accountName) {
+ if (accountName != null) {
+ return accountName.substring(0, accountName.lastIndexOf('@'));
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Returns owncloud account identified by accountName or null if it does not exist.
+ * @param context the context
+ * @param accountName name of account to be returned
+ * @return owncloud account named accountName
+ */
+ public static Account getOwnCloudAccountByName(Context context, String accountName) {
+ Account[] ocAccounts = AccountManager.get(context).getAccountsByType(MainApp.getAccountType(context));
+ for (Account account : ocAccounts) {
+ if(account.name.equals(accountName)) {
+ return account;
+ }
+ }
+ return null;
+ }
+
+
+ public static boolean setCurrentOwnCloudAccount(final Context context, String accountName) {
+ boolean result = false;
+ if (accountName != null) {
+ boolean found;
+ for (final Account account : getAccounts(context)) {
+ found = (account.name.equals(accountName));
+ if (found) {
+ SharedPreferences.Editor appPrefs = PreferenceManager.getDefaultSharedPreferences(context).edit();
+ appPrefs.putString(PREF_SELECT_OC_ACCOUNT, accountName);
+
+ // update credentials
+ Thread t = new Thread(() -> {
+ FileDataStorageManager storageManager = new FileDataStorageManager(account,
+ context.getContentResolver());
+ GetCapabilitiesOperarion getCapabilities = new GetCapabilitiesOperarion();
+ RemoteOperationResult updateResult = getCapabilities.execute(storageManager, context);
+ Log_OC.w(TAG, "Update Capabilities: " + updateResult.isSuccess());
+ });
+
+ t.start();
+
+ appPrefs.apply();
+ result = true;
+ break;
+ }
+ }
+ }
+ return result;
+ }
+
+ public static void resetOwnCloudAccount(Context context) {
+ SharedPreferences.Editor appPrefs = PreferenceManager.getDefaultSharedPreferences(context).edit();
+ appPrefs.putString(PREF_SELECT_OC_ACCOUNT, null);
+
+ appPrefs.apply();
+ }
+
+ /**
+ * Access the version of the OC server corresponding to an account SAVED IN THE ACCOUNTMANAGER
+ *
+ * @param account ownCloud account
+ * @return Version of the OC server corresponding to account, according to the data saved
+ * in the system AccountManager
+ */
+ public static @NonNull
+ OwnCloudVersion getServerVersion(Account account) {
+ OwnCloudVersion serverVersion = OwnCloudVersion.nextcloud_10;
+ if (account != null) {
+ AccountManager accountMgr = AccountManager.get(MainApp.getAppContext());
+ String serverVersionStr = accountMgr.getUserData(account, Constants.KEY_OC_VERSION);
+ if (serverVersionStr != null) {
+ serverVersion = new OwnCloudVersion(serverVersionStr);
+ }
+ }
+ return serverVersion;
+ }
+
+ public static boolean hasSearchSupport(Account account) {
+ return getServerVersion(account).isSearchSupported();
+ }
+}
diff --git a/src/main/java/com/owncloud/android/datamodel/ThumbnailsCacheManager.java b/src/main/java/com/owncloud/android/datamodel/ThumbnailsCacheManager.java
index 3f52d5098d..97bcfc76ce 100644
--- a/src/main/java/com/owncloud/android/datamodel/ThumbnailsCacheManager.java
+++ b/src/main/java/com/owncloud/android/datamodel/ThumbnailsCacheManager.java
@@ -46,7 +46,6 @@ import android.widget.ImageView;
import com.owncloud.android.MainApp;
import com.owncloud.android.R;
-import com.owncloud.android.authentication.AccountUtils;
import com.owncloud.android.lib.common.OwnCloudAccount;
import com.owncloud.android.lib.common.OwnCloudClient;
import com.owncloud.android.lib.common.OwnCloudClientManagerFactory;
@@ -54,7 +53,6 @@ import com.owncloud.android.lib.common.operations.RemoteOperation;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.lib.resources.files.ServerFileInterface;
import com.owncloud.android.lib.resources.files.TrashbinFile;
-import com.owncloud.android.lib.resources.status.OwnCloudVersion;
import com.owncloud.android.ui.TextDrawable;
import com.owncloud.android.ui.adapter.DiskLruImageCache;
import com.owncloud.android.ui.fragment.FileFragment;
@@ -286,45 +284,39 @@ public class ThumbnailsCacheManager {
} else {
// Download thumbnail from server
- OwnCloudVersion serverOCVersion = AccountUtils.getServerVersion(account);
-
if (mClient != null) {
- if (serverOCVersion.supportsRemoteThumbnails()) {
- GetMethod getMethod = null;
- try {
- String uri = mClient.getBaseUri() + "/index.php/core/preview.png?file="
- + URLEncoder.encode(file.getRemotePath())
- + "&x=" + pxW + "&y=" + pxH + "&a=1&mode=cover&forceIcon=0";
- getMethod = new GetMethod(uri);
+ GetMethod getMethod = null;
+ try {
+ String uri = mClient.getBaseUri() + "/index.php/core/preview.png?file="
+ + URLEncoder.encode(file.getRemotePath())
+ + "&x=" + pxW + "&y=" + pxH + "&a=1&mode=cover&forceIcon=0";
+ getMethod = new GetMethod(uri);
- int status = mClient.executeMethod(getMethod);
- if (status == HttpStatus.SC_OK) {
- InputStream inputStream = getMethod.getResponseBodyAsStream();
- thumbnail = BitmapFactory.decodeStream(inputStream);
- } else {
- mClient.exhaustResponse(getMethod.getResponseBodyAsStream());
- }
+ int status = mClient.executeMethod(getMethod);
+ if (status == HttpStatus.SC_OK) {
+ InputStream inputStream = getMethod.getResponseBodyAsStream();
+ thumbnail = BitmapFactory.decodeStream(inputStream);
+ } else {
+ mClient.exhaustResponse(getMethod.getResponseBodyAsStream());
+ }
// Handle PNG
if (thumbnail != null && file.getMimeType().equalsIgnoreCase(PNG_MIMETYPE)) {
thumbnail = handlePNG(thumbnail, thumbnail.getWidth(), thumbnail.getHeight());
}
- // Add thumbnail to cache
- if (thumbnail != null) {
- Log_OC.d(TAG, "add thumbnail to cache: " + file.getFileName());
- addBitmapToCache(imageKey, thumbnail);
- }
-
- } catch (Exception e) {
- Log_OC.d(TAG, e.getMessage(), e);
- } finally {
- if (getMethod != null) {
- getMethod.releaseConnection();
- }
+ // Add thumbnail to cache
+ if (thumbnail != null) {
+ Log_OC.d(TAG, "add thumbnail to cache: " + file.getFileName());
+ addBitmapToCache(imageKey, thumbnail);
+ }
+
+ } catch (Exception e) {
+ Log_OC.d(TAG, e.getMessage(), e);
+ } finally {
+ if (getMethod != null) {
+ getMethod.releaseConnection();
}
- } else {
- Log_OC.d(TAG, "Server too old");
}
}
}
@@ -548,7 +540,7 @@ public class ThumbnailsCacheManager {
thumbnail = ThumbnailUtils.extractThumbnail(resizedImage, pxW, pxH);
} else {
// Download thumbnail from server
- if (mClient != null && AccountUtils.getServerVersion(mAccount).supportsRemoteThumbnails()) {
+ if (mClient != null) {
getMethod = null;
try {
// thumbnail
@@ -589,8 +581,6 @@ public class ThumbnailsCacheManager {
getMethod.releaseConnection();
}
}
- } else {
- Log_OC.d(TAG, "Server too old");
}
}
@@ -603,7 +593,6 @@ public class ThumbnailsCacheManager {
}
return thumbnail;
-
}
/**
@@ -820,9 +809,9 @@ public class ThumbnailsCacheManager {
thumbnail = doAvatarInBackground();
- } catch(OutOfMemoryError oome) {
+ } catch (OutOfMemoryError oome) {
Log_OC.e(TAG, "Out of memory");
- } catch(Throwable t){
+ } catch (Throwable t) {
// the app should never break due to a problem with avatars
Log_OC.e(TAG, "Generation of avatar for " + mUserId + " failed", t);
}
@@ -843,6 +832,7 @@ public class ThumbnailsCacheManager {
/**
* Converts size of file icon from dp to pixel
+ *
* @return int
*/
private int getAvatarDimension() {
@@ -865,81 +855,77 @@ public class ThumbnailsCacheManager {
int px = getAvatarDimension();
// Download avatar from server
- OwnCloudVersion serverOCVersion = AccountUtils.getServerVersion(mAccount);
if (mClient != null) {
- if (serverOCVersion.supportsRemoteThumbnails()) {
- GetMethod get = null;
- try {
- String uri = mClient.getBaseUri() + "/index.php/avatar/" + Uri.encode(mUserId) + "/" + px;
- Log_OC.d("Avatar", "URI: " + uri);
- get = new GetMethod(uri);
+ GetMethod get = null;
+ try {
+ String uri = mClient.getBaseUri() + "/index.php/avatar/" + Uri.encode(mUserId) + "/" + px;
+ Log_OC.d("Avatar", "URI: " + uri);
+ get = new GetMethod(uri);
- // only use eTag if available and corresponding avatar is still there
- // (might be deleted from cache)
- if (!eTag.isEmpty() && getBitmapFromDiskCache(avatarKey) != null) {
- get.setRequestHeader("If-None-Match", eTag);
- }
-
- int status = mClient.executeMethod(get);
-
- // we are using eTag to download a new avatar only if it changed
- switch (status) {
- case HttpStatus.SC_OK:
- // new avatar
- InputStream inputStream = get.getResponseBodyAsStream();
-
- String newETag = null;
- if (get.getResponseHeader(ETAG) != null) {
- newETag = get.getResponseHeader(ETAG).getValue().replace("\"", "");
- arbitraryDataProvider.storeOrUpdateKeyValue(accountName, AVATAR, newETag);
- }
-
- Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
- avatar = ThumbnailUtils.extractThumbnail(bitmap, px, px);
-
- // Add avatar to cache
- if (avatar != null && !TextUtils.isEmpty(newETag)) {
- avatar = handlePNG(avatar, px, px);
- String newImageKey = "a_" + mUserId + "_" + mServerName + "_" + newETag;
- addBitmapToCache(newImageKey, avatar);
- } else {
- return TextDrawable.createAvatar(mAccount.name, mAvatarRadius);
- }
- break;
-
- case HttpStatus.SC_NOT_MODIFIED:
- // old avatar
- avatar = getBitmapFromDiskCache(avatarKey);
- mClient.exhaustResponse(get.getResponseBodyAsStream());
- break;
-
- default:
- // everything else
- mClient.exhaustResponse(get.getResponseBodyAsStream());
- break;
-
- }
- } catch (Exception e) {
- try {
- return TextDrawable.createAvatar(mAccount.name, mAvatarRadius);
- } catch (Exception e1) {
- Log_OC.e(TAG, "Error generating fallback avatar");
- }
- } finally {
- if (get != null) {
- get.releaseConnection();
- }
+ // only use eTag if available and corresponding avatar is still there
+ // (might be deleted from cache)
+ if (!eTag.isEmpty() && getBitmapFromDiskCache(avatarKey) != null) {
+ get.setRequestHeader("If-None-Match", eTag);
}
- } else {
- Log_OC.d(TAG, "Server too old");
+ int status = mClient.executeMethod(get);
+
+ // we are using eTag to download a new avatar only if it changed
+ switch (status) {
+ case HttpStatus.SC_OK:
+ // new avatar
+ InputStream inputStream = get.getResponseBodyAsStream();
+
+ String newETag = null;
+ if (get.getResponseHeader(ETAG) != null) {
+ newETag = get.getResponseHeader(ETAG).getValue().replace("\"", "");
+ arbitraryDataProvider.storeOrUpdateKeyValue(accountName, AVATAR, newETag);
+ }
+
+ Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
+ avatar = ThumbnailUtils.extractThumbnail(bitmap, px, px);
+
+ // Add avatar to cache
+ if (avatar != null && !TextUtils.isEmpty(newETag)) {
+ avatar = handlePNG(avatar, px, px);
+ String newImageKey = "a_" + mUserId + "_" + mServerName + "_" + newETag;
+ addBitmapToCache(newImageKey, avatar);
+ } else {
+ return TextDrawable.createAvatar(mAccount.name, mAvatarRadius);
+ }
+ break;
+
+ case HttpStatus.SC_NOT_MODIFIED:
+ // old avatar
+ avatar = getBitmapFromDiskCache(avatarKey);
+ mClient.exhaustResponse(get.getResponseBodyAsStream());
+ break;
+
+ default:
+ // everything else
+ mClient.exhaustResponse(get.getResponseBodyAsStream());
+ break;
+
+ }
+ } catch (Exception e) {
try {
return TextDrawable.createAvatar(mAccount.name, mAvatarRadius);
- } catch (Exception e) {
+ } catch (Exception e1) {
Log_OC.e(TAG, "Error generating fallback avatar");
}
+ } finally {
+ if (get != null) {
+ get.releaseConnection();
+ }
+ }
+
+ try {
+ return TextDrawable.createAvatar(mAccount.name, mAvatarRadius);
+ } catch (Exception e) {
+ Log_OC.e(TAG, "Error generating fallback avatar");
}
}
+
return BitmapUtils.bitmapToCircularBitmapDrawable(mResources, avatar);
}
}
@@ -1095,6 +1081,7 @@ public class ThumbnailsCacheManager {
return null;
}
+
public static class AsyncThumbnailDrawable extends BitmapDrawable {
private final WeakReference bitmapWorkerTaskReference;
diff --git a/src/main/java/com/owncloud/android/files/services/FileUploader.java b/src/main/java/com/owncloud/android/files/services/FileUploader.java
index 752177d93f..bcacb2cf1f 100644
--- a/src/main/java/com/owncloud/android/files/services/FileUploader.java
+++ b/src/main/java/com/owncloud/android/files/services/FileUploader.java
@@ -545,7 +545,6 @@ public class FileUploader extends Service
boolean retry = intent.getBooleanExtra(KEY_RETRY, false);
AbstractList requestedUploads = new Vector<>();
- boolean chunked = AccountUtils.getServerVersion(account).isChunkedUploadSupported();
boolean onWifiOnly = intent.getBooleanExtra(KEY_WHILE_ON_WIFI_ONLY, false);
boolean whileChargingOnly = intent.getBooleanExtra(KEY_WHILE_CHARGING_ONLY, false);
@@ -633,7 +632,6 @@ public class FileUploader extends Service
account,
files[i],
ocUpload,
- chunked,
forceOverwrite,
localAction,
this,
@@ -692,7 +690,6 @@ public class FileUploader extends Service
account,
null,
upload,
- chunked,
upload.isForceOverwrite(), // TODO should be read from DB?
upload.getLocalAction(), // TODO should be read from DB?
this,
diff --git a/src/main/java/com/owncloud/android/operations/CommentFileOperation.java b/src/main/java/com/owncloud/android/operations/CommentFileOperation.java
index 3a6f6758b4..0b48e2bbba 100644
--- a/src/main/java/com/owncloud/android/operations/CommentFileOperation.java
+++ b/src/main/java/com/owncloud/android/operations/CommentFileOperation.java
@@ -79,7 +79,7 @@ public class CommentFileOperation extends SyncOperation {
RemoteOperationResult result;
try {
- String url = client.getNewWebdavUri(false) + "/comments/files/" + fileId;
+ String url = client.getNewWebdavUri() + "/comments/files/" + fileId;
PostMethod postMethod = new PostMethod(url);
postMethod.addRequestHeader("Content-type", "application/json");
diff --git a/src/main/java/com/owncloud/android/operations/EmptyTrashbinFileOperation.java b/src/main/java/com/owncloud/android/operations/EmptyTrashbinFileOperation.java
index 845b62c7e0..25f5ad71f8 100644
--- a/src/main/java/com/owncloud/android/operations/EmptyTrashbinFileOperation.java
+++ b/src/main/java/com/owncloud/android/operations/EmptyTrashbinFileOperation.java
@@ -63,7 +63,7 @@ public class EmptyTrashbinFileOperation extends SyncOperation {
RemoteOperationResult result;
try {
- DeleteMethod delete = new DeleteMethod(client.getNewWebdavUri(false) + "/trashbin/" + userId + "/trash");
+ DeleteMethod delete = new DeleteMethod(client.getNewWebdavUri() + "/trashbin/" + userId + "/trash");
int status = client.executeMethod(delete, RESTORE_READ_TIMEOUT, RESTORE_CONNECTION_TIMEOUT);
result = new RemoteOperationResult(isSuccess(status), delete);
diff --git a/src/main/java/com/owncloud/android/operations/RefreshFolderOperation.java b/src/main/java/com/owncloud/android/operations/RefreshFolderOperation.java
index 760e3f459b..83477506f7 100644
--- a/src/main/java/com/owncloud/android/operations/RefreshFolderOperation.java
+++ b/src/main/java/com/owncloud/android/operations/RefreshFolderOperation.java
@@ -106,9 +106,6 @@ public class RefreshFolderOperation extends RemoteOperation {
*/
private boolean mSyncFullAccount;
- /** 'True' means that Share resources bound to the files into should be refreshed also */
- private boolean mIsShareSupported;
-
/** 'True' means that the remote folder changed and should be fetched */
private boolean mRemoteFolderChanged;
@@ -126,7 +123,6 @@ public class RefreshFolderOperation extends RemoteOperation {
* @param currentSyncTime Time stamp for the synchronization process in progress.
* @param syncFullAccount 'True' means that this operation is part of a full account
* synchronization.
- * @param isShareSupported 'True' means that the server supports the sharing API.
* @param ignoreETag 'True' means that the content of the remote folder should
* be fetched and updated even though the 'eTag' did not
* change.
@@ -137,7 +133,6 @@ public class RefreshFolderOperation extends RemoteOperation {
public RefreshFolderOperation(OCFile folder,
long currentSyncTime,
boolean syncFullAccount,
- boolean isShareSupported,
boolean ignoreETag,
FileDataStorageManager dataStorageManager,
Account account,
@@ -145,7 +140,6 @@ public class RefreshFolderOperation extends RemoteOperation {
mLocalFolder = folder;
mCurrentSyncTime = currentSyncTime;
mSyncFullAccount = syncFullAccount;
- mIsShareSupported = isShareSupported;
mStorageManager = dataStorageManager;
mAccount = account;
mContext = context;
@@ -219,7 +213,7 @@ public class RefreshFolderOperation extends RemoteOperation {
);
}
- if (result.isSuccess() && mIsShareSupported && !mSyncFullAccount) {
+ if (result.isSuccess() && !mSyncFullAccount) {
refreshSharesForFolder(client); // share result is ignored
}
@@ -237,14 +231,8 @@ public class RefreshFolderOperation extends RemoteOperation {
UpdateOCVersionOperation update = new UpdateOCVersionOperation(mAccount, mContext);
RemoteOperationResult result = update.execute(client);
if (result.isSuccess()) {
- mIsShareSupported = update.getOCVersion().isSharedSupported();
-
// Update Capabilities for this account
- if (update.getOCVersion().isVersionWithCapabilitiesAPI()) {
- updateCapabilities();
- } else {
- Log_OC.d(TAG, "Capabilities API disabled");
- }
+ updateCapabilities();
}
}
diff --git a/src/main/java/com/owncloud/android/operations/RestoreFileVersionOperation.java b/src/main/java/com/owncloud/android/operations/RestoreFileVersionOperation.java
index 86edbfd705..67970b3ad3 100644
--- a/src/main/java/com/owncloud/android/operations/RestoreFileVersionOperation.java
+++ b/src/main/java/com/owncloud/android/operations/RestoreFileVersionOperation.java
@@ -69,8 +69,8 @@ public class RestoreFileVersionOperation extends SyncOperation {
RemoteOperationResult result;
try {
- String source = client.getNewWebdavUri(false) + "/versions/" + userId + "/versions/" + fileId + "/" + fileName;
- String target = client.getNewWebdavUri(false) + "/versions/" + userId + "/restore/" + fileId;
+ String source = client.getNewWebdavUri() + "/versions/" + userId + "/versions/" + fileId + "/" + fileName;
+ String target = client.getNewWebdavUri() + "/versions/" + userId + "/restore/" + fileId;
MoveMethod move = new MoveMethod(source, target, true);
int status = client.executeMethod(move, RESTORE_READ_TIMEOUT, RESTORE_CONNECTION_TIMEOUT);
diff --git a/src/main/java/com/owncloud/android/operations/RestoreTrashbinFileOperation.java b/src/main/java/com/owncloud/android/operations/RestoreTrashbinFileOperation.java
index ef53e11097..d1affdfa82 100644
--- a/src/main/java/com/owncloud/android/operations/RestoreTrashbinFileOperation.java
+++ b/src/main/java/com/owncloud/android/operations/RestoreTrashbinFileOperation.java
@@ -70,8 +70,8 @@ public class RestoreTrashbinFileOperation extends SyncOperation {
RemoteOperationResult result;
try {
- String source = client.getNewWebdavUri(false) + WebdavUtils.encodePath(sourcePath);
- String target = client.getNewWebdavUri(false) + "/trashbin/" + userId + "/restore/" + fileName;
+ String source = client.getNewWebdavUri() + WebdavUtils.encodePath(sourcePath);
+ String target = client.getNewWebdavUri() + "/trashbin/" + userId + "/restore/" + fileName;
MoveMethod move = new MoveMethod(source, target, true);
int status = client.executeMethod(move, RESTORE_READ_TIMEOUT, RESTORE_CONNECTION_TIMEOUT);
diff --git a/src/main/java/com/owncloud/android/operations/UploadFileOperation.java b/src/main/java/com/owncloud/android/operations/UploadFileOperation.java
index b2a1b5b0b7..0850fbb48f 100644
--- a/src/main/java/com/owncloud/android/operations/UploadFileOperation.java
+++ b/src/main/java/com/owncloud/android/operations/UploadFileOperation.java
@@ -113,7 +113,6 @@ public class UploadFileOperation extends SyncOperation {
private OCFile mOldFile;
private String mRemotePath = null;
private String mFolderUnlockToken;
- private boolean mChunked = false;
private boolean mRemoteFolderToBeCreated = false;
private boolean mForceOverwrite = false;
private int mLocalBehaviour = FileUploader.LOCAL_BEHAVIOUR_COPY;
@@ -175,7 +174,6 @@ public class UploadFileOperation extends SyncOperation {
public UploadFileOperation(Account account,
OCFile file,
OCUpload upload,
- boolean chunked,
boolean forceOverwrite,
int localBehaviour,
Context context,
@@ -208,7 +206,6 @@ public class UploadFileOperation extends SyncOperation {
mOnWifiOnly = onWifiOnly;
mWhileChargingOnly = whileChargingOnly;
mRemotePath = upload.getRemotePath();
- mChunked = chunked;
mForceOverwrite = forceOverwrite;
mLocalBehaviour = localBehaviour;
mOriginalStoragePath = mFile.getStoragePath();
@@ -342,10 +339,6 @@ public class UploadFileOperation extends SyncOperation {
mRenameUploadListener = listener;
}
- public boolean isChunkedUploadSupported() {
- return mChunked;
- }
-
public Context getContext() {
return mContext;
}
@@ -579,7 +572,7 @@ public class UploadFileOperation extends SyncOperation {
}
/// perform the upload
- if (mChunked && (size > ChunkedUploadRemoteFileOperation.CHUNK_SIZE)) {
+ if (size > ChunkedUploadRemoteFileOperation.CHUNK_SIZE) {
mUploadOperation = new ChunkedUploadRemoteFileOperation(mContext, encryptedTempFile.getAbsolutePath(),
mFile.getParentRemotePath() + encryptedFileName, mFile.getMimeType(),
mFile.getEtagInConflict(), timeStamp);
@@ -820,7 +813,7 @@ public class UploadFileOperation extends SyncOperation {
}
// perform the upload
- if (mChunked && (size > ChunkedUploadRemoteFileOperation.CHUNK_SIZE)) {
+ if (size > ChunkedUploadRemoteFileOperation.CHUNK_SIZE) {
mUploadOperation = new ChunkedUploadRemoteFileOperation(mContext, mFile.getStoragePath(),
mFile.getRemotePath(), mFile.getMimeType(), mFile.getEtagInConflict(), timeStamp);
} else {
diff --git a/src/main/java/com/owncloud/android/syncadapter/FileSyncAdapter.java b/src/main/java/com/owncloud/android/syncadapter/FileSyncAdapter.java
index 5403d92bd8..9f3b724e5b 100644
--- a/src/main/java/com/owncloud/android/syncadapter/FileSyncAdapter.java
+++ b/src/main/java/com/owncloud/android/syncadapter/FileSyncAdapter.java
@@ -112,10 +112,6 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
/** {@link SyncResult} instance to return to the system when the synchronization finish */
private SyncResult mSyncResult;
- /** 'True' means that the server supports the share API */
- private boolean mIsShareSupported;
-
-
/**
* Creates a {@link FileSyncAdapter}
*
@@ -238,8 +234,6 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
RemoteOperationResult result = update.execute(getClient());
if (!result.isSuccess()) {
mLastFailedResult = result;
- } else {
- mIsShareSupported = update.getOCVersion().isSharedSupported();
}
}
@@ -265,7 +259,6 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
RefreshFolderOperation synchFolderOp = new RefreshFolderOperation( folder,
mCurrentSyncTime,
true,
- mIsShareSupported,
false,
getStorageManager(),
getAccount(),
diff --git a/src/main/java/com/owncloud/android/ui/activities/ActivitiesActivity.java b/src/main/java/com/owncloud/android/ui/activities/ActivitiesActivity.java
index dad3d46f8b..9b952ae16e 100644
--- a/src/main/java/com/owncloud/android/ui/activities/ActivitiesActivity.java
+++ b/src/main/java/com/owncloud/android/ui/activities/ActivitiesActivity.java
@@ -235,8 +235,7 @@ public class ActivitiesActivity extends FileActivity implements ActivityListInte
@Override
public void onActivityClicked(RichObject richObject) {
String path = FileUtils.PATH_SEPARATOR + richObject.getPath();
- mActionListener.openActivity(path, this,
- getFileOperationsHelper().isSharedSupported());
+ mActionListener.openActivity(path, this);
}
@Override
diff --git a/src/main/java/com/owncloud/android/ui/activities/ActivitiesContract.java b/src/main/java/com/owncloud/android/ui/activities/ActivitiesContract.java
index df67d98f7b..4067f838ee 100644
--- a/src/main/java/com/owncloud/android/ui/activities/ActivitiesContract.java
+++ b/src/main/java/com/owncloud/android/ui/activities/ActivitiesContract.java
@@ -39,7 +39,8 @@ public interface ActivitiesContract {
interface ActionListener {
void loadActivities(String pageUrl);
- void openActivity(String fileUrl, BaseActivity baseActivity, boolean isSharingSupported);
+
+ void openActivity(String fileUrl, BaseActivity baseActivity);
void stopLoadingActivity();
}
diff --git a/src/main/java/com/owncloud/android/ui/activities/ActivitiesPresenter.java b/src/main/java/com/owncloud/android/ui/activities/ActivitiesPresenter.java
index 7c6a3e913e..404fdbd57d 100644
--- a/src/main/java/com/owncloud/android/ui/activities/ActivitiesPresenter.java
+++ b/src/main/java/com/owncloud/android/ui/activities/ActivitiesPresenter.java
@@ -71,10 +71,9 @@ public class ActivitiesPresenter implements ActivitiesContract.ActionListener {
}
@Override
- public void openActivity(String fileUrl, BaseActivity baseActivity, boolean isSharingSupported) {
+ public void openActivity(String fileUrl, BaseActivity baseActivity) {
activitiesView.setProgressIndicatorState(true);
- filesRepository.readRemoteFile(fileUrl, baseActivity, isSharingSupported,
- new FilesRepository.ReadRemoteFileCallback() {
+ filesRepository.readRemoteFile(fileUrl, baseActivity, new FilesRepository.ReadRemoteFileCallback() {
@Override
public void onFileLoaded(@Nullable OCFile ocFile) {
activitiesView.setProgressIndicatorState(false);
diff --git a/src/main/java/com/owncloud/android/ui/activities/data/files/FilesRepository.java b/src/main/java/com/owncloud/android/ui/activities/data/files/FilesRepository.java
index 106007f1ea..612c81133f 100644
--- a/src/main/java/com/owncloud/android/ui/activities/data/files/FilesRepository.java
+++ b/src/main/java/com/owncloud/android/ui/activities/data/files/FilesRepository.java
@@ -33,6 +33,5 @@ public interface FilesRepository {
void onFileLoadError(String error);
}
- void readRemoteFile(String path, BaseActivity activity, boolean isSharingSupported,
- @NonNull ReadRemoteFileCallback callback);
+ void readRemoteFile(String path, BaseActivity activity, @NonNull ReadRemoteFileCallback callback);
}
diff --git a/src/main/java/com/owncloud/android/ui/activities/data/files/FilesServiceApi.java b/src/main/java/com/owncloud/android/ui/activities/data/files/FilesServiceApi.java
index 08c43561ee..b78bf44dd9 100644
--- a/src/main/java/com/owncloud/android/ui/activities/data/files/FilesServiceApi.java
+++ b/src/main/java/com/owncloud/android/ui/activities/data/files/FilesServiceApi.java
@@ -32,6 +32,5 @@ public interface FilesServiceApi {
void onError(String error);
}
- void readRemoteFile(String fileUrl, BaseActivity activity, boolean isSharingSupported,
- FilesServiceApi.FilesServiceCallback callback);
+ void readRemoteFile(String fileUrl, BaseActivity activity, FilesServiceApi.FilesServiceCallback callback);
}
diff --git a/src/main/java/com/owncloud/android/ui/activities/data/files/FilesServiceApiImpl.java b/src/main/java/com/owncloud/android/ui/activities/data/files/FilesServiceApiImpl.java
index 8c4425eebc..773eaaaa7d 100644
--- a/src/main/java/com/owncloud/android/ui/activities/data/files/FilesServiceApiImpl.java
+++ b/src/main/java/com/owncloud/android/ui/activities/data/files/FilesServiceApiImpl.java
@@ -49,10 +49,8 @@ public class FilesServiceApiImpl implements FilesServiceApi {
private static final String TAG = FilesServiceApiImpl.class.getSimpleName();
@Override
- public void readRemoteFile(String fileUrl, BaseActivity activity,
- boolean isSharingSupported, FilesServiceCallback callback) {
- ReadRemoteFileTask readRemoteFileTask = new ReadRemoteFileTask(fileUrl, activity,
- isSharingSupported, callback);
+ public void readRemoteFile(String fileUrl, BaseActivity activity, FilesServiceCallback callback) {
+ ReadRemoteFileTask readRemoteFileTask = new ReadRemoteFileTask(fileUrl, activity, callback);
readRemoteFileTask.execute();
}
@@ -62,15 +60,11 @@ public class FilesServiceApiImpl implements FilesServiceApi {
private String errorMessage;
// TODO: Figure out a better way to do this than passing a BaseActivity reference.
private final BaseActivity baseActivity;
- private final boolean isSharingSupported;
private final String fileUrl;
- private ReadRemoteFileTask(String fileUrl, BaseActivity baseActivity,
- boolean isSharingSupported,
- FilesServiceCallback callback) {
+ private ReadRemoteFileTask(String fileUrl, BaseActivity baseActivity, FilesServiceCallback callback) {
this.callback = callback;
this.baseActivity = baseActivity;
- this.isSharingSupported = isSharingSupported;
this.fileUrl = fileUrl;
}
@@ -97,7 +91,6 @@ public class FilesServiceApiImpl implements FilesServiceApi {
RemoteOperation synchFolderOp = new RefreshFolderOperation(remoteOcFile,
System.currentTimeMillis(),
false,
- isSharingSupported,
true,
baseActivity.getStorageManager(),
baseActivity.getAccount(),
diff --git a/src/main/java/com/owncloud/android/ui/activities/data/files/RemoteFilesRepository.java b/src/main/java/com/owncloud/android/ui/activities/data/files/RemoteFilesRepository.java
index e603dc480c..11bb170e61 100644
--- a/src/main/java/com/owncloud/android/ui/activities/data/files/RemoteFilesRepository.java
+++ b/src/main/java/com/owncloud/android/ui/activities/data/files/RemoteFilesRepository.java
@@ -33,9 +33,8 @@ class RemoteFilesRepository implements FilesRepository {
@Override
- public void readRemoteFile(String path, BaseActivity activity, boolean isSharingSupported, @NonNull ReadRemoteFileCallback callback) {
- filesServiceApi.readRemoteFile(path, activity, isSharingSupported,
- new FilesServiceApi.FilesServiceCallback() {
+ public void readRemoteFile(String path, BaseActivity activity, @NonNull ReadRemoteFileCallback callback) {
+ filesServiceApi.readRemoteFile(path, activity, new FilesServiceApi.FilesServiceCallback() {
@Override
public void onLoaded(OCFile ocFile) {
callback.onFileLoaded(ocFile);
diff --git a/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java b/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java
index 53d699424b..247645e575 100644
--- a/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java
+++ b/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java
@@ -581,14 +581,8 @@ public class FileDisplayActivity extends HookActivity
return OCShare.READ_PERMISSION_FLAG; // minimum permissions
} else if (isFederated) {
- if (com.owncloud.android.authentication.AccountUtils
- .getServerVersion(getAccount()).isNotReshareableFederatedSupported()) {
- return (getFile().isFolder() ? OCShare.FEDERATED_PERMISSIONS_FOR_FOLDER_AFTER_OC9 :
- OCShare.FEDERATED_PERMISSIONS_FOR_FILE_AFTER_OC9);
- } else {
- return (getFile().isFolder() ? OCShare.FEDERATED_PERMISSIONS_FOR_FOLDER_UP_TO_OC9 :
- OCShare.FEDERATED_PERMISSIONS_FOR_FILE_UP_TO_OC9);
- }
+ return (getFile().isFolder() ? OCShare.FEDERATED_PERMISSIONS_FOR_FOLDER_AFTER_OC9 :
+ OCShare.FEDERATED_PERMISSIONS_FOR_FILE_AFTER_OC9);
} else {
return (getFile().isFolder() ? OCShare.MAXIMUM_PERMISSIONS_FOR_FOLDER :
OCShare.MAXIMUM_PERMISSIONS_FOR_FILE);
@@ -2201,7 +2195,6 @@ public class FileDisplayActivity extends HookActivity
RemoteOperation synchFolderOp = new RefreshFolderOperation(folder,
currentSyncTime,
false,
- getFileOperationsHelper().isSharedSupported(),
ignoreETag,
getStorageManager(),
getAccount(),
diff --git a/src/main/java/com/owncloud/android/ui/activity/FolderPickerActivity.java b/src/main/java/com/owncloud/android/ui/activity/FolderPickerActivity.java
index 04f61dfa31..3d737d3c48 100644
--- a/src/main/java/com/owncloud/android/ui/activity/FolderPickerActivity.java
+++ b/src/main/java/com/owncloud/android/ui/activity/FolderPickerActivity.java
@@ -250,8 +250,7 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
// perform folder synchronization
RemoteOperation refreshFolderOperation = new RefreshFolderOperation(folder, currentSyncTime, false,
- getFileOperationsHelper().isSharedSupported(), ignoreETag, getStorageManager(), getAccount(),
- getApplicationContext());
+ ignoreETag, getStorageManager(), getAccount(), getApplicationContext());
refreshFolderOperation.execute(getAccount(), this, null, null);
setIndeterminate(true);
diff --git a/src/main/java/com/owncloud/android/ui/activity/ReceiveExternalFilesActivity.java b/src/main/java/com/owncloud/android/ui/activity/ReceiveExternalFilesActivity.java
index e131d50dfa..a975c463e2 100755
--- a/src/main/java/com/owncloud/android/ui/activity/ReceiveExternalFilesActivity.java
+++ b/src/main/java/com/owncloud/android/ui/activity/ReceiveExternalFilesActivity.java
@@ -835,7 +835,6 @@ public class ReceiveExternalFilesActivity extends FileActivity
currentSyncTime,
false,
false,
- false,
getStorageManager(),
getAccount(),
getApplicationContext()
diff --git a/src/main/java/com/owncloud/android/ui/activity/ShareActivity.java b/src/main/java/com/owncloud/android/ui/activity/ShareActivity.java
index 90205ecd15..24883ad05a 100644
--- a/src/main/java/com/owncloud/android/ui/activity/ShareActivity.java
+++ b/src/main/java/com/owncloud/android/ui/activity/ShareActivity.java
@@ -148,14 +148,8 @@ public class ShareActivity extends FileActivity implements ShareFragmentListener
return OCShare.READ_PERMISSION_FLAG; // minimum permissions
} else if (isFederated) {
- if (com.owncloud.android.authentication.AccountUtils
- .getServerVersion(getAccount()).isNotReshareableFederatedSupported()) {
return (getFile().isFolder() ? OCShare.FEDERATED_PERMISSIONS_FOR_FOLDER_AFTER_OC9 :
OCShare.FEDERATED_PERMISSIONS_FOR_FILE_AFTER_OC9);
- } else {
- return (getFile().isFolder() ? OCShare.FEDERATED_PERMISSIONS_FOR_FOLDER_UP_TO_OC9 :
- OCShare.FEDERATED_PERMISSIONS_FOR_FILE_UP_TO_OC9);
- }
} else {
return (getFile().isFolder() ? OCShare.MAXIMUM_PERMISSIONS_FOR_FOLDER :
OCShare.MAXIMUM_PERMISSIONS_FOR_FILE);
diff --git a/src/main/java/com/owncloud/android/ui/adapter/OCFileListAdapter.java b/src/main/java/com/owncloud/android/ui/adapter/OCFileListAdapter.java
index bed440e905..3294e67f8c 100644
--- a/src/main/java/com/owncloud/android/ui/adapter/OCFileListAdapter.java
+++ b/src/main/java/com/owncloud/android/ui/adapter/OCFileListAdapter.java
@@ -30,6 +30,7 @@ import android.graphics.Bitmap;
import android.graphics.Color;
import android.os.Handler;
import android.os.Looper;
+import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.LayoutInflater;
@@ -89,7 +90,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter mFiles = new ArrayList<>();
private List mFilesAll = new ArrayList<>();
private boolean mHideItemOptions;
- private boolean gridView = false;
+ private boolean gridView;
private boolean multiSelect = false;
private HashSet checkedFiles;
@@ -218,8 +219,9 @@ public class OCFileListAdapter extends RecyclerView.Adapter 0;
switchCompat.setChecked(canEdit);
- boolean areEditOptionsAvailable = !isFederated || isNotReshareableFederatedSupported;
+ boolean areEditOptionsAvailable = !isFederated;
if (mFile.isFolder() && areEditOptionsAvailable) {
/// TODO change areEditOptionsAvailable in order to delete !isFederated
diff --git a/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java b/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java
index b7dd2151be..3fb7d5c1e0 100644
--- a/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java
+++ b/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java
@@ -1080,12 +1080,10 @@ public class OCFileListFragment extends ExtendedListFragment implements
private void updateLayout() {
// decide grid vs list view
- if (AccountUtils.getServerVersion(((FileActivity) mContainerActivity).getAccount())
- .supportsRemoteThumbnails() && isGridViewPreferred(mFile)) {
+ if (isGridViewPreferred(mFile)) {
switchToGridView();
} else {
switchToListView();
-
}
invalidateActionMode();
diff --git a/src/main/java/com/owncloud/android/ui/fragment/ShareFileFragment.java b/src/main/java/com/owncloud/android/ui/fragment/ShareFileFragment.java
index ee1ded900a..441f704eed 100644
--- a/src/main/java/com/owncloud/android/ui/fragment/ShareFileFragment.java
+++ b/src/main/java/com/owncloud/android/ui/fragment/ShareFileFragment.java
@@ -47,7 +47,6 @@ import android.widget.ScrollView;
import android.widget.TextView;
import com.owncloud.android.R;
-import com.owncloud.android.authentication.AccountUtils;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.datamodel.ThumbnailsCacheManager;
import com.owncloud.android.lib.common.utils.Log_OC;
@@ -227,17 +226,8 @@ public class ShareFileFragment extends Fragment implements ShareUserListAdapter.
addUserGroupButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
- boolean shareWithUsersEnable = AccountUtils.hasSearchUsersSupport(mAccount);
- if (shareWithUsersEnable) {
- // Show Search Fragment
- mListener.showSearchUsersAndGroups();
- } else {
- Snackbar.make(
- getActivity().findViewById(android.R.id.content),
- getString(R.string.share_sharee_unavailable),
- Snackbar.LENGTH_LONG
- ).show();
- }
+ // Show Search Fragment
+ mListener.showSearchUsersAndGroups();
}
});
diff --git a/src/main/java/com/owncloud/android/ui/fragment/contactsbackup/ContactsBackupFragment.java b/src/main/java/com/owncloud/android/ui/fragment/contactsbackup/ContactsBackupFragment.java
index fb2412400f..3a7cf36d8e 100644
--- a/src/main/java/com/owncloud/android/ui/fragment/contactsbackup/ContactsBackupFragment.java
+++ b/src/main/java/com/owncloud/android/ui/fragment/contactsbackup/ContactsBackupFragment.java
@@ -225,7 +225,7 @@ public class ContactsBackupFragment extends FileFragment implements DatePickerDi
if (folder != null) {
RefreshFolderOperation operation = new RefreshFolderOperation(folder, System.currentTimeMillis(),
- false, false, false, storageManager, account, getContext());
+ false, false, storageManager, account, getContext());
RemoteOperationResult result = operation.execute(account, getContext());
return result.isSuccess();
diff --git a/src/main/java/com/owncloud/android/ui/helpers/FileOperationsHelper.java b/src/main/java/com/owncloud/android/ui/helpers/FileOperationsHelper.java
index db11347db0..740df96da5 100755
--- a/src/main/java/com/owncloud/android/ui/helpers/FileOperationsHelper.java
+++ b/src/main/java/com/owncloud/android/ui/helpers/FileOperationsHelper.java
@@ -57,7 +57,6 @@ import com.owncloud.android.lib.resources.files.FileVersion;
import com.owncloud.android.lib.resources.shares.OCShare;
import com.owncloud.android.lib.resources.shares.ShareType;
import com.owncloud.android.lib.resources.status.OCCapability;
-import com.owncloud.android.lib.resources.status.OwnCloudVersion;
import com.owncloud.android.operations.SynchronizeFileOperation;
import com.owncloud.android.services.OperationsService;
import com.owncloud.android.ui.activity.ConflictsResolveActivity;
@@ -356,47 +355,36 @@ public class FileOperationsHelper {
* @param password Optional password to protect the public share.
*/
public void shareFileViaLink(OCFile file, String password) {
- if (isSharedSupported()) {
- if (file != null) {
- mFileActivity.showLoadingDialog(mFileActivity.getString(R.string.wait_a_moment));
- Intent service = new Intent(mFileActivity, OperationsService.class);
- service.setAction(OperationsService.ACTION_CREATE_SHARE_VIA_LINK);
- service.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
- if (password != null && password.length() > 0) {
- service.putExtra(OperationsService.EXTRA_SHARE_PASSWORD, password);
- }
- service.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
- mWaitingForOpId = mFileActivity.getOperationsServiceBinder().queueNewOperation(service);
-
- } else {
- Log_OC.e(TAG, "Trying to share a NULL OCFile");
- // TODO user-level error?
+ if (file != null) {
+ mFileActivity.showLoadingDialog(mFileActivity.getString(R.string.wait_a_moment));
+ Intent service = new Intent(mFileActivity, OperationsService.class);
+ service.setAction(OperationsService.ACTION_CREATE_SHARE_VIA_LINK);
+ service.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
+ if (password != null && password.length() > 0) {
+ service.putExtra(OperationsService.EXTRA_SHARE_PASSWORD, password);
}
+ service.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
+ mWaitingForOpId = mFileActivity.getOperationsServiceBinder().queueNewOperation(service);
} else {
- // Show a Message
- DisplayUtils.showSnackMessage(mFileActivity, R.string.share_link_no_support_share_api);
+ Log_OC.e(TAG, "Trying to share a NULL OCFile");
+ // TODO user-level error?
}
}
public void getFileWithLink(OCFile file) {
- if (isSharedSupported()) {
- if (file != null) {
- mFileActivity.showLoadingDialog(mFileActivity.getApplicationContext().
- getString(R.string.wait_a_moment));
+ if (file != null) {
+ mFileActivity.showLoadingDialog(mFileActivity.getApplicationContext().
+ getString(R.string.wait_a_moment));
- Intent service = new Intent(mFileActivity, OperationsService.class);
- service.setAction(OperationsService.ACTION_CREATE_SHARE_VIA_LINK);
- service.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
- service.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
- mWaitingForOpId = mFileActivity.getOperationsServiceBinder().queueNewOperation(service);
+ Intent service = new Intent(mFileActivity, OperationsService.class);
+ service.setAction(OperationsService.ACTION_CREATE_SHARE_VIA_LINK);
+ service.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
+ service.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
+ mWaitingForOpId = mFileActivity.getOperationsServiceBinder().queueNewOperation(service);
- } else {
- Log_OC.e(TAG, "Trying to share a NULL OCFile");
- }
} else {
- // Show a Message
- DisplayUtils.showSnackMessage(mFileActivity, R.string.share_link_no_support_share_api);
+ Log_OC.e(TAG, "Trying to share a NULL OCFile");
}
}
@@ -450,16 +438,6 @@ public class FileOperationsHelper {
}
}
-
- /**
- * @return 'True' if the server supports the Share API
- */
- public boolean isSharedSupported() {
- return mFileActivity.getAccount() != null &&
- AccountUtils.getServerVersion(mFileActivity.getAccount()).isSharedSupported();
- }
-
-
/**
* Helper method to unshare a file publicly shared via link.
* Starts a request to do it in {@link OperationsService}
@@ -492,19 +470,11 @@ public class FileOperationsHelper {
queueShareIntent(unshareService);
}
-
private void queueShareIntent(Intent shareIntent) {
- if (isSharedSupported()) {
- // Unshare the file
- mWaitingForOpId = mFileActivity.getOperationsServiceBinder().queueNewOperation(shareIntent);
+ // Unshare the file
+ mWaitingForOpId = mFileActivity.getOperationsServiceBinder().queueNewOperation(shareIntent);
- mFileActivity.showLoadingDialog(mFileActivity.getApplicationContext().
- getString(R.string.wait_a_moment));
-
- } else {
- // Show a Message
- DisplayUtils.showSnackMessage(mFileActivity, R.string.share_link_no_support_share_api);
- }
+ mFileActivity.showLoadingDialog(mFileActivity.getApplicationContext().getString(R.string.wait_a_moment));
}
/**
@@ -661,29 +631,13 @@ public class FileOperationsHelper {
if (hideFileListing) {
updateShareIntent.putExtra(OperationsService.EXTRA_SHARE_PERMISSIONS, OCShare.CREATE_PERMISSION_FLAG);
} else {
- if (AccountUtils.getServerVersion(mFileActivity.getAccount()).isNotReshareableFederatedSupported()) {
- updateShareIntent.putExtra(OperationsService.EXTRA_SHARE_PERMISSIONS,
- OCShare.FEDERATED_PERMISSIONS_FOR_FOLDER_AFTER_OC9);
- } else {
- updateShareIntent.putExtra(OperationsService.EXTRA_SHARE_PERMISSIONS,
- OCShare.FEDERATED_PERMISSIONS_FOR_FOLDER_UP_TO_OC9);
- }
+ updateShareIntent.putExtra(OperationsService.EXTRA_SHARE_PERMISSIONS,
+ OCShare.FEDERATED_PERMISSIONS_FOR_FOLDER_AFTER_OC9);
}
queueShareIntent(updateShareIntent);
}
- /**
- * @return 'True' if the server supports the Search Users API
- */
- public boolean isSearchUserSupportedSupported() {
- if (mFileActivity.getAccount() != null) {
- OwnCloudVersion serverVersion = AccountUtils.getServerVersion(mFileActivity.getAccount());
- return serverVersion.isSearchUsersSupported();
- }
- return false;
- }
-
public void sendShareFile(OCFile file, boolean hideNcSharingOptions) {
// Show dialog
FragmentManager fm = mFileActivity.getSupportFragmentManager();
@@ -970,14 +924,6 @@ public class FileOperationsHelper {
mWaitingForOpId = waitingForOpId;
}
- /**
- * @return 'True' if the server doesn't need to check forbidden characters
- */
- public boolean isVersionWithForbiddenCharacters() {
- return mFileActivity.getAccount() != null &&
- AccountUtils.getServerVersion(mFileActivity.getAccount()).isVersionWithForbiddenCharacters();
- }
-
/**
* Starts a check of the currently stored credentials for the given account.
*
diff --git a/src/main/java/com/owncloud/android/utils/glide/HttpStreamFetcher.java b/src/main/java/com/owncloud/android/utils/glide/HttpStreamFetcher.java
index bfe7806ec4..08ceb71e70 100644
--- a/src/main/java/com/owncloud/android/utils/glide/HttpStreamFetcher.java
+++ b/src/main/java/com/owncloud/android/utils/glide/HttpStreamFetcher.java
@@ -59,23 +59,19 @@ public class HttpStreamFetcher implements DataFetcher {
getClientFor(ocAccount, MainApp.getAppContext());
if (mClient != null) {
- if (AccountUtils.getServerVersion(mAccount).supportsRemoteThumbnails()) {
- GetMethod get = null;
- try {
- get = new GetMethod(mURL);
- get.setRequestHeader("Cookie", "nc_sameSiteCookielax=true;nc_sameSiteCookiestrict=true");
- get.setRequestHeader(RemoteOperation.OCS_API_HEADER, RemoteOperation.OCS_API_HEADER_VALUE);
- int status = mClient.executeMethod(get);
- if (status == HttpStatus.SC_OK) {
- return get.getResponseBodyAsStream();
- } else {
- mClient.exhaustResponse(get.getResponseBodyAsStream());
- }
- } catch (Exception e) {
- Log_OC.d(TAG, e.getMessage(), e);
+ GetMethod get;
+ try {
+ get = new GetMethod(mURL);
+ get.setRequestHeader("Cookie", "nc_sameSiteCookielax=true;nc_sameSiteCookiestrict=true");
+ get.setRequestHeader(RemoteOperation.OCS_API_HEADER, RemoteOperation.OCS_API_HEADER_VALUE);
+ int status = mClient.executeMethod(get);
+ if (status == HttpStatus.SC_OK) {
+ return get.getResponseBodyAsStream();
+ } else {
+ mClient.exhaustResponse(get.getResponseBodyAsStream());
}
- } else {
- Log_OC.d(TAG, "Server too old");
+ } catch (Exception e) {
+ Log_OC.e(TAG, e.getMessage(), e);
}
}
return null;
diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml
index cc08469fe1..9d850c1607 100644
--- a/src/main/res/values/strings.xml
+++ b/src/main/res/values/strings.xml
@@ -359,7 +359,6 @@
Use subfolders
Store in subfolders based on year and month
- Sharing is not enabled on your server. Please contact your admin
Unable to share. Please check whether the file exists
An error occurred while trying to share this file or folder
Unable to unshare. Please check whether the file exists
diff --git a/src/test/java/com/owncloud/android/ui/activities/ActivitiesPresenterTest.java b/src/test/java/com/owncloud/android/ui/activities/ActivitiesPresenterTest.java
index 84bfeb1506..18d51a702f 100644
--- a/src/test/java/com/owncloud/android/ui/activities/ActivitiesPresenterTest.java
+++ b/src/test/java/com/owncloud/android/ui/activities/ActivitiesPresenterTest.java
@@ -1,4 +1,4 @@
-/**
+/*
* Nextcloud Android client application
*
* Copyright (C) 2018 Edvard Holst
@@ -114,11 +114,11 @@ public class ActivitiesPresenterTest {
@Test
public void loadRemoteFileFromRepositoryShowDetailUI() {
// When retrieving remote file from repository...
- mPresenter.openActivity("null", mBaseActivity, true);
+ mPresenter.openActivity("null", mBaseActivity);
// Progress indicator is shown in view
verify(mView).setProgressIndicatorState(eq(true));
// Repository retrieves remote file
- verify(mFileRepository).readRemoteFile(eq("null"), eq(mBaseActivity), eq(true),
+ verify(mFileRepository).readRemoteFile(eq("null"), eq(mBaseActivity),
mReadRemoteFilleCallbackCaptor.capture());
// Repository returns valid file object
mReadRemoteFilleCallbackCaptor.getValue().onFileLoaded(mOCFile);
@@ -131,11 +131,11 @@ public class ActivitiesPresenterTest {
@Test
public void loadRemoteFileFromRepositoryShowEmptyFile() {
// When retrieving remote file from repository...
- mPresenter.openActivity("null", mBaseActivity, true);
+ mPresenter.openActivity("null", mBaseActivity);
// Progress indicator is shown in view
verify(mView).setProgressIndicatorState(eq(true));
// Repository retrieves remote file
- verify(mFileRepository).readRemoteFile(eq("null"), eq(mBaseActivity), eq(true),
+ verify(mFileRepository).readRemoteFile(eq("null"), eq(mBaseActivity),
mReadRemoteFilleCallbackCaptor.capture());
// Repository returns an valid but Null value file object.
mReadRemoteFilleCallbackCaptor.getValue().onFileLoaded(null);
@@ -148,11 +148,11 @@ public class ActivitiesPresenterTest {
@Test
public void loadRemoteFileFromRepositoryShowError() {
// When retrieving remote file from repository...
- mPresenter.openActivity("null", mBaseActivity, true);
+ mPresenter.openActivity("null", mBaseActivity);
// Progress indicator is shown in view
verify(mView).setProgressIndicatorState(eq(true));
// Repository retrieves remote file
- verify(mFileRepository).readRemoteFile(eq("null"), eq(mBaseActivity), eq(true),
+ verify(mFileRepository).readRemoteFile(eq("null"), eq(mBaseActivity),
mReadRemoteFilleCallbackCaptor.capture());
// Repository returns valid file object
mReadRemoteFilleCallbackCaptor.getValue().onFileLoadError("error");
diff --git a/src/test/java/com/owncloud/android/ui/activities/data/files/RemoteFilesRepositoryTest.java b/src/test/java/com/owncloud/android/ui/activities/data/files/RemoteFilesRepositoryTest.java
index 3765f4c6bf..6e618a9127 100644
--- a/src/test/java/com/owncloud/android/ui/activities/data/files/RemoteFilesRepositoryTest.java
+++ b/src/test/java/com/owncloud/android/ui/activities/data/files/RemoteFilesRepositoryTest.java
@@ -1,4 +1,4 @@
-/**
+/*
* Nextcloud Android client application
*
* Copyright (C) 2018 Edvard Holst
@@ -57,20 +57,16 @@ public class RemoteFilesRepositoryTest {
@Test
public void readRemoteFileReturnSuccess() {
- mFilesRepository.readRemoteFile("path", baseActivity, true,
- mockedReadRemoteFileCallback);
- verify(serviceApi).readRemoteFile(eq("path"), eq(baseActivity), eq(true),
- filesServiceCallbackCaptor.capture());
+ mFilesRepository.readRemoteFile("path", baseActivity, mockedReadRemoteFileCallback);
+ verify(serviceApi).readRemoteFile(eq("path"), eq(baseActivity), filesServiceCallbackCaptor.capture());
filesServiceCallbackCaptor.getValue().onLoaded(mOCFile);
verify(mockedReadRemoteFileCallback).onFileLoaded(eq(mOCFile));
}
@Test
public void readRemoteFileReturnError() {
- mFilesRepository.readRemoteFile("path", baseActivity, true,
- mockedReadRemoteFileCallback);
- verify(serviceApi).readRemoteFile(eq("path"), eq(baseActivity), eq(true),
- filesServiceCallbackCaptor.capture());
+ mFilesRepository.readRemoteFile("path", baseActivity, mockedReadRemoteFileCallback);
+ verify(serviceApi).readRemoteFile(eq("path"), eq(baseActivity), filesServiceCallbackCaptor.capture());
filesServiceCallbackCaptor.getValue().onError("error");
verify(mockedReadRemoteFileCallback).onFileLoadError(eq("error"));
}