Bug 1838580 - [a11y] Increase tap area for search engine icon

The touching area for search engine icon (Google by default) from
the search bar was only 28dp.
To Increase tap area to reach the minimum accessibility touch target
size of 48dp, it was used TouchDelegate. This way there are no visual
changes.
fenix/124.1.0
RebecaTudor 5 months ago committed by mergify[bot]
parent f1ea102053
commit 22e4f2b9e4

@ -30,6 +30,23 @@ fun View.increaseTapArea(@Dimension(unit = DP) extraDps: Int) {
}
}
/**
* Increase tap area only vertically.
*
* @param extraDps the extra dps that's wanted to be added on top and bottom of the view
*/
fun View.increaseTapAreaVertically(@Dimension(unit = DP) extraDps: Int) {
val dips = extraDps.dpToPx(resources.displayMetrics)
val parent = this.parent as View
parent.post {
val touchArea = Rect()
getHitRect(touchArea)
touchArea.top -= dips
touchArea.bottom += dips
parent.touchDelegate = TouchDelegate(touchArea, this)
}
}
fun View.removeTouchDelegate() {
val parent = this.parent as View
parent.post {

@ -20,6 +20,7 @@ import mozilla.components.support.ktx.android.content.getColorFromAttr
import org.mozilla.fenix.GleanMetrics.UnifiedSearch
import org.mozilla.fenix.R
import org.mozilla.fenix.databinding.FragmentHomeBinding
import org.mozilla.fenix.ext.increaseTapAreaVertically
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.search.toolbar.SearchSelectorMenu
@ -51,6 +52,8 @@ class SearchSelectorBinding(
orientation = orientation,
)
}
increaseTapAreaVertically(SEARCH_SELECTOR_INCREASE_HEIGHT_DPS)
}
}
@ -76,4 +79,8 @@ class SearchSelectorBinding(
binding.searchSelectorButton.setIcon(icon, name)
}
}
companion object {
const val SEARCH_SELECTOR_INCREASE_HEIGHT_DPS = 10
}
}

Loading…
Cancel
Save