Skip to content

Commit

Permalink
ANDROID-14435 Make bottom sheet handle accessible in order to be able…
Browse files Browse the repository at this point in the history
… to close window on tap (#338)
  • Loading branch information
dpastor authored Apr 4, 2024
1 parent d2661a8 commit 51a52c9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package com.telefonica.mistica.catalog.ui
import android.os.Bundle
import android.view.View
import androidx.annotation.StyleRes
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.runtime.Composable
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
Expand Down Expand Up @@ -79,7 +80,7 @@ import com.telefonica.mistica.compose.theme.brand.TuBrand
import com.telefonica.mistica.compose.theme.brand.VivoBrand
import com.telefonica.mistica.compose.theme.brand.VivoNewBrand

class ComponentCatalogActivity : FragmentActivity() {
class ComponentCatalogActivity : AppCompatActivity() {

private lateinit var binding: ScreenComponentCatalogBinding

Expand Down
5 changes: 5 additions & 0 deletions library/src/main/java/com/telefonica/mistica/sheet/Sheet.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import android.widget.LinearLayout
import android.widget.Space
import android.widget.TextView
import androidx.coordinatorlayout.widget.CoordinatorLayout
import androidx.core.view.ViewCompat
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.ViewModelStoreOwner
import androidx.lifecycle.setViewTreeLifecycleOwner
Expand Down Expand Up @@ -49,6 +50,8 @@ open class SheetView(
}

val root = View.inflate(getContext(), R.layout.sheet_layout, null)
/* In case no accessibility pane title is specified, Talkback reads twice first element in Bottom Sheet */
ViewCompat.setAccessibilityPaneTitle(root, " ")
setContentView(root)
setUpBehavior(root)
fillData(root, sheetModel, context, onSheetTappedWrapped)
Expand Down Expand Up @@ -86,6 +89,7 @@ open class SheetView(
root: View,
sheetModel: SheetModel,
) {
val handler = root.findViewById<View>(R.id.handler)
val title = root.findViewById<TextView>(R.id.title)
val subtitle = root.findViewById<TextView>(R.id.subtitle)
val description = root.findViewById<TextView>(R.id.description)
Expand All @@ -95,6 +99,7 @@ open class SheetView(
val subtitleText = sheetModel.header.subtitle
val descriptionText = sheetModel.header.description

handler.setOnClickListener { cancel() }
title.setTextOrHide(titleText)
titleSpace.setSpaceOrGone(titleText)
subtitle.setTextOrHide(subtitleText)
Expand Down
8 changes: 5 additions & 3 deletions library/src/main/res/layout/sheet_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
android:id="@+id/handler"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:importantForAccessibility="no"
android:padding="8dp"
android:contentDescription="@string/close_button_content_description"
android:clickable="true"
android:focusable="true"
android:layout_gravity="center"
app:srcCompat="@drawable/sheet_handler"
/>
Expand All @@ -24,7 +26,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="16dp"
android:paddingTop="20dp"
android:paddingTop="12dp"
android:paddingBottom="8dp"
tools:ignore="RtlSymmetry"
tools:text="Title"
Expand Down

0 comments on commit 51a52c9

Please sign in to comment.