Merge "Check for text when adding CollectionInfo and CollectionItemInfo" into rvc-dev
This commit is contained in:
@@ -22,6 +22,7 @@ import android.annotation.Nullable;
|
|||||||
import android.compat.annotation.UnsupportedAppUsage;
|
import android.compat.annotation.UnsupportedAppUsage;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -484,21 +485,21 @@ public class RadioGroup extends LinearLayout {
|
|||||||
super.onInitializeAccessibilityNodeInfo(info);
|
super.onInitializeAccessibilityNodeInfo(info);
|
||||||
if (this.getOrientation() == HORIZONTAL) {
|
if (this.getOrientation() == HORIZONTAL) {
|
||||||
info.setCollectionInfo(AccessibilityNodeInfo.CollectionInfo.obtain(1,
|
info.setCollectionInfo(AccessibilityNodeInfo.CollectionInfo.obtain(1,
|
||||||
getVisibleChildCount(), false,
|
getVisibleChildWithTextCount(), false,
|
||||||
AccessibilityNodeInfo.CollectionInfo.SELECTION_MODE_SINGLE));
|
AccessibilityNodeInfo.CollectionInfo.SELECTION_MODE_SINGLE));
|
||||||
} else {
|
} else {
|
||||||
info.setCollectionInfo(
|
info.setCollectionInfo(
|
||||||
AccessibilityNodeInfo.CollectionInfo.obtain(getVisibleChildCount(),
|
AccessibilityNodeInfo.CollectionInfo.obtain(getVisibleChildWithTextCount(),
|
||||||
1, false,
|
1, false,
|
||||||
AccessibilityNodeInfo.CollectionInfo.SELECTION_MODE_SINGLE));
|
AccessibilityNodeInfo.CollectionInfo.SELECTION_MODE_SINGLE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getVisibleChildCount() {
|
private int getVisibleChildWithTextCount() {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (int i = 0; i < getChildCount(); i++) {
|
for (int i = 0; i < getChildCount(); i++) {
|
||||||
if (this.getChildAt(i) instanceof RadioButton) {
|
if (this.getChildAt(i) instanceof RadioButton) {
|
||||||
if (((RadioButton) this.getChildAt(i)).getVisibility() == VISIBLE) {
|
if (isVisibleWithText((RadioButton) this.getChildAt(i))) {
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -513,15 +514,19 @@ public class RadioGroup extends LinearLayout {
|
|||||||
int index = 0;
|
int index = 0;
|
||||||
for (int i = 0; i < getChildCount(); i++) {
|
for (int i = 0; i < getChildCount(); i++) {
|
||||||
if (this.getChildAt(i) instanceof RadioButton) {
|
if (this.getChildAt(i) instanceof RadioButton) {
|
||||||
RadioButton radioButton = (RadioButton) this.getChildAt(i);
|
RadioButton button = (RadioButton) this.getChildAt(i);
|
||||||
if (radioButton == child) {
|
if (button == child) {
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
if (radioButton.getVisibility() == VISIBLE) {
|
if (isVisibleWithText(button)) {
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isVisibleWithText(RadioButton button) {
|
||||||
|
return button.getVisibility() == VISIBLE && !TextUtils.isEmpty(button.getText());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user