diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java
index bd6fda98..4d4ee483 100644
--- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java
+++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java
@@ -33,6 +33,7 @@ import android.widget.Toast;
import net.java.otr4j.session.SessionStatus;
+import java.net.URLConnection;
import java.util.ArrayList;
import java.util.List;
import java.util.NoSuchElementException;
@@ -408,7 +409,7 @@ public class ConversationFragment extends Fragment {
activity.getMenuInflater().inflate(R.menu.message_context, menu);
menu.setHeaderTitle(R.string.message_options);
MenuItem copyText = menu.findItem(R.id.copy_text);
- MenuItem shareImage = menu.findItem(R.id.share_image);
+ MenuItem shareWith = menu.findItem(R.id.share_with);
MenuItem sendAgain = menu.findItem(R.id.send_again);
MenuItem copyUrl = menu.findItem(R.id.copy_url);
MenuItem downloadImage = menu.findItem(R.id.download_image);
@@ -416,8 +417,10 @@ public class ConversationFragment extends Fragment {
if (m.getType() != Message.TYPE_TEXT || m.getDownloadable() != null) {
copyText.setVisible(false);
}
- if (m.getType() != Message.TYPE_IMAGE || m.getDownloadable() != null) {
- shareImage.setVisible(false);
+ if (m.getType() == Message.TYPE_TEXT
+ || m.getType() == Message.TYPE_PRIVATE
+ || m.getDownloadable() != null) {
+ shareWith.setVisible(false);
}
if (m.getStatus() != Message.STATUS_SEND_FAILED) {
sendAgain.setVisible(false);
@@ -425,24 +428,25 @@ public class ConversationFragment extends Fragment {
if ((m.getType() != Message.TYPE_IMAGE && m.getDownloadable() == null)
|| m.getImageParams().url == null) {
copyUrl.setVisible(false);
- }
+ }
if (m.getType() != Message.TYPE_TEXT
|| m.getDownloadable() != null
|| !m.bodyContainsDownloadable()) {
downloadImage.setVisible(false);
- }
+ }
if (!((m.getDownloadable() != null && !(m.getDownloadable() instanceof DownloadablePlaceholder))
- || (m.isFileOrImage() && m.getStatus() == Message.STATUS_WAITING))) {
+ || (m.isFileOrImage() && (m.getStatus() == Message.STATUS_WAITING
+ || m.getStatus() == Message.STATUS_OFFERED)))) {
cancelTransmission.setVisible(false);
- }
+ }
}
}
@Override
public boolean onContextItemSelected(MenuItem item) {
switch (item.getItemId()) {
- case R.id.share_image:
- shareImage(selectedMessage);
+ case R.id.share_with:
+ shareWith(selectedMessage);
return true;
case R.id.copy_text:
copyText(selectedMessage);
@@ -464,16 +468,20 @@ public class ConversationFragment extends Fragment {
}
}
- private void shareImage(Message message) {
+ private void shareWith(Message message) {
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM,
activity.xmppConnectionService.getFileBackend()
.getJingleFileUri(message));
shareIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
- shareIntent.setType("image/webp");
- activity.startActivity(Intent.createChooser(shareIntent,
- getText(R.string.share_with)));
+ String path = message.getRelativeFilePath();
+ String mime = path == null ? null :URLConnection.guessContentTypeFromName(path);
+ if (mime == null) {
+ mime = "image/webp";
+ }
+ shareIntent.setType(mime);
+ activity.startActivity(Intent.createChooser(shareIntent,getText(R.string.share_with)));
}
private void copyText(Message message) {
diff --git a/src/main/res/menu/message_context.xml b/src/main/res/menu/message_context.xml
index 3be52442..21659266 100644
--- a/src/main/res/menu/message_context.xml
+++ b/src/main/res/menu/message_context.xml
@@ -5,8 +5,8 @@
android:id="@+id/copy_text"
android:title="@string/copy_text"/>
+ android:id="@+id/share_with"
+ android:title="@string/share_with"/>
diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml
index cdf5d438..7db008ea 100644
--- a/src/main/res/values/strings.xml
+++ b/src/main/res/values/strings.xml
@@ -47,7 +47,7 @@
Would you like to remove %s as a bookmark? The conversation associated with this bookmark will not be removed.
Register new account on server
Change password on server
- Share with
+ Share with…
Start Conversation
Invite Contact
Contacts
@@ -328,7 +328,6 @@
Check image file size
Message options
Copy text
- Share image
Copy original URL
Send again
Image URL