youtube_lectures#18
Conversation
Update agp version in gradle/libs.versions.toml from 9.0.1 to 9.1.0 to adopt the newer Android Gradle Plugin release. Keeps build tooling up-to-date and includes upstream fixes and improvements.
There was a problem hiding this comment.
Pull request overview
Adds a Canvas “to-do assignments” sync flow (via personal access token) and updates the video lecture demo to load a YouTube video and search within a locally loaded transcript.
Changes:
- Add Canvas Retrofit API client/models and a token-entry dialog to sync upcoming assignments into the Room DB.
- Update VideoLectureActivity to embed YouTube videos by ID and search within a parsed transcript.
- Update build tooling/dependencies (Gradle wrapper + AGP) and adjust assignment item layout constraints.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 13 comments.
Show a summary per file
| File | Description |
|---|---|
| gradle/wrapper/gradle-wrapper.properties | Bumps Gradle wrapper distribution version/hash. |
| gradle/libs.versions.toml | Updates AGP version in the version catalog. |
| app/src/main/res/layout/item_assignment.xml | Tweaks constraints/margins for assignment list item UI. |
| app/src/main/java/com/example/studentproductivityapp/features/video_lectures/VideoLectureActivity.kt | Switches to AppCompatActivity, embeds YouTube via iframe HTML, loads/parses a local transcript, and searches/jumps to timestamps. |
| app/src/main/java/com/example/studentproductivityapp/features/home/MainActivity.kt | Adds Canvas sync dialog + Retrofit call to fetch assignments and insert into Room. |
| app/src/main/java/com/example/studentproductivityapp/CanvasAPI.kt | Introduces Canvas API data models, service interface, and Retrofit client. |
| app/build.gradle.kts | Adds additional Retrofit dependencies for Canvas API calls. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| private fun loadVideoAtTime(seconds: Int) { | ||
| if (currentVideoId.isEmpty()) return | ||
|
|
||
| val html = """ | ||
| <!DOCTYPE html> | ||
| <html> | ||
| <head> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
| </head> | ||
| <body style="margin:0;padding:0;background-color:#000;"> | ||
| <iframe width="100%" height="100%" | ||
| src="https://www.youtube.com/embed/$currentVideoId?start=$seconds&autoplay=1&playsinline=1&enablejsapi=1&origin=https://localhost" | ||
| frameborder="0" |
There was a problem hiding this comment.
currentVideoId is interpolated directly into an HTML string that is loaded into a JavaScript-enabled WebView. A crafted URL could inject characters that break out of the attribute and execute script in the page context. Validate/sanitize currentVideoId (e.g., strict YouTube video ID pattern) before using it, or URL-encode it and reject invalid input.
| distributionSha256Sum=2ab2958f2a1e51120c326cad6f385153bb11ee93b3c216c5fccebfdfbb7ec6cb | ||
| distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.1-bin.zip |
There was a problem hiding this comment.
This PR upgrades Gradle wrapper (9.3.1 → 9.4.1) and AGP (via version catalog) but the PR description only mentions Canvas sync and video lecture search. Toolchain upgrades can have wide impact; please document the rationale/compatibility in the PR description or split the build tool upgrade into a separate PR.
|
|
||
| //Retrofit for Canvas API Calls | ||
| implementation("com.squareup.retrofit2:retrofit:2.9.0") | ||
| implementation("com.squareup.retrofit2:converter-gson:2.9.0") |
There was a problem hiding this comment.
These new Retrofit dependencies duplicate the existing Retrofit dependencies already declared earlier in this same file (implementation(libs.retrofit) / implementation(libs.retrofit.gson)) and introduce a conflicting downgrade to 2.9.0 while the version catalog is 2.11.0. Remove the hard-coded entries and use the version-catalog aliases consistently to avoid dependency version conflicts.
| //Retrofit for Canvas API Calls | |
| implementation("com.squareup.retrofit2:retrofit:2.9.0") | |
| implementation("com.squareup.retrofit2:converter-gson:2.9.0") |
| Assignment( | ||
| title = canvasAssign.name, | ||
| courseName = "Course ID: ${canvasAssign.course_id}", | ||
| dueDateMillis = parsedMillis, | ||
| isCompleted = false | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| if (newAssignments.isNotEmpty()) { | ||
| newAssignments.forEach { assignmentDao.insert(it) } | ||
|
|
There was a problem hiding this comment.
Canvas sync inserts all fetched assignments every time without any de-duplication key (local Assignment uses an auto-generated PK), so repeated syncs will create duplicate rows. Consider storing the Canvas assignment id (e.g., canvasId) with a UNIQUE index and using upsert, or clearing/replacing the previous Canvas-synced items before inserting.
Trosper3
left a comment
There was a problem hiding this comment.
This is fantastic! Nice job with it and the idea to move it over to YouTube was excellent.
Thanks for using StudentProductivityApp!
Here's what's new: