summaryrefslogtreecommitdiffstats
path: root/src/org
diff options
context:
space:
mode:
Diffstat (limited to 'src/org')
-rw-r--r--src/org/madore/android/unicodeMap/UnicodeCharacter.java35
-rw-r--r--src/org/madore/android/unicodeMap/UnicodeMapActivity.java64
2 files changed, 99 insertions, 0 deletions
diff --git a/src/org/madore/android/unicodeMap/UnicodeCharacter.java b/src/org/madore/android/unicodeMap/UnicodeCharacter.java
new file mode 100644
index 0000000..c499921
--- /dev/null
+++ b/src/org/madore/android/unicodeMap/UnicodeCharacter.java
@@ -0,0 +1,35 @@
+package org.madore.android.unicodeMap;
+
+import java.util.Formatter;
+
+public class UnicodeCharacter {
+
+ protected final int codePoint;
+ protected final String name;
+
+ public UnicodeCharacter(int codePoint, String name) {
+ this.codePoint = codePoint;
+ this.name = name;
+ }
+
+ public int getCodePoint() {
+ return codePoint;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder s = new StringBuilder();
+ s.append(Character.toChars(codePoint));
+ 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);
+ }
+
+}
diff --git a/src/org/madore/android/unicodeMap/UnicodeMapActivity.java b/src/org/madore/android/unicodeMap/UnicodeMapActivity.java
new file mode 100644
index 0000000..6caad15
--- /dev/null
+++ b/src/org/madore/android/unicodeMap/UnicodeMapActivity.java
@@ -0,0 +1,64 @@
+package org.madore.android.unicodeMap;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.io.InputStreamReader;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import android.content.Context;
+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 class UnicodeMapActivity extends ListActivity {
+
+ static final List<UnicodeCharacter> list = new ArrayList<UnicodeCharacter>(12);
+
+ protected void parseUnicodeData() {
+ AssetManager amgr = getAssets();
+ try {
+ BufferedReader rd
+ = new BufferedReader(new InputStreamReader(amgr.open("UnicodeData.txt"),
+ "US-ASCII"));
+ String line;
+ while ( ( line = rd.readLine() ) != null ) {
+ String[] bits = line.split(";");
+ int codePoint = Integer.parseInt(bits[0], 16);
+ String name = bits[1];
+ if ( name.charAt(0) != '<' )
+ list.add(new UnicodeCharacter(codePoint, name));
+ }
+ } catch (UnsupportedEncodingException e) {
+ throw new AssertionError("US-ASCII encoding unsupported");
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /** Called when the activity is first created. */
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ parseUnicodeData();
+ final ClipboardManager cmgr
+ = (ClipboardManager)getSystemService(Context.CLIPBOARD_SERVICE);
+ setListAdapter(new ArrayAdapter<UnicodeCharacter>(this, R.layout.list_item, list));
+ 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);
+ Toast.makeText(getApplicationContext(), it.getName(),
+ Toast.LENGTH_SHORT).show();
+ cmgr.setText(new String(Character.toChars(it.getCodePoint())));
+ }
+ });
+
+ }
+
+}