Skip to content

Commit

Permalink
klint
Browse files Browse the repository at this point in the history
  • Loading branch information
Vishwajith-Shettigar committed Jul 6, 2024
1 parent 32ee035 commit 673ba94
Show file tree
Hide file tree
Showing 14 changed files with 28 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import org.oppia.android.app.fragment.InjectableFragment
import org.oppia.android.app.model.HelpIndex
import org.oppia.android.app.model.StateFragmentArguments
import org.oppia.android.app.model.UserAnswer
import org.oppia.android.app.model.UserAnswerState
import org.oppia.android.app.player.state.answerhandling.InteractionAnswerErrorOrAvailabilityCheckReceiver
import org.oppia.android.app.player.state.answerhandling.InteractionAnswerHandler
import org.oppia.android.app.player.state.answerhandling.InteractionAnswerReceiver
Expand All @@ -23,7 +24,6 @@ import org.oppia.android.app.player.state.listener.SubmitNavigationButtonListene
import org.oppia.android.util.extensions.getProto
import org.oppia.android.util.extensions.putProto
import javax.inject.Inject
import org.oppia.android.app.model.UserAnswerState

/** Fragment that represents the current state of an exploration. */
class StateFragment :
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import org.oppia.android.app.model.ProfileId
import org.oppia.android.app.model.State
import org.oppia.android.app.model.SurveyQuestionName
import org.oppia.android.app.model.UserAnswer
import org.oppia.android.app.model.UserAnswerState
import org.oppia.android.app.player.audio.AudioButtonListener
import org.oppia.android.app.player.audio.AudioFragment
import org.oppia.android.app.player.audio.AudioUiManager
Expand Down Expand Up @@ -54,7 +55,6 @@ import org.oppia.android.util.gcsresource.DefaultResourceBucketName
import org.oppia.android.util.parser.html.ExplorationHtmlParserEntityType
import org.oppia.android.util.system.OppiaClock
import javax.inject.Inject
import org.oppia.android.app.model.UserAnswerState

