-
Notifications
You must be signed in to change notification settings - Fork 530
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…tivity (#4511) * RecentlyPlayedActivityParams proto created with ActivityRouter * Nit changes * Optimize imports * Shifted applicationComponent to developerApplicationComponent * Optimized import * ActivityRouterModule updated * Updated RECENTLY_PLAYED_ACTIVITY_INTENT_EXTRAS_KEY in ProfileProgressFragmentTest * Static checks fixed * setTitle added in ReceltyPlayedActivityPresenter * bazel added and set title to toolbar * removed unused import * nit changes * test updated and made changes in bazel * dependencies added BUILD.bazel * static and lint checks fixed * protobuf lint issue fixed * Revert "protobuf lint issue fixed" This reverts commit 8b0c707. * protofub lint test fixed * UNSPECIFIED enum renamed * order changed in bazel * src of bazel fixed * dagger deps added in bazel * KDoc updated for bazel * nit changes * Revert "nit changes" This reverts commit 00c426a. * Updated kdoc and optimized code * klint issue fixed * reformated route/BUILD.bazel * regex pattern checks fixed * optimized import * Nit changes * Test updated and RecentlyPlayedActivityTitle used * Optimized import * Added newline EOF * ActivityRouter added to bazel * reformat bazel * corrected path * made nit changes * Nit changes * added new line * New approach implemented for dagger * code optimized * Fix broken builds for #4511. * Fixed intentname failing tests * Imports optimized * Added tests for ActivityRouter and ActivityRouterModule * optimized code * Added KDoc and ActivityRouter in bazel * fixed typo * removed practicetab * ActivityRouterModule added in BottomSheetOptionsMenu * Optimized imports * Updated failing tests * Added activityRouterModule in Intrumentation * removed activity_router_module from bazel in Instrumentation * removed activityRouterModule from LogReportingModuleTest * removed activity_component_factory from bazel in route/BUILD.bazel * Nit changes * Optimized import * Tests for ActivityRouter and ActivityRouterModule updated * Optimized code for null safety in ProfileProgressHeaderViewModel * Optimized code * Updated KDoc * Updated kDoc * Nit changes * Added new tests and updated ActivityRouter to fix failing CI * Update app/src/sharedTest/java/org/oppia/android/app/profileprogress/ProfileProgressFragmentTest.kt Co-authored-by: Ben Henning <[email protected]> * Revert "Update app/src/sharedTest/java/org/oppia/android/app/profileprogress/ProfileProgressFragmentTest.kt" This reverts commit 3c141fb. * Updated testname * Updated logic in ActivityRouter Co-authored-by: Ben Henning <[email protected]> Co-authored-by: Ben Henning <[email protected]>
- Loading branch information
1 parent
23795b9
commit 162a50e
Showing
182 changed files
with
1,334 additions
and
293 deletions.
There are no files selected for viewing
This file contains 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 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 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
31 changes: 31 additions & 0 deletions
31
app/src/main/java/org/oppia/android/app/activity/route/ActivityRouter.kt
This file contains 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,31 @@ | ||
package org.oppia.android.app.activity.route | ||
|
||
import androidx.appcompat.app.AppCompatActivity | ||
import org.oppia.android.app.model.DestinationScreen | ||
import org.oppia.android.app.model.DestinationScreen.DestinationScreenCase | ||
import org.oppia.android.util.logging.ConsoleLogger | ||
import javax.inject.Inject | ||
|
||
/** | ||
* 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 destinationRoutes: Map<DestinationScreenCase, @JvmSuppressWildcards Route>, | ||
private val consoleLogger: ConsoleLogger | ||
) { | ||
/** Opens the activity corresponding to the specified [destinationScreen]. */ | ||
fun routeToScreen(destinationScreen: DestinationScreen) { | ||
val routeIntent = destinationRoutes[destinationScreen.destinationScreenCase] | ||
?.createIntent( | ||
activity, | ||
destinationScreen | ||
) | ||
if (routeIntent != null) { | ||
activity.startActivity(routeIntent) | ||
} else { | ||
consoleLogger.w("ActivityRouter", "Destination screen case is not identified.") | ||
} | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
app/src/main/java/org/oppia/android/app/activity/route/ActivityRouterModule.kt
This file contains 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,30 @@ | ||
package org.oppia.android.app.activity.route | ||
|
||
import android.content.Context | ||
import android.content.Intent | ||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.multibindings.IntoMap | ||
import org.oppia.android.app.home.recentlyplayed.RecentlyPlayedActivity | ||
import org.oppia.android.app.model.DestinationScreen | ||
|
||
/** Module to bind destination screens to navigable activity routes. */ | ||
@Module | ||
class ActivityRouterModule { | ||
@Provides | ||
@IntoMap | ||
@RouteKey(DestinationScreen.DestinationScreenCase.RECENTLY_PLAYED_ACTIVITY_PARAMS) | ||
fun provideRecentlyPlayedActivityRoute(): Route { | ||
return object : Route { | ||
override fun createIntent( | ||
context: Context, | ||
destinationScreen: DestinationScreen | ||
): Intent { | ||
return RecentlyPlayedActivity.createRecentlyPlayedActivityIntent( | ||
context, | ||
destinationScreen.recentlyPlayedActivityParams | ||
) | ||
} | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
app/src/main/java/org/oppia/android/app/activity/route/BUILD.bazel
This file contains 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,29 @@ | ||
""" | ||
Constructs for setting up activity routing support in the Dagger graph. | ||
""" | ||
|
||
load("@dagger//:workspace_defs.bzl", "dagger_rules") | ||
load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_android_library") | ||
|
||
# TODO(#59): Define these exported files as separate libraries from top-level targets. | ||
exports_files([ | ||
"ActivityRouterModule.kt", | ||
]) | ||
|
||
kt_android_library( | ||
name = "activity_router", | ||
srcs = [ | ||
"ActivityRouter.kt", | ||
"Route.kt", | ||
"RouteKey.kt", | ||
], | ||
visibility = ["//:oppia_api_visibility"], | ||
deps = [ | ||
":dagger", | ||
"//model/src/main/proto:arguments_java_proto_lite", | ||
"//third_party:androidx_appcompat_appcompat", | ||
"//utility/src/main/java/org/oppia/android/util/logging:console_logger", | ||
], | ||
) | ||
|
||
dagger_rules() |
20 changes: 20 additions & 0 deletions
20
app/src/main/java/org/oppia/android/app/activity/route/Route.kt
This file contains 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,20 @@ | ||
package org.oppia.android.app.activity.route | ||
|
||
import android.content.Context | ||
import android.content.Intent | ||
import org.oppia.android.app.model.DestinationScreen | ||
|
||
/** Represents a possible navigation route to a specific activity in the app. */ | ||
interface Route { | ||
/** | ||
* Creates an [Intent] to route to the activity corresponding to this route. | ||
* | ||
* @param context the context to be used for creating the [Intent] | ||
* @param params the parameters to pass to the activity via its extras bundle | ||
* @return the intent that can be used to navigate to this route's activity | ||
*/ | ||
fun createIntent( | ||
context: Context, | ||
destinationScreen: DestinationScreen | ||
): Intent | ||
} |
8 changes: 8 additions & 0 deletions
8
app/src/main/java/org/oppia/android/app/activity/route/RouteKey.kt
This file contains 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,8 @@ | ||
package org.oppia.android.app.activity.route | ||
|
||
import dagger.MapKey | ||
import org.oppia.android.app.model.DestinationScreen | ||
|
||
/** Specifies [DestinationScreenCase] which can be used to pass in activity Route. */ | ||
@MapKey | ||
annotation class RouteKey(val value: DestinationScreen.DestinationScreenCase) |
This file contains 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 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 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 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 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 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
4 changes: 3 additions & 1 deletion
4
app/src/main/java/org/oppia/android/app/home/RouteToRecentlyPlayedListener.kt
This file contains 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 |
---|---|---|
@@ -1,6 +1,8 @@ | ||
package org.oppia.android.app.home | ||
|
||
import org.oppia.android.app.model.RecentlyPlayedActivityTitle | ||
|
||
/** Listener for when an activity should route to [RecentlyPlayedActivity]. */ | ||
interface RouteToRecentlyPlayedListener { | ||
fun routeToRecentlyPlayed() | ||
fun routeToRecentlyPlayed(recentlyPlayedActivityTitle: RecentlyPlayedActivityTitle) | ||
} |
This file contains 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
Oops, something went wrong.