Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SES-1486] Short voice message fix #1523

Merged
merged 31 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
3cdd383
Initial working push with debug comments
alansley Jun 25, 2024
def1265
Fixes #1522
alansley Jun 25, 2024
c15a8ee
Cleanup, prevent multi-pointer recording, and don't show short msg to…
alansley Jun 25, 2024
d9e1f73
Adjusted comment phrasing
alansley Jun 25, 2024
d5339b7
Fix comment phrasing
alansley Jun 25, 2024
6bb760f
Fixed inadvertant short voice message toast on exit conversation acti…
alansley Jun 25, 2024
9e6c6af
Comment adjustment
alansley Jun 25, 2024
753b49c
Comment phrasing
alansley Jun 25, 2024
939694d
Adjusted AudioRecorder.startRecording to take a callback function rat…
alansley Jun 25, 2024
bd3655b
Performed Thomas' PR feedback
alansley Jun 25, 2024
d8799c9
Move comment to more relevant place
alansley Jun 25, 2024
5d8fe27
Removed unused / leftover callback definition
alansley Jun 25, 2024
5858688
Removed all redundant null checks after asserting binding is not null
alansley Jun 25, 2024
880148f
Removed remaining not-null assertions & added some logged feedback to…
alansley Jun 25, 2024
bce6526
Addressed PR feedback
alansley Jun 26, 2024
e5371c5
Implemented additional PR feedback
alansley Jun 26, 2024
ae52e54
Merge branch 'dev' into SES-1486_ShortVoiceMessageFix
alansley Jun 26, 2024
1c054b8
Merge branch 'dev' into SES-1486_ShortVoiceMessageFix
AL-Session Jun 30, 2024
bc13d20
Adjusted InputBar property visibility as per PR feedback & adjusted T…
AL-Session Jun 30, 2024
6f0277b
Minor adjustment to inform user if we see an obvious network issue wh…
AL-Session Jul 1, 2024
25d6982
Merge dev
alansley Jul 2, 2024
5d9c242
Adjust comment phrasing following further testing
alansley Jul 2, 2024
f2267e9
Merge dev
alansley Jul 2, 2024
849a8f1
Added TODO comments to replace hard-coded string in toasts
alansley Jul 2, 2024
fea66bc
Addressed Thomas PR feedback suggestion
alansley Jul 3, 2024
e83b70c
Addressed another feedback suggestion
alansley Jul 3, 2024
bd9fdc7
Adjustment to continue informing user of network / node path issues
alansley Jul 3, 2024
50d3857
Improved & moved network check method
alansley Jul 3, 2024
4ecda43
Corrected ticket number into TODO comments
alansley Jul 3, 2024
05e8fd8
Addressed Andy PR feedback
alansley Jul 3, 2024
af55ae7
Adjust network connectivity checks to just log issues rather than inf…
alansley Jul 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,28 +1,22 @@
package org.thoughtcrime.securesms.audio;

import android.annotation.TargetApi;

import android.content.Context;
import android.net.Uri;
import android.os.Build;
import android.os.ParcelFileDescriptor;
import android.util.Pair;
import androidx.annotation.NonNull;

import java.io.IOException;
import java.util.concurrent.ExecutorService;
import org.session.libsession.utilities.MediaTypes;
import org.session.libsignal.utilities.Log;
import android.util.Pair;

import org.thoughtcrime.securesms.providers.BlobProvider;
import org.thoughtcrime.securesms.util.MediaUtil;

import org.session.libsignal.utilities.ThreadUtils;
import org.session.libsession.utilities.Util;
import org.session.libsignal.utilities.ListenableFuture;
import org.session.libsignal.utilities.Log;
import org.session.libsignal.utilities.SettableFuture;
import org.session.libsignal.utilities.ThreadUtils;
import org.thoughtcrime.securesms.providers.BlobProvider;
import org.thoughtcrime.securesms.util.MediaUtil;

import java.io.IOException;
import java.util.concurrent.ExecutorService;

@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public class AudioRecorder {

private static final String TAG = AudioRecorder.class.getSimpleName();
Expand All @@ -34,11 +28,16 @@ public class AudioRecorder {
private AudioCodec audioCodec;
private Uri captureUri;

// Simple interface that allows us to provide a callback method to our `startRecording` method
public interface AudioMessageRecordingFinishedCallback {
void onAudioMessageRecordingFinished();
}

public AudioRecorder(@NonNull Context context) {
this.context = context;
}

public void startRecording() {
public void startRecording(AudioMessageRecordingFinishedCallback callback) {
Log.i(TAG, "startRecording()");

executor.execute(() -> {
Expand All @@ -55,9 +54,16 @@ public void startRecording() {
.forData(new ParcelFileDescriptor.AutoCloseInputStream(fds[0]), 0)
.withMimeType(MediaTypes.AUDIO_AAC)
.createForSingleSessionOnDisk(context, e -> Log.w(TAG, "Error during recording", e));
audioCodec = new AudioCodec();

audioCodec = new AudioCodec();
audioCodec.start(new ParcelFileDescriptor.AutoCloseOutputStream(fds[1]));

// If we just tap the record audio button then by the time we actually finish setting up and
// get here the recording has been cancelled and the voice recorder state is Idle! As such
// we'll only tick the recorder state over to Recording if we were still in the
// SettingUpToRecord state when we got here (i.e., the record voice message button is still
// held or is locked to keep recording audio without being held).
callback.onAudioMessageRecordingFinished();
} catch (IOException e) {
Log.w(TAG, e);
}
Expand Down
Loading