From db6a63bcf6c100f24b90778c3d69e8b6cec31b16 Mon Sep 17 00:00:00 2001 From: iNPUTmice Date: Tue, 10 Mar 2015 21:46:13 +0100 Subject: [PATCH] open location directly from notification --- .../services/NotificationService.java | 25 ++++++++++++++++++ .../res/drawable-hdpi/ic_room_white_24dp.png | Bin 0 -> 494 bytes .../res/drawable-mdpi/ic_room_white_24dp.png | Bin 0 -> 362 bytes .../res/drawable-xhdpi/ic_room_white_24dp.png | Bin 0 -> 587 bytes .../drawable-xxhdpi/ic_room_white_24dp.png | Bin 0 -> 861 bytes .../drawable-xxxhdpi/ic_room_white_24dp.png | Bin 0 -> 1093 bytes 6 files changed, 25 insertions(+) create mode 100644 src/main/res/drawable-hdpi/ic_room_white_24dp.png create mode 100644 src/main/res/drawable-mdpi/ic_room_white_24dp.png create mode 100644 src/main/res/drawable-xhdpi/ic_room_white_24dp.png create mode 100644 src/main/res/drawable-xxhdpi/ic_room_white_24dp.png create mode 100644 src/main/res/drawable-xxxhdpi/ic_room_white_24dp.png 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 messages) { + for(final Message message : messages) { + if (GeoHelper.isGeoUri(message.getBody())) { + return message; + } + } + return null; + } + private CharSequence getMergedBodies(final ArrayList 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 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 0000000000000000000000000000000000000000..c2ccd51064b3d487236a833c280f9000c4c35d2c GIT binary patch literal 494 zcmV004R> z004l5008;`004mK004C`008P>0026e000+ooVrmw00002VoOIv0RM-N%)bBt010qN zS#tmY3ljhU3ljkVnw%H_00Cx6L_t(Y$K94aO9Md=hL;o(gBSd$LR$R~f^86kSQ~p| zMA4X9Td~sGCjN&=4gyvpVxcLF_y+>onFv9POX6cA;#}@__hK5I?dF|*irv|HSD{9; z)Sm)5r6xk#VFCjA1@S%MFAzbAS`M)wx9$z=;E4jJ5U)@oZ5gEFvkb; zW>D3)sY{((JYTkA0?p798(dN-6e(OEeo_xw5#P# zoDo_^X#0B5jwsFxtst~*J!mQPjK+8r+M*sbO+WC~($qx0&y=Z;u6!NiaYvo5FMDZj z$SrJQ(+o<|F=9G{6Cmi(o)|&LcCSChyB72IbpaNG?MMqcw4aa;&!Lzn`w6K~tc8Md zQC-9h#8ji(QJVGurbT)fU&{@ER)=-kGl3}&Z`p|-Q}I5?gzUY4j#mKM%>MQhk)=?nRCMRxz&|0vS>1a3cw$(*+uPXGV_07*qoM6N<$f)$O!rT_o{ literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..a4fcd7708002165c9c36dd4b69440a763a0080d9 GIT binary patch literal 362 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM0wlfaz7_*1g=CK)Uj~LMH3o);76yi2K%s^g z3=E|P3=FRl7#OT(FffQ0%-I!a1C(G&@^*J&_}|`tWO=~G=WkMH z$kW9!#NzbUDc*dHjsk7gF;087$uvk$C}8e1-tdg!(5d9U!+osYhctVpKG!*tzA)JE z${B%=*H^9nr~lF~bnC$y@n_`psPdyLWibs00Y!@cgmDVcoizFlL-4rY_k=P5idcUA*^%i!ti=d#Wzp$P#0 C%ZaT3 literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..e1e60a5c26885fd697ca7e693c7a71d022d9e49b GIT binary patch literal 587 zcmV-R0<`^!P)004R> z004l5008;`004mK004C`008P>0026e000+ooVrmw00002VoOIv0RM-N%)bBt010qN zS#tmY3ljhU3ljkVnw%H_00F~EL_t(o!|j*5N&`U{g|mthLPFj`FpV}|io|FY;;j&0 zK*Tzr27Ch*Q;4l1K7eSnSG=V1)@bFWh!&bkOrqeTe744!-OTJx3L*cNd*=U!-MO3- zAkf$+&;*zPSPYS)KnWY07fx9riDd@R$_x+4>W*nz`~o_;#I4Th@BVSe|_J1{bL35%GC<%k(f@VO_JgWo54HgtMAwl!04*2i{cvlBJ zDXfsBped>Y4u!!xf@WXP9H;}9B#SUxqgaqA7S#bM=|;*kK!^}Y$?O67nJNdg^QL`N zywav~*llS8HuX-^er-UX?uB!q)&4^NMw`?EOy~nFZj{?!J9{LzOMhG$Fy_^^94oay z^6rbe`KsIgi!MLTZmlk0)t_~Y@aWpUNW`!CO}hfpChYr$WBYY8`5^4zlI{tc3Lw3b zTiT|_WQ3X*0CQ$Dn#EpC`(5)PFv{&O9~x~$%8XG4piHb$F?N)1z8Ps`PR@{NCjI{g Z_yLBqowqvfpDF+V002ovPDHLkV1hcM`3C?1 literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..00b15508b22a0efce9043713aa51d25c7e84b5e1 GIT binary patch literal 861 zcmV-j1ETziP)004R> z004l5008;`004mK004C`008P>0026e000+ooVrmw00002VoOIv0RM-N%)bBt010qN zS#tmY3ljhU3ljkVnw%H_00PxXL_t(&-tC&dYg17a#}iD9$<(0~`ol$`w2PKlsAQ;^ zKR`jSs3;}ItQ7}G5j&*a{Lw{ha1ex$irPVu;tx9LYPBt)2tskOP187}27~F>L2cFM zp7-88=e|UE=dJI1^Wo;)ch5cF>w~Yk9-jx~0eL{%PY7|0Vj6iAQAHI+PXP!uz;6VK3R9w>qd)L=Kh;|BJa1nR*8oW^@}n*xeq9Xhdw!zO@Y z*nn=7F(3`pqd7a6fEDp%>@b(TPOg0#xMd~ZwHaU3iXbC=03o2qb6|_jy)c3@I?#mSUF)^S)sdL$!2+o|`LGg?T&{;X4 zUHHJp`A8IW8qJ0z8|b`j_alHM7S58r`Ek-8I>7=uX`+MnS{vt$nU>xFHnngz?f1`| zHa#<1KzGe`VOxn~k-CO%HQA?5IR?65wsG#qOGh}b%v%fl9JGfwu-^@@W5hPlh&$$s zAJ1*!ynx>=d#Vd1OPmt+y6Kkeq1 literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..a5dde3b94ee3e494268ad8b5ab71d6975d9c0737 GIT binary patch literal 1093 zcmV-L1iJf)P)004R> z004l5008;`004mK004C`008P>0026e000+ooVrmw00002VoOIv0RM-N%)bBt010qN zS#tmY3ljhU3ljkVnw%H_00X^AL_t(|+U=W7NK{c2$6q?*jMl0Ya+G1*go{=h%_2l; zDIw0Ft=i-!WAH26TmToq1#kge0A~RdB8*-PBZ)<-td zo5ZbzNbmUp9uv}zks?hHA|?0%?vWO*f@e5gVzCP-8F zuR3J_juQufb%mskRi0`oe@^aPs7DJxj~qa$slyR9rBNn%Haad2FfDtydqy1Ktn~fB zYti!G$X{?=6a{FL2k?-#_i9=;Zv#=eBfBgH(52^+&xg+<<$r-+*FABE2tbFvi*7GI zu$MotW`k0-8k}bbxS-qYF~?f|GaS+lP{#^TXNO;Cg01{X^(w3Yl;?3MQng7qj1jV& z@$3(-+UJ?`Ftm2B;IY%S7`C`i&fv7&w#yrq0B+jv8!fi5Du1+YedTcOHegq&{9QCS z#XEgV3E;MK%-?>zHC_HY6g$biUPHPB+$LX+eWn1eIqv~P0TSf$6LdF<&KDd3 ztP&kr0luufFIpN2f2g}?bn+vh!Mp&2&VI$@!EDa*XRWnvI-X&bW97i|SJWKpdI1d7 zV<&6*JE-T+CIMie+nSBcegFfb`^q1c$s`5f|L53cPUYCpP5=XeJtwH2_$RMCfPvaS zUiU53$YqfPFc3io88l1gkOeT%BlF**4?z6m0=NJ!fD7OPSo-`16T)}G++ta@00000 LNkvXXu0mjf7}C=e literal 0 HcmV?d00001