From 2582ece2105f98a7a20d72d8c8dc70772a48286f Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Mon, 4 May 2015 04:38:12 +0200 Subject: open market if share location plugin isn't installed --- .../eu/siacs/conversations/ui/ConversationActivity.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/main/java/eu/siacs') diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java index a76efbc3..349d8ffe 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java @@ -409,6 +409,7 @@ public class ConversationActivity extends XmppActivity public void onPresenceSelected() { Intent intent = new Intent(); boolean chooser = false; + String fallbackPackageId = null; switch (attachmentChoice) { case ATTACHMENT_CHOICE_CHOOSE_IMAGE: intent.setAction(Intent.ACTION_GET_CONTENT); @@ -436,6 +437,7 @@ public class ConversationActivity extends XmppActivity break; case ATTACHMENT_CHOICE_LOCATION: intent.setAction("eu.siacs.conversations.location.request"); + fallbackPackageId = "eu.siacs.conversations.sharelocation"; break; } if (intent.resolveActivity(getPackageManager()) != null) { @@ -446,12 +448,25 @@ public class ConversationActivity extends XmppActivity } else { 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) { switch (attachmentChoice) { case ATTACHMENT_CHOICE_LOCATION: -- cgit v1.2.3