Skip to content

Commit

Permalink
Merge branch 'develop' into feat/audio-loading-ui
Browse files Browse the repository at this point in the history
  • Loading branch information
adhiamboperes committed Nov 14, 2023
2 parents 2a2ab7a + 642a778 commit 1f4b0f0
Show file tree
Hide file tree
Showing 18 changed files with 212 additions and 110 deletions.
4 changes: 2 additions & 2 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ git_repository(
# to correctly size in-line SVGs (such as those needed for LaTeX-based math expressions).
git_repository(
name = "androidsvg",
commit = "1265eb1087056cf3fc2e10442e5545bc65c109ce",
commit = "5bc9c7553e94c3476e8ea32baea3c77567228fcd",
remote = "https://github.com/oppia/androidsvg",
shallow_since = "1686302944 -0700",
shallow_since = "1686304726 -0700",
)

git_repository(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,10 @@ class StateFragmentPresenter @Inject constructor(

fun onSubmitButtonClicked() {
hideKeyboard()
handleSubmitAnswer(viewModel.getPendingAnswer(recyclerViewAssembler::getPendingAnswerHandler))
val answer = viewModel.getPendingAnswer(recyclerViewAssembler::getPendingAnswerHandler)
if (answer != null) {
handleSubmitAnswer(answer)
}
}

fun onResponsesHeaderClicked() {
Expand All @@ -215,7 +218,10 @@ class StateFragmentPresenter @Inject constructor(
fun handleKeyboardAction() {
hideKeyboard()
if (viewModel.getCanSubmitAnswer().get() == true) {
handleSubmitAnswer(viewModel.getPendingAnswer(recyclerViewAssembler::getPendingAnswerHandler))
val answer = viewModel.getPendingAnswer(recyclerViewAssembler::getPendingAnswerHandler)
if (answer != null) {
handleSubmitAnswer(answer)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@ class StateViewModel @Inject constructor(

fun getPendingAnswer(
retrieveAnswerHandler: (List<StateItemViewModel>) -> InteractionAnswerHandler?
): UserAnswer {
): UserAnswer? {
return getPendingAnswerWithoutError(
retrieveAnswerHandler(
getAnswerItemList()
)
) ?: UserAnswer.getDefaultInstance()
)
}

fun canQuicklyToggleBetweenSwahiliAndEnglish(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,10 @@ class SurveyFragmentPresenter @Inject constructor(

private fun subscribeToCurrentQuestion() {
ephemeralQuestionLiveData.observe(
fragment,
{
processEphemeralQuestionResult(it)
}
)
fragment.viewLifecycleOwner
) {
processEphemeralQuestionResult(it)
}
}

private fun processEphemeralQuestionResult(result: AsyncResult<EphemeralSurveyQuestion>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/administrator_controls_guideline"
app:layout_constraintTop_toBottomOf="@id/extra_controls_title" />
app:layout_constraintTop_toBottomOf="@id/extra_controls_title"
tools:ignore="InconsistentLayout" />

<View
android:id="@+id/administrator_controls_toolbar_shadow_view"
Expand Down
9 changes: 6 additions & 3 deletions app/src/main/res/layout-sw600dp/help_activity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
android:visibility="gone"
app:layout_constraintStart_toEndOf="@id/multipane_guideline"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_arrow_back_black_24_dp" />
app:srcCompat="@drawable/ic_arrow_back_black_24_dp"
tools:ignore="InconsistentLayout" />

<TextView
android:id="@+id/help_multipane_options_title_textview"
Expand All @@ -61,7 +62,8 @@
android:textColor="@color/component_color_shared_primary_text_color"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/help_multipane_options_back_button"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toTopOf="parent"
tools:ignore="InconsistentLayout" />

<FrameLayout
android:id="@+id/multipane_options_container"
Expand All @@ -71,7 +73,8 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/multipane_guideline"
app:layout_constraintTop_toBottomOf="@id/help_multipane_options_title_textview" />
app:layout_constraintTop_toBottomOf="@id/help_multipane_options_title_textview"
tools:ignore="InconsistentLayout" />

<androidx.constraintlayout.widget.Guideline
android:id="@+id/multipane_guideline"
Expand Down
6 changes: 4 additions & 2 deletions app/src/main/res/layout-sw600dp/option_activity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@
android:textSize="18sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/multipane_guideline"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toTopOf="parent"
tools:ignore="InconsistentLayout" />

<FrameLayout
android:id="@+id/multipane_options_container"
Expand All @@ -55,7 +56,8 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/multipane_guideline"
app:layout_constraintTop_toBottomOf="@id/options_activity_selected_options_title" />
app:layout_constraintTop_toBottomOf="@id/options_activity_selected_options_title"
tools:ignore="InconsistentLayout" />

<androidx.constraintlayout.widget.Guideline
android:id="@+id/multipane_guideline"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/options_activity_drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
Expand Down Expand Up @@ -44,7 +45,8 @@
android:textSize="18sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/multipane_guideline"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toTopOf="parent"
tools:ignore="InconsistentLayout" />

<FrameLayout
android:id="@+id/multipane_options_container"
Expand All @@ -54,7 +56,8 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/multipane_guideline"
app:layout_constraintTop_toBottomOf="@id/options_activity_selected_options_title" />
app:layout_constraintTop_toBottomOf="@id/options_activity_selected_options_title"
tools:ignore="InconsistentLayout" />

<androidx.constraintlayout.widget.Guideline
android:id="@+id/multipane_guideline"
Expand Down
9 changes: 6 additions & 3 deletions app/src/main/res/values-pcm-rNG/strings.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Authors:
* Busayo
* Confidence
* Osetiemoria
-->
<resources>
Expand All @@ -9,6 +10,7 @@
<string name="menu_my_downloads">My Downloads</string>
<string name="menu_help">Help</string>
<string name="exploration_activity_title">Lesson Player</string>
<string name="play_exploration_button_text">play exploration</string>
<string name="help_activity_title">Help</string>
<string name="bottom_sheet_options_menu_close">Close</string>
<string name="menu_switch_profile">Change Profile</string>
Expand All @@ -19,18 +21,19 @@
<string name="audio_play_description">Play di audio</string>
<string name="audio_pause_description">Pause di audio</string>
<string name="audio_unavailable_in_selected_language">%s audio no dey available.</string>
<string name="audio_language_select_dialog_okay_button" fuzzy="true">OK</string>
<string name="audio_language_select_dialog_okay_button">OK</string>
<string name="audio_language_select_dialog_cancel_button">Cancel am</string>
<string name="audio_language_select_dialog_title">Audio Language</string>
<string name="audio_dialog_offline_title">You dey offline</string>
<string name="audio_dialog_offline_message">Make sure sey Wi-Fi or mobile data dey on, den try am again.</string>
<string name="audio_dialog_offline_positive" fuzzy="true">OK</string>
<string name="cellular_data_alert_dialog_okay_button" fuzzy="true">OK</string>
<string name="audio_dialog_offline_positive">OK</string>
<string name="cellular_data_alert_dialog_okay_button">OK</string>
<string name="cellular_data_alert_dialog_cancel_button">Cancel am</string>
<string name="cellular_data_alert_dialog_title">Na your data you dey use now</string>
<string name="cellular_data_alert_dialog_description">Playing di audio go use plenti mobile data.</string>
<string name="cellular_data_alert_dialog_checkbox">No show this message again</string>
<string name="concept_card_toolbar_title">Concept Card</string>
<string name="concept_card_one_button_text">Concept Card 1</string>
<string name="revision_card_toolbar_title">Revision Card</string>
<string name="unsaved_exploration_dialog_title">Comot go the topic page?</string>
<string name="unsaved_exploration_dialog_description">Wetin you don do before no go save</string>
Expand Down
56 changes: 14 additions & 42 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -472,48 +472,20 @@
<string name="completed_story_list_recyclerview_tag">completed_story_list_recyclerview_tag</string>
<string name="item_selection_text">Please select all correct choices.</string>
<!-- SplashActivity -->
<string name="unsupported_app_version_dialog_title" description="The title of the dialog shown when a user's pre-release app has expired.">
Unsupported app version
</string>
<string name="unsupported_app_version_dialog_message" description="The main message of the dialog shown when a user's pre-release app has expired.">
This version of the app is no longer supported. Please update it through the Play Store.
</string>
<string name="unsupported_app_version_dialog_close_button_text" description="The close button text of the dialog shown when a user's pre-release app has expired.">
Close app
</string>
<string name="forced_app_update_dialog_title" description="The title of the dialog shown when a user's pre-release app has expired.">
App update required
</string>
<string name="forced_app_update_dialog_message" description="The main message of the dialog shown when a user's app has expired.">
A new version of %s is now available. The new version is more secure, and improves your learning experience.\n\nThis version is no longer supported. To continue using the app, please update to the latest version.
</string>
<string name="forced_app_update_dialog_update_button_text" description="The update button text of the dialog shown when a user's pre-release app has expired.">
Update
</string>
<string name="forced_app_update_dialog_close_button_text" description="The close button text of the dialog shown when a user's pre-release app has expired.">
Close app
</string>
<string name="optional_app_update_dialog_title" description="The title of the dialog shown when an optional app update is available.">
New update available
</string>
<string name="optional_app_update_dialog_message" description="The main message of the dialog shown when an optional app update is available.">
A new version of %s is now available. We recommend that you update the app for bug fixes and a better learning experience.
</string>
<string name="optional_app_update_dialog_dismiss_button_text" description="The dismiss button text of the dialog shown when an optional app update is available.">
Dismiss
</string>
<string name="optional_app_update_dialog_update_button_text" description="The update button text of the dialog shown when an optional app update is available.">
Update
</string>
<string name="os_deprecation_dialog_title" description="The title of the dialog shown when an the OS the user is using is no longer supported.">
Update your Android OS
</string>
<string name="os_deprecation_dialog_message" description="The main message of the dialog shown when an the OS the user is using is no longer supported.">
We recommend updating your Android OS to take advantage of %s\'s new features and lessons.\n\nVisit your phone\'s Settings app to update your OS.
</string>
<string name="os_deprecation_dialog_dismiss_button_text" description="The dismiss button text of the dialog shown when an the OS the user is using is no longer supported.">
Dismiss
</string>
<string name="unsupported_app_version_dialog_title" description="The title of the dialog shown when a user's pre-release app has expired.">Unsupported app version</string>
<string name="unsupported_app_version_dialog_message" description="The main message of the dialog shown when a user's pre-release app has expired.">This version of the app is no longer supported. Please update it through the Play Store.</string>
<string name="unsupported_app_version_dialog_close_button_text" description="The close button text of the dialog shown when a user's pre-release app has expired.">Close app</string>
<string name="forced_app_update_dialog_title" description="The title of the dialog shown when a user's pre-release app has expired.">App update required</string>
<string name="forced_app_update_dialog_message" description="The main message of the dialog shown when a user's app has expired.">A new version of %s is now available. The new version is more secure, and improves your learning experience.\n\nThis version is no longer supported. To continue using the app, please update to the latest version.</string>
<string name="forced_app_update_dialog_update_button_text" description="The update button text of the dialog shown when a user's pre-release app has expired.">Update</string>
<string name="forced_app_update_dialog_close_button_text" description="The close button text of the dialog shown when a user's pre-release app has expired.">Close app</string>
<string name="optional_app_update_dialog_title" description="The title of the dialog shown when an optional app update is available.">New update available</string>
<string name="optional_app_update_dialog_message" description="The main message of the dialog shown when an optional app update is available.">A new version of %s is now available. We recommend that you update the app for bug fixes and a better learning experience.</string>
<string name="optional_app_update_dialog_dismiss_button_text" description="The dismiss button text of the dialog shown when an optional app update is available.">Dismiss</string>
<string name="optional_app_update_dialog_update_button_text" description="The update button text of the dialog shown when an optional app update is available.">Update</string>
<string name="os_deprecation_dialog_title" description="The title of the dialog shown when an the OS the user is using is no longer supported.">Update your Android OS</string>
<string name="os_deprecation_dialog_message" description="The main message of the dialog shown when an the OS the user is using is no longer supported.">We recommend updating your Android OS to take advantage of %s\'s new features and lessons.\n\nVisit your phone\'s Settings app to update your OS.</string>
<string name="os_deprecation_dialog_dismiss_button_text" description="The dismiss button text of the dialog shown when an the OS the user is using is no longer supported.">Dismiss</string>
<string name="splash_screen_developer_label">Developer Build</string>
<string name="splash_screen_alpha_label">Alpha</string>
<string name="splash_screen_beta_label">Beta</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,24 @@ class StateFragmentTest {
}
}

@Test
@RunOn(TestPlatform.ESPRESSO) // Robolectric tests don't rotate like this to recreate activity
fun testStateFragment_loadExp_invalidAnswer_changeConfiguration_submitButtonIsDisplayed() {
setUpTestWithLanguageSwitchingFeatureOff()
launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use {
startPlayingExploration()
clickContinueInteractionButton()

typeFractionText("1/")

clickSubmitAnswerButton()

rotateToLandscape()

onView(withId(R.id.submit_answer_button)).check(matches(isDisplayed()))
}
}

@Test
fun testStateFragment_loadExp_secondState_invalidAnswer_updated_submitAnswerIsEnabled() {
setUpTestWithLanguageSwitchingFeatureOff()
Expand Down
2 changes: 1 addition & 1 deletion utility/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ dependencies {
'androidx.appcompat:appcompat:1.0.2',
'androidx.lifecycle:lifecycle-livedata-ktx:2.2.0-alpha03',
'androidx.work:work-runtime-ktx:2.4.0',
'com.github.oppia:androidsvg:1265eb1087056cf3fc2e10442e5545bc65c109ce',
'com.github.oppia:androidsvg:5bc9c7553e94c3476e8ea32baea3c77567228fcd',
'com.github.oppia:kotlitex:43139c140833c7120f351d63d74b42c253d2b213',
'com.github.bumptech.glide:glide:4.11.0',
'com.google.dagger:dagger:2.24',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,26 @@ class HtmlParser private constructor(
supportsLinks: Boolean = false,
supportsConceptCards: Boolean = false
): Spannable {

var htmlContent = rawString

// Canvas does not support RTL, it always starts from left to right in RTL due to which compound drawables are
// not center aligned. To avoid this situation check if RTL is enabled and set the textDirection.
if (isRtl) {
htmlContentTextView.textDirection = View.TEXT_DIRECTION_RTL

val regex = Regex("""<oppia-noninteractive-image [^>]*>.*?</oppia-noninteractive-image>""")
val modifiedHtmlContent = rawString.replace(regex) {
val oppiaImageTag = it.value
"""<div style="text-align: center;">$oppiaImageTag</div>"""
}
htmlContent = modifiedHtmlContent
} else {
htmlContentTextView.textDirection = View.TEXT_DIRECTION_LTR
}

htmlContentTextView.invalidate()

var htmlContent = rawString
if ("\n\t" in htmlContent) {
htmlContent = htmlContent.replace("\n\t", "")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import android.view.View
import android.view.ViewGroup
import android.view.ViewTreeObserver
import android.widget.TextView
import androidx.core.view.ViewCompat
import com.bumptech.glide.request.target.CustomTarget
import com.bumptech.glide.request.transition.Transition
import org.oppia.android.util.R
Expand Down Expand Up @@ -234,6 +235,11 @@ class UrlImageParser private constructor(
private val autoResizeImage: Boolean
) : AutoAdjustingImageTarget<T, D>(targetConfiguration) {

private fun isRTLMode(): Boolean {
return ViewCompat.getLayoutDirection(htmlContentTextView) == ViewCompat
.LAYOUT_DIRECTION_RTL
}

override fun computeBounds(
context: Context,
drawable: D,
Expand Down Expand Up @@ -304,11 +310,13 @@ class UrlImageParser private constructor(
drawableWidth *= multipleFactor
}
}
val drawableLeft = if (imageCenterAlign) {

val drawableLeft = if (imageCenterAlign && !isRTLMode()) {
calculateInitialMargin(maxAvailableWidth, drawableWidth)
} else {
0f
}

val drawableTop = 0f
val drawableRight = drawableLeft + drawableWidth
val drawableBottom = drawableTop + drawableHeight
Expand Down
Loading

0 comments on commit 1f4b0f0

Please sign in to comment.