aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authoriNPUTmice <daniel@gultsch.de>2015-01-18 20:27:16 +0100
committeriNPUTmice <daniel@gultsch.de>2015-01-18 20:27:16 +0100
commitfc2e458053fa42ef792773a4a6b1a86ef4d6be01 (patch)
treeebb51690694a5fbd07d576a312912c7b46a09af2 /src
parent149a6716b8a5d4afe61e8a9c257a0d551a6d0e3d (diff)
fixed bug when sharing files from google drive
Diffstat (limited to 'src')
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ShareWithActivity.java18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/ShareWithActivity.java b/src/main/java/eu/siacs/conversations/ui/ShareWithActivity.java
index a3904d21..6be238dc 100644
--- a/src/main/java/eu/siacs/conversations/ui/ShareWithActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/ShareWithActivity.java
@@ -135,14 +135,9 @@ public class ShareWithActivity extends XmppActivity {
public void onStart() {
final String type = getIntent().getType();
final Uri uri = getIntent().getParcelableExtra(Intent.EXTRA_STREAM);
- if (type != null && uri != null && !type.startsWith("text/")) {
+ if (type != null && uri != null && !type.equalsIgnoreCase("text/plain")) {
this.share.uri = uri;
- try {
- String guess = URLConnection.guessContentTypeFromName(uri.toString());
- this.share.image = type.startsWith("image/") || (guess != null && guess.startsWith("image/"));
- } catch (final StringIndexOutOfBoundsException ignored) {
- this.share.image = false;
- }
+ this.share.image = type.startsWith("image/") || isImage(uri);
} else {
this.share.text = getIntent().getStringExtra(Intent.EXTRA_TEXT);
}
@@ -152,6 +147,15 @@ public class ShareWithActivity extends XmppActivity {
super.onStart();
}
+ protected boolean isImage(Uri uri) {
+ try {
+ String guess = URLConnection.guessContentTypeFromName(uri.toString());
+ return (guess != null && guess.startsWith("image/"));
+ } catch (final StringIndexOutOfBoundsException ignored) {
+ return false;
+ }
+ }
+
@Override
void onBackendConnected() {
if (xmppConnectionServiceBound && share != null