Skip to content

Commit

Permalink
[MBL-17212][Student][Teacher] Open external routes from discussions (#…
Browse files Browse the repository at this point in the history
…2258)

refs: MBL-17212
affects: Student, Teacher
release note: none

test plan: Navigate to an external route from the discussion redesign page.
  • Loading branch information
hermannakos authored Nov 22, 2023
1 parent 2ca952f commit f4b7a4b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package com.instructure.student.navigation
import androidx.fragment.app.FragmentActivity
import com.instructure.canvasapi2.utils.ApiPrefs
import com.instructure.pandautils.navigation.WebViewRouter
import com.instructure.student.fragment.InternalWebviewFragment
import com.instructure.student.router.RouteMatcher

class StudentWebViewRouter(val activity: FragmentActivity) : WebViewRouter {
Expand All @@ -34,4 +35,8 @@ class StudentWebViewRouter(val activity: FragmentActivity) : WebViewRouter {
override fun openMedia(url: String) {
RouteMatcher.openMedia(activity, url)
}

override fun routeExternally(url: String) {
RouteMatcher.route(activity, InternalWebviewFragment.makeRoute(url, url, false, ""))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@
package com.instructure.teacher.navigation

import androidx.fragment.app.FragmentActivity
import com.instructure.canvasapi2.models.CanvasContext
import com.instructure.canvasapi2.utils.ApiPrefs
import com.instructure.interactions.router.Route
import com.instructure.pandautils.navigation.WebViewRouter
import com.instructure.teacher.fragments.FullscreenInternalWebViewFragment
import com.instructure.teacher.fragments.InternalWebViewFragment
import com.instructure.teacher.router.RouteMatcher

class TeacherWebViewRouter(val activity: FragmentActivity) : WebViewRouter {
Expand All @@ -34,4 +38,14 @@ class TeacherWebViewRouter(val activity: FragmentActivity) : WebViewRouter {
override fun openMedia(url: String) {
RouteMatcher.openMedia(activity, url)
}

override fun routeExternally(url: String) {
val bundle = InternalWebViewFragment.makeBundle(url, url, false, "")
RouteMatcher.route(
activity, Route(
FullscreenInternalWebViewFragment::class.java,
CanvasContext.emptyUserContext(), bundle
)
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class DiscussionDetailsWebViewFragment : Fragment() {

override fun routeInternallyCallback(url: String) {
if (!webViewRouter.canRouteInternally(url, routeIfPossible = true)) {
webViewRouter.routeInternally(url)
webViewRouter.routeExternally(url)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ interface WebViewRouter {
fun routeInternally(url: String)

fun openMedia(url: String)

fun routeExternally(url: String)
}

0 comments on commit f4b7a4b

Please sign in to comment.