summaryrefslogtreecommitdiffstats
path: root/src/org/madore/android/unicodeMap/UnicodeMapActivity.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/madore/android/unicodeMap/UnicodeMapActivity.java')
-rw-r--r--src/org/madore/android/unicodeMap/UnicodeMapActivity.java64
1 files changed, 64 insertions, 0 deletions
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())));
+ }
+ });
+
+ }
+
+}