Browse Source

Good behaviiour in servers not supporting SHAREE API: show the menu option and a messsage when try to share with a new user/group

masensio 9 years ago
parent
commit
d1294ca584

+ 3 - 0
res/values/strings.xml

@@ -375,4 +375,7 @@
     <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>

+ 1 - 3
src/com/owncloud/android/files/FileMenuFilter.java

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

+ 10 - 2
src/com/owncloud/android/ui/fragment/ShareFileFragment.java

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