File tree Expand file tree Collapse file tree 3 files changed +33
-0
lines changed
lib/java/com/google/android/material/snackbar
tests/javatests/com/google/android/material/snackbar Expand file tree Collapse file tree 3 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -388,6 +388,8 @@ protected BaseTransientBottomBar(
388388
389389 view .setAccessibilityLiveRegion (View .ACCESSIBILITY_LIVE_REGION_POLITE );
390390 view .setImportantForAccessibility (View .IMPORTANT_FOR_ACCESSIBILITY_YES );
391+ ViewCompat .setAccessibilityPaneTitle (
392+ view , getContext ().getString (R .string .snackbar_accessibility_pane_title ));
391393
392394 // Make sure that we fit system windows and have a listener to apply any insets
393395 view .setFitsSystemWindows (true );
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" utf-8" ?>
2+ <!--
3+ ~ Copyright (C) 2024 The Android Open Source Project
4+ ~
5+ ~ Licensed under the Apache License, Version 2.0 (the "License");
6+ ~ you may not use this file except in compliance with the License.
7+ ~ You may obtain a copy of the License at
8+ ~
9+ ~ http://www.apache.org/licenses/LICENSE-2.0
10+ ~
11+ ~ Unless required by applicable law or agreed to in writing, software
12+ ~ distributed under the License is distributed on an "AS IS" BASIS,
13+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+ ~ See the License for the specific language governing permissions and
15+ ~ limitations under the License.
16+ -->
17+ <resources xmlns : tools =" http://schemas.android.com/tools" >
18+ <!-- An accessibility pane title for a Snackbar. [CHAR LIMIT=NONE] -->
19+ <string name =" snackbar_accessibility_pane_title" >Alert</string >
20+ </resources >
Original file line number Diff line number Diff line change 2929import static com .google .android .material .testutils .TestUtilsActions .setLayoutDirection ;
3030import static org .hamcrest .Matchers .not ;
3131import static org .hamcrest .core .AllOf .allOf ;
32+ import static org .junit .Assert .assertEquals ;
3233import static org .junit .Assert .assertFalse ;
3334import static org .junit .Assert .assertTrue ;
3435import static org .mockito .ArgumentMatchers .any ;
@@ -399,6 +400,16 @@ public void testMultipleCallbacksWithRemoval() throws Throwable {
399400 .onDismissed (snackbar , BaseTransientBottomBar .BaseCallback .DISMISS_EVENT_MANUAL );
400401 }
401402
403+ @ Test
404+ public void testAccessibilityPaneTitle () throws Throwable {
405+ final Snackbar snackbar =
406+ Snackbar .make (coordinatorLayout , MESSAGE_TEXT , Snackbar .LENGTH_INDEFINITE )
407+ .setAction (ACTION_TEXT , mock (View .OnClickListener .class ));
408+ assertEquals (
409+ snackbar .getContext ().getString (R .string .snackbar_accessibility_pane_title ),
410+ ViewCompat .getAccessibilityPaneTitle (snackbar .getView ()).toString ());
411+ }
412+
402413 @ Test
403414 public void testDefaultContext_usesAppCompat () throws Throwable {
404415 final Snackbar snackbar =
You can’t perform that action at this time.
0 commit comments