Browse Source

search for the right ocShare with public link

tobiasKaminsky 8 năm trước cách đây
mục cha
commit
1f9be869c2
1 tập tin đã thay đổi với 12 bổ sung1 xóa
  1. 12 1
      src/com/owncloud/android/ui/activity/ShareActivity.java

+ 12 - 1
src/com/owncloud/android/ui/activity/ShareActivity.java

@@ -289,7 +289,18 @@ public class ShareActivity extends FileActivity
 
             // Create dialog to allow the user choose an app to send the link
             Intent intentToShareLink = new Intent(Intent.ACTION_SEND);
-            String link = ((OCShare) (result.getData().get(0))).getShareLink();
+
+            // if share to user and share via link multiple ocshares are returned,
+            // therefore filtering for public_link
+            String link = "";
+            for (Object object : result.getData()) {
+                OCShare shareLink = (OCShare) object;
+                if (shareLink.getShareType().name().equalsIgnoreCase("PUBLIC_LINK")) {
+                    link = shareLink.getShareLink();
+                    break;
+                }
+            }
+
             intentToShareLink.putExtra(Intent.EXTRA_TEXT, link);
             intentToShareLink.setType("text/plain");
             String username = AccountUtils.getUsernameForAccount(getAccount());