From 8603d24bcb85b47d8c14b80efea3f71f1e3f0ebb Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sat, 30 May 2020 10:30:57 +0200 Subject: [PATCH] add record voice mail button to busy screen. fixes #3754 --- .../ui/ConversationFragment.java | 5 ++ .../ui/ConversationsActivity.java | 2 + .../conversations/ui/RtpSessionActivity.java | 46 ++++++++++++------ .../drawable-hdpi/ic_voicemail_white_24dp.png | Bin 0 -> 478 bytes .../drawable-mdpi/ic_voicemail_white_24dp.png | Bin 0 -> 221 bytes .../ic_voicemail_white_24dp.png | Bin 0 -> 487 bytes .../ic_voicemail_white_24dp.png | Bin 0 -> 625 bytes .../ic_voicemail_white_24dp.png | Bin 0 -> 971 bytes 8 files changed, 38 insertions(+), 15 deletions(-) create mode 100644 src/main/res/drawable-hdpi/ic_voicemail_white_24dp.png create mode 100644 src/main/res/drawable-mdpi/ic_voicemail_white_24dp.png create mode 100644 src/main/res/drawable-xhdpi/ic_voicemail_white_24dp.png create mode 100644 src/main/res/drawable-xxhdpi/ic_voicemail_white_24dp.png create mode 100644 src/main/res/drawable-xxxhdpi/ic_voicemail_white_24dp.png diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java index 1aaa14380..d60516cc6 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java @@ -2121,6 +2121,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke final String downloadUuid = extras.getString(ConversationsActivity.EXTRA_DOWNLOAD_UUID); final String text = extras.getString(Intent.EXTRA_TEXT); 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 pm = extras.getBoolean(ConversationsActivity.EXTRA_IS_PRIVATE_MESSAGE, 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); } } + if (ConversationsActivity.POST_ACTION_RECORD_VOICE.equals(postInitAction)) { + attachFile(ATTACHMENT_CHOICE_RECORD_VOICE); + return; + } final Message message = downloadUuid == null ? null : conversation.findMessageWithFileAndUuid(downloadUuid); if (message != null) { startDownloadable(message); diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationsActivity.java b/src/main/java/eu/siacs/conversations/ui/ConversationsActivity.java index 43addb299..24e167e85 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationsActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationsActivity.java @@ -94,6 +94,8 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio public static final String EXTRA_NICK = "nick"; 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_POST_INIT_ACTION = "post_init_action"; + public static final String POST_ACTION_RECORD_VOICE = "record_voice"; private static List VIEW_AND_SHARE_ACTIONS = Arrays.asList( ACTION_VIEW_CONVERSATION, diff --git a/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java b/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java index 8c70413a5..76522cee8 100644 --- a/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java @@ -44,6 +44,7 @@ import eu.siacs.conversations.R; import eu.siacs.conversations.databinding.ActivityRtpSessionBinding; import eu.siacs.conversations.entities.Account; import eu.siacs.conversations.entities.Contact; +import eu.siacs.conversations.entities.Conversation; import eu.siacs.conversations.services.AppRTCAudioManager; import eu.siacs.conversations.services.XmppConnectionService; 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 public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -372,7 +381,6 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe } } - @RequiresApi(api = Build.VERSION_CODES.O) private void startPictureInPicture() { 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.setVisibility(View.VISIBLE); } else if (state == RtpEndUserState.DECLINED_OR_BUSY) { - this.binding.rejectCall.setVisibility(View.INVISIBLE); - this.binding.endCall.setOnClickListener(this::exit); - this.binding.endCall.setImageResource(R.drawable.ic_clear_white_48dp); - this.binding.endCall.setVisibility(View.VISIBLE); - this.binding.acceptCall.setVisibility(View.INVISIBLE); + this.binding.rejectCall.setOnClickListener(this::exit); + this.binding.rejectCall.setImageResource(R.drawable.ic_clear_white_48dp); + this.binding.rejectCall.setVisibility(View.VISIBLE); + this.binding.endCall.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)) { this.binding.rejectCall.setOnClickListener(this::exit); 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 getLocalVideoTrack() { final JingleRtpConnection connection = this.rtpConnectionReference != null ? this.rtpConnectionReference.get() : null; if (connection == null) { @@ -847,7 +849,21 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe 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(); } diff --git a/src/main/res/drawable-hdpi/ic_voicemail_white_24dp.png b/src/main/res/drawable-hdpi/ic_voicemail_white_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..03a62e15f90fc0cbfc0d743228e74a8ab242c781 GIT binary patch literal 478 zcmV<40U`d0P)9Khkv``(~Y_QNAu3K!9%5J@DOqOlM(kN$}Mg#sr_oWntC3KB%HwNDdL_78XEpZwmIUWW%pfm+M+3^F!iBtTyx*DAAIUHjx%-0 zJ?kx4-~_L`WW8OVm{4WvYftmtUXJmWKRnGV6M{ol&092YlUX>uR zFpP_aA{j0l`Z!>}VUY|64ewJr3A1F)5DJ7&!Yo-cghEOaVT-IS!Wlv{p-fhZ(46vx z&`wqdVV$r+XeX^5wBi4z<(OkvSbv72K|oHQ&^r(G!x=$+p70eQYbmvva!KO(N7*idOe<+q%wP5*BkoyF@ zJ4*vW6on^MHu0InUI})J{wu{0Z51sf8qgm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