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();
}
});
}
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
}
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();
}
});
}
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);
}
}
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);
}
}
Aggregations