From: masensio Date: Mon, 5 Oct 2015 09:25:24 +0000 (+0200) Subject: Show share with users option if the server supports search users function X-Git-Tag: oc-android-1.9^2~30^2~67 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/a94c176c75ef3ad0b914340471f64f93d86fcbee Show share with users option if the server supports search users function --- diff --git a/owncloud-android-library b/owncloud-android-library index f02dffb1..875fce9f 160000 --- a/owncloud-android-library +++ b/owncloud-android-library @@ -1 +1 @@ -Subproject commit f02dffb1d3c46305c70d246f696cde7b8c3b0971 +Subproject commit 875fce9f9c19190ba976cfc3634c63029362eda5 diff --git a/src/com/owncloud/android/authentication/AccountUtils.java b/src/com/owncloud/android/authentication/AccountUtils.java index 87766b54..2f05a3e5 100644 --- a/src/com/owncloud/android/authentication/AccountUtils.java +++ b/src/com/owncloud/android/authentication/AccountUtils.java @@ -289,4 +289,15 @@ public class AccountUtils { return serverVersion; } + public static boolean hasSearchUsersSupport(Account account){ + OwnCloudVersion serverVersion = null; + 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 != null ? serverVersion.isSearchUsersSupported() : false); + } } diff --git a/src/com/owncloud/android/files/FileMenuFilter.java b/src/com/owncloud/android/files/FileMenuFilter.java index f45d69f6..6d53c997 100644 --- a/src/com/owncloud/android/files/FileMenuFilter.java +++ b/src/com/owncloud/android/files/FileMenuFilter.java @@ -29,6 +29,7 @@ import android.view.Menu; import android.view.MenuItem; import com.owncloud.android.R; +import com.owncloud.android.authentication.AccountUtils; import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.files.services.FileDownloader; import com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder; @@ -57,7 +58,8 @@ public class FileMenuFilter { * {@link FileUploader} and {@link FileDownloader} services * @param context Android {@link Context}, needed to access build setup resources. */ - public FileMenuFilter(OCFile targetFile, Account account, ComponentsGetter cg, Context context) { + public FileMenuFilter(OCFile targetFile, Account account, ComponentsGetter cg, + Context context) { mFile = targetFile; mAccount = account; mComponentsGetter = cg; @@ -105,6 +107,7 @@ public class FileMenuFilter { * @param toHide List to save the options that must be shown in the menu. */ private void filter(List toShow, List toHide) { + boolean shareWithUsersEnable = false; boolean synchronizing = false; if (mComponentsGetter != null && mFile != null && mAccount != null) { OperationsServiceBinder opsBinder = mComponentsGetter.getOperationsServiceBinder(); @@ -118,6 +121,7 @@ public class FileMenuFilter { // uploading (uploaderBinder != null && uploaderBinder.isUploading(mAccount, mFile)) ); + shareWithUsersEnable = AccountUtils.hasSearchUsersSupport(mAccount); } /// decision is taken for each possible action on a file in the menu @@ -198,15 +202,14 @@ public class FileMenuFilter { } // SHARE FILE, with Users - if (!shareAllowed || mFile == null) { + if (!shareAllowed || !shareWithUsersEnable || mFile == null) { toHide.add(R.id.action_share_with_users); } else { toShow.add(R.id.action_share_with_users); } // UNSHARE FILE, with Users - // TODO add check on SHARE available on server side? - if ( !shareAllowed || (mFile == null || !mFile.isShareByLink())) { + if ( !shareAllowed || !shareWithUsersEnable || (mFile == null || !mFile.isShareByLink())) { toHide.add(R.id.action_unshare_with_users); } else { toShow.add(R.id.action_unshare_with_users);