Support scheduled voice notes.

Resolves #13957
This commit is contained in:
Sagar
2025-01-31 19:47:58 +05:30
committed by Michelle Tang
parent da5c8ff6ea
commit 52c8dfc998
6 changed files with 54 additions and 21 deletions

View File

@@ -62,7 +62,6 @@ import org.thoughtcrime.securesms.database.model.MmsMessageRecord;
import org.thoughtcrime.securesms.database.model.Quote;
import org.thoughtcrime.securesms.database.model.StickerRecord;
import org.thoughtcrime.securesms.keyboard.KeyboardPage;
import org.thoughtcrime.securesms.keyvalue.SignalStore;
import org.thoughtcrime.securesms.linkpreview.LinkPreview;
import org.thoughtcrime.securesms.linkpreview.LinkPreviewRepository;
import org.thoughtcrime.securesms.mms.DecryptableStreamUriLoader;
@@ -625,10 +624,21 @@ public class InputPanel extends ConstraintLayout
if (listener != null) listener.onRecorderLocked();
}
@Override
public void onRecordSaved() {
Log.d(TAG, "Recording saved");
onRecordHideEvent();
if (listener != null) listener.onRecorderSaveDraft();
}
public void onPause() {
this.microphoneRecorderView.cancelAction(false);
}
public void onSaveRecordDraft() {
this.microphoneRecorderView.saveAction();
}
public @NonNull Observer<VoiceNotePlaybackState> getPlaybackStateObserver() {
return voiceNoteDraftView.getPlaybackStateObserver();
}
@@ -692,7 +702,7 @@ public class InputPanel extends ConstraintLayout
return microphoneRecorderView.isRecordingLocked();
}
public void releaseRecordingLock() {
public void releaseRecordingLockAndSend() {
microphoneRecorderView.unlockAction();
}
@@ -794,6 +804,7 @@ public class InputPanel extends ConstraintLayout
public interface Listener extends VoiceNoteDraftView.Listener {
void onRecorderStarted();
void onRecorderLocked();
void onRecorderSaveDraft();
void onRecorderFinished();
void onRecorderCanceled(boolean byUser);
void onRecorderPermissionRequired();

View File

@@ -70,6 +70,17 @@ public final class MicrophoneRecorderView extends FrameLayout implements View.On
}
}
public void saveAction() {
if (state != State.NOT_RUNNING) {
state = State.NOT_RUNNING;
hideUi();
if (handler != null) {
handler.onRecordSaved();
}
}
}
public boolean isRecordingLocked() {
return state == State.RUNNING_LOCKED;
}

View File

@@ -41,19 +41,11 @@ class SendButton(context: Context, attributeSet: AttributeSet?) : AppCompatImage
if (!isEnabled) {
return false
}
val scheduleListener = scheduledSendListener
return if (scheduleListener?.canSchedule() == true) {
scheduleListener.onSendScheduled()
true
} else {
false
}
scheduledSendListener?.onSendScheduled()
return true
}
interface ScheduledSendListener {
fun onSendScheduled()
fun canSchedule(): Boolean
}
}