open market if share location plugin isn't installed

This commit is contained in:
Daniel Gultsch 2015-05-04 04:38:12 +02:00
parent 7415c8f3b3
commit 2582ece210

View file

@ -409,6 +409,7 @@ public class ConversationActivity extends XmppActivity
public void onPresenceSelected() { public void onPresenceSelected() {
Intent intent = new Intent(); Intent intent = new Intent();
boolean chooser = false; boolean chooser = false;
String fallbackPackageId = null;
switch (attachmentChoice) { switch (attachmentChoice) {
case ATTACHMENT_CHOICE_CHOOSE_IMAGE: case ATTACHMENT_CHOICE_CHOOSE_IMAGE:
intent.setAction(Intent.ACTION_GET_CONTENT); intent.setAction(Intent.ACTION_GET_CONTENT);
@ -436,6 +437,7 @@ public class ConversationActivity extends XmppActivity
break; break;
case ATTACHMENT_CHOICE_LOCATION: case ATTACHMENT_CHOICE_LOCATION:
intent.setAction("eu.siacs.conversations.location.request"); intent.setAction("eu.siacs.conversations.location.request");
fallbackPackageId = "eu.siacs.conversations.sharelocation";
break; break;
} }
if (intent.resolveActivity(getPackageManager()) != null) { if (intent.resolveActivity(getPackageManager()) != null) {
@ -446,12 +448,25 @@ public class ConversationActivity extends XmppActivity
} else { } else {
startActivityForResult(intent, attachmentChoice); startActivityForResult(intent, attachmentChoice);
} }
} else if (fallbackPackageId != null) {
startActivity(getInstallApkIntent(fallbackPackageId));
} }
} }
}); });
} }
} }
private Intent getInstallApkIntent(final String packageId) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("market://details?id="+packageId));
if (intent.resolveActivity(getPackageManager()) != null) {
return intent;
} else {
intent.setData(Uri.parse("http://play.google.com/store/apps/details?id="+packageId));
return intent;
}
}
public void attachFile(final int attachmentChoice) { public void attachFile(final int attachmentChoice) {
switch (attachmentChoice) { switch (attachmentChoice) {
case ATTACHMENT_CHOICE_LOCATION: case ATTACHMENT_CHOICE_LOCATION: