Skip to content

Commit acf97c5

Browse files
authored
Merge branch 'develop' into multiple-classrooms-refactor-ui
2 parents 871ff72 + 436cf9e commit acf97c5

File tree

110 files changed

+2700
-2028
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+2700
-2028
lines changed

app/src/main/java/org/oppia/android/app/activity/ActivityIntentFactories.kt

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,23 @@ interface ActivityIntentFactories {
1616
* This must be injected within an activity context.
1717
*/
1818
interface TopicActivityIntentFactory {
19-
/** Returns a new [Intent] to start the topic activity for the specified profile and topic. */
20-
fun createIntent(profileId: ProfileId, topicId: String): Intent
19+
/**
20+
* Returns a new [Intent] to start the topic activity for the specified profile, classroom
21+
* and topic.
22+
*/
23+
fun createIntent(profileId: ProfileId, classroomId: String, topicId: String): Intent
2124

2225
/**
23-
* Returns a new [Intent] to start the topic activity for the specified profile, topic, and
24-
* story (where the activity will automatically navigate to & expand the specified story in the
25-
* topic).
26+
* Returns a new [Intent] to start the topic activity for the specified profile, classroom,
27+
* topic, and story (where the activity will automatically navigate to & expand the specified
28+
* story in the topic).
2629
*/
27-
fun createIntent(profileId: ProfileId, topicId: String, storyId: String): Intent
30+
fun createIntent(
31+
profileId: ProfileId,
32+
classroomId: String,
33+
topicId: String,
34+
storyId: String
35+
): Intent
2836
}
2937

3038
/**

app/src/main/java/org/oppia/android/app/classroom/ClassroomListActivity.kt

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ import org.oppia.android.app.model.ProfileId
1919
import org.oppia.android.app.model.RecentlyPlayedActivityParams
2020
import org.oppia.android.app.model.RecentlyPlayedActivityTitle
2121
import org.oppia.android.app.model.ScreenName.CLASSROOM_LIST_ACTIVITY
22-
import org.oppia.android.app.topic.TopicActivity
22+
import org.oppia.android.app.topic.TopicActivity.Companion.createTopicActivityIntent
23+
import org.oppia.android.app.topic.TopicActivity.Companion.createTopicPlayStoryActivityIntent
2324
import org.oppia.android.app.translation.AppLanguageResourceHandler
2425
import org.oppia.android.util.logging.CurrentAppScreenNameIntentDecorator.decorateWithScreenName
2526
import org.oppia.android.util.profile.CurrentUserProfileIdIntentDecorator.decorateWithUserProfileId
@@ -98,15 +99,23 @@ class ClassroomListActivity :
9899
)
99100
}
100101

101-
override fun routeToTopic(internalProfileId: Int, topicId: String) {
102-
startActivity(TopicActivity.createTopicActivityIntent(this, internalProfileId, topicId))
102+
override fun routeToTopic(internalProfileId: Int, classroomId: String, topicId: String) {
103+
startActivity(
104+
createTopicActivityIntent(this, internalProfileId, classroomId, topicId)
105+
)
103106
}
104107

105-
override fun routeToTopicPlayStory(internalProfileId: Int, topicId: String, storyId: String) {
108+
override fun routeToTopicPlayStory(
109+
internalProfileId: Int,
110+
classroomId: String,
111+
topicId: String,
112+
storyId: String
113+
) {
106114
startActivity(
107-
TopicActivity.createTopicPlayStoryActivityIntent(
115+
createTopicPlayStoryActivityIntent(
108116
this,
109117
internalProfileId,
118+
classroomId,
110119
topicId,
111120
storyId
112121
)

app/src/main/java/org/oppia/android/app/classroom/ClassroomListFragmentPresenter.kt

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import androidx.compose.ui.res.integerResource
2828
import androidx.compose.ui.unit.dp
2929
import androidx.databinding.ObservableList
3030
import androidx.fragment.app.Fragment
31+
import androidx.lifecycle.Observer
3132
import org.oppia.android.R
3233
import org.oppia.android.app.classroom.classroomlist.AllClassroomsHeaderText
3334
import org.oppia.android.app.classroom.classroomlist.ClassroomList
@@ -43,6 +44,7 @@ import org.oppia.android.app.home.classroomlist.ClassroomSummaryViewModel
4344
import org.oppia.android.app.home.promotedlist.PromotedStoryListViewModel
4445
import org.oppia.android.app.home.topiclist.AllTopicsViewModel
4546
import org.oppia.android.app.home.topiclist.TopicSummaryViewModel
47+
import org.oppia.android.app.model.AppStartupState
4648
import org.oppia.android.app.model.ClassroomSummary
4749
import org.oppia.android.app.model.LessonThumbnail
4850
import org.oppia.android.app.model.LessonThumbnailGraphic
@@ -51,10 +53,14 @@ import org.oppia.android.app.translation.AppLanguageResourceHandler
5153
import org.oppia.android.app.utility.datetime.DateTimeUtil
5254
import org.oppia.android.databinding.ClassroomListFragmentBinding
5355
import org.oppia.android.domain.classroom.ClassroomController
56+
import org.oppia.android.domain.onboarding.AppStartupStateController
5457
import org.oppia.android.domain.oppialogger.OppiaLogger
58+
import org.oppia.android.domain.oppialogger.analytics.AnalyticsController
5559
import org.oppia.android.domain.profile.ProfileManagementController
5660
import org.oppia.android.domain.topic.TopicListController
5761
import org.oppia.android.domain.translation.TranslationController
62+
import org.oppia.android.util.data.AsyncResult
63+
import org.oppia.android.util.data.DataProviders.Companion.toLiveData
5864
import org.oppia.android.util.locale.OppiaLocale
5965
import org.oppia.android.util.parser.html.StoryHtmlParserEntityType
6066
import org.oppia.android.util.parser.html.TopicHtmlParserEntityType
@@ -78,6 +84,8 @@ class ClassroomListFragmentPresenter @Inject constructor(
7884
private val dateTimeUtil: DateTimeUtil,
7985
private val translationController: TranslationController,
8086
private val machineLocale: OppiaLocale.MachineLocale,
87+
private val appStartupStateController: AppStartupStateController,
88+
private val analyticsController: AnalyticsController,
8189
) {
8290
private val routeToTopicPlayStoryListener = activity as RouteToTopicPlayStoryListener
8391
private lateinit var binding: ClassroomListFragmentBinding
@@ -95,6 +103,8 @@ class ClassroomListFragmentPresenter @Inject constructor(
95103

96104
internalProfileId = profileId.internalId
97105

106+
logHomeActivityEvent()
107+
98108
classroomListViewModel = ClassroomListViewModel(
99109
activity,
100110
fragment,
@@ -147,13 +157,16 @@ class ClassroomListFragmentPresenter @Inject constructor(
147157
}
148158
)
149159

160+
logAppOnboardedEvent()
161+
150162
return binding.root
151163
}
152164

153165
/** Routes to the play story view for the first story in the given topic summary. */
154166
fun onTopicSummaryClicked(topicSummary: TopicSummary) {
155167
routeToTopicPlayStoryListener.routeToTopicPlayStory(
156168
internalProfileId,
169+
topicSummary.classroomId,
157170
topicSummary.topicId,
158171
topicSummary.firstStoryId
159172
)
@@ -237,6 +250,45 @@ class ClassroomListFragmentPresenter @Inject constructor(
237250
}
238251
}
239252
}
253+
254+
private fun logAppOnboardedEvent() {
255+
val startupStateProvider = appStartupStateController.getAppStartupState()
256+
val liveData = startupStateProvider.toLiveData()
257+
liveData.observe(
258+
activity,
259+
object : Observer<AsyncResult<AppStartupState>> {
260+
override fun onChanged(startUpStateResult: AsyncResult<AppStartupState>?) {
261+
when (startUpStateResult) {
262+
null, is AsyncResult.Pending -> {
263+
// Do nothing.
264+
}
265+
is AsyncResult.Success -> {
266+
liveData.removeObserver(this)
267+
268+
if (startUpStateResult.value.startupMode ==
269+
AppStartupState.StartupMode.USER_NOT_YET_ONBOARDED
270+
) {
271+
analyticsController.logAppOnboardedEvent(profileId)
272+
}
273+
}
274+
is AsyncResult.Failure -> {
275+
oppiaLogger.e(
276+
"ClassroomListFragment",
277+
"Failed to retrieve app startup state"
278+
)
279+
}
280+
}
281+
}
282+
}
283+
)
284+
}
285+
286+
private fun logHomeActivityEvent() {
287+
analyticsController.logImportantEvent(
288+
oppiaLogger.createOpenHomeContext(),
289+
profileId
290+
)
291+
}
240292
}
241293

