Search in sources :

Example 1 with MediaLayout

use of org.odk.collect.android.views.MediaLayout in project collect by opendatakit.

the class QuestionWidget method createQuestionMediaLayout.

private MediaLayout createQuestionMediaLayout(FormEntryPrompt prompt) {
    String promptText = prompt.getLongText();
    // Add the text view. Textview always exists, regardless of whether there's text.
    TextView questionText = new TextView(getContext());
    questionText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, getQuestionFontSize());
    questionText.setTypeface(null, Typeface.BOLD);
    questionText.setTextColor(ContextCompat.getColor(getContext(), R.color.primaryTextColor));
    questionText.setPadding(0, 0, 0, 7);
    questionText.setText(TextUtils.textToHtml(FormEntryPromptUtils.markQuestionIfIsRequired(promptText, prompt.isRequired())));
    questionText.setMovementMethod(LinkMovementMethod.getInstance());
    // Wrap to the size of the parent view
    questionText.setHorizontallyScrolling(false);
    if ((promptText == null || promptText.isEmpty()) && !(prompt.isRequired() && (prompt.getHelpText() == null || prompt.getHelpText().isEmpty()))) {
        questionText.setVisibility(GONE);
    }
    String imageURI = this instanceof SelectImageMapWidget ? null : prompt.getImageText();
    String audioURI = prompt.getAudioText();
    String videoURI = prompt.getSpecialFormQuestionText("video");
    // shown when image is clicked
    String bigImageURI = prompt.getSpecialFormQuestionText("big-image");
    // Create the layout for audio, image, text
    MediaLayout questionMediaLayout = new MediaLayout(getContext(), getPlayer());
    // assign random id
    questionMediaLayout.setId(ViewIds.generateViewId());
    questionMediaLayout.setAVT(prompt.getIndex(), "", questionText, audioURI, imageURI, videoURI, bigImageURI);
    questionMediaLayout.setAudioListener(this);
    String playColorString = prompt.getFormElement().getAdditionalAttribute(null, "playColor");
    if (playColorString != null) {
        try {
            playColor = Color.parseColor(playColorString);
        } catch (IllegalArgumentException e) {
            Timber.e(e, "Argument %s is incorrect", playColorString);
        }
    }
    questionMediaLayout.setPlayTextColor(getPlayColor());
    return questionMediaLayout;
}
Also used : MediaLayout(org.odk.collect.android.views.MediaLayout) TextView(android.widget.TextView)

Example 2 with MediaLayout

use of org.odk.collect.android.views.MediaLayout in project collect by opendatakit.

the class SelectWidget method createMediaLayout.

protected MediaLayout createMediaLayout(int index, TextView textView) {
    String audioURI = getFormEntryPrompt().getSpecialFormSelectChoiceText(items.get(index), FormEntryCaption.TEXT_FORM_AUDIO);
    String imageURI;
    if (items.get(index) instanceof ExternalSelectChoice) {
        imageURI = ((ExternalSelectChoice) items.get(index)).getImage();
    } else {
        imageURI = getFormEntryPrompt().getSpecialFormSelectChoiceText(items.get(index), FormEntryCaption.TEXT_FORM_IMAGE);
    }
    String videoURI = getFormEntryPrompt().getSpecialFormSelectChoiceText(items.get(index), "video");
    String bigImageURI = getFormEntryPrompt().getSpecialFormSelectChoiceText(items.get(index), "big-image");
    MediaLayout mediaLayout = new MediaLayout(getContext(), getPlayer());
    mediaLayout.setAVT(getFormEntryPrompt().getIndex(), "." + Integer.toString(index), textView, audioURI, imageURI, videoURI, bigImageURI);
    mediaLayout.setAudioListener(this);
    mediaLayout.setPlayTextColor(getPlayColor());
    playList.add(mediaLayout);
    if (index != items.size() - 1) {
        ImageView divider = new ImageView(getContext());
        divider.setBackgroundResource(android.R.drawable.divider_horizontal_bright);
        mediaLayout.addDivider(divider);
    }
    return mediaLayout;
}
Also used : ExternalSelectChoice(org.odk.collect.android.external.ExternalSelectChoice) MediaLayout(org.odk.collect.android.views.MediaLayout) ImageView(android.widget.ImageView)

Aggregations

MediaLayout (org.odk.collect.android.views.MediaLayout)2 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 ExternalSelectChoice (org.odk.collect.android.external.ExternalSelectChoice)1