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
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:9b63fbb772c0d6855f2bc4ddd79e9303102bdcd8)
Merged-In: I6cad869e3a51926405a6f3ae894daa5416050bf8
Change-Id: I6cad869e3a51926405a6f3ae894daa5416050bf8
diff --git a/res/layout/search_bar.xml b/res/layout/search_bar.xml
index 1e83e22..5f6f9c5 100644
--- a/res/layout/search_bar.xml
+++ b/res/layout/search_bar.xml
@@ -34,8 +34,7 @@
android:paddingStart="@dimen/search_bar_padding_start"
android:paddingEnd="@dimen/search_bar_padding_end"
android:background="@drawable/search_bar_selected_background"
- android:focusable="true"
- android:focusableInTouchMode="true"
+ android:touchscreenBlocksFocus="false"
android:nextFocusForward="@+id/homepage_container"
android:contentInsetStartWithNavigation="@dimen/search_bar_content_inset"
android:navigationIcon="@drawable/ic_homepage_search">
diff --git a/res/layout/search_bar_two_pane_version.xml b/res/layout/search_bar_two_pane_version.xml
index 337294e..dec1c45 100644
--- a/res/layout/search_bar_two_pane_version.xml
+++ b/res/layout/search_bar_two_pane_version.xml
@@ -29,8 +29,7 @@
android:paddingStart="@dimen/search_bar_padding_start_two_pane"
android:paddingEnd="@dimen/search_bar_padding_end_two_pane"
android:background="@drawable/search_bar_selected_background"
- android:focusable="true"
- android:focusableInTouchMode="true"
+ android:touchscreenBlocksFocus="false"
android:nextFocusForward="@+id/homepage_container"
android:contentInsetStartWithNavigation="@dimen/search_bar_content_inset"
android:navigationIcon="@drawable/ic_homepage_search">
diff --git a/src/com/android/settings/search/SearchFeatureProvider.java b/src/com/android/settings/search/SearchFeatureProvider.java
index b1d04d4..5707bc2 100644
--- a/src/com/android/settings/search/SearchFeatureProvider.java
+++ b/src/com/android/settings/search/SearchFeatureProvider.java
@@ -100,6 +100,7 @@
// and goes to the search UI. Also set the background to null so there's no ripple.
final View navView = toolbar.getNavigationView();
navView.setClickable(false);
+ navView.setFocusable(false);
navView.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
navView.setBackground(null);