Search in sources :

Example 1 with AudioRecordingField

use of com.ichi2.anki.multimediacard.fields.AudioRecordingField in project AnkiChinaAndroid by ankichinateam.

the class NoteEditor method setMMButtonListener.

private void setMMButtonListener(ImageButton mediaButton, final int index) {
    mediaButton.setOnClickListener(v -> {
        Timber.i("NoteEditor:: Multimedia button pressed for field %d", index);
        if (mEditorNote.items()[index][1].length() > 0) {
            final Collection col = CollectionHelper.getInstance().getCol(NoteEditor.this);
            // If the field already exists then we start the field editor, which figures out the type
            // automatically
            IMultimediaEditableNote mNote = getCurrentMultimediaEditableNote(col);
            startMultimediaFieldEditor(index, mNote);
        } else {
            // Otherwise we make a popup menu allowing the user to choose between audio/image/text field
            // TODO: Update the icons for dark material theme, then can set 3rd argument to true
            PopupMenuWithIcons popup = new PopupMenuWithIcons(NoteEditor.this, v, false);
            MenuInflater inflater = popup.getMenuInflater();
            inflater.inflate(R.menu.popupmenu_multimedia_options, popup.getMenu());
            popup.setOnMenuItemClickListener(item -> {
                int itemId = item.getItemId();
                if (itemId == R.id.menu_multimedia_audio) {
                    Timber.i("NoteEditor:: Record audio button pressed");
                    startMultimediaFieldEditorForField(index, new AudioRecordingField());
                    return true;
                } else if (itemId == R.id.menu_multimedia_audio_clip) {
                    Timber.i("NoteEditor:: Add audio clip button pressed");
                    startMultimediaFieldEditorForField(index, new AudioClipField());
                    return true;
                } else if (itemId == R.id.menu_multimedia_photo) {
                    Timber.i("NoteEditor:: Add image button pressed");
                    startMultimediaFieldEditorForField(index, new ImageField());
                    return true;
                } else if (itemId == R.id.menu_multimedia_text) {
                    Timber.i("NoteEditor:: Advanced editor button pressed");
                    startAdvancedTextEditor(index);
                    return true;
                } else if (itemId == R.id.menu_multimedia_clear_field) {
                    Timber.i("NoteEditor:: Clear field button pressed");
                    clearField(index);
                }
                return false;
            });
            if (AdaptionUtil.isRestrictedLearningDevice()) {
                popup.getMenu().findItem(R.id.menu_multimedia_photo).setVisible(false);
                popup.getMenu().findItem(R.id.menu_multimedia_text).setVisible(false);
            }
            popup.show();
        }
    });
}
Also used : ImageField(com.ichi2.anki.multimediacard.fields.ImageField) MenuInflater(android.view.MenuInflater) PopupMenuWithIcons(com.ichi2.anki.widgets.PopupMenuWithIcons) AudioClipField(com.ichi2.anki.multimediacard.fields.AudioClipField) Collection(com.ichi2.libanki.Collection) IMultimediaEditableNote(com.ichi2.anki.multimediacard.IMultimediaEditableNote) SuppressLint(android.annotation.SuppressLint) AudioRecordingField(com.ichi2.anki.multimediacard.fields.AudioRecordingField)

Example 2 with AudioRecordingField

use of com.ichi2.anki.multimediacard.fields.AudioRecordingField in project AnkiChinaAndroid by ankichinateam.

the class NoteService method updateMultimediaNoteFromFields.

public static void updateMultimediaNoteFromFields(Collection col, String[] fields, long modelId, MultimediaEditableNote mmNote) {
    for (int i = 0; i < fields.length; i++) {
        String value = fields[i];
        IField field = null;
        if (value.startsWith("<img")) {
            field = new ImageField();
        } else if (value.startsWith("[sound:") && value.contains("rec")) {
            field = new AudioRecordingField();
        } else if (value.startsWith("[sound:")) {
            field = new AudioClipField();
        } else {
            field = new TextField();
        }
        field.setFormattedString(col, value);
        mmNote.setField(i, field);
    }
    mmNote.setModelId(modelId);
// TODO: set current id of the note as well
}
Also used : ImageField(com.ichi2.anki.multimediacard.fields.ImageField) AudioClipField(com.ichi2.anki.multimediacard.fields.AudioClipField) TextField(com.ichi2.anki.multimediacard.fields.TextField) IField(com.ichi2.anki.multimediacard.fields.IField) AudioRecordingField(com.ichi2.anki.multimediacard.fields.AudioRecordingField)

Example 3 with AudioRecordingField

use of com.ichi2.anki.multimediacard.fields.AudioRecordingField in project Anki-Android by ankidroid.

the class NoteEditor method setMMButtonListener.

