Commit 40fe0302 authored by newt's avatar newt Committed by Commit bot

Fix language spinners in translate infobar.

These spinners were no longer clickable as a side-effect of this CL
(https://codereview.chromium.org/657893005) which make the TextViews
inside the spinners clickable. As a result, the Spinner never received
click events.

Also, the spinner dropdown arrow was missing on pre-L devices because we
were creating the Spinner using "new Spinner()" instead of inflating it
from a resource. This is a no-no when using the AppCompat theme.

BUG=435491

Review URL: https://codereview.chromium.org/778533002

Cr-Commit-Position: refs/heads/master@{#306522}
parent 74f48029
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2014 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. -->
<!-- A plain old Spinner.
Why is this needed? Because spinners must be inflated from a resource for the AppCompat theme
to work. Simply calling new Spinner() will result in a missing spinner arrow on pre-L devices.
See the FAQ on this page:
http://android-developers.blogspot.com/2014/10/appcompat-v21-material-design-for-pre.html -->
<Spinner />
......@@ -9,6 +9,7 @@ import android.graphics.Color;
import android.text.SpannableString;
import android.text.TextUtils;
import android.text.style.ForegroundColorSpan;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
......@@ -103,8 +104,9 @@ public class TranslateLanguagePanel
mTargetAdapter.measureWidthRequiredForView();
// Create the spinners.
mSourceSpinner = new Spinner(context);
mTargetSpinner = new Spinner(context);
LayoutInflater inflater = LayoutInflater.from(context);
mSourceSpinner = (Spinner) inflater.inflate(R.layout.spinner, null);
mTargetSpinner = (Spinner) inflater.inflate(R.layout.spinner, null);
mSourceSpinner.setOnItemSelectedListener(this);
mTargetSpinner.setOnItemSelectedListener(this);
mSourceSpinner.setAdapter(mSourceAdapter);
......@@ -234,8 +236,9 @@ public class TranslateLanguagePanel
public View getView(int position, View convertView, ViewGroup parent) {
TextView result;
if (!(convertView instanceof TextView)) {
result = (TextView) LayoutInflater.from(getContext()).inflate(
R.layout.infobar_text, null);
result = new TextView(getContext());
result.setTextSize(TypedValue.COMPLEX_UNIT_PX,
getContext().getResources().getDimension(R.dimen.infobar_text_size));
} else {
result = (TextView) convertView;
}
......
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