From f588f0ae45603704383ab77298b3c7c9b80155df Mon Sep 17 00:00:00 2001 From: Liu DongMiao Date: Sun, 9 Mar 2014 14:28:16 +0800 Subject: [PATCH] show cross link --- src/me/piebridge/bible/Chapter.java | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/me/piebridge/bible/Chapter.java b/src/me/piebridge/bible/Chapter.java index 9e52bf3..4257a70 100644 --- a/src/me/piebridge/bible/Chapter.java +++ b/src/me/piebridge/bible/Chapter.java @@ -26,6 +26,7 @@ import android.app.ActionBar; import android.app.Activity; import android.app.AlertDialog; +import android.app.SearchManager; import android.content.ActivityNotFoundException; import android.content.Context; import android.content.DialogInterface; @@ -317,16 +318,32 @@ public void onClick(DialogInterface dialog, int which) { protected void showAnnotation(String link, String annotation) { String title = link; + boolean isCross = false; if (link.contains("!f.") || link.startsWith("f")) { title = getString(R.string.flink); } else if (link.contains("!x.") || link.startsWith("c")) { + isCross = true; title = getString(R.string.xlink); } // 2:1–11Serving the Lord is not without its trials (v. 1); but no matter what happens, the genuine believer will remain sincere, steadfast, and faithful (vv. 2–3). Misfortune and humiliation are means of purification to prove one’s worth (vv. 4–5). Ben Sira believed that patience and unwavering trust in God are ultimately rewarded with the benefits of God’s mercy and of lasting joy (vv. 6–11). annotation = annotation.replaceAll("(.*?)", "$1 "); - new AlertDialog.Builder(Chapter.this).setTitle(title) + annotation = annotation.replaceAll("(.*?)", ""); + final AlertDialog dialog = new AlertDialog.Builder(Chapter.this).setTitle(title) .setMessage(Html.fromHtml(annotation)).setPositiveButton(android.R.string.ok, null).show(); - // ((TextView) dialog.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance()); + if (!isCross) { + return; + } + final TextView message = (TextView) dialog.findViewById(android.R.id.message); + message.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + dialog.dismiss(); + Intent intent = new Intent(Chapter.this, Passage.class); + intent.setAction(Intent.ACTION_SEARCH); + intent.putExtra(SearchManager.QUERY, message.getText().toString()); + startActivity(intent); + } + }); } @Override