Good behaviiour in servers not supporting SHAREE API: show the menu option and a...
authormasensio <masensio@solidgear.es>
Mon, 26 Oct 2015 12:13:06 +0000 (13:13 +0100)
committerDavid A. Velasco <dvelasco@solidgear.es>
Fri, 30 Oct 2015 15:50:49 +0000 (16:50 +0100)
res/values/strings.xml
src/com/owncloud/android/files/FileMenuFilter.java
src/com/owncloud/android/ui/fragment/ShareFileFragment.java

index 591527d..2458d70 100644 (file)
     <string name="search_users_and_groups_hint">Search users and groups</string>
     <string name="share_group_clarification">%1$s (group)</string>
 
+    <string name="share_sharee_unavailable">Sorry, your server version does not allow share with users within clients.
+        \nPlease contact your administrator</string>
+
 </resources>
index 8c04842..66ada1c 100644 (file)
@@ -107,7 +107,6 @@ 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();
@@ -121,7 +120,6 @@ 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
@@ -202,7 +200,7 @@ public class FileMenuFilter {
         }
 
         // SHARE FILE, with Users
-        if (!shareAllowed || !shareWithUsersEnable || mFile == null) {
+        if (!shareAllowed ||  mFile == null) {
             toHide.add(R.id.action_share_with_users);
         } else {
             toShow.add(R.id.action_share_with_users);
index 1b95186..7051767 100644 (file)
@@ -32,8 +32,10 @@ import android.widget.Button;
 import android.widget.ImageView;
 import android.widget.ListView;
 import android.widget.TextView;
+import android.widget.Toast;
 
 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;
@@ -137,8 +139,14 @@ public class ShareFileFragment extends Fragment
         addUserGroupButton.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View view) {
-                // Show Search Fragment
-                mListener.showSearchUsersAndGroups(mShares);
+                 boolean shareWithUsersEnable = AccountUtils.hasSearchUsersSupport(mAccount);
+                if (shareWithUsersEnable) {
+                    // Show Search Fragment
+                    mListener.showSearchUsersAndGroups(mShares);
+                } else {
+                    String message = getString(R.string.share_sharee_unavailable);
+                    Toast.makeText(getActivity(), message, Toast.LENGTH_LONG).show();
+                }
             }
         });