diff options
author | Christian Schneppe <christian@pix-art.de> | 2017-12-23 21:44:41 +0100 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2017-12-23 21:44:41 +0100 |
commit | 11a4291585d9aaf8daf2c9324774bc589790c36f (patch) | |
tree | fd972b8dbeb6b04813a2a67b23dcd60e77568511 /src/main/java/de/pixart/messenger/utils/GeoHelper.java | |
parent | bbd9150b88fd2d5d2680c28be229be8e4e2a435a (diff) |
fix location view
Diffstat (limited to 'src/main/java/de/pixart/messenger/utils/GeoHelper.java')
-rw-r--r-- | src/main/java/de/pixart/messenger/utils/GeoHelper.java | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/main/java/de/pixart/messenger/utils/GeoHelper.java b/src/main/java/de/pixart/messenger/utils/GeoHelper.java index 909912966..de8fe4dbd 100644 --- a/src/main/java/de/pixart/messenger/utils/GeoHelper.java +++ b/src/main/java/de/pixart/messenger/utils/GeoHelper.java @@ -1,5 +1,6 @@ package de.pixart.messenger.utils; +import android.content.Context; import android.content.Intent; import android.net.Uri; @@ -13,8 +14,10 @@ import de.pixart.messenger.Config; import de.pixart.messenger.entities.Contact; import de.pixart.messenger.entities.Conversation; import de.pixart.messenger.entities.Message; +import de.pixart.messenger.ui.ShowLocationActivity; public class GeoHelper { + public static Pattern GEO_URI = Pattern.compile("geo:([\\-0-9.]+),([\\-0-9.]+)(?:,([\\-0-9.]+))?(?:\\?(.*))?", Pattern.CASE_INSENSITIVE); public static String MapPreviewUri(Message message) { @@ -39,7 +42,7 @@ public class GeoHelper { return "https://xmpp.pix-art.de/staticmap/staticmap.php?center=" + latitude + "," + longitude + "&size=500x500&markers=" + latitude + "," + longitude + "&zoom= " + Config.DEFAULT_ZOOM; } - public static ArrayList<Intent> createGeoIntentsFromMessage(Message message) { + public static ArrayList<Intent> createGeoIntentsFromMessage(Message message, Context context) { final ArrayList<Intent> intents = new ArrayList<>(); Matcher matcher = GEO_URI.matcher(message.getBody()); if (!matcher.matches()) { @@ -71,7 +74,7 @@ public class GeoHelper { label = ""; } - Intent locationPluginIntent = new Intent("de.pixart.messenger.location.show"); + Intent locationPluginIntent = new Intent(context, ShowLocationActivity.class); locationPluginIntent.putExtra("latitude", latitude); locationPluginIntent.putExtra("longitude", longitude); if (message.getStatus() != Message.STATUS_RECEIVED) { @@ -91,10 +94,6 @@ public class GeoHelper { Intent geoIntent = new Intent(Intent.ACTION_VIEW); geoIntent.setData(Uri.parse("geo:" + String.valueOf(latitude) + "," + String.valueOf(longitude) + "?q=" + String.valueOf(latitude) + "," + String.valueOf(longitude) + label)); intents.add(geoIntent); - - Intent httpIntent = new Intent(Intent.ACTION_VIEW); - httpIntent.setData(Uri.parse("https://maps.google.com/maps?q=loc:" + String.valueOf(latitude) + "," + String.valueOf(longitude) + label)); - intents.add(httpIntent); return intents; } }
\ No newline at end of file |