Show share with users option if the server supports search users function

This commit is contained in:
masensio 2015-10-05 11:25:24 +02:00 committed by David A. Velasco
parent 3a527a8fe4
commit a94c176c75
3 changed files with 19 additions and 5 deletions

@ -1 +1 @@
Subproject commit f02dffb1d3c46305c70d246f696cde7b8c3b0971
Subproject commit 875fce9f9c19190ba976cfc3634c63029362eda5

View file

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

View file

@ -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<Integer> toShow, List <Integer> 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);