Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / ui / android / java / src / org / chromium / ui / DropdownAdapter.java
index 2b561d1..e4a4a18 100644 (file)
@@ -13,6 +13,8 @@ import android.view.View;
 import android.view.ViewGroup;
 import android.widget.AbsListView.LayoutParams;
 import android.widget.ArrayAdapter;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
 import android.widget.TextView;
 
 import org.chromium.base.ApiCompatibilityUtils;
@@ -62,18 +64,6 @@ public class DropdownAdapter extends ArrayAdapter<DropdownItem> {
             ApiCompatibilityUtils.setBackgroundForView(layout, new DropdownDividerDrawable());
         }
 
-        DropdownItem item = getItem(position);
-
-        TextView labelView = (TextView) layout.findViewById(R.id.dropdown_label);
-        labelView.setText(item.getLabel());
-
-        labelView.setEnabled(item.isEnabled());
-        if (item.isGroupHeader()) {
-            labelView.setTypeface(null, Typeface.BOLD);
-        } else {
-            labelView.setTypeface(null, Typeface.NORMAL);
-        }
-
         DropdownDividerDrawable divider = (DropdownDividerDrawable) layout.getBackground();
         int height = mContext.getResources().getDimensionPixelSize(R.dimen.dropdown_item_height);
         if (position == 0) {
@@ -91,7 +81,25 @@ public class DropdownAdapter extends ArrayAdapter<DropdownItem> {
                                  R.color.dropdown_divider_color));
             }
         }
-        layout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, height));
+
+        // Note: trying to set the height of the root LinearLayout breaks accessibility,
+        // so we have to adjust the height of this LinearLayout that wraps the TextViews instead.
+        // If you need to modify this layout, don't forget to test it with TalkBack and make sure
+        // it doesn't regress.
+        // http://crbug.com/429364
+        View wrapper = layout.findViewById(R.id.dropdown_label_wrapper);
+        wrapper.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, height));
+
+        DropdownItem item = getItem(position);
+        TextView labelView = (TextView) layout.findViewById(R.id.dropdown_label);
+        labelView.setText(item.getLabel());
+
+        labelView.setEnabled(item.isEnabled());
+        if (item.isGroupHeader()) {
+            labelView.setTypeface(null, Typeface.BOLD);
+        } else {
+            labelView.setTypeface(null, Typeface.NORMAL);
+        }
 
         TextView sublabelView = (TextView) layout.findViewById(R.id.dropdown_sublabel);
         CharSequence sublabel = item.getSublabel();
@@ -102,6 +110,14 @@ public class DropdownAdapter extends ArrayAdapter<DropdownItem> {
             sublabelView.setVisibility(View.VISIBLE);
         }
 
+        ImageView iconView = (ImageView) layout.findViewById(R.id.dropdown_icon);
+        if (item.getIconId() == DropdownItem.NO_ICON) {
+            iconView.setVisibility(View.GONE);
+        } else {
+            iconView.setImageResource(item.getIconId());
+            iconView.setVisibility(View.VISIBLE);
+        }
+
         return layout;
     }