-
Notifications
You must be signed in to change notification settings - Fork 503
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix part of #5070: Display empty answer message in text input interac…
…tion (#5311) <!-- READ ME FIRST: Please fill in the explanation section below and check off every point from the Essential Checklist! --> ## Explanation Fixes part of #5070, In TextInteraction UI, leave submit button enabled when answer is empty. Show an error on submitting an empty answer. Created own test suite for text input interaction view. [text_input.webm](https://github.com/oppia/oppia-android/assets/76042077/a5882904-8152-4422-b9c9-c937cb056dd5) <!-- - Explain what your PR does. If this PR fixes an existing bug, please include - "Fixes #bugnum:" in the explanation so that GitHub can auto-close the issue - when this PR is merged. --> ## Essential Checklist <!-- Please tick the relevant boxes by putting an "x" in them. --> - [ ] The PR title and explanation each start with "Fix #bugnum: " (If this PR fixes part of an issue, prefix the title with "Fix part of #bugnum: ...".) - [ ] Any changes to [scripts/assets](https://github.com/oppia/oppia-android/tree/develop/scripts/assets) files have their rationale included in the PR explanation. - [ ] The PR follows the [style guide](https://github.com/oppia/oppia-android/wiki/Coding-style-guide). - [ ] The PR does not contain any unnecessary code changes from Android Studio ([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#undo-unnecessary-changes)). - [ ] The PR is made from a branch that's **not** called "develop" and is up-to-date with "develop". - [ ] The PR is **assigned** to the appropriate reviewers ([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#clarification-regarding-assignees-and-reviewers-section)). ## For UI-specific PRs only <!-- Delete these section if this PR does not include UI-related changes. --> If your PR includes UI-related changes, then: - Add screenshots for portrait/landscape for both a tablet & phone of the before & after UI changes - For the screenshots above, include both English and pseudo-localized (RTL) screenshots (see [RTL guide](https://github.com/oppia/oppia-android/wiki/RTL-Guidelines)) - Add a video showing the full UX flow with a screen reader enabled (see [accessibility guide](https://github.com/oppia/oppia-android/wiki/Accessibility-A11y-Guide)) - For PRs introducing new UI elements or color changes, both light and dark mode screenshots must be included - Add a screenshot demonstrating that you ran affected Espresso tests locally & that they're passing
- Loading branch information
1 parent
0911e71
commit 59a41ab
Showing
12 changed files
with
517 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
app/src/main/java/org/oppia/android/app/testing/TextInputInteractionViewTestActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package org.oppia.android.app.testing | ||
|
||
import android.os.Bundle | ||
import android.view.View | ||
import androidx.databinding.DataBindingUtil | ||
import org.oppia.android.R | ||
import org.oppia.android.app.activity.ActivityComponentImpl | ||
import org.oppia.android.app.activity.InjectableAutoLocalizedAppCompatActivity | ||
import org.oppia.android.app.customview.interaction.TextInputInteractionView | ||
import org.oppia.android.app.model.Interaction | ||
import org.oppia.android.app.model.UserAnswer | ||
import org.oppia.android.app.model.WrittenTranslationContext | ||
import org.oppia.android.app.player.state.answerhandling.AnswerErrorCategory | ||
import org.oppia.android.app.player.state.answerhandling.InteractionAnswerErrorOrAvailabilityCheckReceiver | ||
import org.oppia.android.app.player.state.answerhandling.InteractionAnswerReceiver | ||
import org.oppia.android.app.player.state.itemviewmodel.StateItemViewModel | ||
import org.oppia.android.app.player.state.itemviewmodel.TextInputViewModel | ||
import org.oppia.android.app.player.state.listener.StateKeyboardButtonListener | ||
import org.oppia.android.databinding.ActivityTextInputInteractionViewTestBinding | ||
import javax.inject.Inject | ||
|
||
/** | ||
* This is a dummy activity to test input interaction views. | ||
* It contains [TextInputInteractionView] | ||
*/ | ||
class TextInputInteractionViewTestActivity : | ||
InjectableAutoLocalizedAppCompatActivity(), | ||
StateKeyboardButtonListener, | ||
InteractionAnswerErrorOrAvailabilityCheckReceiver, | ||
InteractionAnswerReceiver { | ||
|
||
private lateinit var binding: ActivityTextInputInteractionViewTestBinding | ||
|
||
@Inject | ||
lateinit var textinputViewModelFactory: TextInputViewModel.FactoryImpl | ||
|
||
/** Gives access to the [TextInputViewModel]. */ | ||
val textInputViewModel by lazy { | ||
textinputViewModelFactory.create<TextInputViewModel>() | ||
} | ||
|
||
/** Gives access to the translation context. */ | ||
lateinit var writtenTranslationContext: WrittenTranslationContext | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
(activityComponent as ActivityComponentImpl).inject(this) | ||
binding = DataBindingUtil.setContentView( | ||
this, R.layout.activity_text_input_interaction_view_test | ||
) | ||
|
||
writtenTranslationContext = WrittenTranslationContext.getDefaultInstance() | ||
binding.textInputViewModel = textInputViewModel | ||
} | ||
|
||
/** Checks submit-time errors. */ | ||
fun getPendingAnswerErrorOnSubmitClick(v: View) { | ||
textInputViewModel.checkPendingAnswerError(AnswerErrorCategory.SUBMIT_TIME) | ||
} | ||
|
||
override fun onPendingAnswerErrorOrAvailabilityCheck( | ||
pendingAnswerError: String?, | ||
inputAnswerAvailable: Boolean | ||
) { | ||
} | ||
|
||
override fun onAnswerReadyForSubmission(answer: UserAnswer) { | ||
} | ||
|
||
override fun onEditorAction(actionCode: Int) { | ||
} | ||
|
||
private inline fun <reified T : StateItemViewModel> | ||
StateItemViewModel.InteractionItemFactory.create( | ||
interaction: Interaction = Interaction.getDefaultInstance() | ||
): T { | ||
return create( | ||
entityId = "fake_entity_id", | ||
hasConversationView = false, | ||
interaction = interaction, | ||
interactionAnswerReceiver = this@TextInputInteractionViewTestActivity, | ||
answerErrorReceiver = this@TextInputInteractionViewTestActivity, | ||
hasPreviousButton = false, | ||
isSplitView = false, | ||
writtenTranslationContext, | ||
timeToStartNoticeAnimationMs = null | ||
) as T | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.