Commit 880e1a51 authored by Jordan Demeulenaere's avatar Jordan Demeulenaere Committed by Commit Bot

[Autofill Assistant] Improve TalkBack support.

Bug: b/135203438
Bug: b/132337665
Change-Id: I3986904c234cd739689c50c49525327ba42b35ad
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1669352
Auto-Submit: Jordan Demeulenaere <jdemeulenaere@chromium.org>
Reviewed-by: default avatarMathias Carlen <mcarlen@chromium.org>
Commit-Queue: Jordan Demeulenaere <jdemeulenaere@chromium.org>
Cr-Commit-Position: refs/heads/master@{#670870}
parent 5cf576bf
......@@ -6,7 +6,6 @@
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="40dp"
......@@ -35,8 +34,8 @@
android:layout_height="32dp"
android:padding="4dp"
android:tint="@color/filled_button_bg"
app:srcCompat="@drawable/ic_remove_outline_white_24dp"
tools:ignore="ContentDescription"/>
android:contentDescription="@string/autofill_assistant_decrease_value"
app:srcCompat="@drawable/ic_remove_outline_white_24dp"/>
<TextView
android:id="@+id/value"
android:layout_width="wrap_content"
......@@ -50,6 +49,6 @@
android:layout_height="32dp"
android:padding="4dp"
android:tint="@color/filled_button_bg"
app:srcCompat="@drawable/ic_add_outline_white_24dp"
tools:ignore="ContentDescription"/>
android:contentDescription="@string/autofill_assistant_increase_value"
app:srcCompat="@drawable/ic_add_outline_white_24dp"/>
</LinearLayout>
......@@ -85,19 +85,35 @@ public class AssistantChipViewHolder extends ViewHolder {
}
mView.setOnClickListener(ignoredView -> chip.getSelectedListener().run());
mView.setIcon(getIconResource(chip.getIcon()), /* tintWithTextColor= */ true);
}
private int getIconResource(@AssistantChip.Icon int icon) {
switch (icon) {
int iconResource;
int iconDescriptionResource = 0;
switch (chip.getIcon()) {
case AssistantChip.Icon.CLEAR:
return R.drawable.ic_clear_black_24dp;
iconResource = R.drawable.ic_clear_black_24dp;
iconDescriptionResource = R.string.close;
break;
case AssistantChip.Icon.DONE:
return R.drawable.ic_done_black_24dp;
iconResource = R.drawable.ic_done_black_24dp;
iconDescriptionResource = R.string.done;
break;
case AssistantChip.Icon.REFRESH:
return R.drawable.ic_refresh_black_24dp;
iconResource = R.drawable.ic_refresh_black_24dp;
iconDescriptionResource = R.string.menu_refresh;
break;
default:
return ButtonView.INVALID_ICON_ID;
iconResource = ButtonView.INVALID_ICON_ID;
break;
}
mView.setIcon(iconResource, /* tintWithTextColor= */ true);
// We set the content description of the icon on the whole button view if there is no text.
// Otherwise the text description will be used by TalkBack.
if (iconDescriptionResource != 0 && text.isEmpty()) {
mView.setContentDescription(mView.getContext().getString(iconDescriptionResource));
} else {
mView.setContentDescription(null);
}
}
}
......@@ -16,6 +16,7 @@ import android.view.ViewGroup;
import android.widget.TextView;
import org.chromium.chrome.autofill_assistant.R;
import org.chromium.chrome.browser.util.AccessibilityUtil;
import java.util.ArrayList;
import java.util.List;
......@@ -77,9 +78,12 @@ class AssistantFormCounterInput extends AssistantFormInput {
mMinimizeText = minimizeText;
mCounters = counters;
// Don't show the expandable section if there is no text to show when minimized/expanded.
mMinimizedCount =
expandText.isEmpty() || minimizeText.isEmpty() ? Integer.MAX_VALUE : minimizedCount;
// Don't show the expandable section if there is no text to show when minimized/expanded, or
// when TalkBack is enabled.
mMinimizedCount = expandText.isEmpty() || minimizeText.isEmpty()
|| AccessibilityUtil.isAccessibilityEnabled()
? Integer.MAX_VALUE
: minimizedCount;
mMinCountersSum = minCountersSum;
mMaxCountersSum = maxCountersSum;
mDelegate = delegate;
......
......@@ -168,6 +168,12 @@
<message name="IDS_AUTOFILL_ASSISTANT_SEND_FEEDBACK" desc="Option shown in the menu when clicking the Autofill Assistant profile icon. Clicking this option will open a feedback sharing dialog.">
Send feedback
</message>
<message name="IDS_AUTOFILL_ASSISTANT_INCREASE_VALUE" desc="Text announced when the '+' button of a counter is highlighted by TalkBack.">
Increase value
</message>
<message name="IDS_AUTOFILL_ASSISTANT_DECREASE_VALUE" desc="Text announced when the '-' button of a counter is highlighted by TalkBack.">
Decrease value
</message>
</messages>
</release>
</grit>
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