Do not show radio/checkboxes for <optgroup> labels.
Fix for http://b/issue?id=2186188. Keep track of <optgroup> labels separately from disabled <option> labels. Requires a change to external/webkit. In CheckedTextView, if the CheckMarkDrawable is set to null, remove it.
This commit is contained in:
@@ -64,6 +64,7 @@ import android.widget.AbsoluteLayout;
|
|||||||
import android.widget.Adapter;
|
import android.widget.Adapter;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.CheckedTextView;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.Scroller;
|
import android.widget.Scroller;
|
||||||
@@ -5299,8 +5300,16 @@ public class WebView extends AbsoluteLayout
|
|||||||
// Need these to provide stable ids to my ArrayAdapter,
|
// Need these to provide stable ids to my ArrayAdapter,
|
||||||
// which normally does not have stable ids. (Bug 1250098)
|
// which normally does not have stable ids. (Bug 1250098)
|
||||||
private class Container extends Object {
|
private class Container extends Object {
|
||||||
|
/**
|
||||||
|
* Possible values for mEnabled. Keep in sync with OptionStatus in
|
||||||
|
* WebViewCore.cpp
|
||||||
|
*/
|
||||||
|
final static int OPTGROUP = -1;
|
||||||
|
final static int OPTION_DISABLED = 0;
|
||||||
|
final static int OPTION_ENABLED = 1;
|
||||||
|
|
||||||
String mString;
|
String mString;
|
||||||
boolean mEnabled;
|
int mEnabled;
|
||||||
int mId;
|
int mId;
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
@@ -5320,6 +5329,23 @@ public class WebView extends AbsoluteLayout
|
|||||||
objects);
|
objects);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View getView(int position, View convertView,
|
||||||
|
ViewGroup parent) {
|
||||||
|
// Always pass in null so that we will get a new CheckedTextView
|
||||||
|
// Otherwise, an item which was previously used as an <optgroup>
|
||||||
|
// element (i.e. has no check), could get used as an <option>
|
||||||
|
// element, which needs a checkbox/radio, but it would not have
|
||||||
|
// one.
|
||||||
|
convertView = super.getView(position, null, parent);
|
||||||
|
Container c = item(position);
|
||||||
|
if (c != null && Container.OPTGROUP == c.mEnabled
|
||||||
|
&& convertView instanceof CheckedTextView) {
|
||||||
|
((CheckedTextView) convertView).setCheckMarkDrawable(null);
|
||||||
|
}
|
||||||
|
return convertView;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasStableIds() {
|
public boolean hasStableIds() {
|
||||||
// AdapterView's onChanged method uses this to determine whether
|
// AdapterView's onChanged method uses this to determine whether
|
||||||
@@ -5355,12 +5381,11 @@ public class WebView extends AbsoluteLayout
|
|||||||
if (item == null) {
|
if (item == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return item.mEnabled;
|
return Container.OPTION_ENABLED == item.mEnabled;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private InvokeListBox(String[] array,
|
private InvokeListBox(String[] array, int[] enabled, int[] selected) {
|
||||||
boolean[] enabled, int[] selected) {
|
|
||||||
mMultiple = true;
|
mMultiple = true;
|
||||||
mSelectedArray = selected;
|
mSelectedArray = selected;
|
||||||
|
|
||||||
@@ -5374,8 +5399,7 @@ public class WebView extends AbsoluteLayout
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private InvokeListBox(String[] array, boolean[] enabled, int
|
private InvokeListBox(String[] array, int[] enabled, int selection) {
|
||||||
selection) {
|
|
||||||
mSelection = selection;
|
mSelection = selection;
|
||||||
mMultiple = false;
|
mMultiple = false;
|
||||||
|
|
||||||
@@ -5506,10 +5530,11 @@ public class WebView extends AbsoluteLayout
|
|||||||
* Request a dropdown menu for a listbox with multiple selection.
|
* Request a dropdown menu for a listbox with multiple selection.
|
||||||
*
|
*
|
||||||
* @param array Labels for the listbox.
|
* @param array Labels for the listbox.
|
||||||
* @param enabledArray Which positions are enabled.
|
* @param enabledArray State for each element in the list. See static
|
||||||
|
* integers in Container class.
|
||||||
* @param selectedArray Which positions are initally selected.
|
* @param selectedArray Which positions are initally selected.
|
||||||
*/
|
*/
|
||||||
void requestListBox(String[] array, boolean[]enabledArray, int[]
|
void requestListBox(String[] array, int[] enabledArray, int[]
|
||||||
selectedArray) {
|
selectedArray) {
|
||||||
mPrivateHandler.post(
|
mPrivateHandler.post(
|
||||||
new InvokeListBox(array, enabledArray, selectedArray));
|
new InvokeListBox(array, enabledArray, selectedArray));
|
||||||
@@ -5520,10 +5545,11 @@ public class WebView extends AbsoluteLayout
|
|||||||
* <select> element.
|
* <select> element.
|
||||||
*
|
*
|
||||||
* @param array Labels for the listbox.
|
* @param array Labels for the listbox.
|
||||||
* @param enabledArray Which positions are enabled.
|
* @param enabledArray State for each element in the list. See static
|
||||||
|
* integers in Container class.
|
||||||
* @param selection Which position is initally selected.
|
* @param selection Which position is initally selected.
|
||||||
*/
|
*/
|
||||||
void requestListBox(String[] array, boolean[]enabledArray, int selection) {
|
void requestListBox(String[] array, int[] enabledArray, int selection) {
|
||||||
mPrivateHandler.post(
|
mPrivateHandler.post(
|
||||||
new InvokeListBox(array, enabledArray, selection));
|
new InvokeListBox(array, enabledArray, selection));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2141,7 +2141,7 @@ final class WebViewCore {
|
|||||||
private native void nativeSetGlobalBounds(int x, int y, int w, int h);
|
private native void nativeSetGlobalBounds(int x, int y, int w, int h);
|
||||||
|
|
||||||
// called by JNI
|
// called by JNI
|
||||||
private void requestListBox(String[] array, boolean[] enabledArray,
|
private void requestListBox(String[] array, int[] enabledArray,
|
||||||
int[] selectedArray) {
|
int[] selectedArray) {
|
||||||
if (mWebView != null) {
|
if (mWebView != null) {
|
||||||
mWebView.requestListBox(array, enabledArray, selectedArray);
|
mWebView.requestListBox(array, enabledArray, selectedArray);
|
||||||
@@ -2149,7 +2149,7 @@ final class WebViewCore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// called by JNI
|
// called by JNI
|
||||||
private void requestListBox(String[] array, boolean[] enabledArray,
|
private void requestListBox(String[] array, int[] enabledArray,
|
||||||
int selection) {
|
int selection) {
|
||||||
if (mWebView != null) {
|
if (mWebView != null) {
|
||||||
mWebView.requestListBox(array, enabledArray, selection);
|
mWebView.requestListBox(array, enabledArray, selection);
|
||||||
|
|||||||
@@ -117,11 +117,11 @@ public class CheckedTextView extends TextView implements Checkable {
|
|||||||
* @param d The Drawable to use for the checkmark.
|
* @param d The Drawable to use for the checkmark.
|
||||||
*/
|
*/
|
||||||
public void setCheckMarkDrawable(Drawable d) {
|
public void setCheckMarkDrawable(Drawable d) {
|
||||||
|
if (mCheckMarkDrawable != null) {
|
||||||
|
mCheckMarkDrawable.setCallback(null);
|
||||||
|
unscheduleDrawable(mCheckMarkDrawable);
|
||||||
|
}
|
||||||
if (d != null) {
|
if (d != null) {
|
||||||
if (mCheckMarkDrawable != null) {
|
|
||||||
mCheckMarkDrawable.setCallback(null);
|
|
||||||
unscheduleDrawable(mCheckMarkDrawable);
|
|
||||||
}
|
|
||||||
d.setCallback(this);
|
d.setCallback(this);
|
||||||
d.setVisible(getVisibility() == VISIBLE, false);
|
d.setVisible(getVisibility() == VISIBLE, false);
|
||||||
d.setState(CHECKED_STATE_SET);
|
d.setState(CHECKED_STATE_SET);
|
||||||
@@ -130,10 +130,10 @@ public class CheckedTextView extends TextView implements Checkable {
|
|||||||
mCheckMarkWidth = d.getIntrinsicWidth();
|
mCheckMarkWidth = d.getIntrinsicWidth();
|
||||||
mPaddingRight = mCheckMarkWidth + mBasePaddingRight;
|
mPaddingRight = mCheckMarkWidth + mBasePaddingRight;
|
||||||
d.setState(getDrawableState());
|
d.setState(getDrawableState());
|
||||||
mCheckMarkDrawable = d;
|
|
||||||
} else {
|
} else {
|
||||||
mPaddingRight = mBasePaddingRight;
|
mPaddingRight = mBasePaddingRight;
|
||||||
}
|
}
|
||||||
|
mCheckMarkDrawable = d;
|
||||||
requestLayout();
|
requestLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user