properly detect images in share with
This commit is contained in:
parent
fd4cf499a2
commit
1a7ed4ed7c
|
@ -30,6 +30,7 @@ public class ShareWithActivity extends XmppActivity {
|
||||||
|
|
||||||
private class Share {
|
private class Share {
|
||||||
public Uri uri;
|
public Uri uri;
|
||||||
|
public boolean image;
|
||||||
public String account;
|
public String account;
|
||||||
public String contact;
|
public String contact;
|
||||||
public String text;
|
public String text;
|
||||||
|
@ -129,10 +130,10 @@ public class ShareWithActivity extends XmppActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart() {
|
public void onStart() {
|
||||||
if (getIntent().getType() != null
|
final String type = getIntent().getType();
|
||||||
&& !getIntent().getType().startsWith("text/")) {
|
if (type != null && !type.startsWith("text/")) {
|
||||||
this.share.uri = (Uri) getIntent().getParcelableExtra(
|
this.share.uri = (Uri) getIntent().getParcelableExtra(Intent.EXTRA_STREAM);
|
||||||
Intent.EXTRA_STREAM);
|
this.share.image = type.startsWith("image/") || URLConnection.guessContentTypeFromName(share.uri.getPath()).startsWith("image/");
|
||||||
} else {
|
} else {
|
||||||
this.share.text = getIntent().getStringExtra(Intent.EXTRA_TEXT);
|
this.share.text = getIntent().getStringExtra(Intent.EXTRA_TEXT);
|
||||||
}
|
}
|
||||||
|
@ -179,8 +180,7 @@ public class ShareWithActivity extends XmppActivity {
|
||||||
selectPresence(conversation, new OnPresenceSelected() {
|
selectPresence(conversation, new OnPresenceSelected() {
|
||||||
@Override
|
@Override
|
||||||
public void onPresenceSelected() {
|
public void onPresenceSelected() {
|
||||||
final String type = URLConnection.guessContentTypeFromName(share.uri.getPath());
|
if (share.image) {
|
||||||
if (type != null && type.startsWith("image/")) {
|
|
||||||
Toast.makeText(getApplicationContext(),
|
Toast.makeText(getApplicationContext(),
|
||||||
getText(R.string.preparing_image),
|
getText(R.string.preparing_image),
|
||||||
Toast.LENGTH_LONG).show();
|
Toast.LENGTH_LONG).show();
|
||||||
|
|
Loading…
Reference in New Issue