Skip to content

Commit

Permalink
nit changes
Browse files Browse the repository at this point in the history
  • Loading branch information
vrajdesai78 committed Aug 27, 2022
1 parent 9675442 commit 00c426a
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 10 deletions.
1 change: 1 addition & 0 deletions app/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,7 @@ kt_android_library(
"//app/src/main/java/org/oppia/android/app/activity:ActivityComponentImpl.kt",
"//app/src/main/java/org/oppia/android/app/activity:ActivityIntentFactoriesModule.kt",
"//app/src/main/java/org/oppia/android/app/activity:ActivityModule.kt",
"//app/src/main/java/org/oppia/android/app/activity/route:activity_router_module",
"//app/src/main/java/org/oppia/android/app/fragment:FragmentComponentBuilderModule.kt",
"//app/src/main/java/org/oppia/android/app/fragment:FragmentComponentImpl.kt",
"//app/src/main/java/org/oppia/android/app/fragment:FragmentModule.kt",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,21 @@ import org.oppia.android.util.logging.ConsoleLogger
import javax.inject.Inject

/**
* ActivityRouter used to route to given [DestinationScreen].
* A central router that can navigate the user to a specific activity based on a provided
* [DestinationScreen].
*/
class ActivityRouter @Inject constructor(
private val activity: AppCompatActivity,
private val consoleLogger: ConsoleLogger
) {

/** Checks the value of [DestinationScreen] and routes to different activities accordingly. */
/** Opens the activity corresponding to the specified [destinationScreen]. */
fun routeToScreen(destinationScreen: DestinationScreen) {
when (destinationScreen.destinationScreenCase) {
when (destinationScreen.destinationScreenCase!!) {
DestinationScreen.DestinationScreenCase.RECENTLY_PLAYED_ACTIVITY_PARAMS -> {
openRecentlyPlayedActivity(destinationScreen.recentlyPlayedActivityParams)
}
else -> {
DestinationScreen.DestinationScreenCase.DESTINATIONSCREEN_NOT_SET -> {
consoleLogger.w("ActivityRouter", "Destination screen case is not identified.")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import dagger.multibindings.IntoMap
import dagger.multibindings.StringKey
import org.oppia.android.app.model.DestinationScreen

/** RouterModule to bind [DestinationScreen]. */
/** Module to bind [DestinationScreen]. */
@Module
class ActivityRouterModule {
@Provides
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Constructs for setting up ActivityRoute for injection in the Dagger graph.
Constructs for setting up activity routing support for injection in the Dagger graph.
"""

load("@dagger//:workspace_defs.bzl", "dagger_rules")
Expand All @@ -16,7 +16,7 @@ kt_android_library(
"ActivityRouterModule.kt",
],
visibility = [
"//app:app_visibility",
"//:oppia_prod_module_visibility",
],
deps = [
":dagger",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import org.oppia.android.util.parser.image.ImageParsingModule
import org.oppia.android.util.system.OppiaClockModule
import org.oppia.android.util.threading.DispatcherModule
import javax.inject.Singleton
import org.oppia.android.app.activity.route.ActivityRouterModule

/**
* Root Dagger component for alpha versions of the application.
Expand All @@ -83,7 +84,7 @@ import javax.inject.Singleton
PlatformParameterModule::class, PlatformParameterSingletonModule::class,
ExplorationStorageModule::class, DeveloperOptionsModule::class,
PlatformParameterSyncUpWorkerModule::class, NetworkConfigProdModule::class, AssetModule::class,
LocaleProdModule::class, ActivityRecreatorProdModule::class,
LocaleProdModule::class, ActivityRecreatorProdModule::class, ActivityRouterModule::class,
NumericExpressionInputModule::class, AlgebraicExpressionInputModule::class,
MathEquationInputModule::class, SplitScreenInteractionModule::class,
LoggingIdentifierModule::class, ApplicationLifecycleModule::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import org.oppia.android.util.parser.image.ImageParsingModule
import org.oppia.android.util.system.OppiaClockModule
import org.oppia.android.util.threading.DispatcherModule
import javax.inject.Singleton
import org.oppia.android.app.activity.route.ActivityRouterModule

/**
* Root Dagger component for the alpha version of the application specific to a user study in Kenya.
Expand All @@ -83,7 +84,7 @@ import javax.inject.Singleton
PlatformParameterAlphaKenyaModule::class, PlatformParameterSingletonModule::class,
ExplorationStorageModule::class, DeveloperOptionsModule::class,
PlatformParameterSyncUpWorkerModule::class, NetworkConfigProdModule::class, AssetModule::class,
LocaleProdModule::class, ActivityRecreatorProdModule::class,
LocaleProdModule::class, ActivityRecreatorProdModule::class, ActivityRouterModule::class,
NumericExpressionInputModule::class, AlgebraicExpressionInputModule::class,
MathEquationInputModule::class, SplitScreenInteractionModule::class,
LoggingIdentifierModule::class, ApplicationLifecycleModule::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import androidx.test.espresso.matcher.ViewMatchers.withText
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.google.android.material.card.MaterialCardView
import com.google.common.truth.Truth.assertThat
import com.google.protobuf.MessageLite
import dagger.Component
import dagger.Module
import dagger.Provides
Expand Down Expand Up @@ -668,9 +669,10 @@ class ProfileProgressFragmentTest {
.setActivityTitle(RecentlyPlayedActivityTitle.RECENTLY_PLAYED_STORIES)
.build()
clickProfileProgressItem(itemPosition = 0, targetViewId = R.id.view_all_text_view)

intended(hasComponent(RecentlyPlayedActivity::class.java.name))
intended(
hasExtra(
hasProtoExtra(
RecentlyPlayedActivity.RECENTLY_PLAYED_ACTIVITY_INTENT_EXTRAS_KEY,
recentlyPlayedActivityParams
)
Expand Down Expand Up @@ -819,6 +821,10 @@ class ProfileProgressFragmentTest {
.check(matches(isDisplayed()))
}

private fun <T: MessageLite> hasProtoExtra(keyName: String, expectedProto: T): Matcher<Intent> {
return hasExtra(keyName, expectedProto.toByteString())
}

@Module
class TestModule {
// TODO(#59): Either isolate these to their own shared test module, or use the real logging
Expand Down

0 comments on commit 00c426a

Please sign in to comment.