Commit 6eced5f2 authored by Simon La Macchia's avatar Simon La Macchia Committed by Commit Bot

Add Bluetooth keyboard support to Protected media content site setting

Problem: The Protected media content Site Setting does not support
Bluetooth keyboard navigation. The three radio buttons are treated as
one clickable target, making the individual radio buttons unselectable.

Solution: Make radio buttons selectable and clickable to support
navigation with a Bluetooth keyboard.
This behavior matches existsing Chrome settings support for Bluetooth
keyboard navigation.
This change does not affect navigate by touch and will work the same as
before.

R=twellington@chromium.org

Bug: 936143
Change-Id: Ib14c4515d5a70fa0cb8344727b367e2c9260c36c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1490016Reviewed-by: default avatarTheresa <twellington@chromium.org>
Reviewed-by: default avatarXiaohan Wang <xhwang@chromium.org>
Commit-Queue: Simon La Macchia <smacchia@amazon.com>
Cr-Commit-Position: refs/heads/master@{#638400}
parent 00ca4c98
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="16dp" android:layout_marginTop="16dp"
android:background="?android:attr/selectableItemBackground"
app:titleText="@string/sync_import_existing_data" /> app:titleText="@string/sync_import_existing_data" />
<org.chromium.chrome.browser.widget.RadioButtonWithDescription <org.chromium.chrome.browser.widget.RadioButtonWithDescription
...@@ -36,6 +37,7 @@ ...@@ -36,6 +37,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="16dp" android:layout_marginTop="16dp"
android:background="?android:attr/selectableItemBackground"
app:titleText="@string/sync_keep_existing_data_separate" /> app:titleText="@string/sync_keep_existing_data_separate" />
</LinearLayout> </LinearLayout>
......
...@@ -12,6 +12,9 @@ ...@@ -12,6 +12,9 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:clickable="false"
android:focusable="false"
android:background="@null"
android:paddingEnd="16dp" /> android:paddingEnd="16dp" />
<TextView <TextView
......
...@@ -8,9 +8,9 @@ ...@@ -8,9 +8,9 @@
<LinearLayout <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
style="@style/PreferenceLayout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:focusable="false"
android:orientation="vertical"> android:orientation="vertical">
<org.chromium.chrome.browser.widget.RadioButtonWithDescription <org.chromium.chrome.browser.widget.RadioButtonWithDescription
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="16dp" android:layout_marginBottom="16dp"
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
android:background="?android:attr/selectableItemBackground"
app:titleText="@string/website_settings_category_allowed" /> app:titleText="@string/website_settings_category_allowed" />
<org.chromium.chrome.browser.widget.RadioButtonWithDescription <org.chromium.chrome.browser.widget.RadioButtonWithDescription
...@@ -25,11 +27,15 @@ ...@@ -25,11 +27,15 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="16dp" android:layout_marginBottom="16dp"
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
android:background="?android:attr/selectableItemBackground"
app:titleText="@string/website_settings_category_ask" /> app:titleText="@string/website_settings_category_ask" />
<org.chromium.chrome.browser.widget.RadioButtonWithDescription <org.chromium.chrome.browser.widget.RadioButtonWithDescription
android:id="@+id/blocked" android:id="@+id/blocked"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
android:background="?android:attr/selectableItemBackground"
app:titleText="@string/website_settings_category_blocked" /> app:titleText="@string/website_settings_category_blocked" />
</LinearLayout> </LinearLayout>
...@@ -29,6 +29,11 @@ public class TriStateSiteSettingsPreference ...@@ -29,6 +29,11 @@ public class TriStateSiteSettingsPreference
public TriStateSiteSettingsPreference(Context context, AttributeSet attrs) { public TriStateSiteSettingsPreference(Context context, AttributeSet attrs) {
super(context, attrs); super(context, attrs);
// Make unselectable, otherwise TriStateSiteSettingsPreference is treated as one
// selectable Preference, instead of three selectable radio buttons.
// Allows radio buttons to be selected via Bluetooth keyboard (key events).
// See: crbug.com/936143
setSelectable(false);
} }
/** /**
......
...@@ -55,8 +55,10 @@ public class RadioButtonWithDescription extends RelativeLayout implements OnClic ...@@ -55,8 +55,10 @@ public class RadioButtonWithDescription extends RelativeLayout implements OnClic
if (attrs != null) applyAttributes(attrs); if (attrs != null) applyAttributes(attrs);
// We want RadioButtonWithDescription to handle the clicks itself. // We want RadioButtonWithDescription to handle the clicks itself.
mRadioButton.setClickable(false);
setOnClickListener(this); setOnClickListener(this);
// Make it focusable for navigation via key events (tab/up/down keys)
// with Bluetooth keyboard. See: crbug.com/936143
setFocusable(true);
} }
private void applyAttributes(AttributeSet attrs) { private void applyAttributes(AttributeSet attrs) {
...@@ -111,6 +113,10 @@ public class RadioButtonWithDescription extends RelativeLayout implements OnClic ...@@ -111,6 +113,10 @@ public class RadioButtonWithDescription extends RelativeLayout implements OnClic
*/ */
public void setChecked(boolean checked) { public void setChecked(boolean checked) {
mRadioButton.setChecked(checked); mRadioButton.setChecked(checked);
// Retain focus on RadioButtonWithDescription after radio button is checked.
// Otherwise focus is lost. This is required for Bluetooth keyboard navigation.
// See: crbug.com/936143
if (checked) requestFocus();
} }
public void setOnCheckedChangeListener(OnCheckedChangeListener listener) { public void setOnCheckedChangeListener(OnCheckedChangeListener listener) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment