Commit 76792526 authored by Christian Dullweber's avatar Christian Dullweber Committed by Commit Bot

Improve accessibility of PageInfo

Make row views selectable. Make divider views unselectable.

Bug: 1077766
Change-Id: I688acf9b3d8161ae4914a9417de961452a7bc47b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2424003
Commit-Queue: Christian Dullweber <dullweber@chromium.org>
Reviewed-by: default avatarEhimare Okoyomon <eokoyomon@chromium.org>
Cr-Commit-Position: refs/heads/master@{#809831}
parent 65e79b3a
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
<org.chromium.components.browser_ui.settings.ChromeBasePreference <org.chromium.components.browser_ui.settings.ChromeBasePreference
android:key="os_permissions_warning_extra" /> android:key="os_permissions_warning_extra" />
<Preference <Preference
android:selectable="false"
android:key="os_permissions_warning_divider" android:key="os_permissions_warning_divider"
android:layout="@layout/divider_preference" /> android:layout="@layout/divider_preference" />
<org.chromium.components.browser_ui.settings.TextMessagePreference <org.chromium.components.browser_ui.settings.TextMessagePreference
...@@ -24,6 +25,7 @@ ...@@ -24,6 +25,7 @@
android:icon="@drawable/btn_info" android:icon="@drawable/btn_info"
app:iconTint="@color/default_icon_color" /> app:iconTint="@color/default_icon_color" />
<Preference <Preference
android:selectable="false"
android:key="intrusive_ads_info_divider" android:key="intrusive_ads_info_divider"
android:layout="@layout/divider_preference" /> android:layout="@layout/divider_preference" />
<PreferenceCategory <PreferenceCategory
......
...@@ -5,44 +5,41 @@ ...@@ -5,44 +5,41 @@
Use of this source code is governed by a BSD-style license that can be Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. found in the LICENSE file.
--> -->
<merge
<RelativeLayout
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"
xmlns:tools="http://schemas.android.com/tools"> xmlns:tools="http://schemas.android.com/tools"
<RelativeLayout android:layout_width="match_parent"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:layout_height="match_parent" android:background="?attr/selectableItemBackground"
android:paddingTop="12dp" android:paddingHorizontal="@dimen/page_info_popup_padding_sides"
android:paddingBottom="12dp" android:paddingVertical="12dp">
android:paddingEnd="@dimen/page_info_popup_padding_sides"
android:paddingStart="@dimen/page_info_popup_padding_sides" >
<ImageView
android:id="@+id/page_info_row_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:ignore="ContentDescription"
android:layout_marginEnd="32dp"
android:layout_centerVertical="true"
android:layout_alignParentStart="true"
app:tint="@color/default_icon_color" />
<org.chromium.ui.widget.TextViewWithLeading <ImageView
android:id="@+id/page_info_row_title" android:id="@+id/page_info_row_icon"
android:textAppearance="@style/TextAppearance.TextLarge.Primary" android:layout_width="wrap_content"
android:layout_toEndOf="@id/page_info_row_icon" android:layout_height="wrap_content"
android:layout_marginBottom="4dp" android:layout_alignParentStart="true"
android:layout_height="wrap_content" android:layout_centerVertical="true"
android:layout_width="match_parent" /> android:layout_marginEnd="32dp"
app:tint="@color/default_icon_color"
tools:ignore="ContentDescription" />
<org.chromium.ui.widget.TextViewWithLeading <org.chromium.ui.widget.TextViewWithLeading
android:id="@+id/page_info_row_subtitle" android:id="@+id/page_info_row_title"
android:textAppearance="@style/TextAppearance.TextMedium.Secondary" android:layout_width="match_parent"
android:layout_toEndOf="@id/page_info_row_icon" android:layout_height="wrap_content"
android:layout_below="@id/page_info_row_title" android:layout_marginBottom="4dp"
app:leading="@dimen/text_size_medium_leading" android:layout_toEndOf="@id/page_info_row_icon"
android:layout_height="wrap_content" android:textAppearance="@style/TextAppearance.TextLarge.Primary" />
android:layout_width="match_parent" />
</RelativeLayout> <org.chromium.ui.widget.TextViewWithLeading
</merge> android:id="@+id/page_info_row_subtitle"
\ No newline at end of file android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/page_info_row_title"
android:layout_toEndOf="@id/page_info_row_icon"
android:textAppearance="@style/TextAppearance.TextMedium.Secondary"
app:leading="@dimen/text_size_medium_leading" />
</RelativeLayout>
...@@ -7,10 +7,8 @@ package org.chromium.components.page_info; ...@@ -7,10 +7,8 @@ package org.chromium.components.page_info;
import android.content.Context; import android.content.Context;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.widget.FrameLayout;
import android.view.View.OnClickListener;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.DrawableRes; import androidx.annotation.DrawableRes;
...@@ -20,7 +18,7 @@ import androidx.annotation.Nullable; ...@@ -20,7 +18,7 @@ import androidx.annotation.Nullable;
/** /**
* View showing an icon, title and subtitle for a page info row. * View showing an icon, title and subtitle for a page info row.
*/ */
public class PageInfoRowView extends RelativeLayout implements OnClickListener { public class PageInfoRowView extends FrameLayout {
/** Parameters to configure the row view. */ /** Parameters to configure the row view. */
public static class ViewParams { public static class ViewParams {
public boolean visible; public boolean visible;
...@@ -33,7 +31,6 @@ public class PageInfoRowView extends RelativeLayout implements OnClickListener { ...@@ -33,7 +31,6 @@ public class PageInfoRowView extends RelativeLayout implements OnClickListener {
private final ImageView mIcon; private final ImageView mIcon;
private final TextView mTitle; private final TextView mTitle;
private final TextView mSubtitle; private final TextView mSubtitle;
private Runnable mClickCallback;
public PageInfoRowView(@NonNull Context context, @Nullable AttributeSet attrs) { public PageInfoRowView(@NonNull Context context, @Nullable AttributeSet attrs) {
super(context, attrs); super(context, attrs);
...@@ -44,24 +41,20 @@ public class PageInfoRowView extends RelativeLayout implements OnClickListener { ...@@ -44,24 +41,20 @@ public class PageInfoRowView extends RelativeLayout implements OnClickListener {
} }
public void setParams(ViewParams params) { public void setParams(ViewParams params) {
setVisibility(params.visible ? View.VISIBLE : View.GONE); setVisibility(params.visible ? VISIBLE : GONE);
mIcon.setImageResource(params.iconResId); mIcon.setImageResource(params.iconResId);
mTitle.setText(params.title); mTitle.setText(params.title);
mTitle.setVisibility(params.title != null ? View.VISIBLE : View.GONE); mTitle.setVisibility(params.title != null ? VISIBLE : GONE);
updateSubtitle(params.subtitle); updateSubtitle(params.subtitle);
mClickCallback = params.clickCallback; if (params.clickCallback != null) {
setOnClickListener(this); setClickable(true);
setFocusable(true);
getChildAt(0).setOnClickListener((v) -> params.clickCallback.run());
}
} }
public void updateSubtitle(String subtitle) { public void updateSubtitle(String subtitle) {
mSubtitle.setText(subtitle); mSubtitle.setText(subtitle);
mSubtitle.setVisibility(subtitle != null ? View.VISIBLE : View.GONE); mSubtitle.setVisibility(subtitle != null ? VISIBLE : GONE);
}
@Override
public void onClick(View view) {
if (mClickCallback != null) {
mClickCallback.run();
}
} }
} }
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