fixed bug when sharing files from google drive
This commit is contained in:
parent
149a6716b8
commit
fc2e458053
|
@ -135,14 +135,9 @@ public class ShareWithActivity extends XmppActivity {
|
||||||
public void onStart() {
|
public void onStart() {
|
||||||
final String type = getIntent().getType();
|
final String type = getIntent().getType();
|
||||||
final Uri uri = getIntent().getParcelableExtra(Intent.EXTRA_STREAM);
|
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;
|
this.share.uri = uri;
|
||||||
try {
|
this.share.image = type.startsWith("image/") || isImage(uri);
|
||||||
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;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
this.share.text = getIntent().getStringExtra(Intent.EXTRA_TEXT);
|
this.share.text = getIntent().getStringExtra(Intent.EXTRA_TEXT);
|
||||||
}
|
}
|
||||||
|
@ -152,6 +147,15 @@ public class ShareWithActivity extends XmppActivity {
|
||||||
super.onStart();
|
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
|
@Override
|
||||||
void onBackendConnected() {
|
void onBackendConnected() {
|
||||||
if (xmppConnectionServiceBound && share != null
|
if (xmppConnectionServiceBound && share != null
|
||||||
|
|
Loading…
Reference in a new issue