Search in sources :

Example 1 with Attachment

use of com.instructure.canvasapi2.models.Attachment in project instructure-android by instructure.

the class AnnouncementFragment method formatHTMLWithAttachment.

private void formatHTMLWithAttachment() {
    RemoteFile attachment = mAnnouncement.getAttachments().get(0);
    String html = mAnnouncement.getMessage() + "<p><a href=\"" + attachment.getUrl() + "\" >" + attachment.getFileName() + "</a></p>";
    mAnnouncementWebView.formatHTML(html, mAnnouncement.getTitle());
}
Also used : RemoteFile(com.instructure.canvasapi2.models.RemoteFile)

Example 2 with Attachment

use of com.instructure.canvasapi2.models.Attachment in project instructure-android by instructure.

the class SubmissionDetailsFragment method populateAttachments.

/**
 * @param extras
 * @param atts
 */
private void populateAttachments(final LinearLayout extras, final List<Attachment> atts) {
    for (int i = 0; i < atts.size(); i++) {
        // Inflate the view
        RelativeLayout extra = (RelativeLayout) (inflater.inflate(R.layout.detailed_conversation_extras, null));
        // The text should be the display name
        TextView content = (TextView) extra.findViewById(R.id.content);
        content.setText(atts.get(i).getDisplayName());
        // underline it.
        content.setPaintFlags(content.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
        // Make it blue
        content.setTextColor(getResources().getColor(R.color.real_blue));
        // Set the image to be the conversation_attachment icon
        ImageView image = (ImageView) extra.findViewById(R.id.image);
        image.setImageResource(R.drawable.vd_attachment);
        // Set hidden mimetype url display name. filename. id
        extra.findViewById(R.id.mime).setTag(atts.get(i).getDisplayName());
        extra.findViewById(R.id.url).setTag(atts.get(i).getUrl());
        extra.findViewById(R.id.file).setTag(atts.get(i).getFilename());
        extra.findViewById(R.id.display).setTag(atts.get(i).getDisplayName());
        // Add a divider
        View divider = new View(getActivity());
        divider.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 1));
        divider.setBackgroundColor(getResources().getColor(R.color.gray));
        // Add the view
        divider.setVisibility(View.GONE);
        extra.setVisibility(View.GONE);
        extras.addView(divider);
        extras.addView(extra);
        final int j = i;
        extra.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                openMedia(atts.get(j).getContentType(), atts.get(j).getUrl(), atts.get(j).getFilename());
            }
        });
        // allows context menu to appear on long press
        registerForContextMenu(extra);
    }
}
Also used : ViewGroup(android.view.ViewGroup) RelativeLayout(android.widget.RelativeLayout) OnClickListener(android.view.View.OnClickListener) TextView(android.widget.TextView) ImageView(android.widget.ImageView) CircleImageView(de.hdodenhof.circleimageview.CircleImageView) ImageView(android.widget.ImageView) AttachmentView(com.instructure.candroid.view.AttachmentView) CircleImageView(de.hdodenhof.circleimageview.CircleImageView) View(android.view.View) AdapterView(android.widget.AdapterView) BeforePageView(com.instructure.canvasapi2.utils.pageview.BeforePageView) PageView(com.instructure.canvasapi2.utils.pageview.PageView) TextView(android.widget.TextView) ListView(android.widget.ListView) Paint(android.graphics.Paint)

Example 3 with Attachment

use of com.instructure.canvasapi2.models.Attachment in project instructure-android by instructure.

the class DiscussionAttachmentTest method shouldShowToUser_lockedForUser_noUnlockDate.

@Test
public void shouldShowToUser_lockedForUser_noUnlockDate() {
    DiscussionAttachment attachment = new DiscussionAttachment();
    attachment.setLockedForUser(true);
    attachment.setUnlockAt(null);
    assertEquals(false, attachment.shouldShowToUser());
}
Also used : DiscussionAttachment(com.instructure.canvasapi2.models.DiscussionAttachment) Test(org.junit.Test)

Example 4 with Attachment

use of com.instructure.canvasapi2.models.Attachment in project instructure-android by instructure.

the class DiscussionAttachmentTest method shouldShowToUser_hiddenForUser.

@Test
public void shouldShowToUser_hiddenForUser() {
    DiscussionAttachment attachment = new DiscussionAttachment();
    attachment.setHiddenForUser(true);
    assertEquals(false, attachment.shouldShowToUser());
}
Also used : DiscussionAttachment(com.instructure.canvasapi2.models.DiscussionAttachment) Test(org.junit.Test)

Example 5 with Attachment

use of com.instructure.canvasapi2.models.Attachment in project instructure-android by instructure.

the class DiscussionAttachmentTest method shouldShowToUser_lockedForUser_unlockDatePassed.

@Test
public void shouldShowToUser_lockedForUser_unlockDatePassed() {
    Date lockDate = new Date(System.currentTimeMillis() - MILLIS_PER_DAY);
    DiscussionAttachment attachment = new DiscussionAttachment();
    attachment.setUnlockAt(APIHelper.dateToString(lockDate));
    attachment.setLockedForUser(true);
    assertEquals(true, attachment.shouldShowToUser());
}
Also used : DiscussionAttachment(com.instructure.canvasapi2.models.DiscussionAttachment) Date(java.util.Date) Test(org.junit.Test)

Aggregations

DiscussionAttachment (com.instructure.canvasapi2.models.DiscussionAttachment)9 Test (org.junit.Test)9 Attachment (com.instructure.canvasapi2.models.Attachment)5 RestBuilder (com.instructure.canvasapi2.builders.RestBuilder)4 RestParams (com.instructure.canvasapi2.builders.RestParams)4 Date (java.util.Date)4 Paint (android.graphics.Paint)3 Intent (android.content.Intent)2 View (android.view.View)2 AdapterView (android.widget.AdapterView)2 ImageView (android.widget.ImageView)2 ListView (android.widget.ListView)2 TextView (android.widget.TextView)2 AttachmentView (com.instructure.candroid.view.AttachmentView)2 RemoteFile (com.instructure.canvasapi2.models.RemoteFile)2 BeforePageView (com.instructure.canvasapi2.utils.pageview.BeforePageView)2 PageView (com.instructure.canvasapi2.utils.pageview.PageView)2 FileUploadNotification (com.instructure.pandautils.utils.FileUploadNotification)2 CircleImageView (de.hdodenhof.circleimageview.CircleImageView)2 Dialog (android.app.Dialog)1