aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2017-12-23 21:44:41 +0100
committerChristian Schneppe <christian@pix-art.de>2017-12-23 21:44:41 +0100
commit11a4291585d9aaf8daf2c9324774bc589790c36f (patch)
treefd972b8dbeb6b04813a2a67b23dcd60e77568511
parentbbd9150b88fd2d5d2680c28be229be8e4e2a435a (diff)
fix location view
-rw-r--r--src/main/java/de/pixart/messenger/services/NotificationService.java2
-rw-r--r--src/main/java/de/pixart/messenger/ui/ConversationActivity.java6
-rw-r--r--src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java2
-rw-r--r--src/main/java/de/pixart/messenger/utils/GeoHelper.java11
4 files changed, 7 insertions, 14 deletions
diff --git a/src/main/java/de/pixart/messenger/services/NotificationService.java b/src/main/java/de/pixart/messenger/services/NotificationService.java
index 9f78fa751..5d33e2b27 100644
--- a/src/main/java/de/pixart/messenger/services/NotificationService.java
+++ b/src/main/java/de/pixart/messenger/services/NotificationService.java
@@ -563,7 +563,7 @@ public class NotificationService {
}
private PendingIntent createShowLocationIntent(final Message message) {
- Iterable<Intent> intents = GeoHelper.createGeoIntentsFromMessage(message);
+ Iterable<Intent> intents = GeoHelper.createGeoIntentsFromMessage(message, this.mXmppConnectionService.getApplicationContext());
for (Intent intent : intents) {
if (intent.resolveActivity(mXmppConnectionService.getPackageManager()) != null) {
return PendingIntent.getActivity(mXmppConnectionService, 18, intent, PendingIntent.FLAG_UPDATE_CURRENT);
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationActivity.java b/src/main/java/de/pixart/messenger/ui/ConversationActivity.java
index 002162041..606374d47 100644
--- a/src/main/java/de/pixart/messenger/ui/ConversationActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/ConversationActivity.java
@@ -976,12 +976,6 @@ public class ConversationActivity extends XmppActivity
}
PopupMenu attachFilePopup = new PopupMenu(this, menuAttachFile);
attachFilePopup.inflate(R.menu.attachment_choices);
- if (new Intent(MediaStore.Audio.Media.RECORD_SOUND_ACTION).resolveActivity(getPackageManager()) == null) {
- attachFilePopup.getMenu().findItem(R.id.attach_record_voice).setVisible(false);
- }
- if (new Intent("de.pixart.messenger.location.request").resolveActivity(getPackageManager()) == null) {
- attachFilePopup.getMenu().findItem(R.id.attach_location).setVisible(false);
- }
attachFilePopup.setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override
diff --git a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java
index 5e158415b..e77e39b20 100644
--- a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java
+++ b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java
@@ -1140,7 +1140,7 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
}
public void showLocation(Message message) {
- for (Intent intent : GeoHelper.createGeoIntentsFromMessage(message)) {
+ for (Intent intent : GeoHelper.createGeoIntentsFromMessage(message, this.getContext())) {
if (intent.resolveActivity(getContext().getPackageManager()) != null) {
getContext().startActivity(intent);
return;
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