From a3e59c4352ffd0c416eb380525f5e8527bf01f8e Mon Sep 17 00:00:00 2001 From: tobiasKaminsky Date: Thu, 15 Feb 2018 07:24:22 +0100 Subject: [PATCH 01/12] remove check for older version (<11) Signed-off-by: tobiasKaminsky --- build.gradle | 6 +- .../android/authentication/AccountUtils.java | 442 +++++++++--------- .../datamodel/ThumbnailsCacheManager.java | 144 +++--- .../android/files/services/FileUploader.java | 5 +- .../operations/RefreshFolderOperation.java | 8 +- .../android/syncadapter/FileSyncAdapter.java | 2 +- .../ui/activity/FileDisplayActivity.java | 2 +- .../ui/activity/FolderPickerActivity.java | 2 +- .../android/ui/activity/ShareActivity.java | 6 - .../ui/dialog/CreateFolderDialogFragment.java | 19 +- .../ui/dialog/RenameFileDialogFragment.java | 18 +- .../ui/fragment/EditShareFragment.java | 6 +- .../ui/fragment/OCFileListFragment.java | 16 +- .../ui/fragment/ShareFileFragment.java | 3 +- .../ui/helpers/FileOperationsHelper.java | 93 +--- .../utils/glide/HttpStreamFetcher.java | 28 +- 16 files changed, 354 insertions(+), 446 deletions(-) diff --git a/build.gradle b/build.gradle index 2a304a3bdf..ab5e5c993c 100644 --- a/build.gradle +++ b/build.gradle @@ -208,9 +208,9 @@ dependencies { // dependencies for app building implementation 'com.android.support:multidex:1.0.3' // implementation project('nextcloud-android-library') - genericImplementation "com.github.nextcloud:android-library:master-SNAPSHOT" - gplayImplementation "com.github.nextcloud:android-library:master-SNAPSHOT" - versionDevImplementation 'com.github.nextcloud:android-library:master-SNAPSHOT' // use always latest master + genericImplementation "com.github.nextcloud:android-library:removeCheckForOlderVersions-SNAPSHOT" + gplayImplementation "com.github.nextcloud:android-library:removeCheckForOlderVersions-SNAPSHOT" + versionDevImplementation 'com.github.nextcloud:android-library:removeCheckForOlderVersions-SNAPSHOT' // use always latest master implementation "com.android.support:support-v4:${supportLibraryVersion}" implementation "com.android.support:design:${supportLibraryVersion}" implementation 'com.jakewharton:disklrucache:2.0.2' diff --git a/src/main/java/com/owncloud/android/authentication/AccountUtils.java b/src/main/java/com/owncloud/android/authentication/AccountUtils.java index 63bdc5798b..dfb7762c78 100644 --- a/src/main/java/com/owncloud/android/authentication/AccountUtils.java +++ b/src/main/java/com/owncloud/android/authentication/AccountUtils.java @@ -1,221 +1,221 @@ -/* - * 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 hasSearchUsersSupport(Account account) { + return getServerVersion(account).isSearchUsersSupported(); + } + + 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..2427cd938a 100644 --- a/src/main/java/com/owncloud/android/datamodel/ThumbnailsCacheManager.java +++ b/src/main/java/com/owncloud/android/datamodel/ThumbnailsCacheManager.java @@ -22,6 +22,7 @@ package com.owncloud.android.datamodel; import android.accounts.Account; +import android.accounts.AccountManager; import android.content.Context; import android.content.res.Resources; import android.graphics.Bitmap; @@ -286,45 +287,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 +543,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 @@ -565,10 +560,10 @@ public class ThumbnailsCacheManager { getMethod = new GetMethod(uri); getMethod.setRequestHeader("Cookie", "nc_sameSiteCookielax=true;nc_sameSiteCookiestrict=true"); - + getMethod.setRequestHeader(RemoteOperation.OCS_API_HEADER, RemoteOperation.OCS_API_HEADER_VALUE); - + int status = mClient.executeMethod(getMethod); if (status == HttpStatus.SC_OK) { InputStream inputStream = getMethod.getResponseBodyAsStream(); @@ -577,7 +572,7 @@ public class ThumbnailsCacheManager { } else { mClient.exhaustResponse(getMethod.getResponseBodyAsStream()); } - + // Handle PNG if (file.getMimeType().equalsIgnoreCase(PNG_MIMETYPE)) { thumbnail = handlePNG(thumbnail, pxW, pxH); @@ -588,9 +583,6 @@ public class ThumbnailsCacheManager { if (getMethod != null) { getMethod.releaseConnection(); } - } - } else { - Log_OC.d(TAG, "Server too old"); } } @@ -865,58 +857,56 @@ 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) + // 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); + 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(); + // 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); - } + 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); + 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; + // 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; + case HttpStatus.SC_NOT_MODIFIED: + // old avatar + avatar = getBitmapFromDiskCache(avatarKey); + mClient.exhaustResponse(get.getResponseBodyAsStream()); + break; - default: - // everything else - mClient.exhaustResponse(get.getResponseBodyAsStream()); - break; + default: + // everything else + mClient.exhaustResponse(get.getResponseBodyAsStream()); + break; } } catch (Exception e) { 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..850f2fa0bf 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,7 @@ public class FileUploader extends Service account, files[i], ocUpload, - chunked, + true, forceOverwrite, localAction, this, @@ -692,7 +691,7 @@ public class FileUploader extends Service account, null, upload, - chunked, + true, 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/RefreshFolderOperation.java b/src/main/java/com/owncloud/android/operations/RefreshFolderOperation.java index 760e3f459b..bb47e32f06 100644 --- a/src/main/java/com/owncloud/android/operations/RefreshFolderOperation.java +++ b/src/main/java/com/owncloud/android/operations/RefreshFolderOperation.java @@ -237,14 +237,10 @@ public class RefreshFolderOperation extends RemoteOperation { UpdateOCVersionOperation update = new UpdateOCVersionOperation(mAccount, mContext); RemoteOperationResult result = update.execute(client); if (result.isSuccess()) { - mIsShareSupported = update.getOCVersion().isSharedSupported(); + mIsShareSupported = true; // 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/syncadapter/FileSyncAdapter.java b/src/main/java/com/owncloud/android/syncadapter/FileSyncAdapter.java index 5403d92bd8..c4f2cf715e 100644 --- a/src/main/java/com/owncloud/android/syncadapter/FileSyncAdapter.java +++ b/src/main/java/com/owncloud/android/syncadapter/FileSyncAdapter.java @@ -239,7 +239,7 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter { if (!result.isSuccess()) { mLastFailedResult = result; } else { - mIsShareSupported = update.getOCVersion().isSharedSupported(); + mIsShareSupported = true; } } 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..c32099b1ff 100644 --- a/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java +++ b/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java @@ -2201,7 +2201,7 @@ public class FileDisplayActivity extends HookActivity RemoteOperation synchFolderOp = new RefreshFolderOperation(folder, currentSyncTime, false, - getFileOperationsHelper().isSharedSupported(), + true, 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..0c07b6595d 100644 --- a/src/main/java/com/owncloud/android/ui/activity/FolderPickerActivity.java +++ b/src/main/java/com/owncloud/android/ui/activity/FolderPickerActivity.java @@ -250,7 +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(), + true, ignoreETag, getStorageManager(), getAccount(), getApplicationContext()); refreshFolderOperation.execute(getAccount(), this, null, null); 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/dialog/CreateFolderDialogFragment.java b/src/main/java/com/owncloud/android/ui/dialog/CreateFolderDialogFragment.java index 504cf51304..8b8783a2bb 100644 --- a/src/main/java/com/owncloud/android/ui/dialog/CreateFolderDialogFragment.java +++ b/src/main/java/com/owncloud/android/ui/dialog/CreateFolderDialogFragment.java @@ -127,24 +127,15 @@ public class CreateFolderDialogFragment DisplayUtils.showSnackMessage(getActivity(), R.string.filename_empty); return; } - boolean serverWithForbiddenChars = ((ComponentsGetter)getActivity()). - getFileOperationsHelper().isVersionWithForbiddenCharacters(); - if (!FileUtils.isValidName(newFolderName, serverWithForbiddenChars)) { - - if (serverWithForbiddenChars) { - DisplayUtils.showSnackMessage(getActivity(), R.string.filename_forbidden_charaters_from_server); - } else { - DisplayUtils.showSnackMessage(getActivity(), R.string.filename_forbidden_characters); - } + if (!FileUtils.isValidName(newFolderName)) { + DisplayUtils.showSnackMessage(getActivity(), R.string.filename_forbidden_charaters_from_server); return; } - - String path = mParentFolder.getRemotePath(); - path += newFolderName + OCFile.PATH_SEPARATOR; - ((ComponentsGetter)getActivity()). - getFileOperationsHelper().createFolder(path, false); + + String path = mParentFolder.getRemotePath() + newFolderName + OCFile.PATH_SEPARATOR; + ((ComponentsGetter) getActivity()).getFileOperationsHelper().createFolder(path, false); } } } diff --git a/src/main/java/com/owncloud/android/ui/dialog/RenameFileDialogFragment.java b/src/main/java/com/owncloud/android/ui/dialog/RenameFileDialogFragment.java index 5f13556ce3..41ddf405ad 100644 --- a/src/main/java/com/owncloud/android/ui/dialog/RenameFileDialogFragment.java +++ b/src/main/java/com/owncloud/android/ui/dialog/RenameFileDialogFragment.java @@ -142,23 +142,13 @@ public class RenameFileDialogFragment return; } - boolean serverWithForbiddenChars = ((ComponentsGetter)getActivity()). - getFileOperationsHelper().isVersionWithForbiddenCharacters(); - - if (!FileUtils.isValidName(newFileName, serverWithForbiddenChars)) { - - if (serverWithForbiddenChars) { - DisplayUtils.showSnackMessage(getActivity(), R.string.filename_forbidden_charaters_from_server); - } else { - DisplayUtils.showSnackMessage(getActivity(), R.string.filename_forbidden_characters); - } - + if (!FileUtils.isValidName(newFileName)) { + DisplayUtils.showSnackMessage(getActivity(), R.string.filename_forbidden_charaters_from_server); + return; } - ((ComponentsGetter)getActivity()).getFileOperationsHelper(). - renameFile(mTargetFile, newFileName); - + ((ComponentsGetter) getActivity()).getFileOperationsHelper().renameFile(mTargetFile, newFileName); } } } diff --git a/src/main/java/com/owncloud/android/ui/fragment/EditShareFragment.java b/src/main/java/com/owncloud/android/ui/fragment/EditShareFragment.java index 4988a6efb5..402d186452 100644 --- a/src/main/java/com/owncloud/android/ui/fragment/EditShareFragment.java +++ b/src/main/java/com/owncloud/android/ui/fragment/EditShareFragment.java @@ -35,7 +35,6 @@ import android.widget.CompoundButton; import android.widget.TextView; import com.owncloud.android.R; -import com.owncloud.android.authentication.AccountUtils; import com.owncloud.android.datamodel.FileDataStorageManager; import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.lib.common.operations.RemoteOperationResult; @@ -44,7 +43,6 @@ import com.owncloud.android.lib.resources.shares.OCShare; import com.owncloud.android.lib.resources.shares.SharePermissionsBuilder; 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.ui.activity.FileActivity; import com.owncloud.android.utils.ThemeUtils; @@ -176,8 +174,6 @@ public class EditShareFragment extends Fragment { int sharePermissions = mShare.getPermissions(); boolean isFederated = ShareType.FEDERATED.equals(mShare.getShareType()); - OwnCloudVersion serverVersion = AccountUtils.getServerVersion(mAccount); - boolean isNotReshareableFederatedSupported = serverVersion.isNotReshareableFederatedSupported(); int accentColor = ThemeUtils.primaryAccentColor(getContext()); @@ -199,7 +195,7 @@ public class EditShareFragment extends Fragment { boolean canEdit = (sharePermissions & anyUpdatePermission) > 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..a429a68c01 100644 --- a/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java +++ b/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java @@ -85,7 +85,6 @@ import com.owncloud.android.ui.activity.FolderPickerActivity; import com.owncloud.android.ui.activity.OnEnforceableRefreshListener; import com.owncloud.android.ui.activity.ToolbarActivity; import com.owncloud.android.ui.activity.UploadFilesActivity; -import com.owncloud.android.ui.adapter.OCFileListAdapter; import com.owncloud.android.ui.dialog.ConfirmationDialogFragment; import com.owncloud.android.ui.dialog.CreateFolderDialogFragment; import com.owncloud.android.ui.dialog.RemoveFilesDialogFragment; @@ -1079,13 +1078,14 @@ public class OCFileListFragment extends ExtendedListFragment implements } private void updateLayout() { - // decide grid vs list view - if (AccountUtils.getServerVersion(((FileActivity) mContainerActivity).getAccount()) - .supportsRemoteThumbnails() && isGridViewPreferred(mFile)) { - switchToGridView(); - } else { - switchToListView(); - + if (!mJustFolders) { + updateFooter(); + // decide grid vs list view + 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..1516a4b97e 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,7 +226,7 @@ public class ShareFileFragment extends Fragment implements ShareUserListAdapter. addUserGroupButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - boolean shareWithUsersEnable = AccountUtils.hasSearchUsersSupport(mAccount); + boolean shareWithUsersEnable = true; if (shareWithUsersEnable) { // Show Search Fragment mListener.showSearchUsersAndGroups(); 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..b19e3af7dd 100755 --- a/src/main/java/com/owncloud/android/ui/helpers/FileOperationsHelper.java +++ b/src/main/java/com/owncloud/android/ui/helpers/FileOperationsHelper.java @@ -356,47 +356,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"); } } @@ -492,19 +481,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 +642,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 +935,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..71a18c6667 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.d(TAG, e.getMessage(), e); } } return null; From 0b19ba7d9ab4507a553af6d9dd70e73b369ea1ad Mon Sep 17 00:00:00 2001 From: tobiasKaminsky Date: Thu, 15 Feb 2018 10:19:02 +0100 Subject: [PATCH 02/12] remove obsolete string Signed-off-by: tobiasKaminsky --- src/main/res/values/strings.xml | 1 - 1 file changed, 1 deletion(-) 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 From 0867879f59e6ebe2d759411be0cf0ccd55586cfa Mon Sep 17 00:00:00 2001 From: tobiasKaminsky Date: Wed, 13 Jun 2018 10:23:18 +0200 Subject: [PATCH 03/12] changes due to rebase Signed-off-by: tobiasKaminsky --- build.gradle | 4 +- .../android/authentication/AccountUtils.java | 4 -- .../datamodel/ThumbnailsCacheManager.java | 50 +++++++++---------- .../operations/RefreshFolderOperation.java | 10 +--- .../android/syncadapter/FileSyncAdapter.java | 7 --- .../ui/activities/ActivitiesActivity.java | 3 +- .../ui/activities/ActivitiesContract.java | 3 +- .../ui/activities/ActivitiesPresenter.java | 5 +- .../data/files/FilesRepository.java | 3 +- .../data/files/FilesServiceApi.java | 3 +- .../data/files/FilesServiceApiImpl.java | 13 ++--- .../data/files/RemoteFilesRepository.java | 5 +- .../ui/activity/FileDisplayActivity.java | 11 +--- .../ui/activity/FolderPickerActivity.java | 3 +- .../ReceiveExternalFilesActivity.java | 1 - .../android/ui/adapter/UserListAdapter.java | 4 +- .../ui/fragment/OCFileListFragment.java | 14 +++--- .../ContactsBackupFragment.java | 2 +- 18 files changed, 49 insertions(+), 96 deletions(-) diff --git a/build.gradle b/build.gradle index ab5e5c993c..ec470533a4 100644 --- a/build.gradle +++ b/build.gradle @@ -208,9 +208,7 @@ dependencies { // dependencies for app building implementation 'com.android.support:multidex:1.0.3' // implementation project('nextcloud-android-library') - genericImplementation "com.github.nextcloud:android-library:removeCheckForOlderVersions-SNAPSHOT" - gplayImplementation "com.github.nextcloud:android-library:removeCheckForOlderVersions-SNAPSHOT" - versionDevImplementation 'com.github.nextcloud:android-library:removeCheckForOlderVersions-SNAPSHOT' // use always latest master + implementation "com.github.nextcloud:android-library:removeCheckForOlderVersions_2-SNAPSHOT" implementation "com.android.support:support-v4:${supportLibraryVersion}" implementation "com.android.support:design:${supportLibraryVersion}" implementation 'com.jakewharton:disklrucache:2.0.2' diff --git a/src/main/java/com/owncloud/android/authentication/AccountUtils.java b/src/main/java/com/owncloud/android/authentication/AccountUtils.java index dfb7762c78..11db8afb4c 100644 --- a/src/main/java/com/owncloud/android/authentication/AccountUtils.java +++ b/src/main/java/com/owncloud/android/authentication/AccountUtils.java @@ -211,10 +211,6 @@ public class AccountUtils { return serverVersion; } - public static boolean hasSearchUsersSupport(Account account) { - return getServerVersion(account).isSearchUsersSupported(); - } - 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 2427cd938a..81ae2cefb8 100644 --- a/src/main/java/com/owncloud/android/datamodel/ThumbnailsCacheManager.java +++ b/src/main/java/com/owncloud/android/datamodel/ThumbnailsCacheManager.java @@ -22,7 +22,6 @@ package com.owncloud.android.datamodel; import android.accounts.Account; -import android.accounts.AccountManager; import android.content.Context; import android.content.res.Resources; import android.graphics.Bitmap; @@ -47,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; @@ -560,10 +558,10 @@ public class ThumbnailsCacheManager { getMethod = new GetMethod(uri); getMethod.setRequestHeader("Cookie", "nc_sameSiteCookielax=true;nc_sameSiteCookiestrict=true"); - + getMethod.setRequestHeader(RemoteOperation.OCS_API_HEADER, RemoteOperation.OCS_API_HEADER_VALUE); - + int status = mClient.executeMethod(getMethod); if (status == HttpStatus.SC_OK) { InputStream inputStream = getMethod.getResponseBodyAsStream(); @@ -572,7 +570,7 @@ public class ThumbnailsCacheManager { } else { mClient.exhaustResponse(getMethod.getResponseBodyAsStream()); } - + // Handle PNG if (file.getMimeType().equalsIgnoreCase(PNG_MIMETYPE)) { thumbnail = handlePNG(thumbnail, pxW, pxH); @@ -583,6 +581,7 @@ public class ThumbnailsCacheManager { if (getMethod != null) { getMethod.releaseConnection(); } + } } } @@ -595,7 +594,6 @@ public class ThumbnailsCacheManager { } return thumbnail; - } /** @@ -812,9 +810,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); } @@ -835,6 +833,7 @@ public class ThumbnailsCacheManager { /** * Converts size of file icon from dp to pixel + * * @return int */ private int getAvatarDimension() { @@ -866,9 +865,9 @@ public class ThumbnailsCacheManager { // 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); - } + if (!eTag.isEmpty() && getBitmapFromDiskCache(avatarKey) != null) { + get.setRequestHeader("If-None-Match", eTag); + } int status = mClient.executeMethod(get); @@ -908,28 +907,26 @@ public class ThumbnailsCacheManager { 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(); - } } - } else { - Log_OC.d(TAG, "Server too old"); - + } 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); } } @@ -1085,6 +1082,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/operations/RefreshFolderOperation.java b/src/main/java/com/owncloud/android/operations/RefreshFolderOperation.java index bb47e32f06..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,8 +231,6 @@ public class RefreshFolderOperation extends RemoteOperation { UpdateOCVersionOperation update = new UpdateOCVersionOperation(mAccount, mContext); RemoteOperationResult result = update.execute(client); if (result.isSuccess()) { - mIsShareSupported = true; - // Update Capabilities for this account updateCapabilities(); } diff --git a/src/main/java/com/owncloud/android/syncadapter/FileSyncAdapter.java b/src/main/java/com/owncloud/android/syncadapter/FileSyncAdapter.java index c4f2cf715e..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 = true; } } @@ -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 c32099b1ff..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, - true, 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 0c07b6595d..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, - true, 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/adapter/UserListAdapter.java b/src/main/java/com/owncloud/android/ui/adapter/UserListAdapter.java index 2d34cd0def..959c7ddfb2 100644 --- a/src/main/java/com/owncloud/android/ui/adapter/UserListAdapter.java +++ b/src/main/java/com/owncloud/android/ui/adapter/UserListAdapter.java @@ -38,7 +38,6 @@ import android.widget.PopupMenu; import android.widget.TextView; import com.owncloud.android.R; -import com.owncloud.android.authentication.AccountUtils; import com.owncloud.android.datamodel.FileDataStorageManager; import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.lib.resources.shares.OCShare; @@ -236,8 +235,7 @@ public class UserListAdapter extends RecyclerView.Adapter Date: Fri, 15 Jun 2018 09:07:41 +0200 Subject: [PATCH 04/12] changes due to CR Signed-off-by: tobiasKaminsky --- .../java/com/owncloud/android/UploadIT.java | 2 -- .../android/files/services/FileUploader.java | 2 -- .../android/operations/UploadFileOperation.java | 11 ++--------- .../android/ui/fragment/ShareFileFragment.java | 13 ++----------- .../android/utils/glide/HttpStreamFetcher.java | 2 +- 5 files changed, 5 insertions(+), 25 deletions(-) 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/files/services/FileUploader.java b/src/main/java/com/owncloud/android/files/services/FileUploader.java index 850f2fa0bf..bcacb2cf1f 100644 --- a/src/main/java/com/owncloud/android/files/services/FileUploader.java +++ b/src/main/java/com/owncloud/android/files/services/FileUploader.java @@ -632,7 +632,6 @@ public class FileUploader extends Service account, files[i], ocUpload, - true, forceOverwrite, localAction, this, @@ -691,7 +690,6 @@ public class FileUploader extends Service account, null, upload, - true, 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/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/ui/fragment/ShareFileFragment.java b/src/main/java/com/owncloud/android/ui/fragment/ShareFileFragment.java index 1516a4b97e..441f704eed 100644 --- a/src/main/java/com/owncloud/android/ui/fragment/ShareFileFragment.java +++ b/src/main/java/com/owncloud/android/ui/fragment/ShareFileFragment.java @@ -226,17 +226,8 @@ public class ShareFileFragment extends Fragment implements ShareUserListAdapter. addUserGroupButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - boolean shareWithUsersEnable = true; - 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/utils/glide/HttpStreamFetcher.java b/src/main/java/com/owncloud/android/utils/glide/HttpStreamFetcher.java index 71a18c6667..08ceb71e70 100644 --- a/src/main/java/com/owncloud/android/utils/glide/HttpStreamFetcher.java +++ b/src/main/java/com/owncloud/android/utils/glide/HttpStreamFetcher.java @@ -71,7 +71,7 @@ public class HttpStreamFetcher implements DataFetcher { mClient.exhaustResponse(get.getResponseBodyAsStream()); } } catch (Exception e) { - Log_OC.d(TAG, e.getMessage(), e); + Log_OC.e(TAG, e.getMessage(), e); } } return null; From aa9caf84b395360cd0249c67cec6e03ab61305ef Mon Sep 17 00:00:00 2001 From: tobiasKaminsky Date: Wed, 20 Jun 2018 11:43:09 +0200 Subject: [PATCH 05/12] changes due to rebase Signed-off-by: tobiasKaminsky --- .../operations/RestoreFileVersionOperation.java | 4 ++-- .../android/ui/helpers/FileOperationsHelper.java | 10 ---------- 2 files changed, 2 insertions(+), 12 deletions(-) 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/ui/helpers/FileOperationsHelper.java b/src/main/java/com/owncloud/android/ui/helpers/FileOperationsHelper.java index b19e3af7dd..ff60592906 100755 --- a/src/main/java/com/owncloud/android/ui/helpers/FileOperationsHelper.java +++ b/src/main/java/com/owncloud/android/ui/helpers/FileOperationsHelper.java @@ -439,16 +439,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} From dbd82f8d5bf59fef9042cad8a6689c6327d42343 Mon Sep 17 00:00:00 2001 From: tobiasKaminsky Date: Thu, 28 Jun 2018 10:03:02 +0200 Subject: [PATCH 06/12] changes due to rebase Signed-off-by: tobiasKaminsky --- .../owncloud/android/datamodel/ThumbnailsCacheManager.java | 1 - .../com/owncloud/android/operations/CommentFileOperation.java | 2 +- .../android/operations/EmptyTrashbinFileOperation.java | 2 +- .../android/operations/RestoreTrashbinFileOperation.java | 4 ++-- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/owncloud/android/datamodel/ThumbnailsCacheManager.java b/src/main/java/com/owncloud/android/datamodel/ThumbnailsCacheManager.java index 81ae2cefb8..97bcfc76ce 100644 --- a/src/main/java/com/owncloud/android/datamodel/ThumbnailsCacheManager.java +++ b/src/main/java/com/owncloud/android/datamodel/ThumbnailsCacheManager.java @@ -53,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; 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/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); From 35b12083c02845e6556d9970b0250ae274a9a682 Mon Sep 17 00:00:00 2001 From: AndyScherzinger Date: Tue, 3 Jul 2018 18:41:40 +0200 Subject: [PATCH 07/12] revert back to master-branch lib version --- build.gradle | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index ec470533a4..2a304a3bdf 100644 --- a/build.gradle +++ b/build.gradle @@ -208,7 +208,9 @@ dependencies { // dependencies for app building implementation 'com.android.support:multidex:1.0.3' // implementation project('nextcloud-android-library') - implementation "com.github.nextcloud:android-library:removeCheckForOlderVersions_2-SNAPSHOT" + genericImplementation "com.github.nextcloud:android-library:master-SNAPSHOT" + gplayImplementation "com.github.nextcloud:android-library:master-SNAPSHOT" + versionDevImplementation 'com.github.nextcloud:android-library:master-SNAPSHOT' // use always latest master implementation "com.android.support:support-v4:${supportLibraryVersion}" implementation "com.android.support:design:${supportLibraryVersion}" implementation 'com.jakewharton:disklrucache:2.0.2' From a5345705c691a09b9dc673fc59fb1b933a72e214 Mon Sep 17 00:00:00 2001 From: AndyScherzinger Date: Tue, 3 Jul 2018 18:42:26 +0200 Subject: [PATCH 08/12] organize imports after rebase --- .../com/owncloud/android/ui/helpers/FileOperationsHelper.java | 1 - 1 file changed, 1 deletion(-) 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 ff60592906..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; From f7402a2e519b83c4aa9843fc94bb14b6a26a0fdf Mon Sep 17 00:00:00 2001 From: AndyScherzinger Date: Tue, 3 Jul 2018 18:50:36 +0200 Subject: [PATCH 09/12] fixes after rebase --- .../com/owncloud/android/ui/adapter/OCFileListAdapter.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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..592a50757c 100644 --- a/src/main/java/com/owncloud/android/ui/adapter/OCFileListAdapter.java +++ b/src/main/java/com/owncloud/android/ui/adapter/OCFileListAdapter.java @@ -632,9 +632,8 @@ public class OCFileListAdapter extends RecyclerView.Adapter Date: Tue, 3 Jul 2018 18:55:10 +0200 Subject: [PATCH 10/12] add missing @NonNull annotations --- .../owncloud/android/ui/adapter/OCFileListAdapter.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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 592a50757c..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 Date: Tue, 3 Jul 2018 19:02:26 +0200 Subject: [PATCH 11/12] lint: set @RequiresApi(api = Build.VERSION_CODES.N) for notification channel importance field --- src/main/java/com/owncloud/android/MainApp.java | 2 ++ 1 file changed, 2 insertions(+) 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) { From fc36bf73d49ffa523befb2d21dfbc9aac7857d5a Mon Sep 17 00:00:00 2001 From: AndyScherzinger Date: Tue, 3 Jul 2018 19:15:09 +0200 Subject: [PATCH 12/12] fix tests after rebase --- .../ui/activities/ActivitiesPresenterTest.java | 14 +++++++------- .../data/files/RemoteFilesRepositoryTest.java | 14 +++++--------- 2 files changed, 12 insertions(+), 16 deletions(-) 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")); }