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