summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid A. Madore <david+git@madore.org>2012-03-16 18:49:50 +0100
committerDavid A. Madore <david+git@madore.org>2012-03-16 18:49:50 +0100
commit3141ca4e4f232a4efae252fcdb15cc8f84e72fed (patch)
tree52ce28ba7f71dce32e0b571a83ed40cbf04b5126
parentec3d53a4066b57cc47b2c0c4880e7566410d20a5 (diff)
downloadUnicodeMap-3141ca4e4f232a4efae252fcdb15cc8f84e72fed.tar.gz
UnicodeMap-3141ca4e4f232a4efae252fcdb15cc8f84e72fed.tar.bz2
UnicodeMap-3141ca4e4f232a4efae252fcdb15cc8f84e72fed.zip
Add copy and append buttons to character popup.
-rw-r--r--res/layout/char_details.xml15
-rw-r--r--res/values/strings.xml1
-rw-r--r--src/org/madore/android/unicodeMap/UnicodeMapActivity.java27
3 files changed, 38 insertions, 5 deletions
diff --git a/res/layout/char_details.xml b/res/layout/char_details.xml
index 8d99be4..b51ec87 100644
--- a/res/layout/char_details.xml
+++ b/res/layout/char_details.xml
@@ -21,4 +21,19 @@
android:layout_height="wrap_content"
android:textSize="16sp"
android:textColor="#ff004000" />
+ <LinearLayout
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal">
+ <Button android:id="@+id/copyCharButton"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:text="@string/copy_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" />
+ </LinearLayout>
</LinearLayout>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 89f82db..1111696 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -5,6 +5,7 @@
<string name="loading_database_title">Initializing database</string>
<string name="loading_database_msg">Please wait</string>
<string name="copy_button">Copy</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/UnicodeMapActivity.java b/src/org/madore/android/unicodeMap/UnicodeMapActivity.java
index 9db0476..f82382b 100644
--- a/src/org/madore/android/unicodeMap/UnicodeMapActivity.java
+++ b/src/org/madore/android/unicodeMap/UnicodeMapActivity.java
@@ -29,6 +29,7 @@ public final class UnicodeMapActivity extends ListActivity {
protected UnicodeDatabase db;
protected ListView lv;
+ protected ClipboardManager cmgr;
protected static abstract class Display {
protected String title;
@@ -300,11 +301,11 @@ public final class UnicodeMapActivity extends ListActivity {
}
public boolean onItemLongClick(AdapterView<?> parent, View view,
int position, long id) {
- UnicodeDisplayable it
+ final UnicodeDisplayable it
= (UnicodeDisplayable)parent.getItemAtPosition(position);
if ( it instanceof UnicodeCharacter ) {
- UnicodeCharacter itch = (UnicodeCharacter)it;
- Dialog dialog = new Dialog(UnicodeMapActivity.this);
+ final UnicodeCharacter itch = (UnicodeCharacter)it;
+ final Dialog dialog = new Dialog(UnicodeMapActivity.this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setOwnerActivity(UnicodeMapActivity.this);
dialog.setContentView(R.layout.char_details);
@@ -327,6 +328,23 @@ public final class UnicodeMapActivity extends ListActivity {
text.setText(new String(s));
text = (TextView) dialog.findViewById(R.id.categoryLabel);
text.setText(itch.getCategory().getDescr());
+ final Button copyCharButton = (Button) dialog.findViewById(R.id.copyCharButton);
+ copyCharButton.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View view) {
+ dialog.dismiss();
+ cmgr.setText(itch.getChar());
+ Toast.makeText(UnicodeMapActivity.this,
+ R.string.copied_toast,
+ Toast.LENGTH_SHORT).show();
+ }
+ });
+ final Button appendCharButton = (Button) dialog.findViewById(R.id.appendCharButton);
+ appendCharButton.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View view) {
+ dialog.dismiss();
+ textForm.append(itch.getChar());
+ }
+ });
if ( UnicodeCharacter.Range.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A.belongs(itch)
|| UnicodeCharacter.Range.CJK_UNIFIED_IDEOGRAPHS.belongs(itch)
|| UnicodeCharacter.Range.CJK_COMPATIBILITY_IDEOGRAPHS.belongs(itch)
@@ -393,6 +411,7 @@ public final class UnicodeMapActivity extends ListActivity {
if ( needPopulate )
launchPopulation();
lv = getListView();
+ cmgr = (ClipboardManager)getSystemService(Context.CLIPBOARD_SERVICE);
Object testament = getLastNonConfigurationInstance();
if ( testament != null ) {
@SuppressWarnings("unchecked")
@@ -405,8 +424,6 @@ public final class UnicodeMapActivity extends ListActivity {
lv.setSelectionFromTop(saved.getSelPosition(), saved.getYOffset());
} else
doDisplay(new RootDisplay(), true);
- final ClipboardManager cmgr
- = (ClipboardManager)getSystemService(Context.CLIPBOARD_SERVICE);
final Button btn = (Button) findViewById(R.id.copyButton);
textForm = (EditText) findViewById(R.id.edit);
btn.setOnClickListener(new View.OnClickListener() {