From e37377a5d3ca4c78c440b097af4186cbbd81a6a0 Mon Sep 17 00:00:00 2001 From: "David A. Madore" Date: Mon, 26 Apr 2010 22:49:35 +0200 Subject: Range details similar to character details. --- res/layout/char_details.xml | 2 +- res/layout/range_details.xml | 19 ++++++++++++++++++ .../android/unicodeMap/UnicodeCharacter.java | 5 +---- .../android/unicodeMap/UnicodeMapActivity.java | 23 ++++++++++++++++++++-- 4 files changed, 42 insertions(+), 7 deletions(-) create mode 100644 res/layout/range_details.xml diff --git a/res/layout/char_details.xml b/res/layout/char_details.xml index 57a6b35..1828d2d 100644 --- a/res/layout/char_details.xml +++ b/res/layout/char_details.xml @@ -10,7 +10,7 @@ android:layout_height="wrap_content" android:textSize="20sp" android:textColor="#ff000000" /> - + + + + diff --git a/src/org/madore/android/unicodeMap/UnicodeCharacter.java b/src/org/madore/android/unicodeMap/UnicodeCharacter.java index 646c696..0805e8c 100644 --- a/src/org/madore/android/unicodeMap/UnicodeCharacter.java +++ b/src/org/madore/android/unicodeMap/UnicodeCharacter.java @@ -284,10 +284,7 @@ public class UnicodeCharacter implements UnicodeDisplayable { protected String makeLabel() { StringBuilder s = new StringBuilder(); Formatter fmt = new Formatter(s); - if ( codePoint < 0x10000 ) - fmt.format("U+%04X %s", codePoint, name); - else - fmt.format("U+%X %s", codePoint, name); + fmt.format("U+%04X %s", codePoint, name); return new String(s); } diff --git a/src/org/madore/android/unicodeMap/UnicodeMapActivity.java b/src/org/madore/android/unicodeMap/UnicodeMapActivity.java index 2d8d61b..1b43d9d 100644 --- a/src/org/madore/android/unicodeMap/UnicodeMapActivity.java +++ b/src/org/madore/android/unicodeMap/UnicodeMapActivity.java @@ -96,12 +96,13 @@ public final class UnicodeMapActivity extends ListActivity { UnicodeCharacter itch = (UnicodeCharacter)it; Dialog dialog = new Dialog(UnicodeMapActivity.this); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); + dialog.setOwnerActivity(UnicodeMapActivity.this); dialog.setContentView(R.layout.char_details); dialog.setCancelable(true); TextView text; text = (TextView) dialog.findViewById(R.id.detailsLabel); text.setText(itch.getLabel()); - text = (TextView) dialog.findViewById(R.id.utf8Label); + text = (TextView) dialog.findViewById(R.id.encodingLabel); StringBuilder s = new StringBuilder(); Formatter fmt = new Formatter(s); fmt.format("UTF-8:"); @@ -117,7 +118,25 @@ public final class UnicodeMapActivity extends ListActivity { dialog.show(); return true; } else if ( it instanceof UnicodeCharacter.Range ) { - return false; + UnicodeCharacter.Range itr = (UnicodeCharacter.Range)it; + Dialog dialog = new Dialog(UnicodeMapActivity.this); + dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); + dialog.setOwnerActivity(UnicodeMapActivity.this); + dialog.setContentView(R.layout.range_details); + dialog.setCancelable(true); + TextView text; + text = (TextView) dialog.findViewById(R.id.rangeDescrLabel); + text.setText(itr.getDescr()); + text = (TextView) dialog.findViewById(R.id.rangeRangeLabel); + StringBuilder s = new StringBuilder(); + Formatter fmt = new Formatter(s); + fmt.format("%04X\u2013%04X (%d slots, %d chars)", + itr.getFrom(), itr.getTo()-1, + itr.getTo()-itr.getFrom(), + db.countRange(itr.getFrom(), itr.getTo())); + text.setText(new String(s)); + dialog.show(); + return true; } else throw new AssertionError("unknown UnicodeDisplayable"); } -- cgit v1.2.3