Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'android/3rd_party/HoloEverywhere/library/src/org/holoeverywhere/widget/TextView.java')
-rw-r--r--android/3rd_party/HoloEverywhere/library/src/org/holoeverywhere/widget/TextView.java84
1 files changed, 84 insertions, 0 deletions
diff --git a/android/3rd_party/HoloEverywhere/library/src/org/holoeverywhere/widget/TextView.java b/android/3rd_party/HoloEverywhere/library/src/org/holoeverywhere/widget/TextView.java
new file mode 100644
index 0000000000..9fb274a53e
--- /dev/null
+++ b/android/3rd_party/HoloEverywhere/library/src/org/holoeverywhere/widget/TextView.java
@@ -0,0 +1,84 @@
+
+package org.holoeverywhere.widget;
+
+import org.holoeverywhere.R;
+
+import android.annotation.SuppressLint;
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.os.Build.VERSION;
+import android.util.AttributeSet;
+
+public class TextView extends android.widget.TextView {
+ private boolean allCaps = false;
+ private CharSequence originalText;
+ private BufferType originalType;
+
+ public TextView(Context context) {
+ this(context, null);
+ }
+
+ public TextView(Context context, AttributeSet attrs) {
+ this(context, attrs, android.R.attr.textViewStyle);
+ }
+
+ public TextView(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ TypedArray a = getContext().obtainStyledAttributes(attrs,
+ R.styleable.TextView, defStyle, 0);
+ if (a.hasValue(R.styleable.TextView_android_textAllCaps)) {
+ allCaps = a.getBoolean(R.styleable.TextView_android_textAllCaps,
+ false);
+ } else {
+ allCaps = a.getBoolean(R.styleable.TextView_textAllCaps, false);
+ }
+ CharSequence text = null;
+ if (a.hasValue(R.styleable.TextView_android_text)) {
+ text = a.getText(R.styleable.TextView_android_text);
+ }
+ a.recycle();
+ if (text != null) {
+ setText(text);
+ }
+ }
+
+ @Override
+ @SuppressLint("NewApi")
+ public void dispatchDisplayHint(int hint) {
+ onDisplayHint(hint);
+ }
+
+ public boolean isAllCaps() {
+ return allCaps;
+ }
+
+ @Override
+ @SuppressLint("NewApi")
+ protected void onDisplayHint(int hint) {
+ if (VERSION.SDK_INT >= 8) {
+ super.onDisplayHint(hint);
+ }
+ }
+
+ @Override
+ public void setAllCaps(boolean allCaps) {
+ this.allCaps = allCaps;
+ updateTextState();
+ }
+
+ @Override
+ public void setText(CharSequence text, BufferType type) {
+ originalText = text;
+ originalType = type;
+ updateTextState();
+ }
+
+ private void updateTextState() {
+ if (originalText == null) {
+ super.setText(null, originalType);
+ return;
+ }
+ super.setText(allCaps ? originalText.toString().toUpperCase()
+ : originalText, originalType);
+ }
+}