242294
/** Adds a grid of items to a LazyListScope with specified arrangement and item content. */

app/src/main/java/org/oppia/android/app/completedstorylist/CompletedStoryItemViewModel.kt

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,24 @@ class CompletedStoryItemViewModel(
3131

3232
/** Called when user clicks on CompletedStoryItem. */
3333
fun onCompletedStoryItemClicked() {
34-
routeToTopicPlayStory(internalProfileId, completedStory.topicId, completedStory.storyId)
34+
routeToTopicPlayStory(
35+
internalProfileId,
36+
completedStory.classroomId,
37+
completedStory.topicId,
38+
completedStory.storyId
39+
)
3540
}
3641

37-
override fun routeToTopicPlayStory(internalProfileId: Int, topicId: String, storyId: String) {
42+
override fun routeToTopicPlayStory(
43+
internalProfileId: Int,
44+
classroomId: String,
45+
topicId: String,
46+
storyId: String
47+
) {
3848
val intent = intentFactoryShim.createTopicPlayStoryActivityIntent(
3949
activity.applicationContext,
4050
internalProfileId,
51+
classroomId,
4152
topicId,
4253
storyId
4354
)

app/src/main/java/org/oppia/android/app/home/HomeActivity.kt

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,10 @@ class HomeActivity :
6767
homeActivityPresenter.handleOnRestart()
6868
}
6969

70-
override fun routeToTopic(internalProfileId: Int, topicId: String) {
71-
startActivity(TopicActivity.createTopicActivityIntent(this, internalProfileId, topicId))
70+
override fun routeToTopic(internalProfileId: Int, classroomId: String, topicId: String) {
71+
startActivity(
72+
TopicActivity.createTopicActivityIntent(this, internalProfileId, classroomId, topicId)
73+
)
7274
}
7375

7476
override fun onBackPressed() {
@@ -87,11 +89,17 @@ class HomeActivity :
8789
dialogFragment.showNow(supportFragmentManager, TAG_SWITCH_PROFILE_DIALOG)
8890
}
8991

90-
override fun routeToTopicPlayStory(internalProfileId: Int, topicId: String, storyId: String) {
92+
override fun routeToTopicPlayStory(
93+
internalProfileId: Int,
94+
classroomId: String,
95+
topicId: String,
96+
storyId: String
97+
) {
9198
startActivity(
9299
TopicActivity.createTopicPlayStoryActivityIntent(
93100
this,
94101
internalProfileId,
102+
classroomId,
95103
topicId,
96104
storyId
97105
)

app/src/main/java/org/oppia/android/app/home/HomeFragmentPresenter.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ class HomeFragmentPresenter @Inject constructor(
197197
fun onTopicSummaryClicked(topicSummary: TopicSummary) {
198198
routeToTopicPlayStoryListener.routeToTopicPlayStory(
199199
internalProfileId,
200+
topicSummary.classroomId,
200201
topicSummary.topicId,
201202
topicSummary.firstStoryId
202203
)

app/src/main/java/org/oppia/android/app/home/RouteToExplorationListener.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import org.oppia.android.app.model.ProfileId
77
interface RouteToExplorationListener {
88
fun routeToExploration(
99
profileId: ProfileId,
10+
classroomId: String,
1011
topicId: String,
1112
storyId: String,
1213
explorationId: String,

app/src/main/java/org/oppia/android/app/home/RouteToTopicListener.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ package org.oppia.android.app.home
22

33
/** Listener for when an activity should route to a topic. */
44
interface RouteToTopicListener {
5-
fun routeToTopic(internalProfileId: Int, topicId: String)
5+
fun routeToTopic(internalProfileId: Int, classroomId: String, topicId: String)
66
}

app/src/main/java/org/oppia/android/app/home/RouteToTopicPlayStoryListener.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,10 @@ package org.oppia.android.app.home
22

33
/** Listener for when an activity should route to a story-item in TopicPlay tab. */
44
interface RouteToTopicPlayStoryListener {
5-
fun routeToTopicPlayStory(internalProfileId: Int, topicId: String, storyId: String)
5+
fun routeToTopicPlayStory(
6+
internalProfileId: Int,
7+
classroomId: String,
8+
topicId: String,
9+
storyId: String
10+
)
611
}

app/src/main/java/org/oppia/android/app/home/promotedlist/PromotedStoryViewModel.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ class PromotedStoryViewModel(
6363
fun clickOnStoryTile() {
6464
routeToTopicPlayStoryListener.routeToTopicPlayStory(
6565
internalProfileId,
66+
promotedStory.classroomId,
6667
promotedStory.topicId,
6768
promotedStory.storyId
6869
)

app/src/main/java/org/oppia/android/app/home/recentlyplayed/RecentlyPlayedActivity.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ class RecentlyPlayedActivity :
6262

6363
override fun routeToExploration(
6464
profileId: ProfileId,
65+
classroomId: String,
6566
topicId: String,
6667
storyId: String,
6768
explorationId: String,
@@ -72,6 +73,7 @@ class RecentlyPlayedActivity :
7273
ExplorationActivity.createExplorationActivityIntent(
7374
this,
7475
profileId,
76+
classroomId,
7577
topicId,
7678
storyId,
7779
explorationId,
@@ -83,6 +85,7 @@ class RecentlyPlayedActivity :
8385

8486
override fun routeToResumeLesson(
8587
profileId: ProfileId,
88+
classroomId: String,
8689
topicId: String,
8790
storyId: String,
8891
explorationId: String,
@@ -93,6 +96,7 @@ class RecentlyPlayedActivity :
9396
ResumeLessonActivity.createResumeLessonActivityIntent(
9497
this,
9598
profileId,
99+
classroomId,
96100
topicId,
97101
storyId,
98102
explorationId,

app/src/main/java/org/oppia/android/app/home/recentlyplayed/RecentlyPlayedFragmentPresenter.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ class RecentlyPlayedFragmentPresenter @Inject constructor(
108108
explorationCheckpointLiveData.removeObserver(this)
109109
routeToResumeLessonListener.routeToResumeLesson(
110110
profileId,
111+
promotedStory.classroomId,
111112
promotedStory.topicId,
112113
promotedStory.storyId,
113114
promotedStory.explorationId,
@@ -117,6 +118,7 @@ class RecentlyPlayedFragmentPresenter @Inject constructor(
117118
} else if (it is AsyncResult.Failure) {
118119
explorationCheckpointLiveData.removeObserver(this)
119120
playExploration(
121+
promotedStory.classroomId,
120122
promotedStory.topicId,
121123
promotedStory.storyId,
122124
promotedStory.explorationId,
@@ -128,6 +130,7 @@ class RecentlyPlayedFragmentPresenter @Inject constructor(
128130
)
129131
} else {
130132
playExploration(
133+
promotedStory.classroomId,
131134
promotedStory.topicId,
132135
promotedStory.storyId,
133136
promotedStory.explorationId,
@@ -162,6 +165,7 @@ class RecentlyPlayedFragmentPresenter @Inject constructor(
162165
}
163166

164167
private fun playExploration(
168+
classroomId: String,
165169
topicId: String,
166170
storyId: String,
167171
explorationId: String,
@@ -174,13 +178,13 @@ class RecentlyPlayedFragmentPresenter @Inject constructor(
174178
// cases, lessons played from this fragment are known to be in progress, and that progress
175179
// can't be resumed here (hence the restart).
176180
explorationDataController.restartExploration(
177-
profileId.internalId, topicId, storyId, explorationId
181+
profileId.internalId, classroomId, topicId, storyId, explorationId
178182
)
179183
} else {
180184
// The only lessons that can't have their progress saved are those that were already
181185
// completed.
182186
explorationDataController.replayExploration(
183-
profileId.internalId, topicId, storyId, explorationId
187+
profileId.internalId, classroomId, topicId, storyId, explorationId
184188
)
185189
}
186190
startPlayingProvider.toLiveData().observe(fragment) { result ->
@@ -192,6 +196,7 @@ class RecentlyPlayedFragmentPresenter @Inject constructor(
192196
oppiaLogger.d("RecentlyPlayedFragment", "Successfully loaded exploration")
193197
routeToExplorationListener.routeToExploration(
194198
profileId,
199+
classroomId,
195200
topicId,
196201
storyId,
197202
explorationId,

app/src/main/java/org/oppia/android/app/ongoingtopiclist/OngoingTopicItemViewModel.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class OngoingTopicItemViewModel(
2727
}
2828

2929
fun onTopicItemClicked() {
30-
routeToTopic(internalProfileId, topic.topicId)
30+
routeToTopic(internalProfileId, topic.classroomId, topic.topicId)
3131
}
3232

3333
fun computeStoryCountText(): String {
@@ -36,10 +36,11 @@ class OngoingTopicItemViewModel(
3636
)
3737
}
3838

39-
override fun routeToTopic(internalProfileId: Int, topicId: String) {
39+
override fun routeToTopic(internalProfileId: Int, classroomId: String, topicId: String) {
4040
val intent = intentFactoryShim.createTopicActivityIntent(
4141
activity.applicationContext,
4242
internalProfileId,
43+
classroomId,
4344
topicId
4445
)
4546
activity.startActivity(intent)

0 commit comments

Comments
 (0)