From c3fa1d5d30f097658d81333cc5a254a068e5505c Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Fri, 10 Jul 2020 19:30:16 +0200 Subject: [PATCH] show switch to chat button during audio call. fixes #3825 --- .../conversations/ui/RtpSessionActivity.java | 27 ++++++++++++++++-- .../ic_question_answer_white_24dp.png | Bin 0 -> 192 bytes .../ic_question_answer_white_24dp.png | Bin 0 -> 137 bytes .../ic_question_answer_white_24dp.png | Bin 0 -> 195 bytes .../ic_question_answer_white_24dp.png | Bin 0 -> 256 bytes .../ic_question_answer_white_24dp.png | Bin 0 -> 320 bytes src/main/res/menu/activity_rtp_session.xml | 9 ++++-- src/main/res/values/attrs.xml | 1 + src/main/res/values/strings.xml | 1 + src/main/res/values/themes.xml | 2 ++ 10 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 src/main/res/drawable-hdpi/ic_question_answer_white_24dp.png create mode 100644 src/main/res/drawable-mdpi/ic_question_answer_white_24dp.png create mode 100644 src/main/res/drawable-xhdpi/ic_question_answer_white_24dp.png create mode 100644 src/main/res/drawable-xxhdpi/ic_question_answer_white_24dp.png create mode 100644 src/main/res/drawable-xxxhdpi/ic_question_answer_white_24dp.png diff --git a/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java b/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java index cf0e01db4..33835119f 100644 --- a/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java @@ -88,6 +88,10 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe RtpEndUserState.APPLICATION_ERROR, RtpEndUserState.CONNECTIVITY_ERROR ); + private static final List STATES_SHOWING_SWITCH_TO_CHAT = Arrays.asList( + RtpEndUserState.CONNECTING, + RtpEndUserState.CONNECTED + ); private static final String PROXIMITY_WAKE_LOCK_TAG = "conversations:in-rtp-session"; private static final int REQUEST_ACCEPT_CALL = 0x1111; private WeakReference rtpConnectionReference; @@ -135,7 +139,9 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe public boolean onCreateOptionsMenu(final Menu menu) { getMenuInflater().inflate(R.menu.activity_rtp_session, menu); final MenuItem help = menu.findItem(R.id.action_help); + final MenuItem gotoChat = menu.findItem(R.id.action_goto_chat); help.setVisible(isHelpButtonVisible()); + gotoChat.setVisible(isSwitchToConversationVisible()); return super.onCreateOptionsMenu(menu); } @@ -153,10 +159,25 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe } } + private boolean isSwitchToConversationVisible() { + final JingleRtpConnection connection = this.rtpConnectionReference != null ? this.rtpConnectionReference.get() : null; + return connection != null && STATES_SHOWING_SWITCH_TO_CHAT.contains(connection.getEndUserState()); + } + + private void switchToConversation() { + final Contact contact = getWith(); + final Conversation conversation = xmppConnectionService.findOrCreateConversation(contact.getAccount(), contact.getJid(), false, true); + switchToConversation(conversation); + } + public boolean onOptionsItemSelected(final MenuItem item) { - if (item.getItemId() == R.id.action_help) { - launchHelpInBrowser(); - return true; + switch (item.getItemId()) { + case R.id.action_help: + launchHelpInBrowser(); + break; + case R.id.action_goto_chat: + switchToConversation(); + break; } return super.onOptionsItemSelected(item); } diff --git a/src/main/res/drawable-hdpi/ic_question_answer_white_24dp.png b/src/main/res/drawable-hdpi/ic_question_answer_white_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..247b7f11d2cdc53a988ec51e63d7678627dd750a GIT binary patch literal 192 zcmeAS@N?(olHy`uVBq!ia0vp^Dj>|k0wldT1B8K8yQhm|NCo5DGlpD;0%V#$KKGqt z6Q=)Y(#{Hv{-E<0?U#sfa`4Mf)LC?Pd&;k^^X2n(s;WO6y0$#{OS!D$d>-}`rw98U z&2c`z)^dsLg?Puw?7BxbbgHvQRiqV5IV2T%@T__FUcs>UUzLXsU+2x$ELFMBW;y4b kP;8Y6f)cEbmGNA;-wkgV*Yg-p20Dqs)78&qol`;+05tPPR{#J2 literal 0 HcmV?d00001 diff --git a/src/main/res/drawable-mdpi/ic_question_answer_white_24dp.png b/src/main/res/drawable-mdpi/ic_question_answer_white_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..dad29526ae38bae2ccea06618caec7e2aae05c6d GIT binary patch literal 137 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM0wlfaz7_+i08bakkP619rwzFp5_p^+%GpjA zezj65g6021&PW%7{1=zj-{S%;9qx k{a7pnAGkCKGwZRl2S4EAmlFCB0W_Pz)78&qol`;+03PivF#rGn literal 0 HcmV?d00001 diff --git a/src/main/res/drawable-xhdpi/ic_question_answer_white_24dp.png b/src/main/res/drawable-xhdpi/ic_question_answer_white_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..dbb131aab6765bfa19ff1e833f63b82d92299dc9 GIT binary patch literal 195 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA0wn)(8}b0DE>9Q7kP61PmkqfNI|w)j#v07H zlhOD3t7@H>#F20!imhrDdLIXQvjdUbKm{dXo zBij$-2WObn*YgFe*qFN@KuBW>3zur+r~UVB12i~AyqH=y9r(V^q+mmnL-JHMpCb&y th6h}D3UUwFj>nQX`O{?urOrevmrhK&zq zI28COSg2i?yLshvAT1yx%+bfma-5|}nZfo(DzmTji-r)j3#;au38+YOOyXrZ$<~y@ s?6|2>;ikic90d=AuoNTfm-UYJ*R<0D!ftKT0eXqS)78&qol`;+01X{npa1{> literal 0 HcmV?d00001 diff --git a/src/main/res/drawable-xxxhdpi/ic_question_answer_white_24dp.png b/src/main/res/drawable-xxxhdpi/ic_question_answer_white_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..9b26c13a08b1733bb7c0792e4fcbc921d6eda543 GIT binary patch literal 320 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD0wg^q?%&M7z{u|D;uuoF`1bn2OlC)s=0wxv zWxk!X7X`{(}HdGO#nzGGGg zo^(C4Ixtz=>N?}PRSisB8Vf+ggVjv;{_`d>G&E1-ZJ5btahdUtu>&KkNB{~k=Ve2+ z*@Nb2y$4Uu@xEn}_gTe~DWM4fmtS}| literal 0 HcmV?d00001 diff --git a/src/main/res/menu/activity_rtp_session.xml b/src/main/res/menu/activity_rtp_session.xml index 540a9def9..04756490a 100644 --- a/src/main/res/menu/activity_rtp_session.xml +++ b/src/main/res/menu/activity_rtp_session.xml @@ -1,11 +1,16 @@ + xmlns:app="http://schemas.android.com/apk/res-auto"> + app:showAsAction="always" /> + \ No newline at end of file diff --git a/src/main/res/values/attrs.xml b/src/main/res/values/attrs.xml index 1f78fb09b..e67517049 100644 --- a/src/main/res/values/attrs.xml +++ b/src/main/res/values/attrs.xml @@ -97,6 +97,7 @@ + diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 75d839f0b..734a015c3 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -918,6 +918,7 @@ Audio call Video call Help + Switch to conversation Your microphone is unavailable You can only have one call at a time. Return to ongoing call diff --git a/src/main/res/values/themes.xml b/src/main/res/values/themes.xml index 50262913f..8def180d8 100644 --- a/src/main/res/values/themes.xml +++ b/src/main/res/values/themes.xml @@ -115,6 +115,7 @@ @drawable/ic_delete_black_24dp @drawable/ic_search_white_24dp @drawable/ic_help_white_24dp + @drawable/ic_question_answer_white_24dp @drawable/ic_lock_open_white_24dp @drawable/ic_settings_black_24dp @drawable/ic_share_white_24dp @@ -269,6 +270,7 @@ @drawable/ic_delete_white_24dp @drawable/ic_search_white_24dp @drawable/ic_help_white_24dp + @drawable/ic_question_answer_white_24dp @drawable/ic_lock_open_white_24dp @drawable/ic_settings_white_24dp @drawable/ic_share_white_24dp