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 #3729, #3730, #3777, #91, #20, part of #3625: Introduce support for localizing lesson content & multi-lingual answer submission #3796

Merged
Show file tree
Hide file tree
Changes from 123 commits
Commits
Show all changes
124 commits
Select commit Hold shift + click to select a range
919ab2b
Add support for AABs, build flavors, and proguard.
BenHenning Sep 1, 2021
c31b07b
Merge branch 'develop' into add-bundles-proguard-build-flavors
BenHenning Sep 1, 2021
ceb1179
Lint & codeowner fixes.
BenHenning Sep 1, 2021
cbe5e76
Fix failures.
BenHenning Sep 1, 2021
d7945d5
Different attempt to fix bad develop reference in CI.
BenHenning Sep 1, 2021
366ab4d
Initial commit.
BenHenning Sep 1, 2021
c38b95c
Merge branch 'develop' into introduce-test-batching
BenHenning Sep 1, 2021
ac73dd6
Introduce infrastructure for batching.
BenHenning Sep 2, 2021
3aec233
Add bucketing strategy.
BenHenning Sep 2, 2021
650570b
Fix caching & stabilize builds.
BenHenning Sep 2, 2021
d66bb2c
Increase sharding & add randomization.
BenHenning Sep 2, 2021
3969a6d
Improving partitionin & readability.
BenHenning Sep 2, 2021
e7b2a0d
Add new tests & fix static analysis errors.
BenHenning Sep 2, 2021
d1da067
Fix script.
BenHenning Sep 2, 2021
fbb3838
Fix broken tests & test configuration.
BenHenning Sep 2, 2021
e9cb61b
Merge branch 'introduce-test-batching' into add-bundles-proguard-buil…
BenHenning Sep 2, 2021
601ff0a
Merge branch 'add-bundles-proguard-build-flavors' of github.com:oppia…
BenHenning Sep 2, 2021
6c91da9
Fix mistake from earlier commit.
BenHenning Sep 2, 2021
e3eb6f2
Try 10 max parallel actions instead.
BenHenning Sep 2, 2021
3ff775f
Merge branch 'introduce-test-batching' into add-bundles-proguard-buil…
BenHenning Sep 2, 2021
62576a1
Fix another error from an earlier commit.
BenHenning Sep 2, 2021
d4f4448
Merge branch 'introduce-test-batching' into add-bundles-proguard-buil…
BenHenning Sep 2, 2021
0644f70
Localisation updates from https://translatewiki.net.
translatewiki Sep 2, 2021
f2a412d
Fix mv command so it works on Linux & OSX.
BenHenning Sep 2, 2021
aa29739
Merge branch 'translatewiki-prs' into temp-branch-combine-prework-and…
BenHenning Sep 2, 2021
c8248ca
Introduce initial domain layer for translations.
BenHenning Sep 4, 2021
512f0b3
Initial app layer implementation for translations.
BenHenning Sep 8, 2021
6b8298d
Domain changes needed per downstream UI changes.
BenHenning Sep 8, 2021
2aa4470
Merge branch 'localization-part4-introduce-controller-and-protos' int…
BenHenning Sep 8, 2021
014ac54
Add patterns & fixes.
BenHenning Sep 10, 2021
583a05c
Add needed domain changes for downstream branch.
BenHenning Sep 10, 2021
ceb66d9
Merge branch 'localization-part4-introduce-controller-and-protos' int…
BenHenning Sep 10, 2021
b4915d1
Merge commit '0c98a6cc1688c3a96bed67246ebd429e79077479' into introduc…
BenHenning Sep 10, 2021
385ad6a
Merge branch 'introduce-test-batching' into add-bundles-proguard-buil…
BenHenning Sep 10, 2021
7160477
Merge branch 'develop' into add-bundles-proguard-build-flavors
BenHenning Sep 10, 2021
7b4b282
Introduce support for content localization.
BenHenning Sep 14, 2021
2f7dc24
Fix structures to work with parsing assumptions.
BenHenning Sep 14, 2021
3f92b84
Fix regex checks for translated strings.
BenHenning Sep 14, 2021
96f31ed
Merge branch 'develop' into fix-regex-checks-for-translated-strings
BenHenning Sep 14, 2021
99130f0
Lint-ish fix.
BenHenning Sep 14, 2021
b48cca6
Merge commit '92ce46b81b2183283e04c4d592fc8682338e1404' into add-bund…
BenHenning Sep 14, 2021
3fcc1e5
Merge branch 'add-bundles-proguard-build-flavors' into temp-branch-co…
BenHenning Sep 14, 2021
060c37e
Merge branch 'fix-regex-checks-for-translated-strings' into temp-bran…
BenHenning Sep 14, 2021
6d556fb
Fix failing regex checks.
BenHenning Sep 14, 2021
abb2164
Merge branch 'localization-part5-introduce-app-string-translations-su…
BenHenning Sep 14, 2021
4a266ba
Add check for nested res subdirectories.
BenHenning Sep 14, 2021
3746880
Clean up locale infra.
BenHenning Sep 15, 2021
cb80423
Merge branch 'localization-part4-introduce-controller-and-protos' int…
BenHenning Sep 15, 2021
fafe5c3
Merge branch 'localization-part5-introduce-app-string-translations-su…
BenHenning Sep 15, 2021
1021a89
Merge commit '2d47a87b9020b95355e86e96254b1ad68f3843b2' into fix-rege…
BenHenning Sep 15, 2021
e58e422
Merge branch 'fix-regex-checks-for-translated-strings' into temp-bran…
BenHenning Sep 15, 2021
2ad1f41
Attempt to delete strings to force history.
BenHenning Sep 15, 2021
c0f8b45
Merge branch 'develop' into temp-branch-combine-prework-and-translations
BenHenning Sep 15, 2021
87f84a8
Merge branch 'temp-branch-combine-prework-and-translations' into loca…
BenHenning Sep 15, 2021
ebe2262
Merge branch 'localization-part4-introduce-controller-and-protos' int…
BenHenning Sep 15, 2021
d863e20
Merge branch 'localization-part5-introduce-app-string-translations-su…
BenHenning Sep 15, 2021
f059838
Make AAB builds/runs manual-only targets.
BenHenning Sep 15, 2021
85e7574
Fix broken tests.
BenHenning Sep 15, 2021
7a9d952
Fix lint issues & add KDocs.
BenHenning Sep 16, 2021
4348fb1
Add 6/11 test suites (& placeholders for other 4).
BenHenning Sep 17, 2021
e8afb60
Add more test suites for domain layers.
BenHenning Sep 18, 2021
08a8219
Introduce wrapper & fake for bidi wrapping.
BenHenning Sep 20, 2021
0112762
Add remaining tests.
BenHenning Sep 20, 2021
2015e8e
Fix Gradle builds.
BenHenning Sep 21, 2021
2acb592
Lint fixes.
BenHenning Sep 21, 2021
0238557
Merge branch 'develop' into localization-part4-introduce-controller-a…
BenHenning Sep 21, 2021
826545a
Resolve remaining incomplete TODOs.
BenHenning Sep 21, 2021
703f770
Add new codeowners.
BenHenning Sep 21, 2021
2cc7c07
Merge branch 'localization-part4-introduce-controller-and-protos' int…
BenHenning Sep 21, 2021
db3a3a8
Post-merge fixes.
BenHenning Sep 21, 2021
d667639
Fix most test targets (builds).
BenHenning Sep 21, 2021
267c6d6
Fix all remaining test builds.
BenHenning Sep 22, 2021
670c5e8
Fix all app layer tests.
BenHenning Sep 22, 2021
cccd1b4
Fix questions & profile issues.
BenHenning Sep 22, 2021
ee88628
Type specifier pattern & fixes.
BenHenning Sep 22, 2021
07b7823
Add missing KDocs.
BenHenning Sep 23, 2021
8ad41f3
Boilerplate & TODOs for needed tests.
BenHenning Sep 23, 2021
f876784
Add new needed test dep.
BenHenning Sep 23, 2021
180bd52
Add needed testing coverage.
BenHenning Sep 24, 2021
e879c04
Two fixes.
BenHenning Sep 24, 2021
326d5d9
Merge branch 'localization-part4-introduce-controller-and-protos' int…
BenHenning Sep 24, 2021
86a50b7
Fix Gradle builds on branch.
BenHenning Sep 25, 2021
afb80e5
Resolve nearly all pending TODOs.
BenHenning Sep 25, 2021
970d561
Lint fixes.
BenHenning Sep 25, 2021
271fbd9
Merge branch 'localization-part5-introduce-app-string-translations-su…
BenHenning Sep 25, 2021
f17f479
Re-add method removed from merge.
BenHenning Sep 25, 2021
3b65ce3
Lint fixes.
BenHenning Sep 25, 2021
20e0d5e
Fix compute affected tests script.
BenHenning Sep 25, 2021
b7f63c3
Fix failures found on CI.
BenHenning Sep 26, 2021
3a85c49
Merge branch 'develop' into localization-part4-introduce-controller-a…
BenHenning Sep 26, 2021
0fa47f7
Merge branch 'localization-part4-introduce-controller-and-protos' int…
BenHenning Sep 26, 2021
d37cdd2
Merge branch 'localization-part5-introduce-app-string-translations-su…
BenHenning Sep 26, 2021
74593a8
Fix remaining Gradle failures found in CI.
BenHenning Sep 26, 2021
5c37975
Merge branch 'localization-part5-introduce-app-string-translations-su…
BenHenning Sep 26, 2021
d7e39f9
Fix existing domain + app layer tests.
BenHenning Sep 27, 2021
51fb398
Merge branch 'develop' into localization-part4-introduce-controller-a…
BenHenning Sep 27, 2021
e66c24d
Merge branch 'localization-part4-introduce-controller-and-protos' int…
BenHenning Sep 27, 2021
ce9446f
Post-merge fix.
BenHenning Sep 27, 2021
3de427e
Gradle Espresso test fix.
BenHenning Sep 27, 2021
d7cf31a
Merge branch 'develop' into localization-part4-introduce-controller-a…
BenHenning Sep 27, 2021
37e852f
Merge branch 'localization-part4-introduce-controller-and-protos' int…
BenHenning Sep 27, 2021
dd11beb
Merge branch 'localization-part5-introduce-app-string-translations-su…
BenHenning Sep 27, 2021
c84b19e
Add missing KDocs, remove extra file, and other cleanups.
BenHenning Sep 27, 2021
a3c167b
Lint fixes.
BenHenning Sep 27, 2021
eec5a9f
Deflake DataProviderTestMonitorTest.
BenHenning Sep 27, 2021
44f47b6
Address reviewer comments.
BenHenning Sep 27, 2021
085fa41
Merge branch 'develop' into localization-part5-introduce-app-string-t…
BenHenning Sep 27, 2021
2377ee5
Lint fixes.
BenHenning Sep 27, 2021
ec58dce
Merge branch 'localization-part5-introduce-app-string-translations-su…
BenHenning Sep 27, 2021
5a89f05
Fix affected tests from earlier changes.
BenHenning Sep 27, 2021
6748464
Fix remaining Gradle failures.
BenHenning Sep 28, 2021
700dfb1
Add placeholders for new needed tests.
BenHenning Sep 28, 2021
a1b0fb0
Fix broken tests.
BenHenning Sep 28, 2021
1e7c3c9
Add needed tests for new behaviors.
BenHenning Sep 29, 2021
b21525a
Fix Gradle build & mechanism change failures.
BenHenning Sep 29, 2021
171a1b8
Lint fixes.
BenHenning Sep 29, 2021
13ad6d5
Merge commit '3a0afb4eb8222d4ff3acd2e2e660b85911d35229' into localiza…
BenHenning Sep 29, 2021
0459300
Merge branch 'localization-part5-introduce-app-string-translations-su…
BenHenning Sep 29, 2021
c97b61a
Merge branch 'develop' into localization-part6-introduce-content-and-…
BenHenning Sep 29, 2021
7af6cc1
Undo inadvertent change to Gradle jvmargs.
BenHenning Sep 29, 2021
e20b742
Disable most tests on Espresso.
BenHenning Sep 29, 2021
8448350
Test fixes + make monitor Espresso-compatible.
BenHenning Sep 30, 2021
48ef103
Lint fixes.
BenHenning Sep 30, 2021
612e17d
Merge branch 'develop' into localization-part6-introduce-content-and-…
BenHenning Oct 6, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ config/oppia-dev-workflow-remote-cache-credentials.json
bazel-*
.bazelproject
.aswb
*.pb
6 changes: 5 additions & 1 deletion app/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ load("@tools_android//tools/googleservices:defs.bzl", "google_services_xml")
load("//app:app_test.bzl", "app_test")
load("//app:test_with_resources.bzl", "test_with_resources")

