Skip to content

Commit

Permalink
Fix oppia#3676: [RTL] Image click input in Exploration. (oppia#3677)
Browse files Browse the repository at this point in the history
* Update selection_interaction_item.xml

* Update selection_interaction_item.xml

* Update return_to_topic_button_item.xml

* Update return_to_topic_button_item.xml

* Update ClickableAreasImage.kt
  • Loading branch information
veena14cs authored Aug 16, 2021
1 parent 7aa1750 commit 54e79d0
Showing 1 changed file with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import org.oppia.android.R
import org.oppia.android.app.model.ImageWithRegions
import org.oppia.android.app.player.state.ImageRegionSelectionInteractionView
import org.oppia.android.app.shim.ViewBindingShim
import org.oppia.android.domain.oppialogger.OppiaLogger
import javax.inject.Inject
import kotlin.math.roundToInt

/**
Expand All @@ -30,6 +32,9 @@ class ClickableAreasImage(
}
}

@Inject
lateinit var oppiaLogger: OppiaLogger

/**
* Called when an image is clicked.
*
Expand Down Expand Up @@ -70,7 +75,7 @@ class ClickableAreasImage(
}

private fun getImageViewContentWidth(): Int {
return imageView.width - imageView.paddingLeft - imageView.paddingRight
return imageView.width - imageView.paddingStart - imageView.paddingEnd
}

private fun getImageViewContentHeight(): Int {
Expand All @@ -81,7 +86,16 @@ class ClickableAreasImage(
fun addRegionViews() {
parentView.let {
if (it.childCount > 2) {
it.removeViews(2, it.childCount - 1) // remove all other views
try {
it.removeViews(2, it.childCount - 1) // remove all other views
} catch (e: IndexOutOfBoundsException) {
if (::oppiaLogger.isInitialized)
oppiaLogger.e(
"ClickableAreaImage",
"Throws exception on Index out of bound",
e
)
}
}
imageView.getClickableAreas().forEach { clickableArea ->
val imageRect = RectF(
Expand Down

0 comments on commit 54e79d0

Please sign in to comment.