-
Notifications
You must be signed in to change notification settings - Fork 108
[MBL-19461][Student] Add My Courses dashboard widget #3429
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
26a035e
[MBL-19461] Add domain layer for My Courses dashboard widget
hermannakos 906ad9b
[MBL-19461] Add UI layer for My Courses dashboard widget
hermannakos dba679a
[MBL-19461] Add color overlay switch support to My Courses widget
hermannakos f2e4c52
[MBL-19461] Update CourseCard design to match Figma specifications
hermannakos 90f60e9
[MBL-19461] Add navigation and grid layout to My Courses widget
hermannakos 587ad12
[MBL-19461] Fix card ripple and add DashboardScreen previews
hermannakos 7b33653
[MBL-19461] Add unit tests for My Courses widget
hermannakos f343542
[MBL-19461] Add interaction tests for My Courses widget
hermannakos cda23f7
Update EnsureDefaultWidgetsUseCaseTest to include courses widget
hermannakos 7281e1e
Add CoursesWidgetBehavior stub to Horizon test module
hermannakos b2f0a87
fix card shadows + all courses button placement
hermannakos b02752b
[MBL-19461] Fix CoursesWidgetTest assertions after UI changes
hermannakos 3a7be1b
[MBL-19461] Fix grade calculations and course filtering in My Courses…
hermannakos 3dcd0d6
[MBL-19461] Fix group colors to use parent course color for course name
hermannakos 3274d93
Merge remote-tracking branch 'origin/master' into MBL-19461-dashboard…
hermannakos e6ff87c
CRs
hermannakos 4858b90
use group color on group card
hermannakos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
apps/student/src/main/java/com/instructure/student/di/feature/CoursesWidgetModule.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| /* | ||
| * Copyright (C) 2025 - present Instructure, Inc. | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, version 3 of the License. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| package com.instructure.student.di.feature | ||
|
|
||
| import com.instructure.pandautils.features.dashboard.widget.courses.CoursesWidgetBehavior | ||
| import com.instructure.pandautils.features.dashboard.widget.courses.CoursesWidgetRouter | ||
| import com.instructure.student.features.dashboard.widget.courses.StudentCoursesWidgetBehavior | ||
| import com.instructure.student.features.dashboard.widget.courses.StudentCoursesWidgetRouter | ||
| import dagger.Module | ||
| import dagger.Provides | ||
| import dagger.hilt.InstallIn | ||
| import dagger.hilt.android.components.ViewModelComponent | ||
|
|
||
| @Module | ||
| @InstallIn(ViewModelComponent::class) | ||
| class CoursesWidgetModule { | ||
|
|
||
| @Provides | ||
| fun provideCoursesWidgetRouter(): CoursesWidgetRouter { | ||
| return StudentCoursesWidgetRouter() | ||
| } | ||
|
|
||
| @Provides | ||
| fun provideCoursesWidgetBehavior( | ||
| studentCoursesWidgetBehavior: StudentCoursesWidgetBehavior | ||
| ): CoursesWidgetBehavior { | ||
| return studentCoursesWidgetBehavior | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
...a/com/instructure/student/features/dashboard/widget/courses/ObserveColorOverlayUseCase.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| /* | ||
| * Copyright (C) 2025 - present Instructure, Inc. | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, version 3 of the License. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| package com.instructure.student.features.dashboard.widget.courses | ||
|
|
||
| import android.content.Context | ||
| import android.content.SharedPreferences | ||
| import com.instructure.pandautils.domain.usecase.BaseFlowUseCase | ||
| import com.instructure.student.util.StudentPrefs | ||
| import dagger.hilt.android.qualifiers.ApplicationContext | ||
| import kotlinx.coroutines.channels.awaitClose | ||
| import kotlinx.coroutines.flow.Flow | ||
| import kotlinx.coroutines.flow.callbackFlow | ||
| import javax.inject.Inject | ||
|
|
||
| class ObserveColorOverlayUseCase @Inject constructor( | ||
| @ApplicationContext private val context: Context | ||
| ) : BaseFlowUseCase<Unit, Boolean>() { | ||
|
|
||
| override fun execute(params: Unit): Flow<Boolean> = callbackFlow { | ||
| val sharedPreferences = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE) | ||
|
|
||
| val listener = SharedPreferences.OnSharedPreferenceChangeListener { _, key -> | ||
| if (key == KEY_HIDE_COURSE_COLOR_OVERLAY) { | ||
| trySend(!StudentPrefs.hideCourseColorOverlay) | ||
| } | ||
| } | ||
|
|
||
| sharedPreferences.registerOnSharedPreferenceChangeListener(listener) | ||
| send(!StudentPrefs.hideCourseColorOverlay) | ||
|
|
||
| awaitClose { | ||
| sharedPreferences.unregisterOnSharedPreferenceChangeListener(listener) | ||
| } | ||
| } | ||
|
|
||
| companion object { | ||
| private const val PREFS_NAME = "candroidSP" | ||
hermannakos marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| private const val KEY_HIDE_COURSE_COLOR_OVERLAY = "hideCourseColorOverlay" | ||
| } | ||
| } | ||
54 changes: 54 additions & 0 deletions
54
...om/instructure/student/features/dashboard/widget/courses/ObserveGradeVisibilityUseCase.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| /* | ||
| * Copyright (C) 2025 - present Instructure, Inc. | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, version 3 of the License. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| package com.instructure.student.features.dashboard.widget.courses | ||
|
|
||
| import android.content.Context | ||
| import android.content.SharedPreferences | ||
| import com.instructure.pandautils.domain.usecase.BaseFlowUseCase | ||
| import com.instructure.student.util.StudentPrefs | ||
| import dagger.hilt.android.qualifiers.ApplicationContext | ||
| import kotlinx.coroutines.channels.awaitClose | ||
| import kotlinx.coroutines.flow.Flow | ||
| import kotlinx.coroutines.flow.callbackFlow | ||
| import javax.inject.Inject | ||
|
|
||
| class ObserveGradeVisibilityUseCase @Inject constructor( | ||
| @ApplicationContext private val context: Context | ||
| ) : BaseFlowUseCase<Unit, Boolean>() { | ||
|
|
||
| override fun execute(params: Unit): Flow<Boolean> = callbackFlow { | ||
| val sharedPreferences = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE) | ||
|
|
||
| val listener = SharedPreferences.OnSharedPreferenceChangeListener { _, key -> | ||
| if (key == KEY_SHOW_GRADES_ON_CARD) { | ||
| trySend(StudentPrefs.showGradesOnCard) | ||
| } | ||
| } | ||
|
|
||
| sharedPreferences.registerOnSharedPreferenceChangeListener(listener) | ||
| send(StudentPrefs.showGradesOnCard) | ||
|
|
||
| awaitClose { | ||
| sharedPreferences.unregisterOnSharedPreferenceChangeListener(listener) | ||
| } | ||
| } | ||
|
|
||
| companion object { | ||
| private const val PREFS_NAME = "candroidSP" | ||
hermannakos marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| private const val KEY_SHOW_GRADES_ON_CARD = "showGradesOnCard" | ||
| } | ||
| } | ||
60 changes: 60 additions & 0 deletions
60
...com/instructure/student/features/dashboard/widget/courses/StudentCoursesWidgetBehavior.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| /* | ||
| * Copyright (C) 2025 - present Instructure, Inc. | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, version 3 of the License. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| package com.instructure.student.features.dashboard.widget.courses | ||
|
|
||
| import androidx.fragment.app.FragmentActivity | ||
| import com.instructure.canvasapi2.models.Course | ||
| import com.instructure.canvasapi2.models.Group | ||
| import com.instructure.pandautils.features.dashboard.widget.courses.CoursesWidgetBehavior | ||
| import com.instructure.pandautils.features.dashboard.widget.courses.CoursesWidgetRouter | ||
| import kotlinx.coroutines.flow.Flow | ||
| import javax.inject.Inject | ||
|
|
||
| class StudentCoursesWidgetBehavior @Inject constructor( | ||
| private val observeGradeVisibilityUseCase: ObserveGradeVisibilityUseCase, | ||
| private val observeColorOverlayUseCase: ObserveColorOverlayUseCase, | ||
| private val router: CoursesWidgetRouter | ||
| ) : CoursesWidgetBehavior { | ||
|
|
||
| override fun observeGradeVisibility(): Flow<Boolean> { | ||
| return observeGradeVisibilityUseCase(Unit) | ||
| } | ||
|
|
||
| override fun observeColorOverlay(): Flow<Boolean> { | ||
| return observeColorOverlayUseCase(Unit) | ||
| } | ||
|
|
||
| override fun onCourseClick(activity: FragmentActivity, course: Course) { | ||
| router.routeToCourse(activity, course) | ||
| } | ||
|
|
||
| override fun onGroupClick(activity: FragmentActivity, group: Group) { | ||
| router.routeToGroup(activity, group) | ||
| } | ||
|
|
||
| override fun onManageOfflineContent(activity: FragmentActivity, course: Course) { | ||
| router.routeToManageOfflineContent(activity, course) | ||
| } | ||
|
|
||
| override fun onCustomizeCourse(activity: FragmentActivity, course: Course) { | ||
| router.routeToCustomizeCourse(activity, course) | ||
| } | ||
|
|
||
| override fun onAllCoursesClicked(activity: FragmentActivity) { | ||
| router.routeToAllCourses(activity) | ||
| } | ||
| } |
48 changes: 48 additions & 0 deletions
48
...a/com/instructure/student/features/dashboard/widget/courses/StudentCoursesWidgetRouter.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| /* | ||
| * Copyright (C) 2025 - present Instructure, Inc. | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, version 3 of the License. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| package com.instructure.student.features.dashboard.widget.courses | ||
|
|
||
| import androidx.fragment.app.FragmentActivity | ||
| import com.instructure.canvasapi2.models.Course | ||
| import com.instructure.canvasapi2.models.Group | ||
| import com.instructure.pandautils.features.dashboard.edit.EditDashboardFragment | ||
| import com.instructure.pandautils.features.dashboard.widget.courses.CoursesWidgetRouter | ||
| import com.instructure.student.features.coursebrowser.CourseBrowserFragment | ||
| import com.instructure.student.router.RouteMatcher | ||
|
|
||
| class StudentCoursesWidgetRouter : CoursesWidgetRouter { | ||
|
|
||
| override fun routeToCourse(activity: FragmentActivity, course: Course) { | ||
| RouteMatcher.route(activity, CourseBrowserFragment.makeRoute(course)) | ||
| } | ||
|
|
||
| override fun routeToGroup(activity: FragmentActivity, group: Group) { | ||
| RouteMatcher.route(activity, CourseBrowserFragment.makeRoute(group)) | ||
| } | ||
|
|
||
| override fun routeToManageOfflineContent(activity: FragmentActivity, course: Course) { | ||
| // TODO: Navigate to manage offline content screen | ||
hermannakos marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| override fun routeToCustomizeCourse(activity: FragmentActivity, course: Course) { | ||
| // TODO: Navigate to customize course screen (color/nickname) | ||
| } | ||
|
|
||
| override fun routeToAllCourses(activity: FragmentActivity) { | ||
| RouteMatcher.route(activity, EditDashboardFragment.makeRoute()) | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.