Skip to content

Commit

Permalink
Merge pull request #2259 from instructure/release/student-7.0.1-257
Browse files Browse the repository at this point in the history
Release Student 7.0.1 (257)
  • Loading branch information
hermannakos authored Nov 23, 2023
2 parents 792f6cc + e30d261 commit 0996bb1
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 5 deletions.
4 changes: 2 additions & 2 deletions apps/student/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ android {
applicationId "com.instructure.candroid"
minSdkVersion Versions.MIN_SDK
targetSdkVersion Versions.TARGET_SDK
versionCode = 256
versionName = '7.0.0'
versionCode = 257
versionName = '7.0.1'

vectorDrawables.useSupportLibrary = true
multiDexEnabled = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ import com.instructure.pandautils.utils.LoaderUtils
import com.instructure.pandautils.utils.PermissionUtils
import com.instructure.pandautils.utils.getDrawableCompat
import com.instructure.pandautils.utils.hasPermissions
import com.instructure.pandautils.utils.toast
import com.instructure.pandautils.views.EmptyView
import com.instructure.student.R
import com.instructure.student.activity.VideoViewActivity
Expand Down Expand Up @@ -381,7 +382,12 @@ abstract class ParentFragment : DialogFragment(), FragmentInteractions, Navigati
}

onMainThread {
LoaderUtils.restartLoaderWithBundle<LoaderManager.LoaderCallbacks<OpenMediaAsyncTaskLoader.LoadedMedia>>(LoaderManager.getInstance(owner), openMediaBundle, loaderCallbacks, R.id.openMediaLoaderID)
try {
LoaderUtils.restartLoaderWithBundle<LoaderManager.LoaderCallbacks<OpenMediaAsyncTaskLoader.LoadedMedia>>(LoaderManager.getInstance(owner), openMediaBundle, loaderCallbacks, R.id.openMediaLoaderID)
} catch (e: Exception) {
toast(R.string.unexpectedErrorOpeningFile)
onMediaLoadingComplete()
}
}
}

Expand Down
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 @@ -24,10 +24,10 @@ import com.instructure.canvasapi2.managers.OAuthManager
import com.instructure.canvasapi2.managers.UserManager
import com.instructure.canvasapi2.utils.ApiPrefs
import com.instructure.pandautils.mvvm.Event
import com.instructure.pandautils.utils.FEATURE_FLAG_OFFLINE
import com.instructure.pandautils.utils.FeatureFlagProvider
import com.instructure.pandautils.utils.NetworkStateProvider
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import javax.inject.Inject

Expand All @@ -49,6 +49,7 @@ class LoginViewModel @Inject constructor(
fun checkLogin(checkToken: Boolean, checkElementary: Boolean): LiveData<Event<LoginResultAction>> {
viewModelScope.launch {
try {
waitForUser()
val offlineEnabled = featureFlagProvider.offlineEnabled()
val offlineLogin = offlineEnabled && !networkStateProvider.isOnline()
if (checkToken && !offlineLogin) {
Expand All @@ -70,6 +71,14 @@ class LoginViewModel @Inject constructor(
return loginResultAction
}

// We need to wait for the user to be set in ApiPrefs
private suspend fun waitForUser() {
repeat(30) {
if (apiPrefs.user != null) return
delay(100)
}
}

private suspend fun checkTermsAcceptance(canvasForElementary: Boolean, offlineLogin: Boolean = false) {
val authenticatedSession = oauthManager.getAuthenticatedSessionAsync("${apiPrefs.fullDomain}/users/self").await()
val requiresTermsAcceptance = authenticatedSession.dataOrNull?.requiresTermsAcceptance ?: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ class LoginViewModelTest {
fun setUp() {
lifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_CREATE)
Dispatchers.setMain(testDispatcher)

every { apiPrefs.user } returns mockk()
}

@After
Expand Down
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 0996bb1

Please sign in to comment.