Search in sources :

Example 1 with TextField

use of com.ichi2.anki.multimediacard.fields.TextField in project Anki-Android by Ramblurr.

the class EditFieldActivity method toTextField.

protected void toTextField() {
    if (mField.getType() != EFieldType.TEXT) {
        mField = new TextField();
        recreateEditingUi();
    }
}
Also used : TextField(com.ichi2.anki.multimediacard.fields.TextField)

Example 2 with TextField

use of com.ichi2.anki.multimediacard.fields.TextField in project Anki-Android by Ramblurr.

the class MockNoteFactory method makeNote.

public static IMultimediaEditableNote makeNote() {
    MultimediaEditableNote note = new MultimediaEditableNote();
    note.setNumFields(4);
    TextField tf = new TextField();
    tf.setText("world");
    note.setField(0, tf);
    TextField tf2 = new TextField();
    tf2.setText("Welt");
    note.setField(1, tf2);
    TextField tf3 = new TextField();
    tf3.setText("Übung");
    note.setField(2, tf3);
    ImageField imageField = new ImageField();
    imageField.setImagePath("/mnt/sdcard/img/1.jpg");
    note.setField(3, imageField);
    return note;
}
Also used : ImageField(com.ichi2.anki.multimediacard.fields.ImageField) MultimediaEditableNote(com.ichi2.anki.multimediacard.impl.MultimediaEditableNote) IMultimediaEditableNote(com.ichi2.anki.multimediacard.IMultimediaEditableNote) TextField(com.ichi2.anki.multimediacard.fields.TextField)

Example 3 with TextField

use of com.ichi2.anki.multimediacard.fields.TextField in project Anki-Android by Ramblurr.

the class NoteService method updateMultimediaNoteFromJsonNote.

public static void updateMultimediaNoteFromJsonNote(final Note editorNoteSrc, final IMultimediaEditableNote noteDst) {
    if (noteDst instanceof MultimediaEditableNote) {
        MultimediaEditableNote mmNote = (MultimediaEditableNote) noteDst;
        String[] values = editorNoteSrc.getFields();
        for (int i = 0; i < values.length; i++) {
            String value = values[i];
            IField field = null;
            if (value.startsWith("<img")) {
                field = new ImageField();
            } else if (value.startsWith("[sound:")) {
                field = new AudioField();
            } else {
                field = new TextField();
            }
            field.setFormattedString(value);
            mmNote.setField(i, field);
        }
        mmNote.setModelId(editorNoteSrc.getMid());
    // TODO: set current id of the note as well
    }
}
Also used : AudioField(com.ichi2.anki.multimediacard.fields.AudioField) ImageField(com.ichi2.anki.multimediacard.fields.ImageField) MultimediaEditableNote(com.ichi2.anki.multimediacard.impl.MultimediaEditableNote) IMultimediaEditableNote(com.ichi2.anki.multimediacard.IMultimediaEditableNote) TextField(com.ichi2.anki.multimediacard.fields.TextField) IField(com.ichi2.anki.multimediacard.fields.IField)

Example 4 with TextField

use of com.ichi2.anki.multimediacard.fields.TextField in project Anki-Android by Ramblurr.

the class NoteService method createEmptyNote.

/**
     * Creates an empty Note from given Model
     * 
     * @param model the model in JSOBObject format
     * @return a new note instance
     */
public static MultimediaEditableNote createEmptyNote(JSONObject model) {
    try {
        JSONArray fieldsArray = model.getJSONArray("flds");
        int numOfFields = fieldsArray.length();
        if (numOfFields > 0) {
            MultimediaEditableNote note = new MultimediaEditableNote();
            note.setNumFields(numOfFields);
            for (int i = 0; i < numOfFields; i++) {
                JSONObject fieldObject = fieldsArray.getJSONObject(i);
                TextField uiTextField = new TextField();
                uiTextField.setName(fieldObject.getString("name"));
                uiTextField.setText(fieldObject.getString("name"));
                note.setField(i, uiTextField);
            }
            note.setModelId(model.getLong("id"));
            return note;
        }
    } catch (JSONException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return null;
}
Also used : MultimediaEditableNote(com.ichi2.anki.multimediacard.impl.MultimediaEditableNote) IMultimediaEditableNote(com.ichi2.anki.multimediacard.IMultimediaEditableNote) JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray) TextField(com.ichi2.anki.multimediacard.fields.TextField) JSONException(org.json.JSONException)

Example 5 with TextField

use of com.ichi2.anki.multimediacard.fields.TextField in project Anki-Android by Ramblurr.

the class NoteFactory method createNote.

public static IMultimediaEditableNote createNote() {
    MultimediaEditableNote note = new MultimediaEditableNote();
    note.setNumFields(4);
    TextField tf = new TextField();
    tf.setText("world");
    note.setField(0, tf);
    TextField tf2 = new TextField();
    tf2.setText("Welt");
    note.setField(1, tf2);
    TextField tf3 = new TextField();
    tf3.setText("Übung");
    note.setField(2, tf3);
    ImageField imageField = new ImageField();
    imageField.setImagePath("/mnt/sdcard/img/1.jpg");
    note.setField(3, imageField);
    return note;
}
Also used : ImageField(com.ichi2.anki.multimediacard.fields.ImageField) IMultimediaEditableNote(com.ichi2.anki.multimediacard.IMultimediaEditableNote) TextField(com.ichi2.anki.multimediacard.fields.TextField)

Aggregations

TextField (com.ichi2.anki.multimediacard.fields.TextField)6 IMultimediaEditableNote (com.ichi2.anki.multimediacard.IMultimediaEditableNote)4 ImageField (com.ichi2.anki.multimediacard.fields.ImageField)3 MultimediaEditableNote (com.ichi2.anki.multimediacard.impl.MultimediaEditableNote)3 Intent (android.content.Intent)1 AudioField (com.ichi2.anki.multimediacard.fields.AudioField)1 IField (com.ichi2.anki.multimediacard.fields.IField)1 File (java.io.File)1 JSONArray (org.json.JSONArray)1 JSONException (org.json.JSONException)1 JSONObject (org.json.JSONObject)1