Commit 0fc6aab6 authored by Mehran Mahmoudi's avatar Mehran Mahmoudi Committed by Commit Bot

Fix focus issue in Protected Media settings

This fixes an issue in Protected Media settings that happens on small
screens when using keyboard input. It prevents focusing the
TriStateSiteSettingsPreference items using directional keys.

Bug: 974413
Change-Id: I8c432774ba92dc9a2419ccdbd57946e69c11db9f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1680832Reviewed-by: default avatarFinnur Thorarinsson <finnur@chromium.org>
Commit-Queue: Mehran Mahmoudi <mahmoudi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#673335}
parent a8c16f39
...@@ -88,6 +88,8 @@ public class SingleCategoryPreferences extends PreferenceFragment ...@@ -88,6 +88,8 @@ public class SingleCategoryPreferences extends PreferenceFragment
*/ */
public static final String EXTRA_SELECTED_DOMAINS = "selected_domains"; public static final String EXTRA_SELECTED_DOMAINS = "selected_domains";
// The list that contains preferences.
private ListView mListView;
// The view to show when the list is empty. // The view to show when the list is empty.
private TextView mEmptyView; private TextView mEmptyView;
// The item for searching the list of items. // The item for searching the list of items.
...@@ -325,10 +327,10 @@ public class SingleCategoryPreferences extends PreferenceFragment ...@@ -325,10 +327,10 @@ public class SingleCategoryPreferences extends PreferenceFragment
@Override @Override
public void onActivityCreated(Bundle savedInstanceState) { public void onActivityCreated(Bundle savedInstanceState) {
PreferenceUtils.addPreferencesFromResource(this, R.xml.website_preferences); PreferenceUtils.addPreferencesFromResource(this, R.xml.website_preferences);
ListView listView = (ListView) getView().findViewById(android.R.id.list); mListView = (ListView) getView().findViewById(android.R.id.list);
mEmptyView = (TextView) getView().findViewById(android.R.id.empty); mEmptyView = (TextView) getView().findViewById(android.R.id.empty);
listView.setEmptyView(mEmptyView); mListView.setEmptyView(mEmptyView);
listView.setDivider(null); mListView.setDivider(null);
mClearButton = (Button) getView().findViewById(R.id.clear_button); mClearButton = (Button) getView().findViewById(R.id.clear_button);
if (mClearButton != null) mClearButton.setOnClickListener(this); if (mClearButton != null) mClearButton.setOnClickListener(this);
...@@ -882,6 +884,11 @@ public class SingleCategoryPreferences extends PreferenceFragment ...@@ -882,6 +884,11 @@ public class SingleCategoryPreferences extends PreferenceFragment
// Only show the link that explains protected content settings when needed. // Only show the link that explains protected content settings when needed.
if (!mCategory.showSites(SiteSettingsCategory.Type.PROTECTED_MEDIA)) { if (!mCategory.showSites(SiteSettingsCategory.Type.PROTECTED_MEDIA)) {
screen.removePreference(explainProtectedMediaKey); screen.removePreference(explainProtectedMediaKey);
mListView.setFocusable(true);
} else {
// On small screens with no touch input, nested focusable items inside a LinearLayout in
// ListView cause focus problems when using a keyboard (crbug.com/974413).
mListView.setFocusable(false);
} }
// When this menu opens, make sure the Blocked list is collapsed. // When this menu opens, make sure the Blocked list is collapsed.
......
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