private void setMMButtonListener(ImageButton mediaButton, final int index) {
    mediaButton.setOnClickListener(v -> {
        Timber.i("NoteEditor:: Multimedia button pressed for field %d", index);
        if (mEditorNote.items()[index][1].length() > 0) {
            final Collection col = CollectionHelper.getInstance().getCol(NoteEditor.this);
            // If the field already exists then we start the field editor, which figures out the type
            // automatically
            IMultimediaEditableNote note = getCurrentMultimediaEditableNote(col);
            startMultimediaFieldEditor(index, note);
        } else {
            // Otherwise we make a popup menu allowing the user to choose between audio/image/text field
            // TODO: Update the icons for dark material theme, then can set 3rd argument to true
            PopupMenuWithIcons popup = new PopupMenuWithIcons(NoteEditor.this, v, true);
            MenuInflater inflater = popup.getMenuInflater();
            inflater.inflate(R.menu.popupmenu_multimedia_options, popup.getMenu());
            popup.setOnMenuItemClickListener(item -> {
                int itemId = item.getItemId();
                if (itemId == R.id.menu_multimedia_audio) {
                    Timber.i("NoteEditor:: Record audio button pressed");
                    startMultimediaFieldEditorForField(index, new AudioRecordingField());
                    return true;
                } else if (itemId == R.id.menu_multimedia_audio_clip || itemId == R.id.menu_multimedia_video_clip) {
                    Timber.i("NoteEditor:: Add audio clip button pressed");
                    startMultimediaFieldEditorForField(index, new MediaClipField());
                    return true;
                } else if (itemId == R.id.menu_multimedia_photo) {
                    Timber.i("NoteEditor:: Add image button pressed");
                    startMultimediaFieldEditorForField(index, new ImageField());
                    return true;
                } else if (itemId == R.id.menu_multimedia_text) {
                    Timber.i("NoteEditor:: Advanced editor button pressed");
                    startAdvancedTextEditor(index);
                    return true;
                } else if (itemId == R.id.menu_multimedia_clear_field) {
                    Timber.i("NoteEditor:: Clear field button pressed");
                    clearField(index);
                }
                return false;
            });
            if (AdaptionUtil.isRestrictedLearningDevice()) {
                popup.getMenu().findItem(R.id.menu_multimedia_photo).setVisible(false);
                popup.getMenu().findItem(R.id.menu_multimedia_text).setVisible(false);
            }
            popup.show();
        }
    });
}
Also used : ImageField(com.ichi2.anki.multimediacard.fields.ImageField) MenuInflater(android.view.MenuInflater) PopupMenuWithIcons(com.ichi2.anki.widgets.PopupMenuWithIcons) Collection(com.ichi2.libanki.Collection) MediaClipField(com.ichi2.anki.multimediacard.fields.MediaClipField) IMultimediaEditableNote(com.ichi2.anki.multimediacard.IMultimediaEditableNote) SuppressLint(android.annotation.SuppressLint) AudioRecordingField(com.ichi2.anki.multimediacard.fields.AudioRecordingField)

Example 4 with AudioRecordingField

use of com.ichi2.anki.multimediacard.fields.AudioRecordingField in project Anki-Android by ankidroid.

the class MultimediaEditFieldActivity method toAudioRecordingField.

protected void toAudioRecordingField() {
    if (mField.getType() != EFieldType.AUDIO_RECORDING) {
        ChangeUIRequest request = ChangeUIRequest.uiChange(new AudioRecordingField());
        recreateEditingUi(request);
    }
}
Also used : AudioRecordingField(com.ichi2.anki.multimediacard.fields.AudioRecordingField)

Example 5 with AudioRecordingField

use of com.ichi2.anki.multimediacard.fields.AudioRecordingField in project AnkiChinaAndroid by ankichinateam.

the class MultimediaEditFieldActivity method toAudioRecordingField.

protected void toAudioRecordingField() {
    if (mField.getType() != EFieldType.AUDIO_RECORDING) {
        ChangeUIRequest request = ChangeUIRequest.uiChange(new AudioRecordingField());
        recreateEditingUi(request);
    }
}
Also used : AudioRecordingField(com.ichi2.anki.multimediacard.fields.AudioRecordingField)

Aggregations

AudioRecordingField (com.ichi2.anki.multimediacard.fields.AudioRecordingField)5 ImageField (com.ichi2.anki.multimediacard.fields.ImageField)3 SuppressLint (android.annotation.SuppressLint)2 MenuInflater (android.view.MenuInflater)2 IMultimediaEditableNote (com.ichi2.anki.multimediacard.IMultimediaEditableNote)2 AudioClipField (com.ichi2.anki.multimediacard.fields.AudioClipField)2 PopupMenuWithIcons (com.ichi2.anki.widgets.PopupMenuWithIcons)2 Collection (com.ichi2.libanki.Collection)2 IField (com.ichi2.anki.multimediacard.fields.IField)1 MediaClipField (com.ichi2.anki.multimediacard.fields.MediaClipField)1 TextField (com.ichi2.anki.multimediacard.fields.TextField)1