Skip to content

Commit

Permalink
Restore audio action (PR gsantner#2481)
Browse files Browse the repository at this point in the history
harshad1 authored Dec 22, 2024
1 parent cc9518b commit 9f4ace5
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.Toast;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
@@ -98,6 +99,7 @@ public static void showInsertImageOrLinkDialog(
final Button buttonPictureGallery = view.findViewById(R.id.ui__select_path_dialog__gallery_picture);
final Button buttonPictureCamera = view.findViewById(R.id.ui__select_path_dialog__camera_picture);
final Button buttonPictureEdit = view.findViewById(R.id.ui__select_path_dialog__edit_picture);
final Button buttonAudioRecord = view.findViewById(R.id.ui__select_path_dialog__record_audio);

// Extract filepath if using Markdown
if (textFormatId == FormatRegistry.FORMAT_MARKDOWN) {
@@ -133,6 +135,11 @@ public static void showInsertImageOrLinkDialog(
dialog.setTitle(R.string.insert_image);
browseType = InsertType.IMAGE_BROWSE;
okType = InsertType.IMAGE_DIALOG;
} else if (action == AUDIO_ACTION) {
dialog.setTitle(R.string.audio);
buttonAudioRecord.setVisibility(View.VISIBLE);
browseType = InsertType.AUDIO_BROWSE;
okType = InsertType.AUDIO_DIALOG;
} else {
dialog.setTitle(R.string.insert_link);
buttonSelectSpecial.setVisibility(View.VISIBLE);
@@ -148,6 +155,7 @@ public static void showInsertImageOrLinkDialog(
buttonSearch.setOnClickListener(v -> _insertItem.callback(InsertType.LINK_SEARCH));
buttonPictureCamera.setOnClickListener(b -> _insertItem.callback(InsertType.IMAGE_CAMERA));
buttonPictureGallery.setOnClickListener(v -> _insertItem.callback(InsertType.IMAGE_GALLERY));
buttonAudioRecord.setOnClickListener(v -> _insertItem.callback(InsertType.AUDIO_RECORDING));
buttonPictureEdit.setOnClickListener(v -> _insertItem.callback(InsertType.IMAGE_EDIT));

dialog.show();
@@ -400,7 +408,7 @@ private static void insertItem(
}
case AUDIO_RECORDING: {
if (!cu.requestAudioRecording(activity, insertFileLink)) {
// noop, OM library is outdated and so voice recording feature removed
Toast.makeText(activity, "❌", Toast.LENGTH_SHORT).show();
}
break;
}
9 changes: 9 additions & 0 deletions app/src/main/res/layout/select_path_dialog.xml
Original file line number Diff line number Diff line change
@@ -93,6 +93,15 @@
android:drawableLeft="@drawable/ic_crop_black_24dp"
android:visibility="gone"
android:text="@string/edit_picture" />

<Button
android:id="@+id/ui__select_path_dialog__record_audio"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableStart="@drawable/ic_keyboard_voice_black_24dp"
android:drawableLeft="@drawable/ic_keyboard_voice_black_24dp"
android:visibility="gone"
android:text="@string/record_audio" />
</LinearLayout>

</ScrollView>

0 comments on commit 9f4ace5

Please sign in to comment.