Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix part of #4865: Refactor topic to use profileId #5598

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -103,22 +103,22 @@ class ClassroomListActivity :
)
}

override fun routeToTopic(internalProfileId: Int, classroomId: String, topicId: String) {
override fun routeToTopic(profileId: ProfileId, classroomId: String, topicId: String) {
startActivity(
createTopicActivityIntent(this, internalProfileId, classroomId, topicId)
createTopicActivityIntent(this, profileId, classroomId, topicId)
)
}

override fun routeToTopicPlayStory(
internalProfileId: Int,
profileId: ProfileId,
classroomId: String,
topicId: String,
storyId: String
) {
startActivity(
createTopicPlayStoryActivityIntent(
this,
internalProfileId,
profileId,
classroomId,
topicId,
storyId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class ClassroomListFragmentPresenter @Inject constructor(
/** Routes to the play story view for the first story in the given topic summary. */
fun onTopicSummaryClicked(topicSummary: TopicSummary) {
routeToTopicPlayStoryListener.routeToTopicPlayStory(
profileId.internalId,
profileId,
topicSummary.classroomId,
topicSummary.topicId,
topicSummary.firstStoryId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.oppia.android.app.completedstorylist
import androidx.appcompat.app.AppCompatActivity
import org.oppia.android.app.home.RouteToTopicPlayStoryListener
import org.oppia.android.app.model.CompletedStory
import org.oppia.android.app.model.ProfileId
import org.oppia.android.app.shim.IntentFactoryShim
import org.oppia.android.app.viewmodel.ObservableViewModel
import org.oppia.android.domain.translation.TranslationController
Expand Down Expand Up @@ -32,22 +33,22 @@ class CompletedStoryItemViewModel(
/** Called when user clicks on CompletedStoryItem. */
fun onCompletedStoryItemClicked() {
routeToTopicPlayStory(
internalProfileId,
ProfileId.newBuilder().setInternalId(internalProfileId).build(),
completedStory.classroomId,
completedStory.topicId,
completedStory.storyId
)
}

override fun routeToTopicPlayStory(
internalProfileId: Int,
profileId: ProfileId,
classroomId: String,
topicId: String,
storyId: String
) {
val intent = intentFactoryShim.createTopicPlayStoryActivityIntent(
activity.applicationContext,
internalProfileId,
profileId.internalId,
classroomId,
topicId,
storyId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,22 +69,22 @@ class HomeActivity :
title = resourceHandler.getStringInLocale(R.string.home_activity_title)
}

override fun routeToTopic(internalProfileId: Int, classroomId: String, topicId: String) {
override fun routeToTopic(profileId: ProfileId, classroomId: String, topicId: String) {
startActivity(
TopicActivity.createTopicActivityIntent(this, internalProfileId, classroomId, topicId)
TopicActivity.createTopicActivityIntent(this, profileId, classroomId, topicId)
)
}

override fun routeToTopicPlayStory(
internalProfileId: Int,
profileId: ProfileId,
classroomId: String,
topicId: String,
storyId: String
) {
startActivity(
TopicActivity.createTopicPlayStoryActivityIntent(
this,
internalProfileId,
profileId,
classroomId,
topicId,
storyId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ class HomeFragmentPresenter @Inject constructor(

fun onTopicSummaryClicked(topicSummary: TopicSummary) {
routeToTopicPlayStoryListener.routeToTopicPlayStory(
internalProfileId,
ProfileId.newBuilder().setInternalId(internalProfileId).build(),
topicSummary.classroomId,
topicSummary.topicId,
topicSummary.firstStoryId
Expand Down
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.ProfileId

/** Listener for when an activity should route to a topic. */
interface RouteToTopicListener {
fun routeToTopic(internalProfileId: Int, classroomId: String, topicId: String)
fun routeToTopic(profileId: ProfileId, classroomId: String, topicId: String)
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package org.oppia.android.app.home

import org.oppia.android.app.model.ProfileId

/** Listener for when an activity should route to a story-item in TopicPlay tab. */
interface RouteToTopicPlayStoryListener {
fun routeToTopicPlayStory(
internalProfileId: Int,
profileId: ProfileId,
classroomId: String,
topicId: String,
storyId: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.ViewModel
import org.oppia.android.R
import org.oppia.android.app.home.RouteToTopicPlayStoryListener
import org.oppia.android.app.model.ProfileId
import org.oppia.android.app.model.PromotedStory
import org.oppia.android.app.viewmodel.ObservableViewModel
import org.oppia.android.domain.translation.TranslationController
Expand Down Expand Up @@ -62,7 +63,7 @@ class PromotedStoryViewModel(

fun clickOnStoryTile() {
routeToTopicPlayStoryListener.routeToTopicPlayStory(
internalProfileId,
ProfileId.newBuilder().setInternalId(internalProfileId).build(),
promotedStory.classroomId,
promotedStory.topicId,
promotedStory.storyId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import androidx.lifecycle.ViewModel
import org.oppia.android.R
import org.oppia.android.app.home.RouteToTopicListener
import org.oppia.android.app.model.EphemeralTopic
import org.oppia.android.app.model.ProfileId
import org.oppia.android.app.shim.IntentFactoryShim
import org.oppia.android.app.translation.AppLanguageResourceHandler
import org.oppia.android.app.viewmodel.ObservableViewModel
Expand All @@ -27,7 +28,11 @@ class OngoingTopicItemViewModel(
}

fun onTopicItemClicked() {
routeToTopic(internalProfileId, topic.classroomId, topic.topicId)
routeToTopic(
profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build(),
classroomId = topic.classroomId,
topicId = topic.topicId
)
}

fun computeStoryCountText(): String {
Expand All @@ -36,7 +41,7 @@ class OngoingTopicItemViewModel(
)
}

override fun routeToTopic(internalProfileId: Int, classroomId: String, topicId: String) {
override fun routeToTopic(profileId: ProfileId, classroomId: String, topicId: String) {
val intent = intentFactoryShim.createTopicActivityIntent(
activity.applicationContext,
internalProfileId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ class ExplorationActivityPresenter @Inject constructor(
activity.startActivity(
TopicActivity.createTopicActivityIntent(
context,
profileId.internalId,
profileId,
classroomId,
topicId
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.oppia.android.app.profileprogress
import androidx.appcompat.app.AppCompatActivity
import org.oppia.android.R
import org.oppia.android.app.home.RouteToTopicPlayStoryListener
import org.oppia.android.app.model.ProfileId
import org.oppia.android.app.model.PromotedStory
import org.oppia.android.app.shim.IntentFactoryShim
import org.oppia.android.app.translation.AppLanguageResourceHandler
Expand Down Expand Up @@ -36,7 +37,10 @@ class RecentlyPlayedStorySummaryViewModel(

fun onStoryItemClicked() {
routeToTopicPlayStory(
internalProfileId, promotedStory.classroomId, promotedStory.topicId, promotedStory.storyId
profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build(),
classroomId = promotedStory.classroomId,
topicId = promotedStory.topicId,
storyId = promotedStory.storyId
)
}

Expand All @@ -47,14 +51,14 @@ class RecentlyPlayedStorySummaryViewModel(
}

override fun routeToTopicPlayStory(
internalProfileId: Int,
profileId: ProfileId,
classroomId: String,
topicId: String,
storyId: String
) {
val intent = intentFactoryShim.createTopicPlayStoryActivityIntent(
activity.applicationContext,
internalProfileId,
profileId.internalId,
classroomId,
topicId,
storyId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import org.oppia.android.app.home.HomeFragment
import org.oppia.android.app.home.RouteToRecentlyPlayedListener
import org.oppia.android.app.home.RouteToTopicListener
import org.oppia.android.app.home.RouteToTopicPlayStoryListener
import org.oppia.android.app.model.ProfileId
import org.oppia.android.app.model.ProfileType
import org.oppia.android.app.model.RecentlyPlayedActivityTitle
import org.oppia.android.app.testing.activity.TestActivity
Expand Down Expand Up @@ -36,9 +37,9 @@ class HomeFragmentTestActivity :
}

// Override functions are needed to fulfill listener definitions.
override fun routeToTopic(internalProfileId: Int, classroomId: String, topicId: String) {}
override fun routeToTopic(profileId: ProfileId, classroomId: String, topicId: String) {}
override fun routeToTopicPlayStory(
internalProfileId: Int,
profileId: ProfileId,
classroomId: String,
topicId: String,
storyId: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,22 +59,22 @@ class NavigationDrawerTestActivity :
title = resourceHandler.getStringInLocale(R.string.home_activity_title)
}

override fun routeToTopic(internalProfileId: Int, classroomId: String, topicId: String) {
override fun routeToTopic(profileId: ProfileId, classroomId: String, topicId: String) {
startActivity(
TopicActivity.createTopicActivityIntent(this, internalProfileId, classroomId, topicId)
TopicActivity.createTopicActivityIntent(this, profileId, classroomId, topicId)
)
}

override fun routeToTopicPlayStory(
internalProfileId: Int,
profileId: ProfileId,
classroomId: String,
topicId: String,
storyId: String
) {
startActivity(
TopicActivity.createTopicPlayStoryActivityIntent(
this,
internalProfileId,
profileId,
classroomId,
topicId,
storyId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.oppia.android.app.testing
import android.os.Bundle
import org.oppia.android.app.activity.ActivityComponentImpl
import org.oppia.android.app.activity.InjectableAutoLocalizedAppCompatActivity
import org.oppia.android.app.model.ProfileId
import org.oppia.android.app.topic.RouteToRevisionCardListener
import org.oppia.android.app.topic.revision.TopicRevisionFragment
import org.oppia.android.app.topic.revisioncard.RevisionCardActivity
Expand All @@ -23,15 +24,15 @@ class TopicRevisionTestActivity :
}

override fun routeToRevisionCard(
internalProfileId: Int,
profileId: ProfileId,
topicId: String,
subtopicId: Int,
subtopicListSize: Int
) {
startActivity(
RevisionCardActivity.createRevisionCardActivityIntent(
this,
internalProfileId,
profileId,
topicId,
subtopicId,
subtopicListSize
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.oppia.android.app.testing
import androidx.appcompat.app.AppCompatActivity
import org.oppia.android.R
import org.oppia.android.app.activity.ActivityScope
import org.oppia.android.app.model.ProfileId
import org.oppia.android.app.topic.revision.TopicRevisionFragment
import javax.inject.Inject

Expand All @@ -14,8 +15,9 @@ class TopicRevisionTestActivityPresenter @Inject constructor(

fun handleOnCreate() {
activity.setContentView(R.layout.topic_revision_test_activity)
val profileId = ProfileId.newBuilder().setInternalId(0).build()
val topicRevisionFragment =
TopicRevisionFragment.newInstance(internalProfileId = 0, topicId = "")
TopicRevisionFragment.newInstance(profileId = profileId, topicId = "")
activity.supportFragmentManager.beginTransaction()
.add(
R.id.topic_revision_container,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ class TopicTestActivity :

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val profileId = ProfileId.newBuilder().setInternalId(0).build()
(activityComponent as ActivityComponentImpl).inject(this)
topicActivityPresenter.handleOnCreate(
internalProfileId = 0,
profileId = profileId,
classroomId = TEST_CLASSROOM_ID_0,
topicId = TEST_TOPIC_ID_0,
storyId = ""
Expand Down Expand Up @@ -90,14 +91,14 @@ class TopicTestActivity :
}

override fun routeToRevisionCard(
internalProfileId: Int,
profileId: ProfileId,
topicId: String,
subtopicId: Int,
subtopicListSize: Int
) {
startActivity(
RevisionCardActivity.createRevisionCardActivityIntent(
this, internalProfileId, topicId, subtopicId, subtopicListSize
this, profileId, topicId, subtopicId, subtopicListSize
)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ class TopicTestActivityForStory :

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val profileId = ProfileId.newBuilder().setInternalId(0).build()
(activityComponent as ActivityComponentImpl).inject(this)
topicActivityPresenter.handleOnCreate(
internalProfileId = 0,
profileId = profileId,
classroomId = TEST_CLASSROOM_ID_0,
topicId = TEST_TOPIC_ID_0,
storyId = TEST_STORY_ID_0
Expand Down Expand Up @@ -118,14 +119,14 @@ class TopicTestActivityForStory :
}

override fun routeToRevisionCard(
internalProfileId: Int,
profileId: ProfileId,
topicId: String,
subtopicId: Int,
subtopicListSize: Int
) {
startActivity(
RevisionCardActivity.createRevisionCardActivityIntent(
this, internalProfileId, topicId, subtopicId, subtopicListSize
this, profileId, topicId, subtopicId, subtopicListSize
)
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package org.oppia.android.app.topic

import org.oppia.android.app.model.ProfileId

/** Listener for when an [TopicActivity] should route to a [RevisionCardFragment]. */
interface RouteToRevisionCardListener {
fun routeToRevisionCard(
internalProfileId: Int,
profileId: ProfileId,
topicId: String,
subtopicId: Int,
subtopicListSize: Int
Expand Down
Loading
Loading