aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authoriNPUTmice <daniel@gultsch.de>2015-03-10 21:46:13 +0100
committeriNPUTmice <daniel@gultsch.de>2015-03-10 21:46:13 +0100
commitdb6a63bcf6c100f24b90778c3d69e8b6cec31b16 (patch)
tree1a5671d0c41989bac38ecdf34491a521a5bee916 /src/main
parent5132cd723476b6f612cf103b927e1fcf869cb039 (diff)
open location directly from notification
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/eu/siacs/conversations/services/NotificationService.java25
-rw-r--r--src/main/res/drawable-hdpi/ic_room_white_24dp.pngbin0 -> 494 bytes
-rw-r--r--src/main/res/drawable-mdpi/ic_room_white_24dp.pngbin0 -> 362 bytes
-rw-r--r--src/main/res/drawable-xhdpi/ic_room_white_24dp.pngbin0 -> 587 bytes
-rw-r--r--src/main/res/drawable-xxhdpi/ic_room_white_24dp.pngbin0 -> 861 bytes
-rw-r--r--src/main/res/drawable-xxxhdpi/ic_room_white_24dp.pngbin0 -> 1093 bytes
6 files changed, 25 insertions, 0 deletions
diff --git a/src/main/java/eu/siacs/conversations/services/NotificationService.java b/src/main/java/eu/siacs/conversations/services/NotificationService.java
index a260d6e2c..f5d733b3f 100644
--- a/src/main/java/eu/siacs/conversations/services/NotificationService.java
+++ b/src/main/java/eu/siacs/conversations/services/NotificationService.java
@@ -40,6 +40,7 @@ import eu.siacs.conversations.entities.Message;
import eu.siacs.conversations.ui.ConversationActivity;
import eu.siacs.conversations.ui.ManageAccountActivity;
import eu.siacs.conversations.ui.TimePreference;
+import eu.siacs.conversations.utils.GeoHelper;
import eu.siacs.conversations.utils.UIHelper;
import eu.siacs.conversations.xmpp.XmppConnection;
@@ -279,6 +280,11 @@ public class NotificationService {
createDownloadIntent(message)
);
}
+ if ((message = getFirstLocationMessage(messages)) != null) {
+ mBuilder.addAction(R.drawable.ic_room_white_24dp,
+ mXmppConnectionService.getString(R.string.show_location),
+ createShowLocationIntent(message));
+ }
mBuilder.setContentIntent(createContentIntent(conversation));
}
return mBuilder;
@@ -342,6 +348,15 @@ public class NotificationService {
return null;
}
+ private Message getFirstLocationMessage(final Iterable<Message> messages) {
+ for(final Message message : messages) {
+ if (GeoHelper.isGeoUri(message.getBody())) {
+ return message;
+ }
+ }
+ return null;
+ }
+
private CharSequence getMergedBodies(final ArrayList<Message> messages) {
final StringBuilder text = new StringBuilder();
for (int i = 0; i < messages.size(); ++i) {
@@ -353,6 +368,16 @@ public class NotificationService {
return text.toString();
}
+ private PendingIntent createShowLocationIntent(final Message message) {
+ Iterable<Intent> intents = GeoHelper.createGeoIntentsFromMessage(message);
+ for(Intent intent : intents) {
+ if (intent.resolveActivity(mXmppConnectionService.getPackageManager()) != null) {
+ return PendingIntent.getActivity(mXmppConnectionService,18,intent,PendingIntent.FLAG_UPDATE_CURRENT);
+ }
+ }
+ return createOpenConversationsIntent();
+ }
+
private PendingIntent createContentIntent(final String conversationUuid, final String downloadMessageUuid) {
final TaskStackBuilder stackBuilder = TaskStackBuilder
.create(mXmppConnectionService);
diff --git a/src/main/res/drawable-hdpi/ic_room_white_24dp.png b/src/main/res/drawable-hdpi/ic_room_white_24dp.png
new file mode 100644
index 000000000..c2ccd5106
--- /dev/null
+++ b/src/main/res/drawable-hdpi/ic_room_white_24dp.png
Binary files differ
diff --git a/src/main/res/drawable-mdpi/ic_room_white_24dp.png b/src/main/res/drawable-mdpi/ic_room_white_24dp.png
new file mode 100644
index 000000000..a4fcd7708
--- /dev/null
+++ b/src/main/res/drawable-mdpi/ic_room_white_24dp.png
Binary files differ
diff --git a/src/main/res/drawable-xhdpi/ic_room_white_24dp.png b/src/main/res/drawable-xhdpi/ic_room_white_24dp.png
new file mode 100644
index 000000000..e1e60a5c2
--- /dev/null
+++ b/src/main/res/drawable-xhdpi/ic_room_white_24dp.png
Binary files differ
diff --git a/src/main/res/drawable-xxhdpi/ic_room_white_24dp.png b/src/main/res/drawable-xxhdpi/ic_room_white_24dp.png
new file mode 100644
index 000000000..00b15508b
--- /dev/null
+++ b/src/main/res/drawable-xxhdpi/ic_room_white_24dp.png
Binary files differ
diff --git a/src/main/res/drawable-xxxhdpi/ic_room_white_24dp.png b/src/main/res/drawable-xxxhdpi/ic_room_white_24dp.png
new file mode 100644
index 000000000..a5dde3b94
--- /dev/null
+++ b/src/main/res/drawable-xxxhdpi/ic_room_white_24dp.png
Binary files differ