const val STATE_FRAGMENT_PROFILE_ID_ARGUMENT_KEY =
"StateFragmentPresenter.state_fragment_profile_id"
Expand Down Expand Up @@ -127,7 +127,7 @@ class StateFragmentPresenter @Inject constructor(
/* attachToRoot= */ false
)
recyclerViewAssembler = createRecyclerViewAssembler(
assemblerBuilderFactory.create(resourceBucketName, entityType, profileId,userAnswerState),
assemblerBuilderFactory.create(resourceBucketName, entityType, profileId, userAnswerState),
binding.congratulationsTextView,
binding.congratulationsTextConfettiView,
binding.fullScreenConfettiView
Expand Down Expand Up @@ -367,7 +367,7 @@ class StateFragmentPresenter @Inject constructor(
private fun subscribeToAnswerOutcome(
answerOutcomeResultLiveData: LiveData<AsyncResult<AnswerOutcome>>
) {
if (stateViewModel.getCanSubmitAnswer().get()==true){
if (stateViewModel.getCanSubmitAnswer().get() == true) {
recyclerViewAssembler.resetUserAnswerState()
}
val answerOutcomeLiveData = getAnswerOutcome(answerOutcomeResultLiveData)
Expand All @@ -392,7 +392,7 @@ class StateFragmentPresenter @Inject constructor(

/** Returns the [UserAnswerState] representing the user's current pending answer. */
fun getUserAnswerState(): UserAnswerState {
return stateViewModel.getUserAnswerState(recyclerViewAssembler::getPendingAnswerHandler)
return stateViewModel.getUserAnswerState(recyclerViewAssembler::getPendingAnswerHandler)
}

/** Helper for subscribeToAnswerOutcome. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import org.oppia.android.app.model.ProfileId
import org.oppia.android.app.model.StringList
import org.oppia.android.app.model.SubtitledHtml
import org.oppia.android.app.model.UserAnswer
import org.oppia.android.app.model.UserAnswerState
import org.oppia.android.app.model.WrittenTranslationContext
import org.oppia.android.app.player.audio.AudioUiManager
import org.oppia.android.app.player.state.StatePlayerRecyclerViewAssembler.Builder.Factory
Expand Down Expand Up @@ -93,7 +94,6 @@ import org.oppia.android.util.accessibility.AccessibilityService
import org.oppia.android.util.parser.html.HtmlParser
import org.oppia.android.util.threading.BackgroundDispatcher
import javax.inject.Inject
import org.oppia.android.app.model.UserAnswerState

private typealias AudioUiManagerRetriever = () -> AudioUiManager?

Expand Down Expand Up @@ -912,7 +912,7 @@ class StatePlayerRecyclerViewAssembler private constructor(
private val translationController: TranslationController,
private val multiTypeBuilderFactory: BindableAdapter.MultiTypeBuilder.Factory,
private val singleTypeBuilderFactory: BindableAdapter.SingleTypeBuilder.Factory,
private val userAnswerState: UserAnswerState
private val userAnswerState: UserAnswerState
) {

private val adapterBuilder: BindableAdapter.MultiTypeBuilder<StateItemViewModel,
Expand Down Expand Up @@ -1425,7 +1425,12 @@ class StatePlayerRecyclerViewAssembler private constructor(
* Returns a new [Builder] for the specified GCS resource bucket information for loading
* assets, and the current logged in [ProfileId].
*/
fun create(resourceBucketName: String, entityType: String, profileId: ProfileId,userAnswerState: UserAnswerState = UserAnswerState.getDefaultInstance()): Builder {
fun create(
resourceBucketName: String,
entityType: String,
profileId: ProfileId,
userAnswerState: UserAnswerState = UserAnswerState.getDefaultInstance()
): Builder {
return Builder(
accessibilityService,
htmlParserFactory,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import org.oppia.android.app.model.OppiaLanguage
import org.oppia.android.app.model.Profile
import org.oppia.android.app.model.ProfileId
import org.oppia.android.app.model.UserAnswer
import org.oppia.android.app.model.UserAnswerState
import org.oppia.android.app.model.WrittenTranslationLanguageSelection
import org.oppia.android.app.player.state.answerhandling.AnswerErrorCategory
import org.oppia.android.app.player.state.answerhandling.InteractionAnswerHandler
Expand All @@ -29,7 +30,6 @@ import org.oppia.android.util.locale.OppiaLocale
import org.oppia.android.util.platformparameter.EnableFastLanguageSwitchingInLesson
import org.oppia.android.util.platformparameter.PlatformParameterValue
import javax.inject.Inject
import org.oppia.android.app.model.UserAnswerState

/** [ViewModel] for state-fragment. */
@FragmentScope
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@ interface InteractionAnswerHandler {
return null
}

fun getUserAnswerState():UserAnswerState{
fun getUserAnswerState(): UserAnswerState {
return UserAnswerState.getDefaultInstance()
}

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import androidx.fragment.app.Fragment
import org.oppia.android.app.model.Interaction
import org.oppia.android.app.model.InteractionObject
import org.oppia.android.app.model.UserAnswer
import org.oppia.android.app.model.UserAnswerState
import org.oppia.android.app.model.WrittenTranslationContext
import org.oppia.android.app.player.state.answerhandling.InteractionAnswerErrorOrAvailabilityCheckReceiver
import org.oppia.android.app.player.state.answerhandling.InteractionAnswerHandler
import org.oppia.android.app.player.state.answerhandling.InteractionAnswerReceiver
import org.oppia.android.app.player.state.listener.PreviousNavigationButtonListener
import javax.inject.Inject
import org.oppia.android.app.model.UserAnswerState

// For context:
// https://github.com/oppia/oppia/blob/37285a/extensions/interactions/Continue/directives/oppia-interactive-continue.directive.ts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import org.oppia.android.app.model.StringList
import org.oppia.android.app.model.SubtitledHtml
import org.oppia.android.app.model.TranslatableHtmlContentId
import org.oppia.android.app.model.UserAnswer
import org.oppia.android.app.model.UserAnswerState
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
Expand All @@ -25,7 +26,6 @@ import org.oppia.android.app.recyclerview.OnItemDragListener
import org.oppia.android.app.translation.AppLanguageResourceHandler
import org.oppia.android.domain.translation.TranslationController
import javax.inject.Inject
import org.oppia.android.app.model.UserAnswerState

/** Represents the type of errors that can be thrown by drag and drop sort interaction. */
enum class DragAndDropSortInteractionError(@StringRes private var error: Int?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import org.oppia.android.R
import org.oppia.android.app.model.Interaction
import org.oppia.android.app.model.InteractionObject
import org.oppia.android.app.model.UserAnswer
import org.oppia.android.app.model.UserAnswerState
import org.oppia.android.app.model.WrittenTranslationContext
import org.oppia.android.app.parser.FractionParsingUiError
import org.oppia.android.app.player.state.answerhandling.AnswerErrorCategory
Expand All @@ -18,7 +19,6 @@ import org.oppia.android.app.translation.AppLanguageResourceHandler
import org.oppia.android.domain.translation.TranslationController
import org.oppia.android.util.math.FractionParser
import javax.inject.Inject
import org.oppia.android.app.model.UserAnswerState

/** [StateItemViewModel] for the fraction input interaction. */
class FractionInteractionViewModel private constructor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import org.oppia.android.app.model.ImageWithRegions
import org.oppia.android.app.model.Interaction
import org.oppia.android.app.model.InteractionObject
import org.oppia.android.app.model.UserAnswer
import org.oppia.android.app.model.UserAnswerState
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
Expand All @@ -20,7 +21,6 @@ import org.oppia.android.app.utility.NamedRegionClickedEvent
import org.oppia.android.app.utility.OnClickableAreaClickedListener
import org.oppia.android.app.utility.RegionClickedEvent
import javax.inject.Inject
import org.oppia.android.app.model.UserAnswerState

/** [StateItemViewModel] for image region selection. */
class ImageRegionSelectionInteractionViewModel private constructor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import org.oppia.android.app.model.MathEquation
import org.oppia.android.app.model.MathExpression
import org.oppia.android.app.model.OppiaLanguage
import org.oppia.android.app.model.UserAnswer
import org.oppia.android.app.model.UserAnswerState
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
Expand Down Expand Up @@ -51,7 +52,6 @@ import org.oppia.android.util.math.toPlainText
import org.oppia.android.util.math.toRawLatex
import javax.inject.Inject
import org.oppia.android.app.model.MathBinaryOperation.Operator as UnaryOperator
import org.oppia.android.app.model.UserAnswerState

/**
* [StateItemViewModel] for input for numeric expressions, algebraic expressions, and math
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import androidx.databinding.ObservableField
import org.oppia.android.app.model.Interaction
import org.oppia.android.app.model.InteractionObject
import org.oppia.android.app.model.UserAnswer
import org.oppia.android.app.model.UserAnswerState
import org.oppia.android.app.model.WrittenTranslationContext
import org.oppia.android.app.parser.StringToNumberParser
import org.oppia.android.app.player.state.answerhandling.AnswerErrorCategory
Expand All @@ -15,7 +16,6 @@ import org.oppia.android.app.player.state.answerhandling.InteractionAnswerHandle
import org.oppia.android.app.player.state.answerhandling.InteractionAnswerReceiver
import org.oppia.android.app.translation.AppLanguageResourceHandler
import javax.inject.Inject
import org.oppia.android.app.model.UserAnswerState

/** [StateItemViewModel] for the numeric input interaction. */
class NumericInputViewModel private constructor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import org.oppia.android.R
import org.oppia.android.app.model.Interaction
import org.oppia.android.app.model.InteractionObject
import org.oppia.android.app.model.UserAnswer
import org.oppia.android.app.model.UserAnswerState
import org.oppia.android.app.model.WrittenTranslationContext
import org.oppia.android.app.parser.StringToRatioParser
import org.oppia.android.app.player.state.answerhandling.AnswerErrorCategory
Expand All @@ -19,7 +20,6 @@ import org.oppia.android.app.utility.toAccessibleAnswerString
import org.oppia.android.domain.translation.TranslationController
import org.oppia.android.util.math.toAnswerString
import javax.inject.Inject
import org.oppia.android.app.model.UserAnswerState

/** [StateItemViewModel] for the ratio expression input interaction. */
class RatioExpressionInputInteractionViewModel private constructor(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.oppia.android.app.player.state.itemviewmodel

import android.util.Log
import androidx.annotation.StringRes
import androidx.databinding.Observable
import androidx.databinding.ObservableBoolean
Expand All @@ -9,10 +8,12 @@ import androidx.databinding.ObservableList
import org.oppia.android.R
import org.oppia.android.app.model.Interaction
import org.oppia.android.app.model.InteractionObject
import org.oppia.android.app.model.ItemSelectionAnswerState
import org.oppia.android.app.model.SetOfTranslatableHtmlContentIds
import org.oppia.android.app.model.SubtitledHtml
import org.oppia.android.app.model.TranslatableHtmlContentId
import org.oppia.android.app.model.UserAnswer
import org.oppia.android.app.model.UserAnswerState
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
Expand All @@ -22,8 +23,6 @@ import org.oppia.android.app.translation.AppLanguageResourceHandler
import org.oppia.android.app.viewmodel.ObservableArrayList
import org.oppia.android.domain.translation.TranslationController
import javax.inject.Inject
import org.oppia.android.app.model.ItemSelectionAnswerState
import org.oppia.android.app.model.UserAnswerState

/** Corresponds to the type of input that should be used for an item selection interaction view. */
enum class SelectionItemInputType {
Expand Down Expand Up @@ -120,8 +119,8 @@ class SelectionInteractionViewModel private constructor(
}
}

override fun getUserAnswerState():UserAnswerState {
return UserAnswerState.newBuilder().apply {
override fun getUserAnswerState(): UserAnswerState {
return UserAnswerState.newBuilder().apply {
this.itemSelection = ItemSelectionAnswerState.newBuilder().addAllSelectedIndexes(
selectedItems
).build()
Expand Down Expand Up @@ -160,7 +159,7 @@ class SelectionInteractionViewModel private constructor(
* It checks the pending error for the current selection input, and correspondingly
* updates the error string based on the specified error category.
*/
override fun checkPendingAnswerError(category:AnswerErrorCategory): String? {
override fun checkPendingAnswerError(category: AnswerErrorCategory): String? {
pendingAnswerError = when (category) {
AnswerErrorCategory.REAL_TIME -> null
AnswerErrorCategory.SUBMIT_TIME ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import org.oppia.android.R
import org.oppia.android.app.model.Interaction
import org.oppia.android.app.model.InteractionObject
import org.oppia.android.app.model.UserAnswer
import org.oppia.android.app.model.UserAnswerState
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
Expand All @@ -17,7 +18,6 @@ import org.oppia.android.app.player.state.answerhandling.InteractionAnswerReceiv
import org.oppia.android.app.translation.AppLanguageResourceHandler
import org.oppia.android.domain.translation.TranslationController
import javax.inject.Inject
import org.oppia.android.app.model.UserAnswerState

/** [StateItemViewModel] for the text input interaction. */
class TextInputViewModel private constructor(
Expand Down

0 comments on commit 673ba94

Please sign in to comment.