blob: 9e52afaed95ec19b0bec5afb5740fced99123f1e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
package org.holoeverywhere.text;
import java.util.Locale;
import android.content.Context;
import android.graphics.Rect;
import android.view.View;
public class AllCapsTransformationMethod implements TransformationMethod {
private boolean mEnabled;
private Locale mLocale;
public AllCapsTransformationMethod(Context context) {
mLocale = context.getResources().getConfiguration().locale;
}
@Override
public CharSequence getTransformation(CharSequence source, View view) {
if (mEnabled) {
return source != null ? source.toString().toUpperCase(mLocale) : null;
}
return source;
}
@Override
public void onFocusChanged(View view, CharSequence sourceText, boolean focused, int direction,
Rect previouslyFocusedRect) {
}
@Override
public void setLengthChangesAllowed(boolean allowLengthChanges) {
mEnabled = allowLengthChanges;
}
}
|