aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2019-06-08 14:22:00 +0200
committerChristian Schneppe <christian@pix-art.de>2019-06-08 14:22:00 +0200
commit6856e84abd40835e78b3873a4070709faa4604bf (patch)
tree131552366980bdc4abb2a61e77dedfa46c449baf /src
parent3839dff5b3e330f3c95b9c01305c4ce974338905 (diff)
put geo uri in attachment preview when shared
Diffstat (limited to 'src')
-rw-r--r--src/main/java/de/pixart/messenger/ui/ConversationFragment.java14
-rw-r--r--src/main/java/de/pixart/messenger/ui/ShareWithActivity.java6
-rw-r--r--src/main/java/de/pixart/messenger/utils/GeoHelper.java2
3 files changed, 17 insertions, 5 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
index ae0b1781e..2379afad2 100644
--- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
+++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
@@ -2247,8 +2247,12 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
final boolean doNotAppend = extras.getBoolean(ConversationsActivity.EXTRA_DO_NOT_APPEND, false);
final List<Uri> uris = extractUris(extras);
if (uris != null && uris.size() > 0) {
- final List<Uri> cleanedUris = cleanUris(new ArrayList<>(uris));
- mediaPreviewAdapter.addMediaPreviews(Attachment.of(getActivity(), cleanedUris));
+ if (uris.size() == 1 && "geo".equals(uris.get(0).getScheme())) {
+ mediaPreviewAdapter.addMediaPreviews(Attachment.of(getActivity(), uris.get(0), Attachment.Type.LOCATION));
+ } else {
+ final List<Uri> cleanedUris = cleanUris(new ArrayList<>(uris));
+ mediaPreviewAdapter.addMediaPreviews(Attachment.of(getActivity(), cleanedUris));
+ }
toggleInputMethod();
return;
}
@@ -2268,7 +2272,11 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
}
}
} else {
- if (text != null && asQuote) {
+ if (text != null && GeoHelper.GEO_URI.matcher(text).matches()) {
+ mediaPreviewAdapter.addMediaPreviews(Attachment.of(getActivity(), Uri.parse(text), Attachment.Type.LOCATION));
+ toggleInputMethod();
+ return;
+ } else if (text != null && asQuote) {
quoteText(text);
} else {
appendText(text, doNotAppend);
diff --git a/src/main/java/de/pixart/messenger/ui/ShareWithActivity.java b/src/main/java/de/pixart/messenger/ui/ShareWithActivity.java
index 26d8debc5..2ae46dac8 100644
--- a/src/main/java/de/pixart/messenger/ui/ShareWithActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/ShareWithActivity.java
@@ -112,10 +112,14 @@ public class ShareWithActivity extends XmppActivity implements XmppConnectionSer
}
final String type = intent.getType();
final String action = intent.getAction();
+ final Uri data = intent.getData();
if (Intent.ACTION_SEND.equals(action)) {
final String text = intent.getStringExtra(Intent.EXTRA_TEXT);
final Uri uri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
- if (type != null && uri != null && (text == null || !type.equals("text/plain"))) {
+ if (data != null && "geo".equals(data.getScheme())) {
+ this.share.uris.clear();
+ this.share.uris.add(data);
+ } else if (type != null && uri != null && (text == null || !type.equals("text/plain"))) {
this.share.uris.clear();
this.share.uris.add(uri);
} else {
diff --git a/src/main/java/de/pixart/messenger/utils/GeoHelper.java b/src/main/java/de/pixart/messenger/utils/GeoHelper.java
index d978c89e0..87620ee8b 100644
--- a/src/main/java/de/pixart/messenger/utils/GeoHelper.java
+++ b/src/main/java/de/pixart/messenger/utils/GeoHelper.java
@@ -21,7 +21,7 @@ import de.pixart.messenger.ui.ShowLocationActivity;
public class GeoHelper {
- public static Pattern GEO_URI = Pattern.compile("geo:(-?\\d+(?:\\.\\d+)?),(-?\\d+(?:\\.\\d+)?)(?:,-?\\d+(?:\\.\\d+)?)?(?:;crs=[\\w-]+)?(?:;u=\\d+(?:\\.\\d+)?)?(?:;[\\w-]+=(?:[\\w-_.!~*'()]|%[\\da-f][\\da-f])+)*", Pattern.CASE_INSENSITIVE);
+ public static Pattern GEO_URI = Pattern.compile("geo:(-?\\d+(?:\\.\\d+)?),(-?\\d+(?:\\.\\d+)?)(?:,-?\\d+(?:\\.\\d+)?)?(?:;crs=[\\w-]+)?(?:;u=\\d+(?:\\.\\d+)?)?(?:;[\\w-]+=(?:[\\w-_.!~*'()]|%[\\da-f][\\da-f])+)*(\\?z=\\d+)?", Pattern.CASE_INSENSITIVE);
public static String MapPreviewUri(Message message) {
Matcher matcher = GEO_URI.matcher(message.getBody());