Commit 31499c74 authored by Wenyu Fu's avatar Wenyu Fu Committed by Commit Bot

Use #setChecked in RadioButtonWithDescription#setCheckedWithFocusChange

RadioButtonWithDescription#setCheckedWithFocusChange is trying to
unchecked other radio button when this current radio button is checked.
For those flipping-to-unchecked radio buttons, we want to call
#setChecked rather than #setCheckedWithFocusChange to cooperate focus
changes.

Bug: 1048863, 1053747
Change-Id: Ia12f5a613594a283f5289c1516bc5e6dfeef2aae
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2081524Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Reviewed-by: default avatarBrandon Wylie <wylieb@chromium.org>
Commit-Queue: Wenyu Fu <wenyufu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#746173}
parent d247eaf7
......@@ -22,6 +22,7 @@
android:key="homepage_radio_group"
android:visibility="gone"
android:selectable="false"
app:allowDividerAbove="true"
app:allowDividerBelow="false" />
<org.chromium.chrome.browser.settings.TextMessagePreference
......
......@@ -208,7 +208,8 @@ public class RadioButtonWithDescription extends RelativeLayout implements OnClic
}
/**
* Sets the checked status.
* Sets the checked status, and retain focus on RadioButtonWithDescription after radio button if
* it is checked.
*
* If the radio button is inside a radio button group and going to be checked, the rest of the
* radio buttons in the group will be set to unchecked.
......@@ -227,7 +228,7 @@ public class RadioButtonWithDescription extends RelativeLayout implements OnClic
* Set the checked status for this radio button without updating the focus.
*
* If the radio button is inside a radio button group and going to be checked, the rest of the
* radio buttons in the group will be set to unchecked.
* radio buttons in the group will be set to unchecked by #setChecked(false).
*
* In most cases, caller should use {@link #setChecked(boolean)} to handle the focus as well.
* @param checked Whether this radio button will be checked.
......@@ -235,7 +236,7 @@ public class RadioButtonWithDescription extends RelativeLayout implements OnClic
protected void setCheckedWithNoFocusChange(boolean checked) {
if (mGroup != null && checked) {
for (RadioButtonWithDescription button : mGroup) {
if (button != this) button.setCheckedWithNoFocusChange(false);
if (button != this) button.setChecked(false);
}
}
mRadioButton.setChecked(checked);
......
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