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 #159: Introduce question player UI structure #500

Merged
merged 149 commits into from
Jun 10, 2020
Merged
Show file tree
Hide file tree
Changes from 119 commits
Commits
Show all changes
149 commits
Select commit Hold shift + click to select a range
9594954
Initial check in for the question data controller
vinitamurthi Oct 8, 2019
6ee7aec
Removed progress controller test
vinitamurthi Oct 8, 2019
848f172
Address the renames suggested in #217.
BenHenning Oct 9, 2019
174e2f4
Merge branch 'develop' into introduce-question-progress-controller-in…
BenHenning Oct 9, 2019
4147857
Introduce thoroughly stubbed QuestionAssessmentProgressController +
BenHenning Oct 9, 2019
4596e86
Review changes
vinitamurthi Oct 9, 2019
f5c23c8
Review changes
vinitamurthi Oct 10, 2019
53d367d
Pass data providers to the assessment controller, and set caps in the…
vinitamurthi Oct 11, 2019
86630b6
Fixed merge conflicts
vinitamurthi Oct 11, 2019
a8adf93
Removed unnecessary imports/variables
vinitamurthi Oct 11, 2019
a7a10f3
Add fake question data for stubbed interfaces
vinitamurthi Oct 11, 2019
459e3e9
Remove duplicate questions while fetching in training controller
vinitamurthi Oct 11, 2019
73c49df
Comment explaining the filter function
vinitamurthi Oct 11, 2019
91cf8e6
Improve duplicate checking - check it while filtering instead of afte…
vinitamurthi Oct 11, 2019
54546d7
Add linked skill id values
vinitamurthi Oct 11, 2019
be375fd
Review changes
vinitamurthi Oct 15, 2019
64b8265
add a new module for questions constants
vinitamurthi Oct 18, 2019
75405a2
fix merge conflicts
vinitamurthi Oct 18, 2019
4878d10
Review changes
vinitamurthi Oct 18, 2019
c37f14b
add a test to verify questions were fetched properly
vinitamurthi Oct 18, 2019
d1bd4a6
reformatted code
vinitamurthi Oct 18, 2019
1c5ca42
Merge branch 'question_data' into introduce-question-progress-control…
BenHenning Oct 20, 2019
86df525
Re-add QuestionTrainingController removed in merge.
BenHenning Oct 20, 2019
54340e6
Finalize question progress controller interface.
BenHenning Oct 20, 2019
6e37b25
Implement QuestionAssessmentProgressController.
BenHenning Oct 20, 2019
aa34f14
Add initial phase of tests for the progress controller based on
BenHenning Oct 28, 2019
543b734
Merge branch 'develop' into introduce-question-progress-controller-in…
BenHenning Oct 28, 2019
73372fe
Fix typo in QuestionTrainingController.
BenHenning Oct 28, 2019
8d29dd1
Post-merge fixes and adjustments.
BenHenning Oct 28, 2019
698e71d
Fix broken ProfileManagementControllerTest.
BenHenning Oct 28, 2019
0cf1371
Merge branch 'introduce-question-progress-controller-interface' into …
BenHenning Oct 28, 2019
f2ea1d2
Merge branch 'fix-broken-profile-management-controller-test' into int…
BenHenning Oct 28, 2019
1d2460e
Post-merge fixes.
BenHenning Oct 28, 2019
7288a51
Update tests to build, but not pass.
BenHenning Oct 28, 2019
5a02bdd
Merge branch 'introduce-question-progress-controller-interface' into …
jamesxu0 Nov 12, 2019
d9c5fc3
Started UI
jamesxu0 Nov 12, 2019
6cdc71e
setup ViewModel
jamesxu0 Nov 13, 2019
3a50d06
added binding adapter
jamesxu0 Nov 13, 2019
66b9450
Handles basic functionality
jamesxu0 Nov 14, 2019
77f21e9
Moved code around
jamesxu0 Nov 14, 2019
81c012c
Added replay button
jamesxu0 Nov 14, 2019
c043ae1
Merge branch 'develop' into question_player_lofi
jamesxu0 Nov 19, 2019
fb38ba2
Merge branch 'develop' into introduce-question-progress-controller-im…
BenHenning Nov 26, 2019
2711acf
Merge branch 'develop' into question_player_lofi
BenHenning Nov 26, 2019
f86e776
Merge branch 'introduce-question-progress-controller-implementation' …
BenHenning Nov 26, 2019
3ed0cf2
Make questions partially work.
BenHenning Nov 26, 2019
d74a1b0
Temporarily remove check in StateDeck that breaks questions.
BenHenning Nov 26, 2019
aef1b58
Ensure all state navigation buttons are on the same line and the same
BenHenning Dec 1, 2019
ddbbca4
Fix dp adjustment that caused previous button to disappear.
BenHenning Dec 1, 2019
0be9562
Undo .idea/misc.xml change that snuck in.
BenHenning Dec 1, 2019
dd42f75
Update & fix StateFragmentTest (at least for Espresso). See #495 desc…
BenHenning Dec 1, 2019
8496db0
Merge branch 'develop' into introduce-question-progress-controller-im…
BenHenning Dec 1, 2019
3071c87
Merge branch 'introduce-question-progress-controller-implementation' …
BenHenning Dec 1, 2019
82a47b5
Merge branch 'align-and-dedup-continue-button-state-fragment' into te…
BenHenning Dec 1, 2019
7d3b53c
Merge branch 'temp-base-branch-for-question-player' into question_pla…
BenHenning Dec 1, 2019
67f8965
Post-merge fixes with some temporary stop-gap solutions.
BenHenning Dec 1, 2019
2dcd1ad
Fix questions image rendering and consolidate GCS resource bucket names.
BenHenning Dec 1, 2019
da371eb
Fix question session not properly being reinitialized for new sessions.
BenHenning Dec 1, 2019
d3c02e2
Merge branch 'introduce-question-progress-controller-implementation' …
BenHenning Dec 1, 2019
689e6e1
Merge branch 'temp-base-branch-for-question-player' into question_pla…
BenHenning Dec 1, 2019
4ace331
Fix index accounting for questions. Before, the index incremented upon
BenHenning Dec 1, 2019
1cf2a42
Remove support for backward navigation in questions since it isn't
BenHenning Dec 1, 2019
1283e82
Merge branch 'introduce-question-progress-controller-implementation' …
BenHenning Dec 1, 2019
28591fb
Merge branch 'temp-base-branch-for-question-player' into question_pla…
BenHenning Dec 1, 2019
93e233e
Set title of question activity to 'Train Mode'.
BenHenning Dec 1, 2019
5f09c80
Add support for a synthetic ephemeral question to represent the end of a
BenHenning Dec 1, 2019
11d4300
Merge branch 'introduce-question-progress-controller-implementation' …
BenHenning Dec 1, 2019
84c4bba
Merge branch 'temp-base-branch-for-question-player' into question_pla…
BenHenning Dec 1, 2019
c29ed4d
Update question progress tracking to be translatable and to ensure that
BenHenning Dec 1, 2019
0c0aaa2
Move most state player functional support into a new configurable
BenHenning Dec 1, 2019
cebe3c8
Hook up StatePlayerRecyclerViewAssembler to the question player fragment
BenHenning Dec 1, 2019
d236445
Introduce proper terminal page and disable overscroll. Note that the end
BenHenning Dec 1, 2019
1700630
Add support & button for training session replay.
BenHenning Dec 2, 2019
7cfc880
Update/add TODOs to correspond to GitHub tracked issues.
BenHenning Dec 2, 2019
928baa7
Fix broken import.
BenHenning Dec 2, 2019
9e4ad96
Merge branch 'develop' into introduce-question-progress-controller-im…
BenHenning Feb 21, 2020
9d70115
Finish tests for Question{Training,AssessmentProgress}Controllers.
BenHenning Feb 28, 2020
5c8471e
Initial introduction of test coroutine dispatchers to replace Kotlin's
BenHenning Mar 16, 2020
b13c965
Introduce a new LiveData mechanism to bridge coroutines from
BenHenning Mar 16, 2020
6aa3b32
Merge branch 'develop' into introduce-test-coroutine-dispatchers
BenHenning Mar 16, 2020
9f6656b
Merge branch 'introduce-test-coroutine-dispatchers' into introduce-ne…
BenHenning Mar 16, 2020
01c2b50
Merge branch 'introduce-new-coroutine-live-data-mechanism' into intro…
BenHenning Mar 16, 2020
14a4e11
Introduce new nested data provider that effectively allows a
BenHenning Mar 16, 2020
c30a494
Merge branch 'introduce-nested-data-provider' into introduce-question…
BenHenning Mar 16, 2020
c115a0f
question player progress-bar hifi
nikitamarysolomanpvt Mar 23, 2020
59fdaee
nit
nikitamarysolomanpvt Mar 23, 2020
b75a512
revert
nikitamarysolomanpvt Mar 23, 2020
39251ff
revert
nikitamarysolomanpvt Mar 23, 2020
b8cdc76
Merge remote-tracking branch 'upstream/introduce-question-player-ui-s…
nikitamarysolomanpvt Mar 23, 2020
be1872f
Early work at introducing FakeSystemClock tests (not yet complete).
BenHenning Apr 1, 2020
9a4f9c2
Merge branch 'introduce-test-coroutine-dispatchers' into introduce-ne…
BenHenning Apr 1, 2020
c70e199
Merge branch 'introduce-new-coroutine-live-data-mechanism' into intro…
BenHenning Apr 1, 2020
9fa54e8
Merge branch 'introduce-nested-data-provider' into introduce-question…
BenHenning Apr 1, 2020
eda11d0
Merge branch 'develop' into introduce-test-coroutine-dispatchers
BenHenning Apr 1, 2020
c704ce8
Merge branch 'introduce-test-coroutine-dispatchers' into introduce-ne…
BenHenning Apr 1, 2020
d1f9b63
Merge branch 'introduce-new-coroutine-live-data-mechanism' into intro…
BenHenning Apr 1, 2020
c9ec7e5
Merge branch 'introduce-nested-data-provider' into introduce-question…
BenHenning Apr 1, 2020
361d664
Merge branch 'develop' into align-and-dedup-continue-button-state-fra…
BenHenning Apr 1, 2020
2b82173
Merge branch 'align-and-dedup-continue-button-state-fragment' into in…
BenHenning May 9, 2020
5855650
Merge branch 'develop' into align-and-dedup-continue-button-state-fra…
BenHenning May 9, 2020
cbd90d8
Post-merge fixes.
BenHenning May 9, 2020
7af0d73
Fix the submit button disabled states: with the new refactor, the submit
BenHenning May 9, 2020
f889779
Revert accidental changes to .idea/misc.xml.
BenHenning May 9, 2020
6eb25c5
Address reviewer comments.
BenHenning May 9, 2020
8696fca
Merge branch 'develop' into introduce-test-coroutine-dispatchers
BenHenning May 9, 2020
7110b6c
Merge branch 'introduce-test-coroutine-dispatchers' into introduce-ne…
BenHenning May 10, 2020
15d6c07
Merge branch 'introduce-new-coroutine-live-data-mechanism' into intro…
BenHenning May 10, 2020
bc5e43d
Merge branch 'introduce-nested-data-provider' into introduce-question…
BenHenning May 10, 2020
c581a57
Remove unnecessary meta file for Mockito.
BenHenning May 10, 2020
00caccd
Merge branch 'align-and-dedup-continue-button-state-fragment' into te…
BenHenning May 10, 2020
6fa60e3
Merge branch 'introduce-question-progress-controller-implementation' …
BenHenning May 10, 2020
3959c01
Minor import cleanup.
BenHenning May 10, 2020
fa3b922
Merge branch 'introduce-question-progress-controller-implementation' …
BenHenning May 10, 2020
fc0f435
Merge branch 'temp-base-branch-for-question-player' into introduce-qu…
BenHenning May 10, 2020
820a0eb
Post-merge fixes.
BenHenning May 10, 2020
48f51b8
Fix audio playback & generalize it to facilitate enabling it for
BenHenning May 10, 2020
e902e82
Address reviewer comments & fix broken tests.
BenHenning May 10, 2020
59abff2
Fix hints & solutions functionality after simplification (some bugs &
BenHenning May 10, 2020
2c22c31
Revert the assembler delays to match the intended durations rather than
BenHenning May 10, 2020
25803b5
Merge branch 'develop' into align-and-dedup-continue-button-state-fra…
BenHenning May 20, 2020
b6d08dc
Address reviewer comments.
BenHenning May 20, 2020
fba02ce
Remove infeasible testing structures, add documentation, and clean up
BenHenning May 20, 2020
9ea55b5
Add notice that the dispatchers utility is temporary.
BenHenning May 20, 2020
c6dbd22
Cleanup new LiveData bridge, add tests for it, and migrate other
BenHenning May 21, 2020
3a6f452
Merge branch 'introduce-test-coroutine-dispatchers' into introduce-ne…
BenHenning May 21, 2020
1245337
Add AsyncResult tests, fix & re-enable an earlier test in PersistentC…
BenHenning May 21, 2020
8ff8805
Use ktlint to reformat TestCoroutineDispatchers per reviewer comment
BenHenning May 21, 2020
e37eaa1
Merge branch 'introduce-test-coroutine-dispatchers' into introduce-ne…
BenHenning May 21, 2020
113fdeb
Reformat files failing linter check.
BenHenning May 21, 2020
7bacc7c
Merge branch 'introduce-new-coroutine-live-data-mechanism' into intro…
BenHenning May 21, 2020
39553a8
Reformat new DataProviders code.
BenHenning May 21, 2020
f4bdeb6
Add new tests for the NestedTransformedDataProvider.
BenHenning May 21, 2020
7611cf2
Merge branch 'develop' into introduce-new-coroutine-live-data-mechanism
BenHenning May 28, 2020
8a2820a
Address reviewer comment.
BenHenning May 28, 2020
98ff4af
Merge branch 'introduce-new-coroutine-live-data-mechanism' into intro…
BenHenning May 28, 2020
a4ac207
Merge branch 'introduce-nested-data-provider' into introduce-question…
BenHenning May 28, 2020
7dd108f
Address reviewer comments.
BenHenning May 28, 2020
c934803
Merge branch 'align-and-dedup-continue-button-state-fragment' into te…
BenHenning May 28, 2020
f4b7467
Merge branch 'introduce-question-progress-controller-implementation' …
BenHenning May 28, 2020
39f13e6
Merge branch 'temp-base-branch-for-question-player' into introduce-qu…
BenHenning May 28, 2020
d07de9c
Address reviewer comments & fix lint issue.
BenHenning May 28, 2020
bf056ec
Merge branch 'develop' into introduce-new-coroutine-live-data-mechanism
BenHenning May 28, 2020
91d4b19
Merge branch 'introduce-new-coroutine-live-data-mechanism' into intro…
BenHenning May 28, 2020
02c1c46
Merge branch 'develop' into introduce-nested-data-provider
BenHenning May 28, 2020
a0d662f
Merge branch 'introduce-nested-data-provider' into introduce-question…
BenHenning May 28, 2020
736e540
Merge branch 'develop' into introduce-question-progress-controller-im…
BenHenning May 28, 2020
bc49c47
Merge branch 'introduce-question-progress-controller-implementation' …
BenHenning May 28, 2020
245fa13
Update hints & solutions handling to more closely follow the intended
BenHenning Jun 8, 2020
bb93490
Merge branch 'develop' into introduce-question-player-ui-structure
BenHenning Jun 9, 2020
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 @@ -11,6 +11,7 @@ app/build
data/build
domain/build
model/build
testing/build
utility/build
.DS_Store
/build
Expand Down
3 changes: 2 additions & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ dependencies {
'androidx.test.espresso:espresso-intents:3.1.0',
'androidx.test.ext:junit:1.1.1',
'com.google.truth:truth:0.43',
'org.robolectric:annotations:4.3',
'org.robolectric:robolectric:4.3',
'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.2.2',
'org.mockito:mockito-core:2.7.22',
Expand All @@ -111,6 +112,7 @@ dependencies {
'com.google.truth:truth:0.43',
'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.2.2',
'org.mockito:mockito-android:2.7.22',
'org.robolectric:annotations:4.3',
)
androidTestUtil(
'androidx.test:orchestrator:1.2.0',
Expand All @@ -127,6 +129,8 @@ dependencies {
// TODO (#59): Remove this once Bazel is introduced
api project(':data')
implementation project(":model")
testImplementation project(":model")
androidTestImplementation project(":model")
implementation project(":domain")
implementation project(":utility")
}
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.oppia.app">

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<!-- TODO(#56): Reenable landscape support. -->
Expand Down Expand Up @@ -64,6 +63,7 @@
android:name=".player.exploration.ExplorationActivity"
android:theme="@style/OppiaThemeWithoutActionBar"
android:windowSoftInputMode="adjustResize" />
<activity android:name=".player.state.testing.StateFragmentTestActivity" />
<activity
android:name=".profile.AddProfileActivity"
android:theme="@style/OppiaThemeNoActionBarColorAccentColorPrimary" />
Expand Down Expand Up @@ -116,7 +116,6 @@
<activity android:name=".testing.AudioFragmentTestActivity" />
<activity android:name=".testing.BindableAdapterTestActivity" />
<activity android:name=".testing.ConceptCardFragmentTestActivity" />
<activity android:name=".testing.ContentCardTestActivity" />
<activity android:name=".testing.ExplorationInjectionActivity" />
<activity android:name=".testing.ExplorationTestActivity" />
<activity android:name=".testing.HomeInjectionActivity" />
Expand All @@ -140,7 +139,8 @@
android:theme="@style/OppiaThemeWithoutActionBar" />
<activity
android:name=".topic.questionplayer.QuestionPlayerActivity"
android:screenOrientation="portrait" />
android:screenOrientation="portrait"
android:label="@string/question_player_title" />
<activity
android:name=".topic.revisioncard.RevisionCardActivity"
android:theme="@style/OppiaThemeWithoutActionBar" />
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/org/oppia/app/activity/ActivityComponent.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import org.oppia.app.options.DefaultAudioActivity
import org.oppia.app.options.OptionsActivity
import org.oppia.app.options.StoryTextSizeActivity
import org.oppia.app.player.exploration.ExplorationActivity
import org.oppia.app.player.state.testing.StateFragmentTestActivity
import org.oppia.app.profile.AddProfileActivity
import org.oppia.app.profile.AdminAuthActivity
import org.oppia.app.profile.AdminPinActivity
Expand All @@ -36,7 +37,6 @@ import org.oppia.app.story.StoryActivity
import org.oppia.app.testing.AudioFragmentTestActivity
import org.oppia.app.testing.BindableAdapterTestActivity
import org.oppia.app.testing.ConceptCardFragmentTestActivity
import org.oppia.app.testing.ContentCardTestActivity
import org.oppia.app.testing.ExplorationInjectionActivity
import org.oppia.app.testing.ExplorationTestActivity
import org.oppia.app.testing.HomeInjectionActivity
Expand Down Expand Up @@ -77,7 +77,6 @@ interface ActivityComponent {
fun inject(bindableAdapterTestActivity: BindableAdapterTestActivity)
fun inject(completedStoryListActivity: CompletedStoryListActivity)
fun inject(conceptCardFragmentTestActivity: ConceptCardFragmentTestActivity)
fun inject(contentCardTestActivity: ContentCardTestActivity)
fun inject(defaultAudioActivity: DefaultAudioActivity)
fun inject(explorationActivity: ExplorationActivity)
fun inject(explorationInjectionActivity: ExplorationInjectionActivity)
Expand Down Expand Up @@ -107,6 +106,7 @@ interface ActivityComponent {
fun inject(recentlyPlayedActivity: RecentlyPlayedActivity)
fun inject(revisionCardActivity: RevisionCardActivity)
fun inject(splashActivity: SplashActivity)
fun inject(stateFragmentTestActivity: StateFragmentTestActivity)
fun inject(storyActivity: StoryActivity)
fun inject(storyTextSizeActivity: StoryTextSizeActivity)
fun inject(topicActivity: TopicActivity)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import org.oppia.domain.classify.rules.multiplechoiceinput.MultipleChoiceInputMo
import org.oppia.domain.classify.rules.numberwithunits.NumberWithUnitsRuleModule
import org.oppia.domain.classify.rules.numericinput.NumericInputRuleModule
import org.oppia.domain.classify.rules.textinput.TextInputRuleModule
import org.oppia.domain.question.QuestionModule
import org.oppia.util.caching.CachingModule
import org.oppia.util.gcsresource.GcsResourceModule
import org.oppia.util.logging.LoggerModule
Expand All @@ -30,7 +31,7 @@ import javax.inject.Singleton
ContinueModule::class, FractionInputModule::class, ItemSelectionInputModule::class, MultipleChoiceInputModule::class,
NumberWithUnitsRuleModule::class, NumericInputRuleModule::class, TextInputRuleModule::class,
InteractionsModule::class, GcsResourceModule::class, GlideImageLoaderModule::class, ImageParsingModule::class,
HtmlParserEntityTypeModule::class, CachingModule::class
HtmlParserEntityTypeModule::class, CachingModule::class, QuestionModule::class
])
interface ApplicationComponent {
@Component.Builder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package org.oppia.app.databinding

import android.graphics.drawable.GradientDrawable
import android.view.View
import android.widget.Button
import androidx.annotation.ColorInt
import androidx.annotation.DrawableRes
import androidx.databinding.BindingAdapter
import org.oppia.app.R

Expand Down Expand Up @@ -34,3 +36,8 @@ fun setRectangleBackgroundDrawable(view: View, @ColorInt colorRgb: Int) {
// The input color needs to have alpha channel prepended to it.
(view.background as GradientDrawable).setColor((0xff000000 or colorRgb.toLong()).toInt())
}

@BindingAdapter("android:button")
fun setBackgroundResource(button: Button, @DrawableRes resource: Int) {
button.setBackgroundResource(resource)
}
13 changes: 10 additions & 3 deletions app/src/main/java/org/oppia/app/player/audio/AudioFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ class AudioFragment : InjectableFragment(), LanguageInterface, AudioUiManager, C
audioFragmentPresenter.handleOnDestroy()
}

override fun enableAudioPlayback(contentId: String?) {
audioFragmentPresenter.handleAudioClick(
shouldEnableAudioPlayback = true, feedbackId = contentId
)
}

override fun disableAudioPlayback() {
audioFragmentPresenter.handleAudioClick(shouldEnableAudioPlayback = false, feedbackId = null)
}

override fun setStateAndExplorationId(newState: State, explorationId: String) =
audioFragmentPresenter.setStateAndExplorationId(newState, explorationId)

Expand All @@ -65,7 +75,4 @@ class AudioFragment : InjectableFragment(), LanguageInterface, AudioUiManager, C

/** Used in data binding to know position of user's touch */
fun getUserPosition() = audioFragmentPresenter.userProgress

fun handleAudioClick(isShowing: Boolean, feedbackId: String?) =
audioFragmentPresenter.handleAudioClick(isShowing, feedbackId)
}
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,9 @@ class AudioFragmentPresenter @Inject constructor(
}
}

fun handleAudioClick(isShowing: Boolean, feedbackId: String?) {
fun handleAudioClick(shouldEnableAudioPlayback: Boolean, feedbackId: String?) {
this.feedbackId = feedbackId
if (isShowing) {
setAudioFragmentVisible(false)
} else {
if (shouldEnableAudioPlayback) {
when (networkConnectionUtil.getCurrentConnectionStatus()) {
NetworkConnectionUtil.ConnectionStatus.LOCAL -> setAudioFragmentVisible(true)
NetworkConnectionUtil.ConnectionStatus.CELLULAR -> {
Expand All @@ -171,6 +169,8 @@ class AudioFragmentPresenter @Inject constructor(
setAudioFragmentVisible(false)
}
}
} else {
setAudioFragmentVisible(false)
}
}

Expand Down
10 changes: 10 additions & 0 deletions app/src/main/java/org/oppia/app/player/audio/AudioUiManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ import org.oppia.app.model.State

/** Manager for updating audio state within the state player. */
interface AudioUiManager {
/**
* Enables audio playback with the specified content ID as the initial content to play. Note that
* this corresponds to a response to the UI which means the action may fail with a dialog
* notifying the user why they can't enable audio playback right now.
*/
fun enableAudioPlayback(contentId: String?)

/** Disables audio playback, stopping any currently playing tracks. */
fun disableAudioPlayback();

/**
* Used to set the state and explorationId for the audio player
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import org.oppia.domain.audio.AudioPlayerController
import org.oppia.domain.audio.AudioPlayerController.PlayProgress
import org.oppia.domain.audio.AudioPlayerController.PlayStatus
import org.oppia.util.data.AsyncResult
import org.oppia.util.gcsresource.DefaultResource
import org.oppia.util.gcsresource.DefaultResourceBucketName
import java.util.Locale
import javax.inject.Inject

Expand All @@ -22,7 +22,7 @@ import javax.inject.Inject
class AudioViewModel @Inject constructor(
private val audioPlayerController: AudioPlayerController,
private val fragment: Fragment,
@DefaultResource private val gcsResource: String
@DefaultResourceBucketName private val gcsResource: String
) : ViewModel() {

private lateinit var state: State
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ import org.oppia.app.player.state.hintsandsolution.RevealHintListener
import org.oppia.app.player.state.hintsandsolution.RevealSolutionInterface
import org.oppia.app.player.state.listener.RouteToHintsAndSolutionListener
import org.oppia.app.player.state.listener.StateKeyboardButtonListener
import org.oppia.app.player.stopexploration.StopExplorationDialogFragment
import org.oppia.app.player.stopexploration.StopExplorationInterface
import org.oppia.app.player.stopplaying.StopExplorationDialogFragment
import org.oppia.app.player.stopplaying.StopStatePlayingSessionListener
import javax.inject.Inject

private const val TAG_STOP_EXPLORATION_DIALOG = "STOP_EXPLORATION_DIALOG"
const val TAG_HINTS_AND_SOLUTION_DIALOG = "HINTS_AND_SOLUTION_DIALOG"

/** The starting point for exploration. */
class ExplorationActivity : InjectableAppCompatActivity(), StopExplorationInterface, StateKeyboardButtonListener,
class ExplorationActivity : InjectableAppCompatActivity(), StopStatePlayingSessionListener, StateKeyboardButtonListener,
AudioButtonListener, HintsAndSolutionListener, RouteToHintsAndSolutionListener, RevealHintListener,
RevealSolutionInterface {

Expand Down Expand Up @@ -77,7 +77,7 @@ class ExplorationActivity : InjectableAppCompatActivity(), StopExplorationInterf
dialogFragment.showNow(supportFragmentManager, TAG_STOP_EXPLORATION_DIALOG)
}

override fun stopExploration() {
override fun stopSession() {
explorationActivityPresenter.stopExploration()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,15 @@ class ExplorationActivityPresenter @Inject constructor(
})
}

fun onKeyboardAction(actionCode: Int) {
if (actionCode == EditorInfo.IME_ACTION_DONE) {
val explorationFragment = activity.supportFragmentManager.findFragmentByTag(
TAG_EXPLORATION_FRAGMENT
) as? ExplorationFragment
explorationFragment?.onKeyboardAction()
}
}

private fun updateToolbarTitle(explorationId: String) {
subscribeToExploration(explorationDataController.getExplorationById(explorationId))
}
Expand Down Expand Up @@ -131,14 +140,6 @@ class ExplorationActivityPresenter @Inject constructor(
return ephemeralStateResult.getOrDefault(Exploration.getDefaultInstance())
}

fun onKeyboardAction(actionCode: Int) {
if (actionCode == EditorInfo.IME_ACTION_DONE) {
val explorationFragment =
activity.supportFragmentManager.findFragmentByTag(TAG_EXPLORATION_FRAGMENT) as ExplorationFragment
explorationFragment.onKeyboardAction()
}
}

fun revealHint(saveUserChoice: Boolean, hintIndex: Int) {
val explorationFragment =
activity.supportFragmentManager.findFragmentByTag(TAG_EXPLORATION_FRAGMENT) as ExplorationFragment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ class ExplorationFragmentPresenter @Inject constructor(

fun scrollToTop() = getStateFragment()?.scrollToTop()

private fun getStateFragment(): StateFragment? {
return fragment.childFragmentManager.findFragmentById(R.id.state_fragment_placeholder) as StateFragment?
}

fun onKeyboardAction() {
getStateFragment()?.handleKeyboardAction()
}
Expand All @@ -59,4 +55,8 @@ class ExplorationFragmentPresenter @Inject constructor(
fun revealSolution(saveUserChoice: Boolean){
getStateFragment()?.revealSolution(saveUserChoice)
}

private fun getStateFragment(): StateFragment? {
return fragment.childFragmentManager.findFragmentById(R.id.state_fragment_placeholder) as StateFragment?
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import org.oppia.app.databinding.MultipleChoiceInteractionItemsBinding
import org.oppia.app.fragment.InjectableFragment
import org.oppia.app.player.state.itemviewmodel.SelectionInteractionContentViewModel
import org.oppia.app.recyclerview.BindableAdapter
import org.oppia.util.gcsresource.DefaultResourceBucketName
import org.oppia.util.parser.ExplorationHtmlParserEntityType
import org.oppia.util.parser.HtmlParser
import javax.inject.Inject
Expand All @@ -37,7 +38,11 @@ class SelectionInteractionView @JvmOverloads constructor(
@Inject
@field:ExplorationHtmlParserEntityType
lateinit var entityType: String
private lateinit var explorationId: String
@Inject
@field:DefaultResourceBucketName
lateinit var resourceBucketName: String

private lateinit var entityId: String

override fun onAttachedToWindow() {
super.onAttachedToWindow()
Expand All @@ -55,8 +60,8 @@ class SelectionInteractionView @JvmOverloads constructor(

// TODO(#264): Clean up HTML parser such that it can be handled completely through a binding adapter, allowing
// TextViews that require custom Oppia HTML parsing to be fully automatically bound through data-binding.
fun setExplorationId(explorationId: String) {
this.explorationId = explorationId
fun setEntityId(entityId: String) {
this.entityId = entityId
}

private fun createAdapter(): BindableAdapter<SelectionInteractionContentViewModel> {
Expand All @@ -72,7 +77,9 @@ class SelectionInteractionView @JvmOverloads constructor(
bindView = { view, viewModel ->
val binding = DataBindingUtil.findBinding<ItemSelectionInteractionItemsBinding>(view)!!
binding.htmlContent =
htmlParserFactory.create(entityType, explorationId, /* imageCenterAlign= */ false).parseOppiaHtml(
htmlParserFactory.create(
resourceBucketName, entityType, entityId, /* imageCenterAlign= */ false
).parseOppiaHtml(
viewModel.htmlContent, binding.itemSelectionContentsTextView
)
binding.viewModel = viewModel
Expand All @@ -90,7 +97,9 @@ class SelectionInteractionView @JvmOverloads constructor(
bindView = { view, viewModel ->
val binding = DataBindingUtil.findBinding<MultipleChoiceInteractionItemsBinding>(view)!!
binding.htmlContent =
htmlParserFactory.create(entityType, explorationId, /* imageCenterAlign= */ false).parseOppiaHtml(
htmlParserFactory.create(
resourceBucketName, entityType, entityId, /* imageCenterAlign= */ false
).parseOppiaHtml(
viewModel.htmlContent, binding.multipleChoiceContentTextView
)
binding.viewModel = viewModel
Expand All @@ -108,7 +117,7 @@ fun setAllOptionsItemInputType(
) = selectionInteractionView.setAllOptionsItemInputType(selectionItemInputType)

/** Sets the exploration ID for a specific [SelectionInteractionView] via data-binding. */
@BindingAdapter("explorationId")
fun setExplorationId(
selectionInteractionView: SelectionInteractionView, explorationId: String
) = selectionInteractionView.setExplorationId(explorationId)
@BindingAdapter("entityId")
fun setEntityId(
selectionInteractionView: SelectionInteractionView, entityId: String
) = selectionInteractionView.setEntityId(entityId)
Loading