package(default_visibility = ["//utility:__subpackages__"])
package(default_visibility = [
"//domain:__subpackages__",
"//utility:__subpackages__",
])

exports_files(["src/main/AndroidManifest.xml"])

Expand Down Expand Up @@ -793,6 +796,7 @@ TEST_DEPS = [
"//app/src/main/java/org/oppia/android/app/translation/testing:test_module",
"//domain",
"//testing",
"//testing/src/main/java/org/oppia/android/testing/data:data_provider_test_monitor",
"//testing/src/main/java/org/oppia/android/testing/espresso:edit_text_input_action",
"//testing/src/main/java/org/oppia/android/testing/espresso:generic_view_matchers",
"//testing/src/main/java/org/oppia/android/testing/espresso:image_view_matcher",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import org.oppia.android.app.fragment.FragmentComponentImpl
import org.oppia.android.app.fragment.InjectableDialogFragment
import org.oppia.android.app.model.HelpIndex
import org.oppia.android.app.model.State
import org.oppia.android.app.model.WrittenTranslationContext
import org.oppia.android.util.extensions.getProto
import org.oppia.android.util.extensions.getStringFromBundle
import org.oppia.android.util.extensions.putProto
Expand Down Expand Up @@ -44,25 +45,32 @@ class HintsAndSolutionDialogFragment :
internal const val ID_ARGUMENT_KEY = "HintsAndSolutionDialogFragment.id"
internal const val STATE_KEY = "HintsAndSolutionDialogFragment.state"
internal const val HELP_INDEX_KEY = "HintsAndSolutionDialogFragment.help_index"
internal const val WRITTEN_TRANSLATION_CONTEXT_KEY =
"HintsAndSolutionDialogFragment.written_translation_context"

/**
* Creates a new instance of a DialogFragment to display hints and solution
*
* @param id Used in ExplorationController/QuestionAssessmentProgressController to get current state data.
* @param id Used in ExplorationController/QuestionAssessmentProgressController to get current
* state data.
* @param state the [State] being viewed by the learner
* @param helpIndex the [HelpIndex] corresponding to the current hints/solution configuration
* @param writtenTranslationContext the [WrittenTranslationContext] needed to translate the
* hints/solution
* @return [HintsAndSolutionDialogFragment]: DialogFragment
*/
fun newInstance(
id: String,
state: State,
helpIndex: HelpIndex
helpIndex: HelpIndex,
writtenTranslationContext: WrittenTranslationContext
): HintsAndSolutionDialogFragment {
return HintsAndSolutionDialogFragment().apply {
arguments = Bundle().apply {
putString(ID_ARGUMENT_KEY, id)
putProto(STATE_KEY, state)
putProto(HELP_INDEX_KEY, helpIndex)
putProto(WRITTEN_TRANSLATION_CONTEXT_KEY, writtenTranslationContext)
}
}
}
Expand Down Expand Up @@ -107,12 +115,15 @@ class HintsAndSolutionDialogFragment :

val state = args.getProto(STATE_KEY, State.getDefaultInstance())
val helpIndex = args.getProto(HELP_INDEX_KEY, HelpIndex.getDefaultInstance())
val writtenTranslationContext =
args.getProto(WRITTEN_TRANSLATION_CONTEXT_KEY, WrittenTranslationContext.getDefaultInstance())

return hintsAndSolutionDialogFragmentPresenter.handleCreateView(
inflater,
container,
state,
helpIndex,
writtenTranslationContext,
id,
currentExpandedHintListIndex,
this as ExpandedHintListIndexListener,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import org.oppia.android.app.model.HelpIndex.IndexTypeCase.LATEST_REVEALED_HINT_
import org.oppia.android.app.model.HelpIndex.IndexTypeCase.NEXT_AVAILABLE_HINT_INDEX
import org.oppia.android.app.model.HelpIndex.IndexTypeCase.SHOW_SOLUTION
import org.oppia.android.app.model.State
import org.oppia.android.app.model.WrittenTranslationContext
import org.oppia.android.app.recyclerview.BindableAdapter
import org.oppia.android.app.translation.AppLanguageResourceHandler
import org.oppia.android.app.viewmodel.ViewModelProvider
Expand Down Expand Up @@ -47,6 +48,7 @@ class HintsAndSolutionDialogFragmentPresenter @Inject constructor(
private lateinit var binding: HintsAndSolutionFragmentBinding
private lateinit var state: State
private lateinit var helpIndex: HelpIndex
private lateinit var writtenTranslationContext: WrittenTranslationContext
private lateinit var itemList: List<HintsAndSolutionItemViewModel>
private lateinit var bindingAdapter: BindableAdapter<HintsAndSolutionItemViewModel>

Expand All @@ -63,6 +65,7 @@ class HintsAndSolutionDialogFragmentPresenter @Inject constructor(
container: ViewGroup?,
state: State,
helpIndex: HelpIndex,
writtenTranslationContext: WrittenTranslationContext,
id: String?,
currentExpandedHintListIndex: Int?,
expandedHintListIndexListener: ExpandedHintListIndexListener,
Expand Down Expand Up @@ -93,6 +96,7 @@ class HintsAndSolutionDialogFragmentPresenter @Inject constructor(

this.state = state
this.helpIndex = helpIndex
this.writtenTranslationContext = writtenTranslationContext
// The newAvailableHintIndex received here is coming from state player but in this
// implementation hints/solutions are shown on every even index and on every odd index we show a
// divider. The relative index therefore needs to be doubled to account for the divider.
Expand Down Expand Up @@ -137,7 +141,9 @@ class HintsAndSolutionDialogFragmentPresenter @Inject constructor(
private fun loadHintsAndSolution(state: State) {
// Check if hints are available for this state.
if (state.interaction.hintList.isNotEmpty()) {
viewModel.initialize(helpIndex, state.interaction.hintList, state.interaction.solution)
viewModel.initialize(
helpIndex, state.interaction.hintList, state.interaction.solution, writtenTranslationContext
)

itemList = viewModel.processHintList()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ import org.oppia.android.app.fragment.FragmentScope
import org.oppia.android.app.model.HelpIndex
import org.oppia.android.app.model.Hint
import org.oppia.android.app.model.Solution
import org.oppia.android.app.model.WrittenTranslationContext
import org.oppia.android.app.translation.AppLanguageResourceHandler
import org.oppia.android.domain.hintsandsolution.isHintRevealed
import org.oppia.android.domain.hintsandsolution.isSolutionRevealed
import org.oppia.android.domain.translation.TranslationController
import javax.inject.Inject

/**
Expand All @@ -24,7 +26,8 @@ private const val DEFAULT_HINT_AND_SOLUTION_SUMMARY = ""
/** [ViewModel] for Hints in [HintsAndSolutionDialogFragment]. */
@FragmentScope
class HintsViewModel @Inject constructor(
private val resourceHandler: AppLanguageResourceHandler
private val resourceHandler: AppLanguageResourceHandler,
private val translationController: TranslationController
) : HintsAndSolutionItemViewModel() {

val newAvailableHintIndex = ObservableField<Int>(-1)
Expand All @@ -39,13 +42,20 @@ class HintsViewModel @Inject constructor(
private lateinit var hintList: List<Hint>
private lateinit var solution: Solution
private lateinit var helpIndex: HelpIndex
private lateinit var writtenTranslationContext: WrittenTranslationContext
val itemList: MutableList<HintsAndSolutionItemViewModel> = ArrayList()

/** Initializes the view model to display hints and a solution. */
fun initialize(helpIndex: HelpIndex, hintList: List<Hint>, solution: Solution) {
fun initialize(
helpIndex: HelpIndex,
hintList: List<Hint>,
solution: Solution,
writtenTranslationContext: WrittenTranslationContext
) {
this.helpIndex = helpIndex
this.hintList = hintList
this.solution = solution
this.writtenTranslationContext = writtenTranslationContext
}

fun processHintList(): List<HintsAndSolutionItemViewModel> {
Expand Down Expand Up @@ -93,9 +103,11 @@ class HintsViewModel @Inject constructor(
}

private fun addHintToList(hintIndex: Int, hint: Hint) {
val hintsViewModel = HintsViewModel(resourceHandler)
val hintsViewModel = HintsViewModel(resourceHandler, translationController)
hintsViewModel.title.set(hint.hintContent.contentId)
hintsViewModel.hintsAndSolutionSummary.set(hint.hintContent.html)
val hintContentHtml =
translationController.extractString(hint.hintContent, writtenTranslationContext)
hintsViewModel.hintsAndSolutionSummary.set(hintContentHtml)
hintsViewModel.isHintRevealed.set(helpIndex.isHintRevealed(hintIndex, hintList))
itemList.add(hintsViewModel)
addDividerItem()
Expand All @@ -109,7 +121,9 @@ class HintsViewModel @Inject constructor(
solutionViewModel.denominator.set(solution.correctAnswer.denominator)
solutionViewModel.wholeNumber.set(solution.correctAnswer.wholeNumber)
solutionViewModel.isNegative.set(solution.correctAnswer.isNegative)
solutionViewModel.solutionSummary.set(solution.explanation.html)
val explanationHtml =
translationController.extractString(solution.explanation, writtenTranslationContext)
solutionViewModel.solutionSummary.set(explanationHtml)
solutionViewModel.isSolutionRevealed.set(helpIndex.isSolutionRevealed())
itemList.add(solutionViewModel)
addDividerItem()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,9 @@ class RecentlyPlayedFragmentPresenter @Inject constructor(
if (promotedStory.chapterPlayState == ChapterPlayState.IN_PROGRESS_SAVED) {
val explorationCheckpointLiveData =
explorationCheckpointController.retrieveExplorationCheckpoint(
ProfileId.getDefaultInstance(),
ProfileId.newBuilder().apply {
internalId = internalProfileId
}.build(),
promotedStory.explorationId
).toLiveData()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import org.oppia.android.app.hintsandsolution.RevealSolutionInterface
import org.oppia.android.app.model.HelpIndex
import org.oppia.android.app.model.ReadingTextSize
import org.oppia.android.app.model.State
import org.oppia.android.app.model.WrittenTranslationContext
import org.oppia.android.app.player.audio.AudioButtonListener
import org.oppia.android.app.player.state.listener.RouteToHintsAndSolutionListener
import org.oppia.android.app.player.state.listener.StateKeyboardButtonListener
Expand Down Expand Up @@ -45,6 +46,7 @@ class ExplorationActivity :
private lateinit var storyId: String
private lateinit var explorationId: String
private lateinit var state: State
private lateinit var writtenTranslationContext: WrittenTranslationContext
private var backflowScreen: Int? = null
private var isCheckpointingEnabled: Boolean = false

Expand Down Expand Up @@ -165,7 +167,8 @@ class ExplorationActivity :
val hintsAndSolutionDialogFragment = HintsAndSolutionDialogFragment.newInstance(
explorationId,
state,
helpIndex
helpIndex,
writtenTranslationContext
)
hintsAndSolutionDialogFragment.showNow(supportFragmentManager, TAG_HINTS_AND_SOLUTION_DIALOG)
}
Expand All @@ -179,8 +182,12 @@ class ExplorationActivity :
explorationActivityPresenter.loadExplorationFragment(readingTextSize)
}

override fun onExplorationStateLoaded(state: State) {
override fun onExplorationStateLoaded(
state: State,
writtenTranslationContext: WrittenTranslationContext
) {
this.state = state
this.writtenTranslationContext = writtenTranslationContext
}

override fun dismissConceptCard() = explorationActivityPresenter.dismissConceptCard()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class HintsAndSolutionExplorationManagerFragmentPresenter @Inject constructor(
// Check if hints are available for this state.
if (ephemeralState.state.interaction.hintList.size != 0) {
(activity as HintsAndSolutionExplorationManagerListener).onExplorationStateLoaded(
ephemeralState.state
ephemeralState.state, ephemeralState.writtenTranslationContext
)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package org.oppia.android.app.player.exploration

import org.oppia.android.app.model.State
import org.oppia.android.app.model.WrittenTranslationContext

/** Listener for fetching current exploration state data. */
interface HintsAndSolutionExplorationManagerListener {
fun onExplorationStateLoaded(state: State)
fun onExplorationStateLoaded(state: State, writtenTranslationContext: WrittenTranslationContext)
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import androidx.databinding.BindingAdapter
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.recyclerview.widget.RecyclerView
import org.oppia.android.app.model.WrittenTranslationContext
import org.oppia.android.app.player.state.itemviewmodel.SelectionInteractionContentViewModel
import org.oppia.android.app.player.state.itemviewmodel.SelectionItemInputType
import org.oppia.android.app.recyclerview.BindableAdapter
Expand Down Expand Up @@ -45,6 +46,7 @@ class SelectionInteractionView @JvmOverloads constructor(
lateinit var bindingInterface: ViewBindingShim

private lateinit var entityId: String
private lateinit var writtenTranslationContext: WrittenTranslationContext

override fun onAttachedToWindow() {
super.onAttachedToWindow()
Expand All @@ -69,6 +71,15 @@ class SelectionInteractionView @JvmOverloads constructor(
this.entityId = entityId
}

/**
* Sets the [WrittenTranslationContext] used to translate strings in this view.
*
* This must be called during view initialization.
*/
fun setWrittenTranslationContext(writtenTranslationContext: WrittenTranslationContext) {
this.writtenTranslationContext = writtenTranslationContext
}

private fun createAdapter(): BindableAdapter<SelectionInteractionContentViewModel> {
return when (selectionItemInputType) {
SelectionItemInputType.CHECKBOXES ->
Expand All @@ -89,7 +100,8 @@ class SelectionInteractionView @JvmOverloads constructor(
htmlParserFactory,
resourceBucketName,
entityType,
entityId
entityId,
writtenTranslationContext
)
}
)
Expand All @@ -112,7 +124,8 @@ class SelectionInteractionView @JvmOverloads constructor(
htmlParserFactory,
resourceBucketName,
entityType,
entityId
entityId,
writtenTranslationContext
)
}
)
Expand All @@ -127,3 +140,10 @@ fun setEntityId(
selectionInteractionView: SelectionInteractionView,
entityId: String
) = selectionInteractionView.setEntityId(entityId)

/** Sets the translation context for a specific [SelectionInteractionView] via data-binding. */
@BindingAdapter("writtenTranslationContext")
fun setWrittenTranslationContext(
selectionInteractionView: SelectionInteractionView,
writtenTranslationContext: WrittenTranslationContext
) = selectionInteractionView.setWrittenTranslationContext(writtenTranslationContext)
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class StateFragmentPresenter @Inject constructor(
/* attachToRoot= */ false
)
recyclerViewAssembler = createRecyclerViewAssembler(
assemblerBuilderFactory.create(resourceBucketName, entityType),
assemblerBuilderFactory.create(resourceBucketName, entityType, profileId),
binding.congratulationsTextView,
binding.congratulationsTextConfettiView,
binding.fullScreenConfettiView
Expand Down Expand Up @@ -275,7 +275,7 @@ class StateFragmentPresenter @Inject constructor(
private fun subscribeToCurrentState() {
ephemeralStateLiveData.observe(
fragment,
Observer { result ->
{ result ->
processEphemeralStateResult(result)
}
)
Expand Down
Loading