summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid A. Madore <david+git@madore.org>2013-09-04 22:30:06 +0200
committerDavid A. Madore <david+git@madore.org>2013-09-04 22:30:06 +0200
commitb0124ceb30ebde2aa7ff42351d4160f5cb85d8c2 (patch)
tree4256afa542808a557f558fbbf49babe53a68c66b
parent47f5265ebe5e2c5a6ae2e4e40f620426f7eb15ed (diff)
downloadUnicodeMap-master.tar.gz
UnicodeMap-master.tar.bz2
UnicodeMap-master.zip
Indicate character block (and not just category) in details.HEADmaster
-rw-r--r--res/layout/char_details.xml25
-rw-r--r--res/values/strings.xml4
-rw-r--r--src/org/madore/android/unicodeMap/UnicodeCharacter.java15
-rw-r--r--src/org/madore/android/unicodeMap/UnicodeMapActivity.java18
4 files changed, 55 insertions, 7 deletions
diff --git a/res/layout/char_details.xml b/res/layout/char_details.xml
index c271da0..20800c3 100644
--- a/res/layout/char_details.xml
+++ b/res/layout/char_details.xml
@@ -3,6 +3,7 @@
android:id="@+id/detailsLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
+ android:minWidth="256dp"
android:padding="10dp"
android:orientation="vertical"
android:background="#f0e0e0e0">
@@ -16,6 +17,11 @@
android:layout_height="wrap_content"
android:textSize="16sp"
android:textColor="#ff404040" />
+ <TextView android:id="@+id/rangeLabel"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:textSize="16sp"
+ android:textColor="#ff400000" />
<TextView android:id="@+id/categoryLabel"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
@@ -29,15 +35,26 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
- android:text="@string/copy_button" />
+ android:text="@string/copy_char_button" />
<Button android:id="@+id/appendCharButton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
- android:text="@string/append_button" />
+ android:text="@string/append_char_button" />
</LinearLayout>
- <Button android:id="@+id/copyNameButton"
+ <LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
- android:text="@string/copy_name_button" />
+ android:orientation="horizontal">
+ <Button android:id="@+id/copyCodeButton"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:text="@string/copy_code_button" />
+ <Button android:id="@+id/copyNameButton"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:text="@string/copy_name_button" />
+ </LinearLayout>
</LinearLayout>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 964ea95..79407af 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -5,8 +5,10 @@
<string name="loading_database_title">Initializing database</string>
<string name="loading_database_msg">Please do not interrupt</string>
<string name="copy_button">Copy</string>
+ <string name="copy_char_button">Copy char</string>
+ <string name="append_char_button">Append char</string>
+ <string name="copy_code_button">Copy number</string>
<string name="copy_name_button">Copy name</string>
- <string name="append_button">Append</string>
<string name="copied_toast">Copied to clipboard</string>
<string name="empty_list">(Empty!)</string>
<string name="unihan_lookup">Unihan lookup</string>
diff --git a/src/org/madore/android/unicodeMap/UnicodeCharacter.java b/src/org/madore/android/unicodeMap/UnicodeCharacter.java
index 0228644..89c83be 100644
--- a/src/org/madore/android/unicodeMap/UnicodeCharacter.java
+++ b/src/org/madore/android/unicodeMap/UnicodeCharacter.java
@@ -233,7 +233,8 @@ public class UnicodeCharacter implements UnicodeDisplayable {
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");
+ SUPPLEMENTARY_PRIVATE_USE_AREA_B(0x100000, 0x10FFFF, "Supplementary Private Use Area-B"),
+ UNASSIGNED(0x110000, 0x110000, "Not Assigned");
protected final int from; protected final int to;
protected final String descr;
Range(int from, int last, String descr) {
@@ -422,6 +423,7 @@ public class UnicodeCharacter implements UnicodeDisplayable {
protected final int codePoint;
protected final String name;
+ protected Range range;
protected final Category category;
protected final boolean isUnicode;
protected final String charStr;
@@ -441,6 +443,7 @@ public class UnicodeCharacter implements UnicodeDisplayable {
public UnicodeCharacter(int codePoint, String name, Category category) {
this.codePoint = codePoint;
this.name = name;
+ this.range = null;
this.category = category;
this.isUnicode = true;
this.charStr = makeCharStr();
@@ -451,6 +454,7 @@ public class UnicodeCharacter implements UnicodeDisplayable {
boolean isUnicode) {
this.codePoint = codePoint;
this.name = name;
+ this.range = null;
this.category = category;
this.isUnicode = isUnicode;
this.charStr = makeCharStr();
@@ -465,6 +469,15 @@ public class UnicodeCharacter implements UnicodeDisplayable {
return this.name;
}
+ public Range getRange() {
+ if ( this.range != null )
+ return this.range;
+ for ( Range r : Range.values() )
+ if ( this.codePoint >= r.from && this.codePoint < r.to )
+ return this.range = r;
+ return this.range = Range.UNASSIGNED;
+ }
+
public Category getCategory() {
return this.category;
}
diff --git a/src/org/madore/android/unicodeMap/UnicodeMapActivity.java b/src/org/madore/android/unicodeMap/UnicodeMapActivity.java
index 57e6a5e..c72549d 100644
--- a/src/org/madore/android/unicodeMap/UnicodeMapActivity.java
+++ b/src/org/madore/android/unicodeMap/UnicodeMapActivity.java
@@ -191,7 +191,8 @@ public final class UnicodeMapActivity extends ListActivity {
&& rng != UnicodeCharacter.Range.LOW_SURROGATES
&& rng != UnicodeCharacter.Range.PRIVATE_USE_AREA
&& rng != UnicodeCharacter.Range.SUPPLEMENTARY_PRIVATE_USE_AREA_A
- && rng != UnicodeCharacter.Range.SUPPLEMENTARY_PRIVATE_USE_AREA_B )
+ && rng != UnicodeCharacter.Range.SUPPLEMENTARY_PRIVATE_USE_AREA_B
+ && rng != UnicodeCharacter.Range.UNASSIGNED )
list.add(rng);
disp.setListCache(list);
adapter = new UnicodeArrayAdapter(this, list);
@@ -339,6 +340,8 @@ public final class UnicodeMapActivity extends ListActivity {
fmt.format(" 0x%02x", bytes[i]);
text.setText(new String(s));
textMakeSelectableIfPossible(text);
+ text = (TextView) dialog.findViewById(R.id.rangeLabel);
+ text.setText(itch.getRange().getDescr());
text = (TextView) dialog.findViewById(R.id.categoryLabel);
text.setText(itch.getCategory().getDescr());
final Button copyCharButton = (Button) dialog.findViewById(R.id.copyCharButton);
@@ -358,6 +361,19 @@ public final class UnicodeMapActivity extends ListActivity {
textForm.append(itch.getChar());
}
});
+ final Button copyCodeButton = (Button) dialog.findViewById(R.id.copyCodeButton);
+ copyCodeButton.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View view) {
+ dialog.dismiss();
+ StringBuilder s = new StringBuilder();
+ Formatter fmt = new Formatter(s);
+ fmt.format("%04X", itch.getCodePoint());
+ cmgr.setText(new String(s));
+ Toast.makeText(UnicodeMapActivity.this,
+ R.string.copied_toast,
+ Toast.LENGTH_SHORT).show();
+ }
+ });
final Button copyNameButton = (Button) dialog.findViewById(R.id.copyNameButton);
copyNameButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {