diff options
author | Victoria Lease <violets@google.com> | 2013-11-01 16:34:03 -0700 |
---|---|---|
committer | Victoria Lease <violets@google.com> | 2013-11-01 16:44:08 -0700 |
commit | 1d80e977da89a660aff006e93470749b359c2393 (patch) | |
tree | 5519e59b39f65fda5fe9adfffbacbe465654e5b8 | |
parent | ee4c84642afffa80f23039bbc2d4f59de11f67da (diff) | |
download | frameworks_base-1d80e977da89a660aff006e93470749b359c2393.zip frameworks_base-1d80e977da89a660aff006e93470749b359c2393.tar.gz frameworks_base-1d80e977da89a660aff006e93470749b359c2393.tar.bz2 |
Compose singleLine & textAllCaps transforms
TextView only supports a single TransformationMethod per TextView, and
singleLine and textAllCaps are both implemented as
TransformationMethods. Composing both operations into a single
TransformationMethod gives us all-caps text (if requested by
kg_use_all_caps) on a single line.
Bug: 11421105
Change-Id: I069721b887ea90b8daf2af2cf82081319e499962
-rw-r--r-- | packages/Keyguard/res/layout/keyguard_emergency_carrier_area.xml | 4 | ||||
-rw-r--r-- | packages/Keyguard/src/com/android/keyguard/CarrierText.java | 27 |
2 files changed, 28 insertions, 3 deletions
diff --git a/packages/Keyguard/res/layout/keyguard_emergency_carrier_area.xml b/packages/Keyguard/res/layout/keyguard_emergency_carrier_area.xml index 8be15cb..b4847f0 100644 --- a/packages/Keyguard/res/layout/keyguard_emergency_carrier_area.xml +++ b/packages/Keyguard/res/layout/keyguard_emergency_carrier_area.xml @@ -32,12 +32,10 @@ android:id="@+id/carrier_text" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:singleLine="true" android:ellipsize="marquee" android:textAppearance="?android:attr/textAppearanceMedium" android:textSize="@dimen/kg_status_line_font_size" - android:textColor="?android:attr/textColorSecondary" - android:textAllCaps="@bool/kg_use_all_caps" /> + android:textColor="?android:attr/textColorSecondary" /> <LinearLayout android:layout_width="match_parent" diff --git a/packages/Keyguard/src/com/android/keyguard/CarrierText.java b/packages/Keyguard/src/com/android/keyguard/CarrierText.java index c33f174..88558cd 100644 --- a/packages/Keyguard/src/com/android/keyguard/CarrierText.java +++ b/packages/Keyguard/src/com/android/keyguard/CarrierText.java @@ -17,14 +17,18 @@ package com.android.keyguard; import android.content.Context; +import android.text.method.SingleLineTransformationMethod; import android.text.TextUtils; import android.util.AttributeSet; +import android.view.View; import android.widget.TextView; import com.android.internal.telephony.IccCardConstants; import com.android.internal.telephony.IccCardConstants.State; import com.android.internal.widget.LockPatternUtils; +import java.util.Locale; + public class CarrierText extends TextView { private static CharSequence mSeparator; @@ -77,6 +81,8 @@ public class CarrierText extends TextView { public CarrierText(Context context, AttributeSet attrs) { super(context, attrs); mLockPatternUtils = new LockPatternUtils(mContext); + boolean useAllCaps = mContext.getResources().getBoolean(R.bool.kg_use_all_caps); + setTransformationMethod(new CarrierTextTransformationMethod(mContext, useAllCaps)); } protected void updateCarrierText(State simState, CharSequence plmn, CharSequence spn) { @@ -258,4 +264,25 @@ public class CarrierText extends TextView { return mContext.getText(carrierHelpTextId); } + + private class CarrierTextTransformationMethod extends SingleLineTransformationMethod { + private final Locale mLocale; + private final boolean mAllCaps; + + public CarrierTextTransformationMethod(Context context, boolean allCaps) { + mLocale = context.getResources().getConfiguration().locale; + mAllCaps = allCaps; + } + + @Override + public CharSequence getTransformation(CharSequence source, View view) { + source = super.getTransformation(source, view); + + if (mAllCaps && source != null) { + source = source.toString().toUpperCase(mLocale); + } + + return source; + } + } } |