Fix toolbar keyboard navigation and touch.

- toolbar default has touchscreenBlocksFocus enabled which make toolbar not focusable when touch screen present. Explicitly set touchscreenBlocksFocus to false make the toolbar can be focus when keyboard navigation.
- Remove focusableInTouchMode which breaks normal touch control. Read https://android-developers.googleblog.com/2008/12/touch-mode.html for more details.

Fix: 327025582
Fix: 324420544
Test: manual test with keyboard and touch navigation

Change-Id: I6cad869e3a51926405a6f3ae894daa5416050bf8
(cherry picked from commit 9b63fbb772)
This commit is contained in:
David Liu
2024-03-01 06:59:03 +00:00
committed by Yvonne Lin
parent bfb4086689
commit 033080b61d
3 changed files with 3 additions and 4 deletions

View File

@@ -34,8 +34,7 @@
android:paddingStart="@dimen/search_bar_padding_start" android:paddingStart="@dimen/search_bar_padding_start"
android:paddingEnd="@dimen/search_bar_padding_end" android:paddingEnd="@dimen/search_bar_padding_end"
android:background="@drawable/search_bar_selected_background" android:background="@drawable/search_bar_selected_background"
android:focusable="true" android:touchscreenBlocksFocus="false"
android:focusableInTouchMode="true"
android:nextFocusForward="@+id/homepage_container" android:nextFocusForward="@+id/homepage_container"
android:contentInsetStartWithNavigation="@dimen/search_bar_content_inset" android:contentInsetStartWithNavigation="@dimen/search_bar_content_inset"
android:navigationIcon="@drawable/ic_homepage_search"> android:navigationIcon="@drawable/ic_homepage_search">

View File

@@ -29,8 +29,7 @@
android:paddingStart="@dimen/search_bar_padding_start_two_pane" android:paddingStart="@dimen/search_bar_padding_start_two_pane"
android:paddingEnd="@dimen/search_bar_padding_end_two_pane" android:paddingEnd="@dimen/search_bar_padding_end_two_pane"
android:background="@drawable/search_bar_selected_background" android:background="@drawable/search_bar_selected_background"
android:focusable="true" android:touchscreenBlocksFocus="false"
android:focusableInTouchMode="true"
android:nextFocusForward="@+id/homepage_container" android:nextFocusForward="@+id/homepage_container"
android:contentInsetStartWithNavigation="@dimen/search_bar_content_inset" android:contentInsetStartWithNavigation="@dimen/search_bar_content_inset"
android:navigationIcon="@drawable/ic_homepage_search"> android:navigationIcon="@drawable/ic_homepage_search">

View File

@@ -100,6 +100,7 @@ public interface SearchFeatureProvider {
// and goes to the search UI. Also set the background to null so there's no ripple. // and goes to the search UI. Also set the background to null so there's no ripple.
final View navView = toolbar.getNavigationView(); final View navView = toolbar.getNavigationView();
navView.setClickable(false); navView.setClickable(false);
navView.setFocusable(false);
navView.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO); navView.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
navView.setBackground(null); navView.setBackground(null);