mirror of
https://github.com/moparisthebest/Conversations
synced 2024-11-24 09:42:17 -05:00
open location directly from notification
This commit is contained in:
parent
5132cd7234
commit
db6a63bcf6
@ -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);
|
||||
|
BIN
src/main/res/drawable-hdpi/ic_room_white_24dp.png
Normal file
BIN
src/main/res/drawable-hdpi/ic_room_white_24dp.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 494 B |
BIN
src/main/res/drawable-mdpi/ic_room_white_24dp.png
Normal file
BIN
src/main/res/drawable-mdpi/ic_room_white_24dp.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 362 B |
BIN
src/main/res/drawable-xhdpi/ic_room_white_24dp.png
Normal file
BIN
src/main/res/drawable-xhdpi/ic_room_white_24dp.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 587 B |
BIN
src/main/res/drawable-xxhdpi/ic_room_white_24dp.png
Normal file
BIN
src/main/res/drawable-xxhdpi/ic_room_white_24dp.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 861 B |
BIN
src/main/res/drawable-xxxhdpi/ic_room_white_24dp.png
Normal file
BIN
src/main/res/drawable-xxxhdpi/ic_room_white_24dp.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
Loading…
Reference in New Issue
Block a user