use of android.text.method.AllCapsTransformationMethod in project android_frameworks_base by ParanoidAndroid.
the class Switch method setSwitchTextAppearance.
/**
* Sets the switch text color, size, style, hint color, and highlight color
* from the specified TextAppearance resource.
*
* @attr ref android.R.styleable#Switch_switchTextAppearance
*/
public void setSwitchTextAppearance(Context context, int resid) {
TypedArray appearance = context.obtainStyledAttributes(resid, com.android.internal.R.styleable.TextAppearance);
ColorStateList colors;
int ts;
colors = appearance.getColorStateList(com.android.internal.R.styleable.TextAppearance_textColor);
if (colors != null) {
mTextColors = colors;
} else {
// If no color set in TextAppearance, default to the view's textColor
mTextColors = getTextColors();
}
ts = appearance.getDimensionPixelSize(com.android.internal.R.styleable.TextAppearance_textSize, 0);
if (ts != 0) {
if (ts != mTextPaint.getTextSize()) {
mTextPaint.setTextSize(ts);
requestLayout();
}
}
int typefaceIndex, styleIndex;
typefaceIndex = appearance.getInt(com.android.internal.R.styleable.TextAppearance_typeface, -1);
styleIndex = appearance.getInt(com.android.internal.R.styleable.TextAppearance_textStyle, -1);
setSwitchTypefaceByIndex(typefaceIndex, styleIndex);
boolean allCaps = appearance.getBoolean(com.android.internal.R.styleable.TextAppearance_textAllCaps, false);
if (allCaps) {
mSwitchTransformationMethod = new AllCapsTransformationMethod(getContext());
mSwitchTransformationMethod.setLengthChangesAllowed(true);
} else {
mSwitchTransformationMethod = null;
}
appearance.recycle();
}
use of android.text.method.AllCapsTransformationMethod in project platform_frameworks_base by android.
the class TextView method setTextAppearance.
/**
* Sets the text color, size, style, hint color, and highlight color
* from the specified TextAppearance resource.
*
* @deprecated Use {@link #setTextAppearance(int)} instead.
*/
@Deprecated
public void setTextAppearance(Context context, @StyleRes int resId) {
final TypedArray ta = context.obtainStyledAttributes(resId, R.styleable.TextAppearance);
final int textColorHighlight = ta.getColor(R.styleable.TextAppearance_textColorHighlight, 0);
if (textColorHighlight != 0) {
setHighlightColor(textColorHighlight);
}
final ColorStateList textColor = ta.getColorStateList(R.styleable.TextAppearance_textColor);
if (textColor != null) {
setTextColor(textColor);
}
final int textSize = ta.getDimensionPixelSize(R.styleable.TextAppearance_textSize, 0);
if (textSize != 0) {
setRawTextSize(textSize);
}
final ColorStateList textColorHint = ta.getColorStateList(R.styleable.TextAppearance_textColorHint);
if (textColorHint != null) {
setHintTextColor(textColorHint);
}
final ColorStateList textColorLink = ta.getColorStateList(R.styleable.TextAppearance_textColorLink);
if (textColorLink != null) {
setLinkTextColor(textColorLink);
}
final String fontFamily = ta.getString(R.styleable.TextAppearance_fontFamily);
final int typefaceIndex = ta.getInt(R.styleable.TextAppearance_typeface, -1);
final int styleIndex = ta.getInt(R.styleable.TextAppearance_textStyle, -1);
setTypefaceFromAttrs(fontFamily, typefaceIndex, styleIndex);
final int shadowColor = ta.getInt(R.styleable.TextAppearance_shadowColor, 0);
if (shadowColor != 0) {
final float dx = ta.getFloat(R.styleable.TextAppearance_shadowDx, 0);
final float dy = ta.getFloat(R.styleable.TextAppearance_shadowDy, 0);
final float r = ta.getFloat(R.styleable.TextAppearance_shadowRadius, 0);
setShadowLayer(r, dx, dy, shadowColor);
}
if (ta.getBoolean(R.styleable.TextAppearance_textAllCaps, false)) {
setTransformationMethod(new AllCapsTransformationMethod(getContext()));
}
if (ta.hasValue(R.styleable.TextAppearance_elegantTextHeight)) {
setElegantTextHeight(ta.getBoolean(R.styleable.TextAppearance_elegantTextHeight, false));
}
if (ta.hasValue(R.styleable.TextAppearance_letterSpacing)) {
setLetterSpacing(ta.getFloat(R.styleable.TextAppearance_letterSpacing, 0));
}
if (ta.hasValue(R.styleable.TextAppearance_fontFeatureSettings)) {
setFontFeatureSettings(ta.getString(R.styleable.TextAppearance_fontFeatureSettings));
}
ta.recycle();
}
use of android.text.method.AllCapsTransformationMethod in project platform_frameworks_base by android.
the class Switch method setSwitchTextAppearance.
/**
* Sets the switch text color, size, style, hint color, and highlight color
* from the specified TextAppearance resource.
*
* @attr ref android.R.styleable#Switch_switchTextAppearance
*/
public void setSwitchTextAppearance(Context context, @StyleRes int resid) {
TypedArray appearance = context.obtainStyledAttributes(resid, com.android.internal.R.styleable.TextAppearance);
ColorStateList colors;
int ts;
colors = appearance.getColorStateList(com.android.internal.R.styleable.TextAppearance_textColor);
if (colors != null) {
mTextColors = colors;
} else {
// If no color set in TextAppearance, default to the view's textColor
mTextColors = getTextColors();
}
ts = appearance.getDimensionPixelSize(com.android.internal.R.styleable.TextAppearance_textSize, 0);
if (ts != 0) {
if (ts != mTextPaint.getTextSize()) {
mTextPaint.setTextSize(ts);
requestLayout();
}
}
int typefaceIndex, styleIndex;
typefaceIndex = appearance.getInt(com.android.internal.R.styleable.TextAppearance_typeface, -1);
styleIndex = appearance.getInt(com.android.internal.R.styleable.TextAppearance_textStyle, -1);
setSwitchTypefaceByIndex(typefaceIndex, styleIndex);
boolean allCaps = appearance.getBoolean(com.android.internal.R.styleable.TextAppearance_textAllCaps, false);
if (allCaps) {
mSwitchTransformationMethod = new AllCapsTransformationMethod(getContext());
mSwitchTransformationMethod.setLengthChangesAllowed(true);
} else {
mSwitchTransformationMethod = null;
}
appearance.recycle();
}
use of android.text.method.AllCapsTransformationMethod in project XobotOS by xamarin.
the class TextView method setTextAppearance.
/**
* Sets the text color, size, style, hint color, and highlight color
* from the specified TextAppearance resource.
*/
public void setTextAppearance(Context context, int resid) {
TypedArray appearance = context.obtainStyledAttributes(resid, com.android.internal.R.styleable.TextAppearance);
int color;
ColorStateList colors;
int ts;
color = appearance.getColor(com.android.internal.R.styleable.TextAppearance_textColorHighlight, 0);
if (color != 0) {
setHighlightColor(color);
}
colors = appearance.getColorStateList(com.android.internal.R.styleable.TextAppearance_textColor);
if (colors != null) {
setTextColor(colors);
}
ts = appearance.getDimensionPixelSize(com.android.internal.R.styleable.TextAppearance_textSize, 0);
if (ts != 0) {
setRawTextSize(ts);
}
colors = appearance.getColorStateList(com.android.internal.R.styleable.TextAppearance_textColorHint);
if (colors != null) {
setHintTextColor(colors);
}
colors = appearance.getColorStateList(com.android.internal.R.styleable.TextAppearance_textColorLink);
if (colors != null) {
setLinkTextColor(colors);
}
int typefaceIndex, styleIndex;
typefaceIndex = appearance.getInt(com.android.internal.R.styleable.TextAppearance_typeface, -1);
styleIndex = appearance.getInt(com.android.internal.R.styleable.TextAppearance_textStyle, -1);
setTypefaceByIndex(typefaceIndex, styleIndex);
if (appearance.getBoolean(com.android.internal.R.styleable.TextAppearance_textAllCaps, false)) {
setTransformationMethod(new AllCapsTransformationMethod(getContext()));
}
appearance.recycle();
}
use of android.text.method.AllCapsTransformationMethod in project android_frameworks_base by AOSPA.
the class PAWorldActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
Typeface bold = Typeface.create("sans-serif", Typeface.BOLD);
Typeface light = Typeface.create("sans-serif-light", Typeface.NORMAL);
mContent = new FrameLayout(this);
mContent.setBackgroundColor(CLEAR_BGCOLOR);
final FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
lp.gravity = Gravity.CENTER;
final ImageView logo = new ImageView(this);
logo.setImageResource(com.android.internal.R.drawable.pa_world_logo);
logo.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
logo.setVisibility(View.INVISIBLE);
final View bg = new View(this);
bg.setBackgroundColor(SOLID_BGCOLOR);
bg.setAlpha(0f);
final TextView letter = new TextView(this);
letter.setTypeface(bold);
letter.setTextSize(200);
letter.setTextColor(TEXT_COLOR);
letter.setGravity(Gravity.CENTER);
letter.setText("PA");
final int p = (int) (4 * metrics.density);
final TextView tv = new TextView(this);
if (light != null)
tv.setTypeface(light);
tv.setTextSize(20);
tv.setPadding(p, p, p, p);
tv.setTextColor(TEXT_COLOR);
tv.setGravity(Gravity.CENTER);
tv.setTransformationMethod(new AllCapsTransformationMethod(this));
String paVersion = SystemProperties.get("ro.pa.version");
paVersion = paVersion.replaceAll("([0-9\\.]+?)-.*", "$1");
tv.setText("Paranoid Android " + paVersion);
tv.setVisibility(View.INVISIBLE);
mContent.addView(bg);
mContent.addView(letter, lp);
mContent.addView(logo, lp);
final FrameLayout.LayoutParams lp2 = new FrameLayout.LayoutParams(lp);
lp2.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
lp2.bottomMargin = p;
mContent.addView(tv, lp2);
mContent.setOnClickListener(new View.OnClickListener() {
int clicks;
@Override
public void onClick(View v) {
clicks++;
if (clicks >= 6) {
mContent.performLongClick();
return;
}
letter.animate().cancel();
final float offset = (int) letter.getRotation() % 360;
letter.animate().rotationBy((Math.random() > 0.5f ? 360 : -360) - offset).setInterpolator(new DecelerateInterpolator()).setDuration(700).start();
}
});
mContent.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
if (logo.getVisibility() != View.VISIBLE) {
bg.setScaleX(0.01f);
bg.animate().alpha(1f).scaleX(1f).setStartDelay(500).start();
letter.animate().alpha(0f).scaleY(0.5f).scaleX(0.5f).rotationBy(360).setInterpolator(new AccelerateInterpolator()).setDuration(1000).start();
logo.setAlpha(0f);
logo.setVisibility(View.VISIBLE);
logo.setScaleX(0.5f);
logo.setScaleY(0.5f);
logo.animate().alpha(1f).scaleX(1f).scaleY(1f).setDuration(1000).setStartDelay(500).setInterpolator(new AnticipateOvershootInterpolator()).start();
tv.setAlpha(0f);
tv.setVisibility(View.VISIBLE);
tv.animate().alpha(1f).setDuration(1000).setStartDelay(1000).start();
return true;
}
return false;
}
});
logo.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
try {
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setClassName("com.android.settings", "com.android.settings.BeanBag").addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getBaseContext().startActivityAsUser(intent, new UserHandle(UserHandle.USER_CURRENT));
} catch (ActivityNotFoundException ex) {
android.util.Log.e("PAWorldActivity", "Couldn't catch a break.");
}
finish();
return true;
}
});
setContentView(mContent);
}
Aggregations