From 766d1d603e29c21972e86933b75f1abf1c9d22aa Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Fri, 3 Apr 2020 16:44:29 +0200 Subject: [PATCH] show preliminary call button if contact supports it --- .../ui/ConversationFragment.java | 4 + .../xmpp/jingle/RtpCapability.java | 58 +++++++++++++ .../res/drawable-hdpi/ic_call_white_24dp.png | Bin 0 -> 340 bytes .../res/drawable-mdpi/ic_call_white_24dp.png | Bin 0 -> 246 bytes .../res/drawable-xhdpi/ic_call_white_24dp.png | Bin 0 -> 420 bytes .../drawable-xxhdpi/ic_call_white_24dp.png | Bin 0 -> 597 bytes .../drawable-xxxhdpi/ic_call_white_24dp.png | Bin 0 -> 778 bytes src/main/res/menu/fragment_conversation.xml | 76 ++++++++++-------- src/main/res/values/attrs.xml | 1 + src/main/res/values/strings.xml | 1 + src/main/res/values/themes.xml | 2 + 11 files changed, 107 insertions(+), 35 deletions(-) create mode 100644 src/main/java/eu/siacs/conversations/xmpp/jingle/RtpCapability.java create mode 100644 src/main/res/drawable-hdpi/ic_call_white_24dp.png create mode 100644 src/main/res/drawable-mdpi/ic_call_white_24dp.png create mode 100644 src/main/res/drawable-xhdpi/ic_call_white_24dp.png create mode 100644 src/main/res/drawable-xxhdpi/ic_call_white_24dp.png create mode 100644 src/main/res/drawable-xxxhdpi/ic_call_white_24dp.png diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java index 9d9ebf819..11f8274eb 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java @@ -116,6 +116,7 @@ import eu.siacs.conversations.utils.UIHelper; import eu.siacs.conversations.xmpp.XmppConnection; import eu.siacs.conversations.xmpp.chatstate.ChatState; import eu.siacs.conversations.xmpp.jingle.JingleFileTransferConnection; +import eu.siacs.conversations.xmpp.jingle.RtpCapability; import rocks.xmpp.addr.Jid; import static eu.siacs.conversations.ui.XmppActivity.EXTRA_ACCOUNT; @@ -950,6 +951,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke final MenuItem menuInviteContact = menu.findItem(R.id.action_invite); final MenuItem menuMute = menu.findItem(R.id.action_mute); final MenuItem menuUnmute = menu.findItem(R.id.action_unmute); + final MenuItem menuCall = menu.findItem(R.id.action_call); if (conversation != null) { @@ -957,7 +959,9 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke menuContactDetails.setVisible(false); menuInviteContact.setVisible(conversation.getMucOptions().canInvite()); menuMucDetails.setTitle(conversation.getMucOptions().isPrivateAndNonAnonymous() ? R.string.action_muc_details : R.string.channel_details); + menuCall.setVisible(false); } else { + menuCall.setVisible(RtpCapability.check(conversation.getContact()) != RtpCapability.Capability.NONE); menuContactDetails.setVisible(!this.conversation.withSelf()); menuMucDetails.setVisible(false); final XmppConnectionService service = activity.xmppConnectionService; diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/RtpCapability.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/RtpCapability.java new file mode 100644 index 000000000..646137495 --- /dev/null +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/RtpCapability.java @@ -0,0 +1,58 @@ +package eu.siacs.conversations.xmpp.jingle; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import eu.siacs.conversations.entities.Contact; +import eu.siacs.conversations.entities.Presence; +import eu.siacs.conversations.entities.Presences; +import eu.siacs.conversations.entities.ServiceDiscoveryResult; +import eu.siacs.conversations.xml.Namespace; + +public class RtpCapability { + + private static List BASIC_RTP_REQUIREMENTS = Arrays.asList( + Namespace.JINGLE, + Namespace.JINGLE_TRANSPORT_ICE_UDP, + Namespace.JINGLE_APPS_RTP, + Namespace.JINGLE_APPS_DTLS + ); + private static List VIDEO_REQUIREMENTS = Arrays.asList( + Namespace.JINGLE_FEATURE_AUDIO, + Namespace.JINGLE_FEATURE_VIDEO + ); + + public static Capability check(final Presence presence) { + final ServiceDiscoveryResult disco = presence.getServiceDiscoveryResult(); + final List features = disco == null ? Collections.emptyList() : disco.getFeatures(); + if (features.containsAll(BASIC_RTP_REQUIREMENTS)) { + if (features.containsAll(VIDEO_REQUIREMENTS)) { + return Capability.VIDEO; + } + if (features.contains(Namespace.JINGLE_FEATURE_AUDIO)) { + return Capability.AUDIO; + } + } + return Capability.NONE; + } + + public static Capability check(final Contact contact) { + final Presences presences = contact.getPresences(); + Capability result = Capability.NONE; + for(Presence presence : presences.getPresences().values()) { + Capability capability = check(presence); + if (capability == Capability.VIDEO) { + result = capability; + } else if (capability == Capability.AUDIO && result == Capability.NONE) { + result = capability; + } + } + return result; + } + + public enum Capability { + NONE, AUDIO, VIDEO + } + +} diff --git a/src/main/res/drawable-hdpi/ic_call_white_24dp.png b/src/main/res/drawable-hdpi/ic_call_white_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..4dc5065155baeba719d76845d4398431c289cde0 GIT binary patch literal 340 zcmV-a0jvIrP)2;3l0LOD$N=(0Aydxv3a1NO%A-5V49kkQ!=X zV`%)ixtjF0)a^NIzfT&=3_}@<#bU8k$;l06(wcI^K4~{{!wzW=azjYkD}h|FPQL}Y zV3vL*xgg+~w1(VpOxmv85YnrTksES+&{fCC9j7Gf82Mn8*e6T!#Wk@r`JzB#L%wJb zYcnT5dC{Hk}*!A?jJR>)4GKBfXec?}<0&9upF*X8-^I07*qoM6N<$f?IEA=l}o! literal 0 HcmV?d00001 diff --git a/src/main/res/drawable-xhdpi/ic_call_white_24dp.png b/src/main/res/drawable-xhdpi/ic_call_white_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..ef45e933a99b720cc5f6127e6da22bc2fa679244 GIT binary patch literal 420 zcmV;V0bBlwP)u7H4zjb0wVlEO#(-afhJ{~L_owyniLh<44m_hh=0)JC~(EtGz}i`o*rY-v?y@O z7&HsExZpoDD~cS_W+YkQAr(Fol6E6IIG(V_N51l%CO?U|VOMi=rhWlQl3!NbcvwOJ O0000IqP)a~F^ihkCNXidBsWB>X=;U*@F%!%#fVZaU}txjgmm7*kE>_wfD zJ4vghX)Y+W+A>RYW}(s9ms0kgvz_-nXXic7bMt;aQYw{7rQ+a|A;-#I(=OY{5am0Y zWfwW3^~f&rM7t`x_(`-r*+q_ML$ZrWqCJ#dj1g^AcJY*GIgD&#kT@-}i3`LzE}J+^ zoB`QH3vni76Nb;kX_ZZk5a)z!;v#YO$R>6Z?LI~}VVI$`08h4Yi&6qS*+(ZU3-IIu z>zHA=08g&aOR)e??y#Lg0iN9A2}>4ekZW`hc1f;bc*&AEHpw*(5q4XyVR%khr(9zf zd6rDFUaoP2usayJMLpAmosw%DC2WCxa*ZLvKCxA9QO8@t-q9$x*vU7-#@QgZ=w^|y zaT*l^!(L9ZMYTZ>h2FDG5%3w|pEvY#jAo3IgrT28vm8(f_+%;eg;zXakY28EhGta@ z!!U(@aT=p#@W~Qqp8cv8YZ#{3JsMO1pDg7VQ}r-hr`Qx-`VXHhbwLu%tSQXU{ z2YEroR7)7z38;u_k5;bnkuu2+*3!Wc)5OWiCJb$y=Ml4%G9VW)G||O5GCXFK4}9eZ jd2$TkDV0j4QgQwO?=x#gyQpL<00000NkvXXu0mjf@K6c} literal 0 HcmV?d00001 diff --git a/src/main/res/drawable-xxxhdpi/ic_call_white_24dp.png b/src/main/res/drawable-xxxhdpi/ic_call_white_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..b0e020573d37e8b4acac23fcd3e01cc39531b5e4 GIT binary patch literal 778 zcmV+l1NHogP)pE0}6<4A=MUgDB6h!xmw?$P#D_ykG zL=hFSC`v&PZLuhB6vP_@=VGGKX8IHCrk*(yzZvID{vUkLBLzVa1VIo437F3S<}L zr)ZZ=%%^~hA`4^@1GpNLMLfgRh%BOnyC&Jg3*1eTJrr;^UH0$M-cTV>3Gwxo}CTrME zHM(UD8LF{E*6;z(an~(-ID@NuOqM-t!_8Bc$|63;MUD>HM8qB5B}b?1Vi)7f(<#eX z$ao5L$u=TxQb~b~>|-0rie%*jX7ZA9MV8AK{777pFXRuF5qDC4;R10P`GnQPT_ln} zi1>rJwekty5O<$e`GbfH#O;+&SVD=n{ma+#35SWhOPl<`Y=(&ICz3zdK)H?b2N7q9 z8>LJB;8XI%J>VnxgC5FVqgDRk80F5=B403-KPmSM&GH4Gk)zykn&k_=WsGva(xNKR z%J=lq!!$J>n@MtxRyiWeBmVObzthK;OjaYYha}heSPsZiAnp~{I7%Nqe8pU5F@+|j zhloQYc}Pa@K$Ze-MmR;g(m@mbBpGEhkt!lXfoc?4pmfkoKgoXLLnR_Zo@xy$Ei`eE zWcOI1GIWurdLv2?5xc2mKW+LSy2w)#rHf6Bk?aBMi1Y@XTphVqhBCv?_)QKhv zE4e})XyOpDiu1fDO*EF!&nPvM1 + xmlns:app="http://schemas.android.com/apk/res-auto"> + android:title="@string/action_secure" + app:showAsAction="always"> - + + android:title="@string/encryption_choice_unencrypted" /> + android:title="@string/encryption_choice_omemo" /> + android:title="@string/encryption_choice_pgp" /> @@ -25,76 +25,82 @@ android:id="@+id/action_attach_file" android:icon="?attr/icon_new_attachment" android:orderInCategory="30" - app:showAsAction="always" - android:title="@string/attach_file"> + android:title="@string/attach_file" + app:showAsAction="always"> + android:icon="?attr/ic_attach_document" + android:title="@string/choose_file" /> + android:icon="?attr/ic_attach_photo" + android:title="@string/attach_choose_picture" /> + android:icon="?attr/ic_attach_camera" + android:title="@string/attach_take_picture" /> + android:icon="?attr/ic_attach_videocam" + android:title="@string/attach_record_video" /> + android:icon="?attr/ic_attach_record" + android:title="@string/attach_record_voice" /> + android:icon="?attr/ic_attach_location" + android:title="@string/send_location" /> + + android:title="@string/action_contact_details" + app:showAsAction="never" /> + android:title="@string/action_muc_details" + app:showAsAction="never" /> + android:title="@string/invite_contact" + app:showAsAction="never" /> + android:title="@string/action_clear_history" + app:showAsAction="never" /> + android:title="@string/action_end_conversation" + app:showAsAction="never" /> + android:title="@string/disable_notifications" + app:showAsAction="never" /> + android:title="@string/enable_notifications" + app:showAsAction="never" /> \ No newline at end of file diff --git a/src/main/res/values/attrs.xml b/src/main/res/values/attrs.xml index ce15d0013..3eab0fecf 100644 --- a/src/main/res/values/attrs.xml +++ b/src/main/res/values/attrs.xml @@ -85,6 +85,7 @@ + diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index ef5dbbf0d..d91374ade 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -884,6 +884,7 @@ Backup About Please enable an account + Make call View %1$d Participant View %1$d Participants diff --git a/src/main/res/values/themes.xml b/src/main/res/values/themes.xml index 219fb6702..454f0ca6c 100644 --- a/src/main/res/values/themes.xml +++ b/src/main/res/values/themes.xml @@ -93,6 +93,7 @@ @drawable/ic_refresh_black_24dp @drawable/ic_attach_file_white_24dp @drawable/ic_lock_open_white_24dp + @drawable/ic_call_white_24dp @drawable/ic_delete_black_24dp @drawable/ic_search_white_24dp @drawable/ic_lock_open_white_24dp @@ -207,6 +208,7 @@ @drawable/ic_refresh_white_24dp @drawable/ic_attach_file_white_24dp @drawable/ic_lock_open_white_24dp + @drawable/ic_call_white_24dp @drawable/ic_delete_white_24dp @drawable/ic_search_white_24dp @drawable/ic_lock_open_white_24dp