add record voice mail button to busy screen. fixes #3754

This commit is contained in:
Daniel Gultsch 2020-05-30 10:30:57 +02:00
parent bc6446beb8
commit 8603d24bcb
8 changed files with 38 additions and 15 deletions

View File

@ -2121,6 +2121,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
final String downloadUuid = extras.getString(ConversationsActivity.EXTRA_DOWNLOAD_UUID); final String downloadUuid = extras.getString(ConversationsActivity.EXTRA_DOWNLOAD_UUID);
final String text = extras.getString(Intent.EXTRA_TEXT); final String text = extras.getString(Intent.EXTRA_TEXT);
final String nick = extras.getString(ConversationsActivity.EXTRA_NICK); final String nick = extras.getString(ConversationsActivity.EXTRA_NICK);
final String postInitAction = extras.getString(ConversationsActivity.EXTRA_POST_INIT_ACTION);
final boolean asQuote = extras.getBoolean(ConversationsActivity.EXTRA_AS_QUOTE); final boolean asQuote = extras.getBoolean(ConversationsActivity.EXTRA_AS_QUOTE);
final boolean pm = extras.getBoolean(ConversationsActivity.EXTRA_IS_PRIVATE_MESSAGE, false); final boolean pm = extras.getBoolean(ConversationsActivity.EXTRA_IS_PRIVATE_MESSAGE, false);
final boolean doNotAppend = extras.getBoolean(ConversationsActivity.EXTRA_DO_NOT_APPEND, false); final boolean doNotAppend = extras.getBoolean(ConversationsActivity.EXTRA_DO_NOT_APPEND, false);
@ -2161,6 +2162,10 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
appendText(text, doNotAppend); appendText(text, doNotAppend);
} }
} }
if (ConversationsActivity.POST_ACTION_RECORD_VOICE.equals(postInitAction)) {
attachFile(ATTACHMENT_CHOICE_RECORD_VOICE);
return;
}
final Message message = downloadUuid == null ? null : conversation.findMessageWithFileAndUuid(downloadUuid); final Message message = downloadUuid == null ? null : conversation.findMessageWithFileAndUuid(downloadUuid);
if (message != null) { if (message != null) {
startDownloadable(message); startDownloadable(message);

View File

@ -94,6 +94,8 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio
public static final String EXTRA_NICK = "nick"; public static final String EXTRA_NICK = "nick";
public static final String EXTRA_IS_PRIVATE_MESSAGE = "pm"; public static final String EXTRA_IS_PRIVATE_MESSAGE = "pm";
public static final String EXTRA_DO_NOT_APPEND = "do_not_append"; public static final String EXTRA_DO_NOT_APPEND = "do_not_append";
public static final String EXTRA_POST_INIT_ACTION = "post_init_action";
public static final String POST_ACTION_RECORD_VOICE = "record_voice";
private static List<String> VIEW_AND_SHARE_ACTIONS = Arrays.asList( private static List<String> VIEW_AND_SHARE_ACTIONS = Arrays.asList(
ACTION_VIEW_CONVERSATION, ACTION_VIEW_CONVERSATION,

View File

@ -44,6 +44,7 @@ import eu.siacs.conversations.R;
import eu.siacs.conversations.databinding.ActivityRtpSessionBinding; import eu.siacs.conversations.databinding.ActivityRtpSessionBinding;
import eu.siacs.conversations.entities.Account; import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.entities.Contact; import eu.siacs.conversations.entities.Contact;
import eu.siacs.conversations.entities.Conversation;
import eu.siacs.conversations.services.AppRTCAudioManager; import eu.siacs.conversations.services.AppRTCAudioManager;
import eu.siacs.conversations.services.XmppConnectionService; import eu.siacs.conversations.services.XmppConnectionService;
import eu.siacs.conversations.ui.util.AvatarWorkerTask; import eu.siacs.conversations.ui.util.AvatarWorkerTask;
@ -101,6 +102,14 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
} }
} }
private static void addSink(final VideoTrack videoTrack, final SurfaceViewRenderer surfaceViewRenderer) {
try {
videoTrack.addSink(surfaceViewRenderer);
} catch (final IllegalStateException e) {
Log.e(Config.LOGTAG, "possible race condition on trying to display video track. ignoring", e);
}
}
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -372,7 +381,6 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
} }
} }
@RequiresApi(api = Build.VERSION_CODES.O) @RequiresApi(api = Build.VERSION_CODES.O)
private void startPictureInPicture() { private void startPictureInPicture() {
try { try {
@ -551,11 +559,13 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
this.binding.acceptCall.setImageResource(R.drawable.ic_call_white_48dp); this.binding.acceptCall.setImageResource(R.drawable.ic_call_white_48dp);
this.binding.acceptCall.setVisibility(View.VISIBLE); this.binding.acceptCall.setVisibility(View.VISIBLE);
} else if (state == RtpEndUserState.DECLINED_OR_BUSY) { } else if (state == RtpEndUserState.DECLINED_OR_BUSY) {
this.binding.rejectCall.setVisibility(View.INVISIBLE); this.binding.rejectCall.setOnClickListener(this::exit);
this.binding.endCall.setOnClickListener(this::exit); this.binding.rejectCall.setImageResource(R.drawable.ic_clear_white_48dp);
this.binding.endCall.setImageResource(R.drawable.ic_clear_white_48dp); this.binding.rejectCall.setVisibility(View.VISIBLE);
this.binding.endCall.setVisibility(View.VISIBLE); this.binding.endCall.setVisibility(View.INVISIBLE);
this.binding.acceptCall.setVisibility(View.INVISIBLE); this.binding.acceptCall.setOnClickListener(this::recordVoiceMail);
this.binding.acceptCall.setImageResource(R.drawable.ic_voicemail_white_24dp);
this.binding.acceptCall.setVisibility(View.VISIBLE);
} else if (asList(RtpEndUserState.CONNECTIVITY_ERROR, RtpEndUserState.APPLICATION_ERROR, RtpEndUserState.RETRACTED).contains(state)) { } else if (asList(RtpEndUserState.CONNECTIVITY_ERROR, RtpEndUserState.APPLICATION_ERROR, RtpEndUserState.RETRACTED).contains(state)) {
this.binding.rejectCall.setOnClickListener(this::exit); this.binding.rejectCall.setOnClickListener(this::exit);
this.binding.rejectCall.setImageResource(R.drawable.ic_clear_white_48dp); this.binding.rejectCall.setImageResource(R.drawable.ic_clear_white_48dp);
@ -789,14 +799,6 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
} }
} }
private static void addSink(final VideoTrack videoTrack, final SurfaceViewRenderer surfaceViewRenderer) {
try {
videoTrack.addSink(surfaceViewRenderer);
} catch (final IllegalStateException e) {
Log.e(Config.LOGTAG, "possible race condition on trying to display video track. ignoring", e);
}
}
private Optional<VideoTrack> getLocalVideoTrack() { private Optional<VideoTrack> getLocalVideoTrack() {
final JingleRtpConnection connection = this.rtpConnectionReference != null ? this.rtpConnectionReference.get() : null; final JingleRtpConnection connection = this.rtpConnectionReference != null ? this.rtpConnectionReference.get() : null;
if (connection == null) { if (connection == null) {
@ -847,7 +849,21 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
proposeJingleRtpSession(account, with, media); proposeJingleRtpSession(account, with, media);
} }
private void exit(View view) { private void exit(final View view) {
finish();
}
private void recordVoiceMail(final View view) {
final Intent intent = getIntent();
final Account account = extractAccount(intent);
final Jid with = Jid.ofEscaped(intent.getStringExtra(EXTRA_WITH));
final Conversation conversation = xmppConnectionService.findOrCreateConversation(account, with, false, true);
final Intent launchIntent = new Intent(this, ConversationsActivity.class);
launchIntent.setAction(ConversationsActivity.ACTION_VIEW_CONVERSATION);
launchIntent.putExtra(ConversationsActivity.EXTRA_CONVERSATION, conversation.getUuid());
launchIntent.setFlags(intent.getFlags() | Intent.FLAG_ACTIVITY_CLEAR_TOP);
launchIntent.putExtra(ConversationsActivity.EXTRA_POST_INIT_ACTION, ConversationsActivity.POST_ACTION_RECORD_VOICE);
startActivity(launchIntent);
finish(); finish();
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 478 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 221 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 487 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 625 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 971 B