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_COMMIT_ATTACHMENTS = 0x0212;
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_TAKE_PHOTO = 0x0302;
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);
}
break;
case R.id.action_call:
checkPermissionAndTriggerRtpSession();
case R.id.action_audio_call:
checkPermissionAndTriggerAudioCall();
break;
case R.id.action_video_call:
checkPermissionAndTriggerVideoCall();
break;
default:
break;
@ -1243,21 +1247,31 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
return super.onOptionsItemSelected(item);
}
private void checkPermissionAndTriggerRtpSession() {
private void checkPermissionAndTriggerAudioCall() {
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_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 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_WITH, contact.getJid().asBareJid().toEscapedString());
startActivity(intent);
@ -1414,7 +1428,10 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
commitAttachments();
break;
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;
default:
attachFile(requestCode);

View File

@ -190,6 +190,7 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
@Override
void onBackendConnected() {
final Intent intent = getIntent();
final String action = intent.getAction();
final Account account = extractAccount(intent);
final Jid with = Jid.of(intent.getStringExtra(EXTRA_WITH));
final String sessionId = intent.getStringExtra(EXTRA_SESSION_ID);
@ -200,10 +201,16 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
requestPermissionsAndAcceptCall();
resetIntent(intent.getExtras());
}
} else if (asList(ACTION_MAKE_VIDEO_CALL, ACTION_MAKE_VOICE_CALL).contains(intent.getAction())) {
proposeJingleRtpSession(account, with, ImmutableSet.of(Media.AUDIO, Media.VIDEO));
} else if (asList(ACTION_MAKE_VIDEO_CALL, ACTION_MAKE_VOICE_CALL).contains(action)) {
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());
} else if (Intent.ACTION_VIEW.equals(intent.getAction())) {
} else if (Intent.ACTION_VIEW.equals(action)) {
final String extraLastState = intent.getStringExtra(EXTRA_LAST_REPORTED_STATE);
if (extraLastState != null) {
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:orderInCategory="35"
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
android:id="@+id/action_contact_details"
android:orderInCategory="40"

View File

@ -45,6 +45,9 @@
<attr name="ic_attach_photo" 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"/>

View File

@ -908,6 +908,8 @@
<string name="outgoing_call">Outgoing call</string>
<string name="outgoing_call_duration">Outgoing call · %s</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">
<item quantity="one">View %1$d Participant</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_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_sent">@drawable/message_bubble_sent</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_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_videocam">@drawable/ic_attach_videocam_white</item>
<item type="reference" name="ic_attach_document">@drawable/ic_attach_document_white</item>