Skip to content

Commit d819e70

Browse files
authored
Merge pull request #1 from oppia/develop
Develop (fork) Branch Update
2 parents 1c4b17a + 4b49cd8 commit d819e70

File tree

115 files changed

+2856
-2036
lines changed

Some content is hidden

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

115 files changed

+2856
-2036
lines changed

.github/workflows/static_checks.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ jobs:
8484
run: |
8585
bash /home/runner/work/oppia-android/oppia-android/scripts/ktlint_lint_check.sh $HOME
8686
87+
- name: Feature flag checks
88+
run: |
89+
bash /home/runner/work/oppia-android/oppia-android/scripts/feature_flags_check.sh $HOME
90+
8791
- name: Protobuf lint check
8892
run: |
8993
bash /home/runner/work/oppia-android/oppia-android/scripts/buf_lint_check.sh $HOME

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
@@ -27,6 +27,7 @@ import androidx.compose.ui.res.integerResource
2727
import androidx.compose.ui.unit.dp
2828
import androidx.databinding.ObservableList
2929
import androidx.fragment.app.Fragment
30+
import androidx.lifecycle.Observer
3031
import org.oppia.android.R
3132
import org.oppia.android.app.classroom.classroomlist.ClassroomList
3233
import org.oppia.android.app.classroom.promotedlist.PromotedStoryList
@@ -40,6 +41,7 @@ import org.oppia.android.app.home.classroomlist.ClassroomSummaryViewModel
4041
import org.oppia.android.app.home.promotedlist.PromotedStoryListViewModel
4142
import org.oppia.android.app.home.topiclist.AllTopicsViewModel
4243
import org.oppia.android.app.home.topiclist.TopicSummaryViewModel
44+
import org.oppia.android.app.model.AppStartupState
4345
import org.oppia.android.app.model.ClassroomSummary
4446
import org.oppia.android.app.model.LessonThumbnail
4547
import org.oppia.android.app.model.LessonThumbnailGraphic
@@ -48,10 +50,14 @@ import org.oppia.android.app.translation.AppLanguageResourceHandler
4850
import org.oppia.android.app.utility.datetime.DateTimeUtil
4951
import org.oppia.android.databinding.ClassroomListFragmentBinding
5052
import org.oppia.android.domain.classroom.ClassroomController
53+
import org.oppia.android.domain.onboarding.AppStartupStateController
5154
import org.oppia.android.domain.oppialogger.OppiaLogger
55+
import org.oppia.android.domain.oppialogger.analytics.AnalyticsController
5256
import org.oppia.android.domain.profile.ProfileManagementController
5357
import org.oppia.android.domain.topic.TopicListController
5458
import org.oppia.android.domain.translation.TranslationController
59+
import org.oppia.android.util.data.AsyncResult
60+
import org.oppia.android.util.data.DataProviders.Companion.toLiveData
5561
import org.oppia.android.util.locale.OppiaLocale
5662
import org.oppia.android.util.parser.html.StoryHtmlParserEntityType
5763
import org.oppia.android.util.parser.html.TopicHtmlParserEntityType
@@ -75,6 +81,8 @@ class ClassroomListFragmentPresenter @Inject constructor(
7581
private val dateTimeUtil: DateTimeUtil,
7682
private val translationController: TranslationController,
7783
private val machineLocale: OppiaLocale.MachineLocale,
84+
private val appStartupStateController: AppStartupStateController,
85+
private val analyticsController: AnalyticsController,
7886
) {
7987
private val routeToTopicPlayStoryListener = activity as RouteToTopicPlayStoryListener
8088
private lateinit var binding: ClassroomListFragmentBinding
@@ -92,6 +100,8 @@ class ClassroomListFragmentPresenter @Inject constructor(
92100

93101
internalProfileId = profileId.internalId
94102

103+
logHomeActivityEvent()
104+
95105
classroomListViewModel = ClassroomListViewModel(
96106
activity,
97107
fragment,
@@ -144,13 +154,16 @@ class ClassroomListFragmentPresenter @Inject constructor(
144154
}
145155
)
146156

157+
logAppOnboardedEvent()
158+
147159
return binding.root
148160
}
149161

150162
/** Routes to the play story view for the first story in the given topic summary. */
151163
fun onTopicSummaryClicked(topicSummary: TopicSummary) {
152164
routeToTopicPlayStoryListener.routeToTopicPlayStory(
153165
internalProfileId,
166+
topicSummary.classroomId,
154167
topicSummary.topicId,
155168
topicSummary.firstStoryId
156169
)
@@ -225,6 +238,45 @@ class ClassroomListFragmentPresenter @Inject constructor(
225238
}
226239
}
227240
}
241+
242+
private fun logAppOnboardedEvent() {
243+
val startupStateProvider = appStartupStateController.getAppStartupState()
244+
val liveData = startupStateProvider.toLiveData()
245+
liveData.observe(
246+
activity,
247+
object : Observer<AsyncResult<AppStartupState>> {
248+
override fun onChanged(startUpStateResult: AsyncResult<AppStartupState>?) {
249+
when (startUpStateResult) {
250+
null, is AsyncResult.Pending -> {
251+
// Do nothing.
252+
}
253+
is AsyncResult.Success -> {
254+
liveData.removeObserver(this)
255+
256+
if (startUpStateResult.value.startupMode ==
257+
AppStartupState.StartupMode.USER_NOT_YET_ONBOARDED
258+
) {
259+
analyticsController.logAppOnboardedEvent(profileId)
260+
}
261+
}
262+
is AsyncResult.Failure -> {
263+
oppiaLogger.e(
264+
"ClassroomListFragment",
265+
"Failed to retrieve app startup state"
266+
)
267+
}
268+
}
269+
}
270+
}
271+
)
272+
}
273+
274+
private fun logHomeActivityEvent() {
275+
analyticsController.logImportantEvent(
276+
oppiaLogger.createOpenHomeContext(),
277+
profileId
278+
)
279+
}
228280
}
229281

230282
/** 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
}

0 commit comments

Comments
 (0)