summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--AndroidManifest.xml1
-rw-r--r--res/layout/char_item.xml (renamed from res/layout/list_item.xml)0
-rw-r--r--res/layout/range_item.xml (renamed from res/layout/map_item.xml)0
-rw-r--r--src/org/madore/android/unicodeMap/UnicodeArrayAdapter.java65
-rw-r--r--src/org/madore/android/unicodeMap/UnicodeCharacter.java279
-rw-r--r--src/org/madore/android/unicodeMap/UnicodeDisplayable.java5
-rw-r--r--src/org/madore/android/unicodeMap/UnicodeListActivity.java62
-rw-r--r--src/org/madore/android/unicodeMap/UnicodeMapActivity.java303
8 files changed, 345 insertions, 370 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 104ba58..f808e80 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -10,6 +10,5 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
- <activity android:name=".UnicodeListActivity" />
</application>
</manifest>
diff --git a/res/layout/list_item.xml b/res/layout/char_item.xml
index 3b8c592..3b8c592 100644
--- a/res/layout/list_item.xml
+++ b/res/layout/char_item.xml
diff --git a/res/layout/map_item.xml b/res/layout/range_item.xml
index fcaf32d..fcaf32d 100644
--- a/res/layout/map_item.xml
+++ b/res/layout/range_item.xml
diff --git a/src/org/madore/android/unicodeMap/UnicodeArrayAdapter.java b/src/org/madore/android/unicodeMap/UnicodeArrayAdapter.java
new file mode 100644
index 0000000..691d525
--- /dev/null
+++ b/src/org/madore/android/unicodeMap/UnicodeArrayAdapter.java
@@ -0,0 +1,65 @@
+package org.madore.android.unicodeMap;
+
+import java.util.List;
+import android.content.Context;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.LayoutInflater;
+import android.widget.ArrayAdapter;
+import android.widget.TextView;
+
+public class UnicodeArrayAdapter
+ extends ArrayAdapter<UnicodeDisplayable> {
+
+ protected Context context;
+ protected LayoutInflater inflater;
+
+ public UnicodeArrayAdapter(Context context) {
+ super(context, 0);
+ this.context = context;
+ this.inflater
+ = (LayoutInflater)context
+ .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ }
+
+ public UnicodeArrayAdapter(Context context,
+ List<UnicodeDisplayable> objects) {
+ super(context, 0, objects);
+ this.context = context;
+ this.inflater
+ = (LayoutInflater)context
+ .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ }
+
+ public View getView(int position, View convertView, ViewGroup parent) {
+ UnicodeDisplayable item = this.getItem(position);
+ View view = null;
+ if ( item instanceof UnicodeCharacter ) {
+ View charTextView = null; View labelTextView = null;
+ if ( convertView != null ) {
+ charTextView = convertView.findViewById(R.id.charText);
+ labelTextView = convertView.findViewById(R.id.labelText);
+ if ( charTextView != null && labelTextView != null )
+ view = convertView;
+ }
+ if ( view == null ) {
+ view = inflater.inflate(R.layout.char_item, parent, false);
+ charTextView = view.findViewById(R.id.charText);
+ labelTextView = view.findViewById(R.id.labelText);
+ }
+ ((TextView)charTextView).setText(((UnicodeCharacter)item).getChar());
+ ((TextView)labelTextView).setText(((UnicodeCharacter)item).getLabel());
+ } else if ( item instanceof UnicodeCharacter.Range ) {
+ if ( convertView != null
+ && convertView instanceof TextView ) {
+ view = convertView;
+ }
+ if ( view == null )
+ view = inflater.inflate(R.layout.range_item, parent, false);
+ ((TextView)view).setText(((UnicodeCharacter.Range)item).getDescr());
+ } else
+ throw new AssertionError("unknown UnicodeDisplayable");
+ return view;
+ }
+
+}
diff --git a/src/org/madore/android/unicodeMap/UnicodeCharacter.java b/src/org/madore/android/unicodeMap/UnicodeCharacter.java
index 7fad75d..8fb64f7 100644
--- a/src/org/madore/android/unicodeMap/UnicodeCharacter.java
+++ b/src/org/madore/android/unicodeMap/UnicodeCharacter.java
@@ -1,16 +1,201 @@
package org.madore.android.unicodeMap;
import java.util.Arrays;
-import java.util.Collection;
import java.util.Set;
import java.util.Map;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Formatter;
-public class UnicodeCharacter implements Map<String,String> {
+public class UnicodeCharacter implements UnicodeDisplayable {
- enum Category {
+ public static enum Range implements UnicodeDisplayable {
+ BASIC_LATIN(0x0000, 0x0080, "Basic Latin"),
+ LATIN_1_SUPPLEMENT(0x0080, 0x0100, "Latin-1 Supplement"),
+ LATIN_EXTENDED_A(0x0100, 0x0180, "Latin Extended-A"),
+ LATIN_EXTENDED_B(0x0180, 0x0250, "Latin Extended-B"),
+ IPA_EXTENSIONS(0x0250, 0x02b0, "IPA Extensions"),
+ SPACING_MODIFIER_LETTERS(0x02B0, 0x02FF, "Spacing Modifier Letters"),
+ COMBINING_DIACRITICAL_MARKS(0x0300, 0x036F, "Combining Diacritical Marks"),
+ GREEK_AND_COPTIC(0x0370, 0x03FF, "Greek and Coptic"),
+ CYRILLIC(0x0400, 0x04FF, "Cyrillic"),
+ CYRILLIC_SUPPLEMENT(0x0500, 0x052F, "Cyrillic Supplement"),
+ ARMENIAN(0x0530, 0x058F, "Armenian"),
+ HEBREW(0x0590, 0x05FF, "Hebrew"),
+ ARABIC(0x0600, 0x06FF, "Arabic"),
+ SYRIAC(0x0700, 0x074F, "Syriac"),
+ ARABIC_SUPPLEMENT(0x0750, 0x077F, "Arabic Supplement"),
+ THAANA(0x0780, 0x07BF, "Thaana"),
+ NKO(0x07C0, 0x07FF, "NKo"),
+ DEVANAGARI(0x0900, 0x097F, "Devanagari"),
+ BENGALI(0x0980, 0x09FF, "Bengali"),
+ GURMUKHI(0x0A00, 0x0A7F, "Gurmukhi"),
+ GUJARATI(0x0A80, 0x0AFF, "Gujarati"),
+ ORIYA(0x0B00, 0x0B7F, "Oriya"),
+ TAMIL(0x0B80, 0x0BFF, "Tamil"),
+ TELUGU(0x0C00, 0x0C7F, "Telugu"),
+ KANNADA(0x0C80, 0x0CFF, "Kannada"),
+ MALAYALAM(0x0D00, 0x0D7F, "Malayalam"),
+ SINHALA(0x0D80, 0x0DFF, "Sinhala"),
+ THAI(0x0E00, 0x0E7F, "Thai"),
+ LAO(0x0E80, 0x0EFF, "Lao"),
+ TIBETAN(0x0F00, 0x0FFF, "Tibetan"),
+ MYANMAR(0x1000, 0x109F, "Myanmar"),
+ GEORGIAN(0x10A0, 0x10FF, "Georgian"),
+ HANGUL_JAMO(0x1100, 0x11FF, "Hangul Jamo"),
+ ETHIOPIC(0x1200, 0x137F, "Ethiopic"),
+ ETHIOPIC_SUPPLEMENT(0x1380, 0x139F, "Ethiopic Supplement"),
+ CHEROKEE(0x13A0, 0x13FF, "Cherokee"),
+ UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS(0x1400, 0x167F, "Unified Canadian Aboriginal Syllabics"),
+ OGHAM(0x1680, 0x169F, "Ogham"),
+ RUNIC(0x16A0, 0x16FF, "Runic"),
+ TAGALOG(0x1700, 0x171F, "Tagalog"),
+ HANUNOO(0x1720, 0x173F, "Hanunoo"),
+ BUHID(0x1740, 0x175F, "Buhid"),
+ TAGBANWA(0x1760, 0x177F, "Tagbanwa"),
+ KHMER(0x1780, 0x17FF, "Khmer"),
+ MONGOLIAN(0x1800, 0x18AF, "Mongolian"),
+ LIMBU(0x1900, 0x194F, "Limbu"),
+ TAI_LE(0x1950, 0x197F, "Tai Le"),
+ NEW_TAI_LUE(0x1980, 0x19DF, "New Tai Lue"),
+ KHMER_SYMBOLS(0x19E0, 0x19FF, "Khmer Symbols"),
+ BUGINESE(0x1A00, 0x1A1F, "Buginese"),
+ BALINESE(0x1B00, 0x1B7F, "Balinese"),
+ SUNDANESE(0x1B80, 0x1BBF, "Sundanese"),
+ LEPCHA(0x1C00, 0x1C4F, "Lepcha"),
+ OL_CHIKI(0x1C50, 0x1C7F, "Ol Chiki"),
+ PHONETIC_EXTENSIONS(0x1D00, 0x1D7F, "Phonetic Extensions"),
+ PHONETIC_EXTENSIONS_SUPPLEMENT(0x1D80, 0x1DBF, "Phonetic Extensions Supplement"),
+ COMBINING_DIACRITICAL_MARKS_SUPPLEMENT(0x1DC0, 0x1DFF, "Combining Diacritical Marks Supplement"),
+ LATIN_EXTENDED_ADDITIONAL(0x1E00, 0x1EFF, "Latin Extended Additional"),
+ GREEK_EXTENDED(0x1F00, 0x1FFF, "Greek Extended"),
+ GENERAL_PUNCTUATION(0x2000, 0x206F, "General Punctuation"),
+ SUPERSCRIPTS_AND_SUBSCRIPTS(0x2070, 0x209F, "Superscripts and Subscripts"),
+ CURRENCY_SYMBOLS(0x20A0, 0x20CF, "Currency Symbols"),
+ COMBINING_DIACRITICAL_MARKS_FOR_SYMBOLS(0x20D0, 0x20FF, "Combining Diacritical Marks for Symbols"),
+ LETTERLIKE_SYMBOLS(0x2100, 0x214F, "Letterlike Symbols"),
+ NUMBER_FORMS(0x2150, 0x218F, "Number Forms"),
+ ARROWS(0x2190, 0x21FF, "Arrows"),
+ MATHEMATICAL_OPERATORS(0x2200, 0x22FF, "Mathematical Operators"),
+ MISCELLANEOUS_TECHNICAL(0x2300, 0x23FF, "Miscellaneous Technical"),
+ CONTROL_PICTURES(0x2400, 0x243F, "Control Pictures"),
+ OPTICAL_CHARACTER_RECOGNITION(0x2440, 0x245F, "Optical Character Recognition"),
+ ENCLOSED_ALPHANUMERICS(0x2460, 0x24FF, "Enclosed Alphanumerics"),
+ BOX_DRAWING(0x2500, 0x257F, "Box Drawing"),
+ BLOCK_ELEMENTS(0x2580, 0x259F, "Block Elements"),
+ GEOMETRIC_SHAPES(0x25A0, 0x25FF, "Geometric Shapes"),
+ MISCELLANEOUS_SYMBOLS(0x2600, 0x26FF, "Miscellaneous Symbols"),
+ DINGBATS(0x2700, 0x27BF, "Dingbats"),
+ MISCELLANEOUS_MATHEMATICAL_SYMBOLS_A(0x27C0, 0x27EF, "Miscellaneous Mathematical Symbols-A"),
+ SUPPLEMENTAL_ARROWS_A(0x27F0, 0x27FF, "Supplemental Arrows-A"),
+ BRAILLE_PATTERNS(0x2800, 0x28FF, "Braille Patterns"),
+ SUPPLEMENTAL_ARROWS_B(0x2900, 0x297F, "Supplemental Arrows-B"),
+ MISCELLANEOUS_MATHEMATICAL_SYMBOLS_B(0x2980, 0x29FF, "Miscellaneous Mathematical Symbols-B"),
+ SUPPLEMENTAL_MATHEMATICAL_OPERATORS(0x2A00, 0x2AFF, "Supplemental Mathematical Operators"),
+ MISCELLANEOUS_SYMBOLS_AND_ARROWS(0x2B00, 0x2BFF, "Miscellaneous Symbols and Arrows"),
+ GLAGOLITIC(0x2C00, 0x2C5F, "Glagolitic"),
+ LATIN_EXTENDED_C(0x2C60, 0x2C7F, "Latin Extended-C"),
+ COPTIC(0x2C80, 0x2CFF, "Coptic"),
+ GEORGIAN_SUPPLEMENT(0x2D00, 0x2D2F, "Georgian Supplement"),
+ TIFINAGH(0x2D30, 0x2D7F, "Tifinagh"),
+ ETHIOPIC_EXTENDED(0x2D80, 0x2DDF, "Ethiopic Extended"),
+ CYRILLIC_EXTENDED_A(0x2DE0, 0x2DFF, "Cyrillic Extended-A"),
+ SUPPLEMENTAL_PUNCTUATION(0x2E00, 0x2E7F, "Supplemental Punctuation"),
+ CJK_RADICALS_SUPPLEMENT(0x2E80, 0x2EFF, "CJK Radicals Supplement"),
+ KANGXI_RADICALS(0x2F00, 0x2FDF, "Kangxi Radicals"),
+ IDEOGRAPHIC_DESCRIPTION_CHARACTERS(0x2FF0, 0x2FFF, "Ideographic Description Characters"),
+ CJK_SYMBOLS_AND_PUNCTUATION(0x3000, 0x303F, "CJK Symbols and Punctuation"),
+ HIRAGANA(0x3040, 0x309F, "Hiragana"),
+ KATAKANA(0x30A0, 0x30FF, "Katakana"),
+ BOPOMOFO(0x3100, 0x312F, "Bopomofo"),
+ HANGUL_COMPATIBILITY_JAMO(0x3130, 0x318F, "Hangul Compatibility Jamo"),
+ KANBUN(0x3190, 0x319F, "Kanbun"),
+ BOPOMOFO_EXTENDED(0x31A0, 0x31BF, "Bopomofo Extended"),
+ CJK_STROKES(0x31C0, 0x31EF, "CJK Strokes"),
+ KATAKANA_PHONETIC_EXTENSIONS(0x31F0, 0x31FF, "Katakana Phonetic Extensions"),
+ ENCLOSED_CJK_LETTERS_AND_MONTHS(0x3200, 0x32FF, "Enclosed CJK Letters and Months"),
+ CJK_COMPATIBILITY(0x3300, 0x33FF, "CJK Compatibility"),
+ CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A(0x3400, 0x4DBF, "CJK Unified Ideographs Extension A"),
+ YIJING_HEXAGRAM_SYMBOLS(0x4DC0, 0x4DFF, "Yijing Hexagram Symbols"),
+ CJK_UNIFIED_IDEOGRAPHS(0x4E00, 0x9FFF, "CJK Unified Ideographs"),
+ YI_SYLLABLES(0xA000, 0xA48F, "Yi Syllables"),
+ YI_RADICALS(0xA490, 0xA4CF, "Yi Radicals"),
+ VAI(0xA500, 0xA63F, "Vai"),
+ CYRILLIC_EXTENDED_B(0xA640, 0xA69F, "Cyrillic Extended-B"),
+ MODIFIER_TONE_LETTERS(0xA700, 0xA71F, "Modifier Tone Letters"),
+ LATIN_EXTENDED_D(0xA720, 0xA7FF, "Latin Extended-D"),
+ SYLOTI_NAGRI(0xA800, 0xA82F, "Syloti Nagri"),
+ PHAGS_PA(0xA840, 0xA87F, "Phags-pa"),
+ SAURASHTRA(0xA880, 0xA8DF, "Saurashtra"),
+ KAYAH_LI(0xA900, 0xA92F, "Kayah Li"),
+ REJANG(0xA930, 0xA95F, "Rejang"),
+ CHAM(0xAA00, 0xAA5F, "Cham"),
+ HANGUL_SYLLABLES(0xAC00, 0xD7AF, "Hangul Syllables"),
+ HIGH_SURROGATES(0xD800, 0xDB7F, "High Surrogates"),
+ HIGH_PRIVATE_USE_SURROGATES(0xDB80, 0xDBFF, "High Private Use Surrogates"),
+ LOW_SURROGATES(0xDC00, 0xDFFF, "Low Surrogates"),
+ PRIVATE_USE_AREA(0xE000, 0xF8FF, "Private Use Area"),
+ CJK_COMPATIBILITY_IDEOGRAPHS(0xF900, 0xFAFF, "CJK Compatibility Ideographs"),
+ ALPHABETIC_PRESENTATION_FORMS(0xFB00, 0xFB4F, "Alphabetic Presentation Forms"),
+ ARABIC_PRESENTATION_FORMS_A(0xFB50, 0xFDFF, "Arabic Presentation Forms-A"),
+ VARIATION_SELECTORS(0xFE00, 0xFE0F, "Variation Selectors"),
+ VERTICAL_FORMS(0xFE10, 0xFE1F, "Vertical Forms"),
+ COMBINING_HALF_MARKS(0xFE20, 0xFE2F, "Combining Half Marks"),
+ CJK_COMPATIBILITY_FORMS(0xFE30, 0xFE4F, "CJK Compatibility Forms"),
+ SMALL_FORM_VARIANTS(0xFE50, 0xFE6F, "Small Form Variants"),
+ ARABIC_PRESENTATION_FORMS_B(0xFE70, 0xFEFF, "Arabic Presentation Forms-B"),
+ HALFWIDTH_AND_FULLWIDTH_FORMS(0xFF00, 0xFFEF, "Halfwidth and Fullwidth Forms"),
+ SPECIALS(0xFFF0, 0xFFFF, "Specials"),
+ LINEAR_B_SYLLABARY(0x10000, 0x1007F, "Linear B Syllabary"),
+ LINEAR_B_IDEOGRAMS(0x10080, 0x100FF, "Linear B Ideograms"),
+ AEGEAN_NUMBERS(0x10100, 0x1013F, "Aegean Numbers"),
+ ANCIENT_GREEK_NUMBERS(0x10140, 0x1018F, "Ancient Greek Numbers"),
+ ANCIENT_SYMBOLS(0x10190, 0x101CF, "Ancient Symbols"),
+ PHAISTOS_DISC(0x101D0, 0x101FF, "Phaistos Disc"),
+ LYCIAN(0x10280, 0x1029F, "Lycian"),
+ CARIAN(0x102A0, 0x102DF, "Carian"),
+ OLD_ITALIC(0x10300, 0x1032F, "Old Italic"),
+ GOTHIC(0x10330, 0x1034F, "Gothic"),
+ UGARITIC(0x10380, 0x1039F, "Ugaritic"),
+ OLD_PERSIAN(0x103A0, 0x103DF, "Old Persian"),
+ DESERET(0x10400, 0x1044F, "Deseret"),
+ SHAVIAN(0x10450, 0x1047F, "Shavian"),
+ OSMANYA(0x10480, 0x104AF, "Osmanya"),
+ CYPRIOT_SYLLABARY(0x10800, 0x1083F, "Cypriot Syllabary"),
+ PHOENICIAN(0x10900, 0x1091F, "Phoenician"),
+ LYDIAN(0x10920, 0x1093F, "Lydian"),
+ KHAROSHTHI(0x10A00, 0x10A5F, "Kharoshthi"),
+ CUNEIFORM(0x12000, 0x123FF, "Cuneiform"),
+ CUNEIFORM_NUMBERS_AND_PUNCTUATION(0x12400, 0x1247F, "Cuneiform Numbers and Punctuation"),
+ BYZANTINE_MUSICAL_SYMBOLS(0x1D000, 0x1D0FF, "Byzantine Musical Symbols"),
+ MUSICAL_SYMBOLS(0x1D100, 0x1D1FF, "Musical Symbols"),
+ ANCIENT_GREEK_MUSICAL_NOTATION(0x1D200, 0x1D24F, "Ancient Greek Musical Notation"),
+ TAI_XUAN_JING_SYMBOLS(0x1D300, 0x1D35F, "Tai Xuan Jing Symbols"),
+ COUNTING_ROD_NUMERALS(0x1D360, 0x1D37F, "Counting Rod Numerals"),
+ MATHEMATICAL_ALPHANUMERIC_SYMBOLS(0x1D400, 0x1D7FF, "Mathematical Alphanumeric Symbols"),
+ MAHJONG_TILES(0x1F000, 0x1F02F, "Mahjong Tiles"),
+ DOMINO_TILES(0x1F030, 0x1F09F, "Domino Tiles"),
+ CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B(0x20000, 0x2A6DF, "CJK Unified Ideographs Extension B"),
+ CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT(0x2F800, 0x2FA1F, "CJK Compatibility Ideographs Supplement"),
+ TAGS(0xE0000, 0xE007F, "Tags"),
+ VARIATION_SELECTORS_SUPPLEMENT(0xE0100, 0xE01EF, "Variation Selectors Supplement"),
+ SUPPLEMENTARY_PRIVATE_USE_AREA_A(0xF0000, 0xFFFFF, "Supplementary Private Use Area-A"),
+ SUPPLEMENTARY_PRIVATE_USE_AREA_B(0x100000, 0x10FFFF, "Supplementary Private Use Area-B");
+ protected final int from; protected final int to;
+ protected final String descr;
+ Range(int from, int to, String descr) {
+ this.from = from;
+ this.to = to;
+ this.descr = descr;
+ }
+ public int getFrom() { return this.from; }
+ public int getTo() { return this.to; }
+ public String getDescr() { return this.descr; }
+ @Override
+ public String toString() { return this.descr; }
+ }
+
+ public static enum Category {
UPPERCASE_LETTER("Lu", Character.UPPERCASE_LETTER),
LOWERCASE_LETTER("Ll", Character.LOWERCASE_LETTER),
TITLECASE_LETTER("Lt", Character.TITLECASE_LETTER),
@@ -41,8 +226,8 @@ public class UnicodeCharacter implements Map<String,String> {
SURROGATE("Cs", Character.SURROGATE),
PRIVATE_USE("Co", Character.PRIVATE_USE),
UNASSIGNED("Cn", Character.UNASSIGNED);
- public final String code;
- public final byte javaValue;
+ protected final String code;
+ protected final byte javaValue;
Category(String code, byte javaValue) {
this.code = code;
this.javaValue = javaValue;
@@ -53,12 +238,14 @@ public class UnicodeCharacter implements Map<String,String> {
for ( Category cat : Category.values() )
revMap.put(cat.code, cat);
}
- static Category fromCode(String code) {
+ public static Category fromCode(String code) {
Category cat = revMap.get(code);
if ( cat == null )
cat = UNASSIGNED;
return cat;
}
+ public String getCode() { return this.code; }
+ public byte getJavaValue() { return this.javaValue; }
}
protected final static Set<Category> printable;
@@ -118,85 +305,7 @@ public class UnicodeCharacter implements Map<String,String> {
@Override
public String toString() {
- StringBuilder s = new StringBuilder();
- if ( this.isPrintable() ) {
- s.append(Character.toChars(codePoint));
- s.append(": ");
- }
- Formatter fmt = new Formatter(s);
- if ( codePoint < 0x10000 )
- fmt.format("U+%04X %s", codePoint, name);
- else
- fmt.format("U+%X %s", codePoint, name);
- return new String(s);
- }
-
- public final static String KEY_CHAR = "char";
- public final static String KEY_LABEL = "label";
-
- public void clear() {
- throw new UnsupportedOperationException();
- }
-
- public boolean containsKey(Object key) {
- throw new UnsupportedOperationException();
- }
-
- public boolean containsValue(Object value) {
- throw new UnsupportedOperationException();
- }
-
- public Set<Map.Entry<String,String>> entrySet() {
- throw new UnsupportedOperationException();
- }
-
- public boolean equals(Object o) {
- throw new UnsupportedOperationException();
- }
-
- public String get(Object key) {
- if ( key == null )
- throw new NullPointerException();
- else if ( key instanceof String && key.equals(KEY_CHAR) )
- return getChar();
- else if ( key instanceof String && key.equals(KEY_LABEL) )
- return getLabel();
- else if ( key instanceof String )
- return null;
- else
- throw new ClassCastException();
- }
-
- public int hashCode() {
- throw new UnsupportedOperationException();
- }
-
- public boolean isEmpty() {
- throw new UnsupportedOperationException();
- }
-
- public Set<String> keySet() {
- throw new UnsupportedOperationException();
- }
-
- public String put(String key, String value) {
- throw new UnsupportedOperationException();
- }
-
- public void putAll(Map<? extends String,? extends String> t) {
- throw new UnsupportedOperationException();
- }
-
- public String remove(Object key) {
- throw new UnsupportedOperationException();
- }
-
- public int size() {
- throw new UnsupportedOperationException();
- }
-
- public Collection<String> values() {
- throw new UnsupportedOperationException();
+ return this.getLabel();
}
}
diff --git a/src/org/madore/android/unicodeMap/UnicodeDisplayable.java b/src/org/madore/android/unicodeMap/UnicodeDisplayable.java
new file mode 100644
index 0000000..5b4043b
--- /dev/null
+++ b/src/org/madore/android/unicodeMap/UnicodeDisplayable.java
@@ -0,0 +1,5 @@
+package org.madore.android.unicodeMap;
+
+public interface UnicodeDisplayable {
+
+}
diff --git a/src/org/madore/android/unicodeMap/UnicodeListActivity.java b/src/org/madore/android/unicodeMap/UnicodeListActivity.java
deleted file mode 100644
index 2e37d6f..0000000
--- a/src/org/madore/android/unicodeMap/UnicodeListActivity.java
+++ /dev/null
@@ -1,62 +0,0 @@
-package org.madore.android.unicodeMap;
-
-import java.util.List;
-import java.util.ArrayList;
-import android.content.Context;
-import android.content.Intent;
-import android.content.res.AssetManager;
-import android.os.Bundle;
-import android.view.View;
-import android.widget.*;
-import android.text.ClipboardManager;
-import android.app.ListActivity;
-
-public final class UnicodeListActivity extends ListActivity {
-
- public static final String EXTRA_FROM
- = "org.madore.android.unicodeMap.range.From";
- public static final String EXTRA_TO
- = "org.madore.android.unicodeMap.range.To";
-
- protected UnicodeDatabase db;
- protected List<UnicodeCharacter> list;
-
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main_layout);
- this.db = new UnicodeDatabase(this);
- Intent intent = getIntent();
- int from = intent.getIntExtra(EXTRA_FROM, 0);
- int to = intent.getIntExtra(EXTRA_TO, from+128);
- this.list = new ArrayList<UnicodeCharacter>(db.countRange(from,to));
- for ( UnicodeCharacter ch : db.getRange(from,to) )
- list.add(ch);
- final ClipboardManager cmgr
- = (ClipboardManager)getSystemService(Context.CLIPBOARD_SERVICE);
- setListAdapter(new SimpleAdapter(this, list, R.layout.list_item,
- new String[] { "char", "label" },
- new int[] { R.id.charText, R.id.labelText }));
- final Button btn = (Button) findViewById(R.id.button);
- final EditText txt = (EditText) findViewById(R.id.edit);
- btn.setOnClickListener(new View.OnClickListener() {
- public void onClick(View view) {
- cmgr.setText(txt.getText());
- Toast.makeText(getApplicationContext(), "Copied to clipboard",
- Toast.LENGTH_SHORT).show();
- }
- });
- final ListView lv = getListView();
- lv.setTextFilterEnabled(true);
- lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
- public void onItemClick(AdapterView<?> parent, View view,
- int position, long id) {
- UnicodeCharacter it = (UnicodeCharacter)parent.getItemAtPosition(position);
- txt.append(new String(Character.toChars(it.getCodePoint())));
- }
- });
-
- }
-
-}
diff --git a/src/org/madore/android/unicodeMap/UnicodeMapActivity.java b/src/org/madore/android/unicodeMap/UnicodeMapActivity.java
index 7ef9b68..aee9e71 100644
--- a/src/org/madore/android/unicodeMap/UnicodeMapActivity.java
+++ b/src/org/madore/android/unicodeMap/UnicodeMapActivity.java
@@ -2,204 +2,56 @@ package org.madore.android.unicodeMap;
import java.util.Arrays;
import java.util.List;
+import java.util.ArrayList;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
+import android.view.KeyEvent;
import android.widget.*;
+import android.text.ClipboardManager;
import android.app.ListActivity;
import android.app.ProgressDialog;
public final class UnicodeMapActivity extends ListActivity {
- protected static enum UnicodeRange {
- BASIC_LATIN(0x0000, 0x0080, "Basic Latin"),
- LATIN_1_SUPPLEMENT(0x0080, 0x0100, "Latin-1 Supplement"),
- LATIN_EXTENDED_A(0x0100, 0x0180, "Latin Extended-A"),
- LATIN_EXTENDED_B(0x0180, 0x0250, "Latin Extended-B"),
- IPA_EXTENSIONS(0x0250, 0x02b0, "IPA Extensions"),
- SPACING_MODIFIER_LETTERS(0x02B0, 0x02FF, "Spacing Modifier Letters"),
- COMBINING_DIACRITICAL_MARKS(0x0300, 0x036F, "Combining Diacritical Marks"),
- GREEK_AND_COPTIC(0x0370, 0x03FF, "Greek and Coptic"),
- CYRILLIC(0x0400, 0x04FF, "Cyrillic"),
- CYRILLIC_SUPPLEMENT(0x0500, 0x052F, "Cyrillic Supplement"),
- ARMENIAN(0x0530, 0x058F, "Armenian"),
- HEBREW(0x0590, 0x05FF, "Hebrew"),
- ARABIC(0x0600, 0x06FF, "Arabic"),
- SYRIAC(0x0700, 0x074F, "Syriac"),
- ARABIC_SUPPLEMENT(0x0750, 0x077F, "Arabic Supplement"),
- THAANA(0x0780, 0x07BF, "Thaana"),
- NKO(0x07C0, 0x07FF, "NKo"),
- DEVANAGARI(0x0900, 0x097F, "Devanagari"),
- BENGALI(0x0980, 0x09FF, "Bengali"),
- GURMUKHI(0x0A00, 0x0A7F, "Gurmukhi"),
- GUJARATI(0x0A80, 0x0AFF, "Gujarati"),
- ORIYA(0x0B00, 0x0B7F, "Oriya"),
- TAMIL(0x0B80, 0x0BFF, "Tamil"),
- TELUGU(0x0C00, 0x0C7F, "Telugu"),
- KANNADA(0x0C80, 0x0CFF, "Kannada"),
- MALAYALAM(0x0D00, 0x0D7F, "Malayalam"),
- SINHALA(0x0D80, 0x0DFF, "Sinhala"),
- THAI(0x0E00, 0x0E7F, "Thai"),
- LAO(0x0E80, 0x0EFF, "Lao"),
- TIBETAN(0x0F00, 0x0FFF, "Tibetan"),
- MYANMAR(0x1000, 0x109F, "Myanmar"),
- GEORGIAN(0x10A0, 0x10FF, "Georgian"),
- HANGUL_JAMO(0x1100, 0x11FF, "Hangul Jamo"),
- ETHIOPIC(0x1200, 0x137F, "Ethiopic"),
- ETHIOPIC_SUPPLEMENT(0x1380, 0x139F, "Ethiopic Supplement"),
- CHEROKEE(0x13A0, 0x13FF, "Cherokee"),
- UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS(0x1400, 0x167F, "Unified Canadian Aboriginal Syllabics"),
- OGHAM(0x1680, 0x169F, "Ogham"),
- RUNIC(0x16A0, 0x16FF, "Runic"),
- TAGALOG(0x1700, 0x171F, "Tagalog"),
- HANUNOO(0x1720, 0x173F, "Hanunoo"),
- BUHID(0x1740, 0x175F, "Buhid"),
- TAGBANWA(0x1760, 0x177F, "Tagbanwa"),
- KHMER(0x1780, 0x17FF, "Khmer"),
- MONGOLIAN(0x1800, 0x18AF, "Mongolian"),
- LIMBU(0x1900, 0x194F, "Limbu"),
- TAI_LE(0x1950, 0x197F, "Tai Le"),
- NEW_TAI_LUE(0x1980, 0x19DF, "New Tai Lue"),
- KHMER_SYMBOLS(0x19E0, 0x19FF, "Khmer Symbols"),
- BUGINESE(0x1A00, 0x1A1F, "Buginese"),
- BALINESE(0x1B00, 0x1B7F, "Balinese"),
- SUNDANESE(0x1B80, 0x1BBF, "Sundanese"),
- LEPCHA(0x1C00, 0x1C4F, "Lepcha"),
- OL_CHIKI(0x1C50, 0x1C7F, "Ol Chiki"),
- PHONETIC_EXTENSIONS(0x1D00, 0x1D7F, "Phonetic Extensions"),
- PHONETIC_EXTENSIONS_SUPPLEMENT(0x1D80, 0x1DBF, "Phonetic Extensions Supplement"),
- COMBINING_DIACRITICAL_MARKS_SUPPLEMENT(0x1DC0, 0x1DFF, "Combining Diacritical Marks Supplement"),
- LATIN_EXTENDED_ADDITIONAL(0x1E00, 0x1EFF, "Latin Extended Additional"),
- GREEK_EXTENDED(0x1F00, 0x1FFF, "Greek Extended"),
- GENERAL_PUNCTUATION(0x2000, 0x206F, "General Punctuation"),
- SUPERSCRIPTS_AND_SUBSCRIPTS(0x2070, 0x209F, "Superscripts and Subscripts"),
- CURRENCY_SYMBOLS(0x20A0, 0x20CF, "Currency Symbols"),
- COMBINING_DIACRITICAL_MARKS_FOR_SYMBOLS(0x20D0, 0x20FF, "Combining Diacritical Marks for Symbols"),
- LETTERLIKE_SYMBOLS(0x2100, 0x214F, "Letterlike Symbols"),
- NUMBER_FORMS(0x2150, 0x218F, "Number Forms"),
- ARROWS(0x2190, 0x21FF, "Arrows"),
- MATHEMATICAL_OPERATORS(0x2200, 0x22FF, "Mathematical Operators"),
- MISCELLANEOUS_TECHNICAL(0x2300, 0x23FF, "Miscellaneous Technical"),
- CONTROL_PICTURES(0x2400, 0x243F, "Control Pictures"),
- OPTICAL_CHARACTER_RECOGNITION(0x2440, 0x245F, "Optical Character Recognition"),
- ENCLOSED_ALPHANUMERICS(0x2460, 0x24FF, "Enclosed Alphanumerics"),
- BOX_DRAWING(0x2500, 0x257F, "Box Drawing"),
- BLOCK_ELEMENTS(0x2580, 0x259F, "Block Elements"),
- GEOMETRIC_SHAPES(0x25A0, 0x25FF, "Geometric Shapes"),
- MISCELLANEOUS_SYMBOLS(0x2600, 0x26FF, "Miscellaneous Symbols"),
- DINGBATS(0x2700, 0x27BF, "Dingbats"),
- MISCELLANEOUS_MATHEMATICAL_SYMBOLS_A(0x27C0, 0x27EF, "Miscellaneous Mathematical Symbols-A"),
- SUPPLEMENTAL_ARROWS_A(0x27F0, 0x27FF, "Supplemental Arrows-A"),
- BRAILLE_PATTERNS(0x2800, 0x28FF, "Braille Patterns"),
- SUPPLEMENTAL_ARROWS_B(0x2900, 0x297F, "Supplemental Arrows-B"),
- MISCELLANEOUS_MATHEMATICAL_SYMBOLS_B(0x2980, 0x29FF, "Miscellaneous Mathematical Symbols-B"),
- SUPPLEMENTAL_MATHEMATICAL_OPERATORS(0x2A00, 0x2AFF, "Supplemental Mathematical Operators"),
- MISCELLANEOUS_SYMBOLS_AND_ARROWS(0x2B00, 0x2BFF, "Miscellaneous Symbols and Arrows"),
- GLAGOLITIC(0x2C00, 0x2C5F, "Glagolitic"),
- LATIN_EXTENDED_C(0x2C60, 0x2C7F, "Latin Extended-C"),
- COPTIC(0x2C80, 0x2CFF, "Coptic"),
- GEORGIAN_SUPPLEMENT(0x2D00, 0x2D2F, "Georgian Supplement"),
- TIFINAGH(0x2D30, 0x2D7F, "Tifinagh"),
- ETHIOPIC_EXTENDED(0x2D80, 0x2DDF, "Ethiopic Extended"),
- CYRILLIC_EXTENDED_A(0x2DE0, 0x2DFF, "Cyrillic Extended-A"),
- SUPPLEMENTAL_PUNCTUATION(0x2E00, 0x2E7F, "Supplemental Punctuation"),
- CJK_RADICALS_SUPPLEMENT(0x2E80, 0x2EFF, "CJK Radicals Supplement"),
- KANGXI_RADICALS(0x2F00, 0x2FDF, "Kangxi Radicals"),
- IDEOGRAPHIC_DESCRIPTION_CHARACTERS(0x2FF0, 0x2FFF, "Ideographic Description Characters"),
- CJK_SYMBOLS_AND_PUNCTUATION(0x3000, 0x303F, "CJK Symbols and Punctuation"),
- HIRAGANA(0x3040, 0x309F, "Hiragana"),
- KATAKANA(0x30A0, 0x30FF, "Katakana"),
- BOPOMOFO(0x3100, 0x312F, "Bopomofo"),
- HANGUL_COMPATIBILITY_JAMO(0x3130, 0x318F, "Hangul Compatibility Jamo"),
- KANBUN(0x3190, 0x319F, "Kanbun"),
- BOPOMOFO_EXTENDED(0x31A0, 0x31BF, "Bopomofo Extended"),
- CJK_STROKES(0x31C0, 0x31EF, "CJK Strokes"),
- KATAKANA_PHONETIC_EXTENSIONS(0x31F0, 0x31FF, "Katakana Phonetic Extensions"),
- ENCLOSED_CJK_LETTERS_AND_MONTHS(0x3200, 0x32FF, "Enclosed CJK Letters and Months"),
- CJK_COMPATIBILITY(0x3300, 0x33FF, "CJK Compatibility"),
- CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A(0x3400, 0x4DBF, "CJK Unified Ideographs Extension A"),
- YIJING_HEXAGRAM_SYMBOLS(0x4DC0, 0x4DFF, "Yijing Hexagram Symbols"),
- CJK_UNIFIED_IDEOGRAPHS(0x4E00, 0x9FFF, "CJK Unified Ideographs"),
- YI_SYLLABLES(0xA000, 0xA48F, "Yi Syllables"),
- YI_RADICALS(0xA490, 0xA4CF, "Yi Radicals"),
- VAI(0xA500, 0xA63F, "Vai"),
- CYRILLIC_EXTENDED_B(0xA640, 0xA69F, "Cyrillic Extended-B"),
- MODIFIER_TONE_LETTERS(0xA700, 0xA71F, "Modifier Tone Letters"),
- LATIN_EXTENDED_D(0xA720, 0xA7FF, "Latin Extended-D"),
- SYLOTI_NAGRI(0xA800, 0xA82F, "Syloti Nagri"),
- PHAGS_PA(0xA840, 0xA87F, "Phags-pa"),
- SAURASHTRA(0xA880, 0xA8DF, "Saurashtra"),
- KAYAH_LI(0xA900, 0xA92F, "Kayah Li"),
- REJANG(0xA930, 0xA95F, "Rejang"),
- CHAM(0xAA00, 0xAA5F, "Cham"),
- HANGUL_SYLLABLES(0xAC00, 0xD7AF, "Hangul Syllables"),
- HIGH_SURROGATES(0xD800, 0xDB7F, "High Surrogates"),
- HIGH_PRIVATE_USE_SURROGATES(0xDB80, 0xDBFF, "High Private Use Surrogates"),
- LOW_SURROGATES(0xDC00, 0xDFFF, "Low Surrogates"),
- PRIVATE_USE_AREA(0xE000, 0xF8FF, "Private Use Area"),
- CJK_COMPATIBILITY_IDEOGRAPHS(0xF900, 0xFAFF, "CJK Compatibility Ideographs"),
- ALPHABETIC_PRESENTATION_FORMS(0xFB00, 0xFB4F, "Alphabetic Presentation Forms"),
- ARABIC_PRESENTATION_FORMS_A(0xFB50, 0xFDFF, "Arabic Presentation Forms-A"),
- VARIATION_SELECTORS(0xFE00, 0xFE0F, "Variation Selectors"),
- VERTICAL_FORMS(0xFE10, 0xFE1F, "Vertical Forms"),
- COMBINING_HALF_MARKS(0xFE20, 0xFE2F, "Combining Half Marks"),
- CJK_COMPATIBILITY_FORMS(0xFE30, 0xFE4F, "CJK Compatibility Forms"),
- SMALL_FORM_VARIANTS(0xFE50, 0xFE6F, "Small Form Variants"),
- ARABIC_PRESENTATION_FORMS_B(0xFE70, 0xFEFF, "Arabic Presentation Forms-B"),
- HALFWIDTH_AND_FULLWIDTH_FORMS(0xFF00, 0xFFEF, "Halfwidth and Fullwidth Forms"),
- SPECIALS(0xFFF0, 0xFFFF, "Specials"),
- LINEAR_B_SYLLABARY(0x10000, 0x1007F, "Linear B Syllabary"),
- LINEAR_B_IDEOGRAMS(0x10080, 0x100FF, "Linear B Ideograms"),
- AEGEAN_NUMBERS(0x10100, 0x1013F, "Aegean Numbers"),
- ANCIENT_GREEK_NUMBERS(0x10140, 0x1018F, "Ancient Greek Numbers"),
- ANCIENT_SYMBOLS(0x10190, 0x101CF, "Ancient Symbols"),
- PHAISTOS_DISC(0x101D0, 0x101FF, "Phaistos Disc"),
- LYCIAN(0x10280, 0x1029F, "Lycian"),
- CARIAN(0x102A0, 0x102DF, "Carian"),
- OLD_ITALIC(0x10300, 0x1032F, "Old Italic"),
- GOTHIC(0x10330, 0x1034F, "Gothic"),
- UGARITIC(0x10380, 0x1039F, "Ugaritic"),
- OLD_PERSIAN(0x103A0, 0x103DF, "Old Persian"),
- DESERET(0x10400, 0x1044F, "Deseret"),
- SHAVIAN(0x10450, 0x1047F, "Shavian"),
- OSMANYA(0x10480, 0x104AF, "Osmanya"),
- CYPRIOT_SYLLABARY(0x10800, 0x1083F, "Cypriot Syllabary"),
- PHOENICIAN(0x10900, 0x1091F, "Phoenician"),
- LYDIAN(0x10920, 0x1093F, "Lydian"),
- KHAROSHTHI(0x10A00, 0x10A5F, "Kharoshthi"),
- CUNEIFORM(0x12000, 0x123FF, "Cuneiform"),
- CUNEIFORM_NUMBERS_AND_PUNCTUATION(0x12400, 0x1247F, "Cuneiform Numbers and Punctuation"),
- BYZANTINE_MUSICAL_SYMBOLS(0x1D000, 0x1D0FF, "Byzantine Musical Symbols"),
- MUSICAL_SYMBOLS(0x1D100, 0x1D1FF, "Musical Symbols"),
- ANCIENT_GREEK_MUSICAL_NOTATION(0x1D200, 0x1D24F, "Ancient Greek Musical Notation"),
- TAI_XUAN_JING_SYMBOLS(0x1D300, 0x1D35F, "Tai Xuan Jing Symbols"),
- COUNTING_ROD_NUMERALS(0x1D360, 0x1D37F, "Counting Rod Numerals"),
- MATHEMATICAL_ALPHANUMERIC_SYMBOLS(0x1D400, 0x1D7FF, "Mathematical Alphanumeric Symbols"),
- MAHJONG_TILES(0x1F000, 0x1F02F, "Mahjong Tiles"),
- DOMINO_TILES(0x1F030, 0x1F09F, "Domino Tiles"),
- CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B(0x20000, 0x2A6DF, "CJK Unified Ideographs Extension B"),
- CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT(0x2F800, 0x2FA1F, "CJK Compatibility Ideographs Supplement"),
- TAGS(0xE0000, 0xE007F, "Tags"),
- VARIATION_SELECTORS_SUPPLEMENT(0xE0100, 0xE01EF, "Variation Selectors Supplement"),
- SUPPLEMENTARY_PRIVATE_USE_AREA_A(0xF0000, 0xFFFFF, "Supplementary Private Use Area-A"),
- SUPPLEMENTARY_PRIVATE_USE_AREA_B(0x100000, 0x10FFFF, "Supplementary Private Use Area-B");
- protected final int from; protected final int to;
- protected final String descr;
- UnicodeRange(int from, int to, String descr) {
- this.from = from;
- this.to = to;
- this.descr = descr;
- }
- public String toString() { return this.descr; }
- public int getFrom() { return this.from; }
- public int getTo() { return this.to; }
- }
+ protected UnicodeDatabase db;
+
+ protected final List<UnicodeDisplayable> rootList
+ = new ArrayList<UnicodeDisplayable>(100);
+
+ protected final List<List<UnicodeDisplayable>> stack
+ = new ArrayList<List<UnicodeDisplayable>>(10);
- protected final List<UnicodeRange> list
- = Arrays.asList(UnicodeRange.values());
+ protected void launchPopulation() {
+ final ProgressDialog progress = new ProgressDialog(this);
+ progress.setOwnerActivity(this);
+ progress.setTitle("Loading Unicode database");
+ progress.setMessage("Please wait");
+ progress.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
+ progress.setCancelable(false);
+ progress.show();
+ final Handler handler = new Handler() {
+ public void handleMessage(Message msg) {
+ int done = msg.getData().getInt("done");
+ int total = msg.getData().getInt("total");
+ progress.setMax(total);
+ progress.setProgress(done);
+ if ( done >= total )
+ progress.dismiss();
+ }
+ };
+ final Thread thr = new Thread() {
+ public void run() {
+ final UnicodeDatabase writeDb
+ = new UnicodeDatabase(UnicodeMapActivity.this);
+ writeDb.populate(handler);
+ }
+ };
+ thr.start();
+ }
/** Called when the activity is first created. */
@Override
@@ -207,51 +59,58 @@ public final class UnicodeMapActivity extends ListActivity {
super.onCreate(savedInstanceState);
android.util.Log.v("UnicodeMapActivity", "creating activity");
setContentView(R.layout.main_layout);
- final UnicodeDatabase db = new UnicodeDatabase(this);
+ db = new UnicodeDatabase(this);
final boolean needPopulate = db.needPopulate();
- db.close();
- if ( needPopulate ) {
- final ProgressDialog progress = new ProgressDialog(this);
- progress.setOwnerActivity(this);
- progress.setTitle("Loading Unicode database");
- progress.setMessage("Please wait");
- progress.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
- progress.setCancelable(false);
- progress.show();
- final Handler handler = new Handler() {
- public void handleMessage(Message msg) {
- int done = msg.getData().getInt("done");
- int total = msg.getData().getInt("total");
- progress.setMax(total);
- progress.setProgress(done);
- if ( done >= total )
- progress.dismiss();
- }
- };
- final Thread thr = new Thread() {
- public void run() {
- final UnicodeDatabase db
- = new UnicodeDatabase(UnicodeMapActivity.this);
- db.populate(handler);
- }
- };
- thr.start();
- }
- setListAdapter(new ArrayAdapter<UnicodeRange>(this, R.layout.map_item, list));
- ListView lv = getListView();
+ if ( needPopulate )
+ launchPopulation();
+ for ( UnicodeCharacter.Range rng : UnicodeCharacter.Range.values() )
+ rootList.add(rng);
+ stack.add(rootList);
+ setListAdapter(new UnicodeArrayAdapter(this, rootList));
+ final ClipboardManager cmgr
+ = (ClipboardManager)getSystemService(Context.CLIPBOARD_SERVICE);
+ final Button btn = (Button) findViewById(R.id.button);
+ final EditText txt = (EditText) findViewById(R.id.edit);
+ btn.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View view) {
+ cmgr.setText(txt.getText());
+ Toast.makeText(getApplicationContext(), "Copied to clipboard",
+ Toast.LENGTH_SHORT).show();
+ }
+ });
+ final ListView lv = getListView();
lv.setTextFilterEnabled(true);
lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
- UnicodeRange it = (UnicodeRange)parent.getItemAtPosition(position);
- Intent intent = new Intent(UnicodeMapActivity.this,
- UnicodeListActivity.class);
- intent.putExtra(UnicodeListActivity.EXTRA_FROM, it.getFrom());
- intent.putExtra(UnicodeListActivity.EXTRA_TO, it.getTo());
- startActivity(intent);
+ UnicodeDisplayable it
+ = (UnicodeDisplayable)parent.getItemAtPosition(position);
+ if ( it instanceof UnicodeCharacter )
+ txt.append(((UnicodeCharacter)it).getChar());
+ else if ( it instanceof UnicodeCharacter.Range ) {
+ int from = ((UnicodeCharacter.Range)it).getFrom();
+ int to = ((UnicodeCharacter.Range)it).getTo();
+ List<UnicodeDisplayable> list
+ = new ArrayList<UnicodeDisplayable>(db.countRange(from,to));
+ for ( UnicodeCharacter ch : db.getRange(from,to) )
+ list.add(ch);
+ stack.add(list);
+ setListAdapter(new UnicodeArrayAdapter(UnicodeMapActivity.this, list));
+ }
}
});
+ }
+ @Override
+ public boolean onKeyDown(int keyCode, KeyEvent event) {
+ if ( ( keyCode == KeyEvent.KEYCODE_BACK) && stack.size() > 1 ) {
+ stack.remove(stack.size()-1);
+ List<UnicodeDisplayable> list
+ = stack.get(stack.size()-1);
+ setListAdapter(new UnicodeArrayAdapter(UnicodeMapActivity.this, list));
+ return true;
+ }
+ return super.onKeyDown(keyCode, event);
}
}