mirror of
https://codeberg.org/tom79/Fedilab.git
synced 2024-12-22 16:50:04 +02:00
voice messages for Android 10+
This commit is contained in:
parent
e06222733c
commit
8c60348939
3 changed files with 17 additions and 8 deletions
|
@ -304,6 +304,12 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
|
|||
public boolean onCreateOptionsMenu(@NonNull Menu menu) {
|
||||
// Inflate the menu; this adds items to the action bar if it is present.
|
||||
getMenuInflater().inflate(R.menu.menu_compose, menu);
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
|
||||
MenuItem micro = menu.findItem(R.id.action_microphone);
|
||||
if (micro != null) {
|
||||
micro.setVisible(false);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -1282,9 +1282,9 @@ public class Helper {
|
|||
|
||||
MimeTypeMap mime = MimeTypeMap.getSingleton();
|
||||
String extension = mime.getExtensionFromMimeType(cR.getType(uri));
|
||||
if (uri.toString().endsWith("fedilab_recorded_audio.m4a")) {
|
||||
extension = ".m4a";
|
||||
attachment.mimeType = "audio/mp4";
|
||||
if (uri.toString().endsWith("fedilab_recorded_audio.ogg")) {
|
||||
extension = "ogg";
|
||||
attachment.mimeType = "audio/ogg";
|
||||
}
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss_" + counter, Locale.getDefault());
|
||||
counter++;
|
||||
|
|
|
@ -274,7 +274,8 @@ public class MediaHelper {
|
|||
* @param listener ActionRecord
|
||||
*/
|
||||
public static void recordAudio(Activity activity, ActionRecord listener) {
|
||||
String filePath = activity.getCacheDir() + "/fedilab_recorded_audio.m4a";
|
||||
//String filePath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getAbsolutePath() + "/fedilab_recorded_audio.ogg";
|
||||
String filePath = activity.getCacheDir() + "/fedilab_recorded_audio.ogg";
|
||||
AudioRecorder mAudioRecorder = AudioRecorder.getInstance();
|
||||
File mAudioFile = new File(filePath);
|
||||
PopupRecordBinding binding = PopupRecordBinding.inflate(activity.getLayoutInflater());
|
||||
|
@ -306,16 +307,18 @@ public class MediaHelper {
|
|||
binding.counter.setText(String.format(Locale.getDefault(), "%s:%s", minutes, seconds));
|
||||
});
|
||||
}
|
||||
}, 1000, 1000);
|
||||
}, 0, 1000);
|
||||
binding.record.setOnClickListener(v -> {
|
||||
mAudioRecorder.stopRecord();
|
||||
timer.cancel();
|
||||
alert.dismiss();
|
||||
listener.onRecorded(filePath);
|
||||
});
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
mAudioRecorder.prepareRecord(MediaRecorder.AudioSource.MIC,
|
||||
MediaRecorder.OutputFormat.MPEG_4, MediaRecorder.AudioEncoder.AAC,
|
||||
MediaRecorder.OutputFormat.OGG, MediaRecorder.AudioEncoder.OPUS, 48000, 384000,
|
||||
mAudioFile);
|
||||
}
|
||||
mAudioRecorder.startRecord();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue