AppCompatAutoCompleteTextView.java revision 012047c60d03e61498955b7fa3e9cb9b409fbad8
1012047c60d03e61498955b7fa3e9cb9b409fbad8Chris Banes/*
2012047c60d03e61498955b7fa3e9cb9b409fbad8Chris Banes * Copyright (C) 2014 The Android Open Source Project
3012047c60d03e61498955b7fa3e9cb9b409fbad8Chris Banes *
4012047c60d03e61498955b7fa3e9cb9b409fbad8Chris Banes * Licensed under the Apache License, Version 2.0 (the "License");
5012047c60d03e61498955b7fa3e9cb9b409fbad8Chris Banes * you may not use this file except in compliance with the License.
6012047c60d03e61498955b7fa3e9cb9b409fbad8Chris Banes * You may obtain a copy of the License at
7012047c60d03e61498955b7fa3e9cb9b409fbad8Chris Banes *
8012047c60d03e61498955b7fa3e9cb9b409fbad8Chris Banes *      http://www.apache.org/licenses/LICENSE-2.0
9012047c60d03e61498955b7fa3e9cb9b409fbad8Chris Banes *
10012047c60d03e61498955b7fa3e9cb9b409fbad8Chris Banes * Unless required by applicable law or agreed to in writing, software
11012047c60d03e61498955b7fa3e9cb9b409fbad8Chris Banes * distributed under the License is distributed on an "AS IS" BASIS,
12012047c60d03e61498955b7fa3e9cb9b409fbad8Chris Banes * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13012047c60d03e61498955b7fa3e9cb9b409fbad8Chris Banes * See the License for the specific language governing permissions and
14012047c60d03e61498955b7fa3e9cb9b409fbad8Chris Banes * limitations under the License.
15012047c60d03e61498955b7fa3e9cb9b409fbad8Chris Banes */
16012047c60d03e61498955b7fa3e9cb9b409fbad8Chris Banes
17012047c60d03e61498955b7fa3e9cb9b409fbad8Chris Banespackage android.support.v7.internal.widget;
18012047c60d03e61498955b7fa3e9cb9b409fbad8Chris Banes
19012047c60d03e61498955b7fa3e9cb9b409fbad8Chris Banesimport android.content.Context;
20012047c60d03e61498955b7fa3e9cb9b409fbad8Chris Banesimport android.os.Build;
21012047c60d03e61498955b7fa3e9cb9b409fbad8Chris Banesimport android.util.AttributeSet;
22012047c60d03e61498955b7fa3e9cb9b409fbad8Chris Banesimport android.widget.AutoCompleteTextView;
23012047c60d03e61498955b7fa3e9cb9b409fbad8Chris Banesimport android.widget.EditText;
24012047c60d03e61498955b7fa3e9cb9b409fbad8Chris Banes
25012047c60d03e61498955b7fa3e9cb9b409fbad8Chris Banes/**
26012047c60d03e61498955b7fa3e9cb9b409fbad8Chris Banes * An tint aware {@link android.widget.AutoCompleteTextView}.
27012047c60d03e61498955b7fa3e9cb9b409fbad8Chris Banes *
28012047c60d03e61498955b7fa3e9cb9b409fbad8Chris Banes * @hide
29012047c60d03e61498955b7fa3e9cb9b409fbad8Chris Banes */
30012047c60d03e61498955b7fa3e9cb9b409fbad8Chris Banespublic class TintAutoCompleteTextView extends AutoCompleteTextView {
31012047c60d03e61498955b7fa3e9cb9b409fbad8Chris Banes
32012047c60d03e61498955b7fa3e9cb9b409fbad8Chris Banes    private static final int[] TINT_ATTRS = {
33012047c60d03e61498955b7fa3e9cb9b409fbad8Chris Banes            android.R.attr.background,
34012047c60d03e61498955b7fa3e9cb9b409fbad8Chris Banes            android.R.attr.popupBackground
35012047c60d03e61498955b7fa3e9cb9b409fbad8Chris Banes    };
36012047c60d03e61498955b7fa3e9cb9b409fbad8Chris Banes
37012047c60d03e61498955b7fa3e9cb9b409fbad8Chris Banes    public TintAutoCompleteTextView(Context context) {
38012047c60d03e61498955b7fa3e9cb9b409fbad8Chris Banes        this(context, null);
39012047c60d03e61498955b7fa3e9cb9b409fbad8Chris Banes    }
40012047c60d03e61498955b7fa3e9cb9b409fbad8Chris Banes
41012047c60d03e61498955b7fa3e9cb9b409fbad8Chris Banes    public TintAutoCompleteTextView(Context context, AttributeSet attrs) {
42012047c60d03e61498955b7fa3e9cb9b409fbad8Chris Banes        this(context, attrs, android.R.attr.autoCompleteTextViewStyle);
43012047c60d03e61498955b7fa3e9cb9b409fbad8Chris Banes    }
44012047c60d03e61498955b7fa3e9cb9b409fbad8Chris Banes
45012047c60d03e61498955b7fa3e9cb9b409fbad8Chris Banes    public TintAutoCompleteTextView(Context context, AttributeSet attrs, int defStyleAttr) {
46012047c60d03e61498955b7fa3e9cb9b409fbad8Chris Banes        super(context, attrs, defStyleAttr);
47012047c60d03e61498955b7fa3e9cb9b409fbad8Chris Banes
48012047c60d03e61498955b7fa3e9cb9b409fbad8Chris Banes        TintTypedArray a = TintTypedArray.obtainStyledAttributes(context, attrs, TINT_ATTRS,
49012047c60d03e61498955b7fa3e9cb9b409fbad8Chris Banes                defStyleAttr, 0);
50012047c60d03e61498955b7fa3e9cb9b409fbad8Chris Banes        setBackgroundDrawable(a.getDrawable(0));
51012047c60d03e61498955b7fa3e9cb9b409fbad8Chris Banes        if (a.hasValue(1)) {
52012047c60d03e61498955b7fa3e9cb9b409fbad8Chris Banes            setDropDownBackgroundDrawable(a.getDrawable(1));
53012047c60d03e61498955b7fa3e9cb9b409fbad8Chris Banes        }
54012047c60d03e61498955b7fa3e9cb9b409fbad8Chris Banes        a.recycle();
55012047c60d03e61498955b7fa3e9cb9b409fbad8Chris Banes    }
56012047c60d03e61498955b7fa3e9cb9b409fbad8Chris Banes}
57