show switch to chat button during audio call. fixes #3825

This commit is contained in:
Daniel Gultsch 2020-07-10 19:30:16 +02:00
parent fffa659881
commit c3fa1d5d30
10 changed files with 35 additions and 5 deletions

View File

@ -88,6 +88,10 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
RtpEndUserState.APPLICATION_ERROR, RtpEndUserState.APPLICATION_ERROR,
RtpEndUserState.CONNECTIVITY_ERROR RtpEndUserState.CONNECTIVITY_ERROR
); );
private static final List<RtpEndUserState> 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 String PROXIMITY_WAKE_LOCK_TAG = "conversations:in-rtp-session";
private static final int REQUEST_ACCEPT_CALL = 0x1111; private static final int REQUEST_ACCEPT_CALL = 0x1111;
private WeakReference<JingleRtpConnection> rtpConnectionReference; private WeakReference<JingleRtpConnection> rtpConnectionReference;
@ -135,7 +139,9 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
public boolean onCreateOptionsMenu(final Menu menu) { public boolean onCreateOptionsMenu(final Menu menu) {
getMenuInflater().inflate(R.menu.activity_rtp_session, menu); getMenuInflater().inflate(R.menu.activity_rtp_session, menu);
final MenuItem help = menu.findItem(R.id.action_help); final MenuItem help = menu.findItem(R.id.action_help);
final MenuItem gotoChat = menu.findItem(R.id.action_goto_chat);
help.setVisible(isHelpButtonVisible()); help.setVisible(isHelpButtonVisible());
gotoChat.setVisible(isSwitchToConversationVisible());
return super.onCreateOptionsMenu(menu); 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) { public boolean onOptionsItemSelected(final MenuItem item) {
if (item.getItemId() == R.id.action_help) { switch (item.getItemId()) {
launchHelpInBrowser(); case R.id.action_help:
return true; launchHelpInBrowser();
break;
case R.id.action_goto_chat:
switchToConversation();
break;
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 192 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 137 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 195 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 256 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 320 B

View File

@ -1,11 +1,16 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" <menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"> xmlns:app="http://schemas.android.com/apk/res-auto">
<item <item
android:id="@+id/action_help" android:id="@+id/action_help"
android:icon="?attr/icon_help" android:icon="?attr/icon_help"
android:title="@string/help" android:title="@string/help"
app:showAsAction="always"/> app:showAsAction="always" />
<item
android:id="@+id/action_goto_chat"
android:icon="?attr/icon_goto_chat"
android:title="@string/switch_to_conversation"
app:showAsAction="always" />
</menu> </menu>

View File

@ -97,6 +97,7 @@
<attr name="icon_remove" format="reference" /> <attr name="icon_remove" format="reference" />
<attr name="icon_search" format="reference" /> <attr name="icon_search" format="reference" />
<attr name="icon_help" format="reference" /> <attr name="icon_help" format="reference" />
<attr name="icon_goto_chat" format="reference" />
<attr name="icon_secure" format="reference" /> <attr name="icon_secure" format="reference" />
<attr name="icon_settings" format="reference" /> <attr name="icon_settings" format="reference" />
<attr name="icon_share" format="reference" /> <attr name="icon_share" format="reference" />

View File

@ -918,6 +918,7 @@
<string name="audio_call">Audio call</string> <string name="audio_call">Audio call</string>
<string name="video_call">Video call</string> <string name="video_call">Video call</string>
<string name="help">Help</string> <string name="help">Help</string>
<string name="switch_to_conversation">Switch to conversation</string>
<string name="microphone_unavailable">Your microphone is unavailable</string> <string name="microphone_unavailable">Your microphone is unavailable</string>
<string name="only_one_call_at_a_time">You can only have one call at a time.</string> <string name="only_one_call_at_a_time">You can only have one call at a time.</string>
<string name="return_to_ongoing_call">Return to ongoing call</string> <string name="return_to_ongoing_call">Return to ongoing call</string>

View File

@ -115,6 +115,7 @@
<item name="icon_remove" type="reference">@drawable/ic_delete_black_24dp</item> <item name="icon_remove" type="reference">@drawable/ic_delete_black_24dp</item>
<item name="icon_search" type="reference">@drawable/ic_search_white_24dp</item> <item name="icon_search" type="reference">@drawable/ic_search_white_24dp</item>
<item name="icon_help" type="reference">@drawable/ic_help_white_24dp</item> <item name="icon_help" type="reference">@drawable/ic_help_white_24dp</item>
<item name="icon_goto_chat" type="reference">@drawable/ic_question_answer_white_24dp</item>
<item name="icon_secure" type="reference">@drawable/ic_lock_open_white_24dp</item> <item name="icon_secure" type="reference">@drawable/ic_lock_open_white_24dp</item>
<item name="icon_settings" type="reference">@drawable/ic_settings_black_24dp</item> <item name="icon_settings" type="reference">@drawable/ic_settings_black_24dp</item>
<item name="icon_share" type="reference">@drawable/ic_share_white_24dp</item> <item name="icon_share" type="reference">@drawable/ic_share_white_24dp</item>
@ -269,6 +270,7 @@
<item name="icon_remove" type="reference">@drawable/ic_delete_white_24dp</item> <item name="icon_remove" type="reference">@drawable/ic_delete_white_24dp</item>
<item name="icon_search" type="reference">@drawable/ic_search_white_24dp</item> <item name="icon_search" type="reference">@drawable/ic_search_white_24dp</item>
<item name="icon_help" type="reference">@drawable/ic_help_white_24dp</item> <item name="icon_help" type="reference">@drawable/ic_help_white_24dp</item>
<item name="icon_goto_chat" type="reference">@drawable/ic_question_answer_white_24dp</item>
<item name="icon_secure" type="reference">@drawable/ic_lock_open_white_24dp</item> <item name="icon_secure" type="reference">@drawable/ic_lock_open_white_24dp</item>
<item name="icon_settings" type="reference">@drawable/ic_settings_white_24dp</item> <item name="icon_settings" type="reference">@drawable/ic_settings_white_24dp</item>
<item name="icon_share" type="reference">@drawable/ic_share_white_24dp</item> <item name="icon_share" type="reference">@drawable/ic_share_white_24dp</item>