Browse Source

search for the right ocShare with public link

tobiasKaminsky 8 years ago
parent
commit
1f9be869c2
1 changed files with 12 additions and 1 deletions
  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());