make seperate menu items for audio and video calls

This commit is contained in:
Daniel Gultsch 2020-04-15 16:26:53 +02:00
parent 17d9b02f41
commit b4df19177f
25 changed files with 73 additions and 11 deletions

View file

@ -140,6 +140,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
public static final int REQUEST_ADD_EDITOR_CONTENT = 0x0211; public static final int REQUEST_ADD_EDITOR_CONTENT = 0x0211;
public static final int REQUEST_COMMIT_ATTACHMENTS = 0x0212; public static final int REQUEST_COMMIT_ATTACHMENTS = 0x0212;
public static final int REQUEST_START_AUDIO_CALL = 0x213; public static final int REQUEST_START_AUDIO_CALL = 0x213;
public static final int REQUEST_START_VIDEO_CALL = 0x214;
public static final int ATTACHMENT_CHOICE_CHOOSE_IMAGE = 0x0301; public static final int ATTACHMENT_CHOICE_CHOOSE_IMAGE = 0x0301;
public static final int ATTACHMENT_CHOICE_TAKE_PHOTO = 0x0302; public static final int ATTACHMENT_CHOICE_TAKE_PHOTO = 0x0302;
public static final int ATTACHMENT_CHOICE_CHOOSE_FILE = 0x0303; public static final int ATTACHMENT_CHOICE_CHOOSE_FILE = 0x0303;
@ -1234,8 +1235,11 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
BlockContactDialog.show((XmppActivity) activity, conversation); BlockContactDialog.show((XmppActivity) activity, conversation);
} }
break; break;
case R.id.action_call: case R.id.action_audio_call:
checkPermissionAndTriggerRtpSession(); checkPermissionAndTriggerAudioCall();
break;
case R.id.action_video_call:
checkPermissionAndTriggerVideoCall();
break; break;
default: default:
break; break;
@ -1243,21 +1247,31 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }
private void checkPermissionAndTriggerRtpSession() { private void checkPermissionAndTriggerAudioCall() {
if (activity.xmppConnectionService.useTorToConnect() || conversation.getAccount().isOnion()) { if (activity.xmppConnectionService.useTorToConnect() || conversation.getAccount().isOnion()) {
Toast.makeText(activity, R.string.disable_tor_to_make_call, Toast.LENGTH_SHORT).show(); Toast.makeText(activity, R.string.disable_tor_to_make_call, Toast.LENGTH_SHORT).show();
return; return;
} }
if (hasPermissions(REQUEST_START_AUDIO_CALL, Manifest.permission.RECORD_AUDIO)) { if (hasPermissions(REQUEST_START_AUDIO_CALL, Manifest.permission.RECORD_AUDIO)) {
triggerRtpSession(); triggerRtpSession(RtpSessionActivity.ACTION_MAKE_VOICE_CALL);
}
}
private void checkPermissionAndTriggerVideoCall() {
if (activity.xmppConnectionService.useTorToConnect() || conversation.getAccount().isOnion()) {
Toast.makeText(activity, R.string.disable_tor_to_make_call, Toast.LENGTH_SHORT).show();
return;
}
if (hasPermissions(REQUEST_START_VIDEO_CALL, Manifest.permission.RECORD_AUDIO, Manifest.permission.CAMERA)) {
triggerRtpSession(RtpSessionActivity.ACTION_MAKE_VIDEO_CALL);
} }
} }
private void triggerRtpSession() { private void triggerRtpSession(final String action) {
final Contact contact = conversation.getContact(); final Contact contact = conversation.getContact();
final Intent intent = new Intent(activity, RtpSessionActivity.class); final Intent intent = new Intent(activity, RtpSessionActivity.class);
intent.setAction(RtpSessionActivity.ACTION_MAKE_VOICE_CALL); intent.setAction(action);
intent.putExtra(RtpSessionActivity.EXTRA_ACCOUNT, contact.getAccount().getJid().toEscapedString()); intent.putExtra(RtpSessionActivity.EXTRA_ACCOUNT, contact.getAccount().getJid().toEscapedString());
intent.putExtra(RtpSessionActivity.EXTRA_WITH, contact.getJid().asBareJid().toEscapedString()); intent.putExtra(RtpSessionActivity.EXTRA_WITH, contact.getJid().asBareJid().toEscapedString());
startActivity(intent); startActivity(intent);
@ -1414,7 +1428,10 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
commitAttachments(); commitAttachments();
break; break;
case REQUEST_START_AUDIO_CALL: case REQUEST_START_AUDIO_CALL:
triggerRtpSession(); triggerRtpSession(RtpSessionActivity.ACTION_MAKE_VOICE_CALL);
break;
case REQUEST_START_VIDEO_CALL:
triggerRtpSession(RtpSessionActivity.ACTION_MAKE_VIDEO_CALL);
break; break;
default: default:
attachFile(requestCode); attachFile(requestCode);

View file

@ -190,6 +190,7 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
@Override @Override
void onBackendConnected() { void onBackendConnected() {
final Intent intent = getIntent(); final Intent intent = getIntent();
final String action = intent.getAction();
final Account account = extractAccount(intent); final Account account = extractAccount(intent);
final Jid with = Jid.of(intent.getStringExtra(EXTRA_WITH)); final Jid with = Jid.of(intent.getStringExtra(EXTRA_WITH));
final String sessionId = intent.getStringExtra(EXTRA_SESSION_ID); final String sessionId = intent.getStringExtra(EXTRA_SESSION_ID);
@ -200,10 +201,16 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
requestPermissionsAndAcceptCall(); requestPermissionsAndAcceptCall();
resetIntent(intent.getExtras()); resetIntent(intent.getExtras());
} }
} else if (asList(ACTION_MAKE_VIDEO_CALL, ACTION_MAKE_VOICE_CALL).contains(intent.getAction())) { } else if (asList(ACTION_MAKE_VIDEO_CALL, ACTION_MAKE_VOICE_CALL).contains(action)) {
proposeJingleRtpSession(account, with, ImmutableSet.of(Media.AUDIO, Media.VIDEO)); final Set<Media> media;
if (ACTION_MAKE_VIDEO_CALL.equals(action)) {
media = ImmutableSet.of(Media.AUDIO, Media.VIDEO);
} else {
media = ImmutableSet.of(Media.AUDIO);
}
proposeJingleRtpSession(account, with, media);
binding.with.setText(account.getRoster().getContact(with).getDisplayName()); binding.with.setText(account.getRoster().getContact(with).getDisplayName());
} else if (Intent.ACTION_VIEW.equals(intent.getAction())) { } else if (Intent.ACTION_VIEW.equals(action)) {
final String extraLastState = intent.getStringExtra(EXTRA_LAST_REPORTED_STATE); final String extraLastState = intent.getStringExtra(EXTRA_LAST_REPORTED_STATE);
if (extraLastState != null) { if (extraLastState != null) {
Log.d(Config.LOGTAG, "restored last state from intent extra"); Log.d(Config.LOGTAG, "restored last state from intent extra");

Binary file not shown.

After

Width:  |  Height:  |  Size: 326 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 169 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 173 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 244 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 127 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 131 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 408 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 171 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 178 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 574 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 224 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 234 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 758 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 270 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 290 B

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/ic_call_black_24dp"
android:tint="@color/black54" />

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/ic_call_white_24dp"
android:tint="@color/white70" />

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/ic_videocam_black_24dp"
android:tint="@color/black54" />

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/ic_videocam_white_24dp"
android:tint="@color/white70" />

View file

@ -65,7 +65,18 @@
android:icon="?attr/icon_call" android:icon="?attr/icon_call"
android:orderInCategory="35" android:orderInCategory="35"
android:title="@string/make_call" android:title="@string/make_call"
app:showAsAction="always" /> app:showAsAction="always">
<menu>
<item
android:id="@+id/action_audio_call"
android:icon="?attr/ic_make_audio_call"
android:title="@string/audio_call" />
<item
android:id="@+id/action_video_call"
android:icon="?attr/ic_make_video_call"
android:title="@string/video_call" />
</menu>
</item>
<item <item
android:id="@+id/action_contact_details" android:id="@+id/action_contact_details"
android:orderInCategory="40" android:orderInCategory="40"

View file

@ -45,6 +45,9 @@
<attr name="ic_attach_photo" format="reference"/> <attr name="ic_attach_photo" format="reference"/>
<attr name="ic_attach_record" format="reference"/> <attr name="ic_attach_record" format="reference"/>
<attr name="ic_make_audio_call" format="reference"/>
<attr name="ic_make_video_call" format="reference"/>
<attr name="ic_cloud_download" format="reference"/> <attr name="ic_cloud_download" format="reference"/>

View file

@ -908,6 +908,8 @@
<string name="outgoing_call">Outgoing call</string> <string name="outgoing_call">Outgoing call</string>
<string name="outgoing_call_duration">Outgoing call · %s</string> <string name="outgoing_call_duration">Outgoing call · %s</string>
<string name="missed_call">Missed call</string> <string name="missed_call">Missed call</string>
<string name="audio_call">Audio call</string>
<string name="video_call">Video call</string>
<plurals name="view_users"> <plurals name="view_users">
<item quantity="one">View %1$d Participant</item> <item quantity="one">View %1$d Participant</item>
<item quantity="other">View %1$d Participants</item> <item quantity="other">View %1$d Participants</item>

View file

@ -54,6 +54,9 @@
<item type="reference" name="ic_attach_photo">@drawable/ic_attach_photo</item> <item type="reference" name="ic_attach_photo">@drawable/ic_attach_photo</item>
<item type="reference" name="ic_attach_record">@drawable/ic_attach_record</item> <item type="reference" name="ic_attach_record">@drawable/ic_attach_record</item>
<item type="reference" name="ic_make_audio_call">@drawable/ic_call_black54_24dp</item>
<item type="reference" name="ic_make_video_call">@drawable/ic_videocam_black54_24dp</item>
<item type="reference" name="message_bubble_received_monochrome">@drawable/message_bubble_received_white</item> <item type="reference" name="message_bubble_received_monochrome">@drawable/message_bubble_received_white</item>
<item type="reference" name="message_bubble_sent">@drawable/message_bubble_sent</item> <item type="reference" name="message_bubble_sent">@drawable/message_bubble_sent</item>
<item type="reference" name="message_bubble_received_green">@drawable/message_bubble_received</item> <item type="reference" name="message_bubble_received_green">@drawable/message_bubble_received</item>
@ -164,6 +167,9 @@
<item type="reference" name="ic_send_videocam_offline">@drawable/ic_send_videocam_offline_white</item> <item type="reference" name="ic_send_videocam_offline">@drawable/ic_send_videocam_offline_white</item>
<item type="reference" name="ic_send_voice_offline">@drawable/ic_send_voice_offline_white</item> <item type="reference" name="ic_send_voice_offline">@drawable/ic_send_voice_offline_white</item>
<item type="reference" name="ic_make_audio_call">@drawable/ic_call_white70_24dp</item>
<item type="reference" name="ic_make_video_call">@drawable/ic_videocam_white70_24dp</item>
<item type="reference" name="ic_attach_camera">@drawable/ic_attach_camera_white</item> <item type="reference" name="ic_attach_camera">@drawable/ic_attach_camera_white</item>
<item type="reference" name="ic_attach_videocam">@drawable/ic_attach_videocam_white</item> <item type="reference" name="ic_attach_videocam">@drawable/ic_attach_videocam_white</item>
<item type="reference" name="ic_attach_document">@drawable/ic_attach_document_white</item> <item type="reference" name="ic_attach_document">@drawable/ic_attach_document_white</item>