summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid A. Madore <david+git@madore.org>2012-03-16 19:58:08 +0100
committerDavid A. Madore <david+git@madore.org>2012-03-16 19:58:08 +0100
commitb821157b9f0f9a2b5479fbdf9a2bb75d287892c9 (patch)
treefd580cc6c71458bd4ed01b8172d1fa9915f234f0
parentd0dc1cb1d518de0a02544654c55b938064e5e3eb (diff)
downloadUnicodeMap-b821157b9f0f9a2b5479fbdf9a2bb75d287892c9.tar.gz
UnicodeMap-b821157b9f0f9a2b5479fbdf9a2bb75d287892c9.tar.bz2
UnicodeMap-b821157b9f0f9a2b5479fbdf9a2bb75d287892c9.zip
Make various text widgets selectable on sufficiently recent Android versions.
-rw-r--r--src/org/madore/android/unicodeMap/UnicodeMapActivity.java15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/org/madore/android/unicodeMap/UnicodeMapActivity.java b/src/org/madore/android/unicodeMap/UnicodeMapActivity.java
index aecea78..1358246 100644
--- a/src/org/madore/android/unicodeMap/UnicodeMapActivity.java
+++ b/src/org/madore/android/unicodeMap/UnicodeMapActivity.java
@@ -27,6 +27,17 @@ import android.app.ProgressDialog;
public final class UnicodeMapActivity extends ListActivity {
+ protected static void textMakeSelectableIfPossible(TextView text) {
+ // .setTextIsSelectable() method is only available on Android
+ // Honeycomb (API 11) and later.
+ try {
+ java.lang.reflect.Method m = TextView.class.getMethod("setTextIsSelectable", new Class[] { boolean.class });
+ m.invoke(text, true);
+ } catch (Exception e) {
+ // Ignore
+ }
+ }
+
protected UnicodeDatabase db;
protected ListView lv;
protected ClipboardManager cmgr;
@@ -313,6 +324,7 @@ public final class UnicodeMapActivity extends ListActivity {
TextView text;
text = (TextView) dialog.findViewById(R.id.detailsLabel);
text.setText(itch.getLabel());
+ textMakeSelectableIfPossible(text);
text = (TextView) dialog.findViewById(R.id.encodingLabel);
StringBuilder s = new StringBuilder();
Formatter fmt = new Formatter(s);
@@ -326,6 +338,7 @@ public final class UnicodeMapActivity extends ListActivity {
for ( int i=0 ; i<bytes.length ; i++ )
fmt.format(" 0x%02x", bytes[i]);
text.setText(new String(s));
+ textMakeSelectableIfPossible(text);
text = (TextView) dialog.findViewById(R.id.categoryLabel);
text.setText(itch.getCategory().getDescr());
final Button copyCharButton = (Button) dialog.findViewById(R.id.copyCharButton);
@@ -391,6 +404,7 @@ public final class UnicodeMapActivity extends ListActivity {
TextView text;
text = (TextView) dialog.findViewById(R.id.rangeDescrLabel);
text.setText(itr.getDescr());
+ textMakeSelectableIfPossible(text);
text = (TextView) dialog.findViewById(R.id.rangeRangeLabel);
StringBuilder s = new StringBuilder();
Formatter fmt = new Formatter(s);
@@ -404,6 +418,7 @@ public final class UnicodeMapActivity extends ListActivity {
itr.getTo()-itr.getFrom(),
db.countRange(itr.getFrom(), itr.getTo()));
text.setText(new String(s));
+ textMakeSelectableIfPossible(text);
dialog.show();
return true;
} else