use of com.instructure.canvasapi2.models.Course in project instructure-android by instructure.
the class DetailViewActivity method routeFromIntent.
private void routeFromIntent(Intent intent) {
DETAIL_FRAGMENT fragmentType = (DETAIL_FRAGMENT) intent.getExtras().getSerializable(Const.FRAGMENT_TYPE);
if (fragmentType != null) {
Student student = intent.getExtras().getParcelable(Const.STUDENT);
switch(fragmentType) {
case WEEK:
Student user = intent.getExtras().getParcelable(Const.USER);
Course course = (Course) intent.getExtras().getSerializable(Const.COURSE);
if (user != null && course != null) {
addFragment(CourseWeekFragment.newInstance(user, course));
}
break;
case ASSIGNMENT:
Assignment assignment = intent.getExtras().getParcelable(Const.ASSIGNMENT);
String courseName = intent.getExtras().getString(Const.NAME);
addFragment(AssignmentFragment.newInstance(assignment, courseName, student), false);
break;
case ANNOUNCEMENT:
DiscussionTopicHeader announcement = intent.getExtras().getParcelable(Const.ANNOUNCEMENT);
String announcementCourseName = intent.getExtras().getString(Const.NAME);
addFragment(AnnouncementFragment.newInstance(announcement, announcementCourseName, student), false);
break;
case EVENT:
ScheduleItem item = intent.getExtras().getParcelable(Const.SCHEDULE_ITEM);
addFragment(EventFragment.newInstance(item, student), false);
break;
case SYLLABUS:
Course syllabusCourse = (Course) intent.getExtras().getSerializable(Const.COURSE);
addFragment(CourseSyllabusFragment.newInstance(syllabusCourse, student), false);
break;
case ACCOUNT_NOTIFICATION:
AccountNotification accountNotification = intent.getExtras().getParcelable(Const.ACCOUNT_NOTIFICATION);
addFragment(AccountNotificationFragment.newInstance(accountNotification, student));
}
}
}
use of com.instructure.canvasapi2.models.Course in project instructure-android by instructure.
the class StudentViewActivity method setupViews.
private void setupViews() {
if (statusBarHeightId > 0) {
// else it uses the default dimens in XML
// Configure views to slide under status bar, will only effect > API 21
int statusBarHeight = getResources().getDimensionPixelSize(statusBarHeightId);
RelativeLayout root = (RelativeLayout) findViewById(R.id.rootView);
RelativeLayout navigationWrapper = (RelativeLayout) findViewById(R.id.navigationWrapper);
FrameLayout.LayoutParams rootParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
rootParams.setMargins(0, -statusBarHeight, 0, 0);
root.setLayoutParams(rootParams);
navigationWrapper.setPadding(0, statusBarHeight, 0, 0);
} else {
RelativeLayout root = (RelativeLayout) findViewById(R.id.rootView);
RelativeLayout navigationWrapper = (RelativeLayout) findViewById(R.id.navigationWrapper);
FrameLayout.LayoutParams rootParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
rootParams.setMargins(0, 0, 0, 0);
root.setLayoutParams(rootParams);
navigationWrapper.setPadding(0, 0, 0, 0);
}
mSettingsButton = (ImageButton) findViewById(R.id.settings);
mStudentName = (TextView) findViewById(R.id.studentName);
// Get the ViewPager and set it's PagerAdapter so that it can display items
final ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
if (mPagerAdapter == null) {
mPagerAdapter = new StudentActivityFragmentPagerAdapter(getSupportFragmentManager(), StudentViewActivity.this);
}
viewPager.setAdapter(mPagerAdapter);
// When loading course page, alert page will need to be updated so we need to be sure to
// keep all fragments in memory
viewPager.setOffscreenPageLimit(2);
// Give the TabLayout the ViewPager
mTabLayout = (TabLayout) findViewById(R.id.sliding_tabs);
mTabLayout.setupWithViewPager(viewPager);
mTabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
if (tab.getCustomView() != null) {
tab.getCustomView().setAlpha(1f);
}
viewPager.setCurrentItem(tab.getPosition());
// set the tab content description to the title of the tab, for a11y/testing
tab.setContentDescription(tab.getText());
onPageScrolled(mCarouselViewPager.getCurrentItem(), 0, 0);
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
if (tab.getCustomView() != null) {
tab.getCustomView().setAlpha(.30f);
}
}
@Override
public void onTabReselected(TabLayout.Tab tab) {
}
});
// Iterate over all tabs and set the custom view
for (int i = 0; i < mTabLayout.getTabCount(); i++) {
TabLayout.Tab tab = mTabLayout.getTabAt(i);
tab.setCustomView(mPagerAdapter.getTabView(i));
if (i != viewPager.getCurrentItem()) {
tab.getCustomView().setAlpha(.30f);
}
}
configureUserCarousel();
Prefs prefs = new Prefs(StudentViewActivity.this, com.instructure.parentapp.util.Const.CANVAS_PARENT_SP);
int pos = prefs.load(Const.TAB, 0);
if (pos != 0) {
viewPager.setCurrentItem(pos);
}
// update unread count
mPagerAdapter.setAlertFragmentUnreadCount(mUnreadAlertCount);
}
use of com.instructure.canvasapi2.models.Course in project instructure-android by instructure.
the class CalendarWeekBinder method bind.
public static void bind(final Context context, final CalendarWeekViewHolder holder, final int courseColor, final ScheduleItem item, final AdapterToFragmentCallback<ScheduleItem> adapterToFragmentCallback, final Map<Long, Course> courseMap) {
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
adapterToFragmentCallback.onRowClicked(item, holder.getAdapterPosition(), false);
}
});
if (item.hasAssignmentOverrides()) {
String title = String.format(context.getResources().getString(R.string.week_assignment_override_title), item.getTitle(), item.getAssignmentOverrides().get(0).title);
holder.title.setText(title);
} else {
holder.title.setText(item.getTitle());
}
switch(item.getItemType()) {
case TYPE_CALENDAR:
case TYPE_ASSIGNMENT:
holder.title.setText(item.getTitle());
Assignment assignment = item.getAssignment();
// need to reset drawables
holder.icon.setImageDrawable(null);
holder.status.setBackgroundDrawable(null);
holder.background.setBackgroundDrawable(null);
setGone(holder.date);
setVisible(holder.status);
int drawable;
if (assignment != null) {
int assignmentState = AssignmentUtils2.getAssignmentState(assignment, assignment.getSubmission());
holder.icon.setContentDescription(context.getString(R.string.assignment));
switch(assignmentState) {
// Looks like: Submitted 95%, Color - Light blue
case (AssignmentUtils2.ASSIGNMENT_STATE_GRADED):
String gradeText = ViewUtils.getGradeText(AssignmentUtils2.ASSIGNMENT_STATE_GRADED, assignment.getSubmission().getScore(), assignment.getPointsPossible(), context);
holder.icon.setImageDrawable(context.getResources().getDrawable(R.drawable.ic_done_white_18dp));
holder.status.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.assignment_graded_background));
holder.background.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.circle_background));
holder.status.setText(gradeText);
break;
// Looks like: Late 95%, Color - Orange-ish yellow
case (AssignmentUtils2.ASSIGNMENT_STATE_GRADED_LATE):
String lateGradeText = ViewUtils.getGradeText(AssignmentUtils2.ASSIGNMENT_STATE_GRADED_LATE, assignment.getSubmission().getScore(), assignment.getPointsPossible(), context);
holder.icon.setImageDrawable(context.getResources().getDrawable(R.drawable.ic_done_white_18dp));
holder.status.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.late_assignment_background));
holder.background.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.orange_circle_background));
holder.status.setText(lateGradeText);
break;
// Looks like: Submitted, Color - Light blue
case (AssignmentUtils2.ASSIGNMENT_STATE_SUBMITTED):
holder.icon.setImageDrawable(context.getResources().getDrawable(R.drawable.ic_done_white_18dp));
holder.status.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.assignment_submitted_background));
holder.background.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.light_blue_circle_background));
holder.status.setText(context.getString(R.string.submitted));
break;
// Looks like: Late, Color - Orange-ish yellow
case (AssignmentUtils2.ASSIGNMENT_STATE_SUBMITTED_LATE):
holder.icon.setImageDrawable(context.getResources().getDrawable(R.drawable.ic_done_white_18dp));
holder.status.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.late_assignment_background));
holder.background.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.orange_circle_background));
holder.status.setText(context.getString(R.string.late));
break;
// Looks like: Missing, Color - Red!
case (AssignmentUtils2.ASSIGNMENT_STATE_MISSING):
holder.icon.setImageDrawable(context.getResources().getDrawable(R.drawable.ic_warning_white_18dp));
holder.date.setVisibility(View.GONE);
holder.status.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.submission_missing_background));
holder.background.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.red_circle_background));
holder.status.setText(context.getString(R.string.missing));
break;
// Looks like: no status, assignment icon/grey
case (AssignmentUtils2.ASSIGNMENT_STATE_DUE):
// match assignment type icon
drawable = ViewUtils.getAssignmentIcon(assignment);
holder.icon.setImageDrawable(ColorKeeper.getColoredDrawable(context, drawable, context.getResources().getColor(R.color.gray)));
holder.background.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.read_circle_background));
setGone(holder.status);
break;
// Looks like: Excused, color, light blue
case (AssignmentUtils2.ASSIGNMENT_STATE_EXCUSED):
holder.icon.setImageDrawable(context.getResources().getDrawable(R.drawable.ic_done_white_18dp));
holder.status.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.assignment_graded_background));
holder.background.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.circle_background));
holder.status.setText(context.getString(R.string.excused));
break;
// Looks like: In-Class, color, light green
case (AssignmentUtils2.ASSIGNMENT_STATE_IN_CLASS):
drawable = ViewUtils.getAssignmentIcon(assignment);
holder.icon.setImageDrawable(ColorKeeper.getColoredDrawable(context, drawable, context.getResources().getColor(R.color.gray)));
holder.status.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.assignment_in_class_background));
holder.background.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.read_circle_background));
holder.status.setText(context.getString(R.string.in_class));
}
setCleanText(holder.description, getCourseNameById(courseMap, item.getAssignment().getCourseId()));
} else {
// Calendar Event
holder.icon.setImageDrawable(context.getResources().getDrawable(R.drawable.vd_calendar_month));
holder.icon.setContentDescription(context.getString(R.string.calendar_event));
holder.background.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.circle_background));
holder.title.setText(item.getTitle());
holder.date.setVisibility(View.VISIBLE);
holder.date.setText(getStartString(context, item));
setGone(holder.status);
setCleanText(holder.description, getCourseNameById(courseMap, item.getCourseId()));
}
// We want to set this at the end so we get the a11y values
com.instructure.pandautils.utils.Utils.testSafeContentDescription(holder.title, String.format(context.getString(R.string.calendar_title_content_desc), holder.getAdapterPosition()), holder.title.getText().toString(), BuildConfig.IS_TESTING);
com.instructure.pandautils.utils.Utils.testSafeContentDescription(holder.description, String.format(context.getString(R.string.description_text_content_desc), holder.getAdapterPosition()), holder.description.getText().toString(), BuildConfig.IS_TESTING);
com.instructure.pandautils.utils.Utils.testSafeContentDescription(holder.status, String.format(context.getString(R.string.status_text_content_desc), holder.getAdapterPosition()), holder.status.getText().toString(), BuildConfig.IS_TESTING);
break;
default:
Logger.d("UNSUPPORTED TYPE FOUND IN SYLLABUS BINDER");
break;
}
}
use of com.instructure.canvasapi2.models.Course in project instructure-android by instructure.
the class CourseListPresenterTest method setUp.
@Before
public void setUp() throws Exception {
course1 = new Course();
course2 = new Course();
Student student = new Student();
presenter = new CourseListPresenter(student);
}
use of com.instructure.canvasapi2.models.Course in project instructure-android by instructure.
the class WeekPresenterTest method setUp.
@Before
public void setUp() throws Exception {
Student student = new Student();
student.setStudentId("student_12345");
student.setParentId("parent_12345");
student.setStudentDomain("https://localhost.com");
student.setStudentName("Man in the Yellow Hat");
Course course = new Course();
course.setName("Curious George and the Hidden Course of Doom");
course.setCourseCode("course_12345");
mPresenter = new WeekViewPresenterFactory(student, course).create();
}
Aggregations