mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-25 05:27:42 +00:00
Avoid recording empty voice messages during an ongoing call.
This commit is contained in:
@@ -8,4 +8,5 @@ interface AudioRecordingHandler {
|
||||
fun onRecordSaved()
|
||||
fun onRecordMoved(offsetX: Float, absoluteX: Float)
|
||||
fun onRecordPermissionRequired()
|
||||
fun onRecorderAlreadyInUse()
|
||||
}
|
||||
|
||||
@@ -568,6 +568,11 @@ public class InputPanel extends ConstraintLayout
|
||||
if (listener != null) listener.onRecorderPermissionRequired();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRecorderAlreadyInUse() {
|
||||
if (listener != null) listener.onRecorderAlreadyInUse();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRecordPressed() {
|
||||
if (listener != null) listener.onRecorderStarted();
|
||||
@@ -815,6 +820,7 @@ public class InputPanel extends ConstraintLayout
|
||||
void onRecorderFinished();
|
||||
void onRecorderCanceled(boolean byUser);
|
||||
void onRecorderPermissionRequired();
|
||||
void onRecorderAlreadyInUse();
|
||||
void onEmojiToggle();
|
||||
void onLinkPreviewCanceled();
|
||||
void onStickerSuggestionSelected(@NonNull StickerRecord sticker);
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.thoughtcrime.securesms.components;
|
||||
import android.Manifest;
|
||||
import android.content.Context;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.media.AudioManager;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
@@ -19,6 +20,7 @@ import android.widget.ImageView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.audio.AudioRecordingHandler;
|
||||
@@ -40,12 +42,16 @@ public final class MicrophoneRecorderView extends FrameLayout implements View.On
|
||||
private @Nullable AudioRecordingHandler handler;
|
||||
private @NonNull State state = State.NOT_RUNNING;
|
||||
|
||||
private final AudioManager audioManager;
|
||||
|
||||
public MicrophoneRecorderView(Context context) {
|
||||
super(context);
|
||||
this.audioManager = ContextCompat.getSystemService(context, AudioManager.class);
|
||||
}
|
||||
|
||||
public MicrophoneRecorderView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
this.audioManager = ContextCompat.getSystemService(context, AudioManager.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -110,10 +116,16 @@ public final class MicrophoneRecorderView extends FrameLayout implements View.On
|
||||
|
||||
@Override
|
||||
public boolean onTouch(View v, final MotionEvent event) {
|
||||
boolean isMicPossiblyInUse = false;
|
||||
if (audioManager != null) {
|
||||
isMicPossiblyInUse = audioManager.getMode() == AudioManager.MODE_IN_COMMUNICATION || audioManager.getMode() == AudioManager.MODE_IN_CALL;
|
||||
}
|
||||
switch (event.getAction()) {
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
if (!Permissions.hasAll(getContext(), Manifest.permission.RECORD_AUDIO)) {
|
||||
if (handler != null) handler.onRecordPermissionRequired();
|
||||
} else if (isMicPossiblyInUse) {
|
||||
if (handler != null) handler.onRecorderAlreadyInUse();
|
||||
} else if (state == State.NOT_RUNNING) {
|
||||
state = State.RUNNING_HELD;
|
||||
floatingRecordButton.display(event.getX(), event.getY());
|
||||
|
||||
@@ -4202,6 +4202,10 @@ class ConversationFragment :
|
||||
.execute()
|
||||
}
|
||||
|
||||
override fun onRecorderAlreadyInUse() {
|
||||
toast(R.string.ConversationFragment_cannot_record_voice_message_during_call)
|
||||
}
|
||||
|
||||
override fun onEmojiToggle() {
|
||||
container.toggleInput(MediaKeyboardFragmentCreator, composeText, showSoftKeyOnHide = true)
|
||||
}
|
||||
|
||||
@@ -546,6 +546,8 @@
|
||||
<string name="ConversationActivity__invite_to_signal">Invite to Signal</string>
|
||||
<!-- Snackbar message shown after dismissing the full screen sms export megaphone indicating we\'ll do it again soon -->
|
||||
<string name="ConversationActivity__you_will_be_reminded_again_soon">You will be reminded again soon.</string>
|
||||
<!-- Toast message shown when trying to record a voice message during an ongoing call -->
|
||||
<string name="ConversationFragment_cannot_record_voice_message_during_call">Cannot record voice message during call.</string>
|
||||
|
||||
<!-- Title for dialog shown when first sending formatted text -->
|
||||
<string name="SendingFormattingTextDialog_title">Sending formatted text</string>
|
||||
|
||||
Reference in New Issue
Block a user