1/* 2 * Copyright (C) 2013 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package android.support.v7.internal.widget; 18 19import android.content.Context; 20import android.content.res.TypedArray; 21import android.graphics.Rect; 22import android.support.v7.appcompat.R; 23import android.support.v7.internal.text.AllCapsTransformationMethod; 24import android.text.method.TransformationMethod; 25import android.util.AttributeSet; 26import android.view.View; 27import android.widget.TextView; 28 29import java.util.Locale; 30 31/** 32 * @hide 33 */ 34public class CompatTextView extends TextView { 35 36 public CompatTextView(Context context) { 37 this(context, null); 38 } 39 40 public CompatTextView(Context context, AttributeSet attrs) { 41 this(context, attrs, 0); 42 } 43 44 public CompatTextView(Context context, AttributeSet attrs, int defStyle) { 45 super(context, attrs, defStyle); 46 47 boolean allCaps = false; 48 49 TypedArray style = context 50 .obtainStyledAttributes(attrs, R.styleable.CompatTextView, defStyle, 0); 51 allCaps = style.getBoolean(R.styleable.CompatTextView_textAllCaps, false); 52 style.recycle(); 53 54 // Framework impl also checks TextAppearance for textAllCaps. This isn't needed for our 55 // purposes so has been omitted. 56 57 if (allCaps) { 58 setTransformationMethod(new AllCapsTransformationMethod(context)); 59 } 60 } 61} 62