• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

タグ

よく使われているワード(クリックで追加)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

はてなハイク・キーワードの検索と入力アプリ


コミットメタ情報

リビジョンb076b7fb5d7c844ff47ee128988e28da2af16731 (tree)
日時2012-09-05 20:45:35
作者Kodakana <kodakana@linu...>
コミッターKodakana

ログメッセージ

コンテキストメニュー及びそこから実行される各機能を追加。項目をタップしたときの動作をコピー/送信から選択できるようにした。送信用テンプレートの設定を追加。

変更サマリ

差分

--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -1,7 +1,7 @@
11 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
22 package="org.pulpdust.kigo"
33 android:versionCode="1"
4- android:versionName="0.1"
4+ android:versionName="0.2"
55 android:installLocation="auto" >
66
77 <uses-sdk
@@ -26,6 +26,10 @@
2626 <action android:name="org.pulpdust.kigo.action.PICK_KEYWORD" />
2727 <category android:name="android.intent.category.DEFAULT" />
2828 </intent-filter>
29+ <intent-filter>
30+ <action android:name="org.pulpdust.kigo.action.PICK_RELATED" />
31+ <category android:name="android.intent.category.DEFAULT" />
32+ </intent-filter>
2933 </activity>
3034 <activity android:name=".KigoPrefs"></activity>
3135 </application>
--- a/bin/AndroidManifest.xml
+++ b/bin/AndroidManifest.xml
@@ -1,7 +1,7 @@
11 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
22 package="org.pulpdust.kigo"
33 android:versionCode="1"
4- android:versionName="0.1"
4+ android:versionName="0.2"
55 android:installLocation="auto" >
66
77 <uses-sdk
@@ -26,6 +26,10 @@
2626 <action android:name="org.pulpdust.kigo.action.PICK_KEYWORD" />
2727 <category android:name="android.intent.category.DEFAULT" />
2828 </intent-filter>
29+ <intent-filter>
30+ <action android:name="org.pulpdust.kigo.action.PICK_RELATED" />
31+ <category android:name="android.intent.category.DEFAULT" />
32+ </intent-filter>
2933 </activity>
3034 <activity android:name=".KigoPrefs"></activity>
3135 </application>
Binary files a/bin/Kigo.apk and b/bin/Kigo.apk differ
Binary files a/bin/classes.dex and b/bin/classes.dex differ
Binary files a/bin/classes/org/pulpdust/kigo/KigoActivity$1.class and b/bin/classes/org/pulpdust/kigo/KigoActivity$1.class differ
Binary files a/bin/classes/org/pulpdust/kigo/KigoActivity$2.class and b/bin/classes/org/pulpdust/kigo/KigoActivity$2.class differ
Binary files a/bin/classes/org/pulpdust/kigo/KigoActivity$3.class and b/bin/classes/org/pulpdust/kigo/KigoActivity$3.class differ
Binary files a/bin/classes/org/pulpdust/kigo/KigoActivity$4.class and b/bin/classes/org/pulpdust/kigo/KigoActivity$4.class differ
Binary files a/bin/classes/org/pulpdust/kigo/KigoActivity$5.class and b/bin/classes/org/pulpdust/kigo/KigoActivity$5.class differ
Binary files /dev/null and b/bin/classes/org/pulpdust/kigo/KigoActivity$6.class differ
Binary files a/bin/classes/org/pulpdust/kigo/KigoActivity.class and b/bin/classes/org/pulpdust/kigo/KigoActivity.class differ
Binary files a/bin/classes/org/pulpdust/kigo/R$array.class and b/bin/classes/org/pulpdust/kigo/R$array.class differ
Binary files a/bin/classes/org/pulpdust/kigo/R$attr.class and b/bin/classes/org/pulpdust/kigo/R$attr.class differ
Binary files /dev/null and b/bin/classes/org/pulpdust/kigo/R$dimen.class differ
Binary files a/bin/classes/org/pulpdust/kigo/R$drawable.class and b/bin/classes/org/pulpdust/kigo/R$drawable.class differ
Binary files a/bin/classes/org/pulpdust/kigo/R$id.class and b/bin/classes/org/pulpdust/kigo/R$id.class differ
Binary files a/bin/classes/org/pulpdust/kigo/R$layout.class and b/bin/classes/org/pulpdust/kigo/R$layout.class differ
Binary files a/bin/classes/org/pulpdust/kigo/R$menu.class and b/bin/classes/org/pulpdust/kigo/R$menu.class differ
Binary files a/bin/classes/org/pulpdust/kigo/R$string.class and b/bin/classes/org/pulpdust/kigo/R$string.class differ
Binary files a/bin/classes/org/pulpdust/kigo/R$style.class and b/bin/classes/org/pulpdust/kigo/R$style.class differ
Binary files a/bin/classes/org/pulpdust/kigo/R$xml.class and b/bin/classes/org/pulpdust/kigo/R$xml.class differ
Binary files a/bin/classes/org/pulpdust/kigo/R.class and b/bin/classes/org/pulpdust/kigo/R.class differ
Binary files a/bin/resources.ap_ and b/bin/resources.ap_ differ
--- a/gen/org/pulpdust/kigo/R.java
+++ b/gen/org/pulpdust/kigo/R.java
@@ -11,39 +11,72 @@ public final class R {
1111 public static final class array {
1212 public static final int font_size_labels=0x7f050001;
1313 public static final int font_size_values=0x7f050000;
14+ public static final int tap_b_l=0x7f050003;
15+ public static final int tap_b_v=0x7f050002;
1416 }
1517 public static final class attr {
1618 }
19+ public static final class dimen {
20+ public static final int info_margin=0x7f060000;
21+ }
1722 public static final class drawable {
1823 public static final int ic_action_search=0x7f020000;
1924 public static final int ic_launcher=0x7f020001;
2025 }
2126 public static final class id {
22- public static final int button1=0x7f090001;
23- public static final int editText1=0x7f090000;
24- public static final int listView1=0x7f090002;
25- public static final int menu_settings=0x7f090003;
27+ public static final int button1=0x7f0a0001;
28+ public static final int editText1=0x7f0a0000;
29+ public static final int layout_root=0x7f0a0003;
30+ public static final int listView1=0x7f0a0002;
31+ public static final int menu_copy=0x7f0a0008;
32+ public static final int menu_info=0x7f0a000b;
33+ public static final int menu_open=0x7f0a000a;
34+ public static final int menu_relat=0x7f0a000c;
35+ public static final int menu_send=0x7f0a0009;
36+ public static final int menu_settings=0x7f0a0007;
37+ public static final int textView1=0x7f0a0004;
38+ public static final int textView2=0x7f0a0005;
39+ public static final int textView3=0x7f0a0006;
2640 }
2741 public static final class layout {
2842 public static final int activity_kigo=0x7f030000;
29- public static final int list_item=0x7f030001;
43+ public static final int info=0x7f030001;
44+ public static final int list_item=0x7f030002;
3045 }
3146 public static final class menu {
32- public static final int activity_kigo=0x7f080000;
47+ public static final int activity_kigo=0x7f090000;
48+ public static final int main_context=0x7f090001;
3349 }
3450 public static final class string {
35- public static final int app_name=0x7f060000;
36- public static final int button_find=0x7f060004;
37- public static final int err_no_net=0x7f060006;
38- public static final int hello_world=0x7f060001;
39- public static final int hint_word=0x7f060005;
40- public static final int menu_settings=0x7f060002;
41- public static final int on_load=0x7f060007;
42- public static final int pref_font=0x7f060008;
43- public static final int title_activity_kigo=0x7f060003;
51+ public static final int app_name=0x7f070000;
52+ public static final int bcc=0x7f07000f;
53+ public static final int button_find=0x7f070004;
54+ public static final int cc=0x7f07000e;
55+ public static final int err_fail_get=0x7f070007;
56+ public static final int err_no_net=0x7f070006;
57+ public static final int hello_world=0x7f070001;
58+ public static final int hint_word=0x7f070005;
59+ public static final int info_entries=0x7f070015;
60+ public static final int info_follows=0x7f070016;
61+ public static final int info_title=0x7f070017;
62+ public static final int info_word=0x7f070018;
63+ public static final int menu_copy=0x7f070010;
64+ public static final int menu_info=0x7f070012;
65+ public static final int menu_open=0x7f070011;
66+ public static final int menu_relat=0x7f070013;
67+ public static final int menu_send=0x7f070014;
68+ public static final int menu_settings=0x7f070002;
69+ public static final int on_load=0x7f070008;
70+ public static final int pref_cat_app=0x7f070009;
71+ public static final int pref_cat_templ=0x7f07000c;
72+ public static final int pref_font=0x7f07000a;
73+ public static final int pref_tap=0x7f07000b;
74+ public static final int relateds=0x7f070019;
75+ public static final int title_activity_kigo=0x7f070003;
76+ public static final int to=0x7f07000d;
4477 }
4578 public static final class style {
46- public static final int AppTheme=0x7f070000;
79+ public static final int AppTheme=0x7f080000;
4780 }
4881 public static final class xml {
4982 public static final int prefs=0x7f040000;
--- /dev/null
+++ b/res/layout/info.xml
@@ -0,0 +1,38 @@
1+<?xml version="1.0" encoding="utf-8"?>
2+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+ android:id="@+id/layout_root"
4+ android:layout_width="match_parent"
5+ android:layout_height="match_parent"
6+ android:orientation="vertical" >
7+
8+ <TextView
9+ android:id="@+id/textView1"
10+ android:layout_width="match_parent"
11+ android:layout_height="wrap_content"
12+ android:layout_marginLeft="@dimen/info_margin"
13+ android:layout_marginRight="@dimen/info_margin"
14+ android:textAppearance="?android:attr/textAppearanceMedium" />
15+
16+ <TextView
17+ android:id="@+id/textView2"
18+ android:layout_width="match_parent"
19+ android:layout_height="wrap_content"
20+ android:layout_marginLeft="@dimen/info_margin"
21+ android:layout_marginRight="@dimen/info_margin"
22+ android:textAppearance="?android:attr/textAppearanceMedium" />
23+
24+ <TextView
25+ android:id="@+id/textView3"
26+ android:layout_width="match_parent"
27+ android:layout_height="wrap_content"
28+ android:layout_marginLeft="@dimen/info_margin"
29+ android:layout_marginRight="@dimen/info_margin"
30+ android:textAppearance="?android:attr/textAppearanceMedium" />
31+
32+<!-- <TextView -->
33+<!-- android:id="@+id/textView4" -->
34+<!-- android:layout_width="match_parent" -->
35+<!-- android:layout_height="wrap_content" -->
36+<!-- android:textAppearance="?android:attr/textAppearanceMedium" /> -->
37+
38+</LinearLayout>
\ No newline at end of file
--- /dev/null
+++ b/res/menu/main_context.xml
@@ -0,0 +1,14 @@
1+<?xml version="1.0" encoding="utf-8"?>
2+<menu xmlns:android="http://schemas.android.com/apk/res/android" >
3+ <item android:id="@+id/menu_copy"
4+ android:title="@string/menu_copy" />
5+ <item android:id="@+id/menu_send"
6+ android:title="@string/menu_send" />
7+ <item android:id="@+id/menu_open"
8+ android:title="@string/menu_open" />
9+ <item android:id="@+id/menu_info"
10+ android:title="@string/menu_info" />
11+ <item android:id="@+id/menu_relat"
12+ android:title="@string/menu_relat" />
13+
14+</menu>
\ No newline at end of file
--- a/res/values/arrays.xml
+++ b/res/values/arrays.xml
@@ -32,5 +32,13 @@
3232 <item>30</item>
3333 <item>32</item>
3434 </string-array>
35+ <string-array name="tap_b_v">
36+ <item>0</item>
37+ <item>1</item>
38+ </string-array>
39+ <string-array name="tap_b_l">
40+ <item>Copy</item>
41+ <item>Send</item>
42+ </string-array>
3543
3644 </resources>
\ No newline at end of file
--- /dev/null
+++ b/res/values/dimens.xml
@@ -0,0 +1,4 @@
1+<?xml version="1.0" encoding="utf-8"?>
2+<resources>
3+ <dimen name="info_margin">4dip</dimen>
4+</resources>
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -7,7 +7,24 @@
77 <string name="button_find">Find</string>
88 <string name="hint_word">Find a Topic</string>
99 <string name="err_no_net">Network is Disabled.</string>
10+ <string name="err_fail_get">Failed to Get from API.</string>
1011 <string name="on_load">Now Loading&#8230;</string>
12+ <string name="pref_cat_app">Application Settings</string>
1113 <string name="pref_font">Font Size</string>
14+ <string name="pref_tap">Tap Behavior</string>
15+ <string name="pref_cat_templ">Send To Template</string>
16+ <string name="to">To:</string>
17+ <string name="cc">CC:</string>
18+ <string name="bcc">BCC:</string>
19+ <string name="menu_copy">Copy</string>
20+ <string name="menu_open">Open</string>
21+ <string name="menu_info">Info</string>
22+ <string name="menu_relat">Relateds</string>
23+ <string name="menu_send">Send</string>
24+ <string name="info_entries"><b>Entries</b>: </string>
25+ <string name="info_follows"><b>Followers</b>: </string>
26+ <string name="info_title"><b>Title</b>: </string>
27+ <string name="info_word"><b>Word</b>: </string>
28+ <string name="relateds">Related Keywords</string>
1229
1330 </resources>
\ No newline at end of file
--- a/res/xml/prefs.xml
+++ b/res/xml/prefs.xml
@@ -1,5 +1,12 @@
11 <?xml version="1.0" encoding="utf-8"?>
22 <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
3+ <PreferenceCategory android:title="@string/pref_cat_app">
4+ <ListPreference
5+ android:key="tap_b"
6+ android:title="@string/pref_tap"
7+ android:entries="@array/tap_b_l"
8+ android:entryValues="@array/tap_b_v"
9+ android:defaultValue="0" />
310 <ListPreference
411 android:key="font_size"
512 android:title="@string/pref_font"
@@ -7,6 +14,17 @@
714 android:entryValues="@array/font_size_values"
815 android:dialogTitle="@string/pref_font"
916 android:defaultValue="16" />
10-
17+ </PreferenceCategory>
18+ <PreferenceCategory android:title="@string/pref_cat_templ">
19+ <EditTextPreference
20+ android:key="send_to"
21+ android:title="@string/to" />
22+ <EditTextPreference
23+ android:key="cc"
24+ android:title="@string/cc" />
25+ <EditTextPreference
26+ android:key="bcc"
27+ android:title="@string/bcc" />
28+ </PreferenceCategory>
1129
1230 </PreferenceScreen>
\ No newline at end of file
--- a/src/org/pulpdust/kigo/KigoActivity.java
+++ b/src/org/pulpdust/kigo/KigoActivity.java
@@ -2,8 +2,10 @@ package org.pulpdust.kigo;
22
33 import java.io.ByteArrayOutputStream;
44 import java.io.StringReader;
5+import java.io.UnsupportedEncodingException;
56 import java.util.ArrayList;
67 import java.util.List;
8+import java.net.URLEncoder;
79
810 import org.apache.http.HttpResponse;
911 import org.apache.http.HttpStatus;
@@ -14,9 +16,11 @@ import org.xmlpull.v1.XmlPullParser;
1416
1517 import android.net.ConnectivityManager;
1618 import android.net.NetworkInfo;
19+import android.net.Uri;
1720 import android.os.Bundle;
1821 import android.preference.PreferenceManager;
1922 import android.app.Activity;
23+import android.app.AlertDialog;
2024 import android.app.ProgressDialog;
2125 import android.content.Context;
2226 import android.content.Intent;
@@ -24,8 +28,12 @@ import android.content.SharedPreferences;
2428 import android.text.ClipboardManager;
2529 import android.util.Log;
2630 import android.util.Xml;
31+import android.view.ContextMenu;
32+import android.view.ContextMenu.ContextMenuInfo;
2733 import android.view.KeyEvent;
34+import android.view.LayoutInflater;
2835 import android.view.Menu;
36+import android.view.MenuInflater;
2937 import android.view.MenuItem;
3038 import android.view.View;
3139 import android.view.ViewGroup;
@@ -42,6 +50,7 @@ import android.widget.TextView;
4250 import android.view.View.OnClickListener;
4351 import android.view.inputmethod.EditorInfo;
4452 import android.widget.AdapterView.OnItemClickListener;
53+import android.widget.AdapterView.OnItemLongClickListener;
4554
4655 public class KigoActivity extends Activity {
4756 static final String TAG = "KigoActivity";
@@ -51,62 +60,96 @@ public class KigoActivity extends Activity {
5160 Button bttn;
5261 ListView lstvw;
5362 HttpResponse res;
54- String uri =
55- "http://h.hatena.ne.jp/api/keywords/list.xml?without_related_keywords=true";
63+ CharSequence cptxt;
64+ String host = "http://h.hatena.ne.jp/";
65+ String base = host + "keyword/";
66+ String uri = host +
67+ "api/keywords/list.xml?without_related_keywords=true";
68+ String iuri = host + "api/keywords/show.xml?word=";
69+ String guri;
5670 String sbj = "";
5771 String obj;
72+ String bwrd = "";
73+ String buri;
5874 String gactn = "org.pulpdust.kigo.action.PICK_KEYWORD";
75+ String gactn2 = "org.pulpdust.kigo.action.PICK_RELATED";
5976 String gextr = "org.pulpdust.kigo.extra.WORD";
77+ String[] send_to = new String[1];
78+ String[] cc = new String[1];
79+ String[] bcc = new String[1];
80+ int tpbhvr;
6081 int fntsz = 12;
6182 boolean prvd;
83+ boolean rltd;
84+
6285
6386 @Override
6487 public void onCreate(Bundle savedInstanceState) {
6588 super.onCreate(savedInstanceState);
6689 if (gactn.equals(getIntent().getAction())){
6790 prvd = true;
91+ rltd = false;
92+ sbj = getIntent().getStringExtra(gextr);
93+ } else if (gactn2.equals(getIntent().getAction())){
94+ prvd = false;
95+ rltd = true;
6896 sbj = getIntent().getStringExtra(gextr);
6997 } else {
7098 prvd = false;
99+ rltd = false;
71100 }
72101 readPrefs();
73102 requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
74103 setContentView(R.layout.activity_kigo);
75104 edttxt = (EditText) findViewById(R.id.editText1);
76- if (sbj != null){
77- edttxt.setText(sbj);
78- }
79- edttxt.setOnEditorActionListener(new OnEditorActionListener(){
80- @Override
81- public boolean onEditorAction(TextView v, int aid, KeyEvent kev) {
82- if (aid == EditorInfo.IME_ACTION_SEARCH){
83- sbj = edttxt.getText().toString().trim();
84- reLoad();
85- }
86- return true;
87- }
105+ if (rltd == true){
106+ edttxt.setVisibility(View.GONE);
107+ } else {
108+ if (sbj != null){
109+ edttxt.setText(sbj);
110+ } else {
111+ sbj = "";
112+ }
113+ edttxt.setOnEditorActionListener(new OnEditorActionListener(){
114+ @Override
115+ public boolean onEditorAction(TextView v, int aid, KeyEvent kev) {
116+ if (aid == EditorInfo.IME_ACTION_SEARCH){
117+ sbj = edttxt.getText().toString().trim();
118+ guri = uri + "&word=" + sbj;
119+ reLoad(guri);
120+ }
121+ return true;
122+ }
88123
89- });
90- edttxt.setOnKeyListener(new OnKeyListener(){
91- @Override
92- public boolean onKey(View v, int kcd, KeyEvent kev) {
93- if (kev.getAction() == KeyEvent.ACTION_UP &&
94- kcd == KeyEvent.KEYCODE_ENTER){
95- sbj = edttxt.getText().toString().trim();
96- reLoad();
97- return true;
98- }
99- return false;
100- }
101- });
124+ });
125+ edttxt.setOnKeyListener(new OnKeyListener(){
126+ @Override
127+ public boolean onKey(View v, int kcd, KeyEvent kev) {
128+ if (kev.getAction() == KeyEvent.ACTION_UP &&
129+ kcd == KeyEvent.KEYCODE_ENTER){
130+ sbj = edttxt.getText().toString().trim();
131+ guri = uri + "&word=" + sbj;
132+ reLoad(guri);
133+ return true;
134+ }
135+ return false;
136+ }
137+ });
138+ }
102139 bttn = (Button) findViewById(R.id.button1);
103- bttn.setOnClickListener(new OnClickListener(){
104- public void onClick(View v){
105- sbj = edttxt.getText().toString().trim();
106- reLoad();
107- }
108- });
140+ if (rltd == true){
141+ bttn.setVisibility(View.GONE);
142+ } else {
143+ bttn.setOnClickListener(new OnClickListener(){
144+ public void onClick(View v){
145+ sbj = edttxt.getText().toString().trim();
146+ guri = uri + "&word=" + sbj;
147+ reLoad(guri);
148+ }
149+ });
150+ }
109151 lstvw = (ListView) findViewById(R.id.listView1);
152+ registerForContextMenu(lstvw);
110153 lstvw.setOnItemClickListener(new OnItemClickListener(){
111154 @Override
112155 public void onItemClick(AdapterView<?> av, View v, int pos,
@@ -117,14 +160,23 @@ public class KigoActivity extends Activity {
117160 setResult(RESULT_OK, intent);
118161 finish();
119162 } else {
120- ClipboardManager clipbd = (ClipboardManager)
121- getSystemService(Context.CLIPBOARD_SERVICE);
122- clipbd.setText(((TextView) v).getText());
123- Toast.makeText(getApplicationContext(), ((TextView) v).getText(),
124- Toast.LENGTH_SHORT).show();
163+ if (tpbhvr == 0){
164+ doCopy(((TextView) v).getText());
165+ } else if (tpbhvr == 1){
166+ sendTo(((TextView) v).getText());
167+ }
125168 }
126169 }
127170 });
171+ lstvw.setOnItemLongClickListener(new OnItemLongClickListener(){
172+ @Override
173+ public boolean onItemLongClick(AdapterView<?> av, View v,
174+ int pos, long id) {
175+ cptxt = ((TextView) v).getText();
176+ openContextMenu(lstvw);
177+ return true;
178+ }
179+ });
128180 arryadpt = new ArrayAdapter<String>(this, R.layout.list_item, lst){
129181 @Override
130182 public View getView(int pos, View v, ViewGroup vg){
@@ -134,31 +186,195 @@ public class KigoActivity extends Activity {
134186 }
135187 };
136188 lstvw.setAdapter(arryadpt);
137- final String save = (String) getLastNonConfigurationInstance();
189+ final String save[] = (String[]) getLastNonConfigurationInstance();
138190 if (save != null){
139- obj = save;
191+ if (save[0] != null){
192+ obj = save[0];
140193 arryadpt.clear();
141- xmlBaker(save);
142- } else {
143- reLoad();
194+ xmlBaker(obj);
195+ }
196+ if (save[1] != null){ buri = save[1]; }
197+ if (save[2] != null){ bwrd = save[2]; }
198+ } else {
199+ if (rltd == true){
200+ guri = iuri + sbj;
201+ } else {
202+ guri = uri + "&word=" + sbj;
203+ }
204+ reLoad(guri);
144205 }
145206 }
207+ public void doCopy(CharSequence text){
208+ ClipboardManager clipbd = (ClipboardManager)
209+ getSystemService(Context.CLIPBOARD_SERVICE);
210+ clipbd.setText(text);
211+ Toast.makeText(getApplicationContext(), text,
212+ Toast.LENGTH_SHORT).show();
213+ }
214+ @Override
215+ public void onCreateContextMenu(ContextMenu cm, View v,
216+ ContextMenuInfo cmi){
217+ super.onCreateContextMenu(cm, v, cmi);
218+ cm.setHeaderTitle(cptxt);
219+ MenuInflater minflater = getMenuInflater();
220+ minflater.inflate(R.menu.main_context, cm);
221+ }
222+ public void sendTo(CharSequence subject){
223+ Uri suri = Uri.parse("mailto:");
224+ if (!send_to[0].equals("")){
225+ suri = Uri.parse("mailto:" + send_to[0]);
226+ }
227+
228+ Intent intent = new Intent(Intent.ACTION_SENDTO, suri);
229+ if (!cc[0].equals("")){
230+ intent.putExtra(Intent.EXTRA_CC, cc);
231+ }
232+ if (!bcc[0].equals("")){
233+ intent.putExtra(Intent.EXTRA_BCC, bcc);
234+ }
235+ intent.putExtra(Intent.EXTRA_SUBJECT, subject);
236+ startActivity(intent);
237+ }
238+ @Override
239+ public boolean onContextItemSelected(MenuItem mi){
240+ switch (mi.getItemId()){
241+ case R.id.menu_copy:
242+ doCopy(cptxt);
243+ return true;
244+ case R.id.menu_send:
245+ sendTo(cptxt);
246+ return true;
247+ case R.id.menu_open:
248+ String openuri;
249+ try {
250+ openuri = base + URLEncoder.encode(cptxt.toString(), "UTF-8");
251+ Intent sendi = new Intent(Intent.ACTION_VIEW, Uri.parse(openuri));
252+ startActivity(sendi);
253+ } catch (UnsupportedEncodingException e) {
254+ // TODO Auto-generated catch block
255+ e.printStackTrace();
256+ }
257+ return true;
258+ case R.id.menu_info:
259+ echoInfo(cptxt.toString());
260+ return true;
261+ case R.id.menu_relat:
262+// Intent intent = new Intent(gactn2);
263+// intent.setClassName("org.pulpdust.kigo", "org.pulpdust.kigo.KigoActivity");
264+// intent.putExtra(gextr, cptxt);
265+// intent.removeCategory(Intent.CATEGORY_DEFAULT);
266+// intent.addCategory(Intent.CATEGORY_LAUNCHER);
267+// intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
268+// try {
269+// startActivity(intent);
270+// return true;
271+// } catch (ActivityNotFoundException e){
272+// Log.e(TAG, e.getMessage());
273+// return false;
274+// }
275+ try {
276+ if (!rltd){
277+ bwrd = sbj;
278+ buri = guri;
279+ rltd = true;
280+ }
281+ guri = iuri + URLEncoder.encode(cptxt.toString(), "UTF-8");
282+ edttxt.setVisibility(View.GONE);
283+ bttn.setVisibility(View.GONE);
284+ setTitle(getString(R.string.app_name) + " - " + getString(R.string.relateds));
285+ reLoad(guri);
286+ return true;
287+ } catch (UnsupportedEncodingException e) {
288+ // TODO Auto-generated catch block
289+ e.printStackTrace();
290+ return false;
291+ }
292+ default:
293+ return false;
294+ }
295+ }
296+ public void echoInfo(String word){
297+ try {
298+ String turi = iuri + URLEncoder.encode(word.toString(), "UTF-8");
299+ String xml = getHttp(turi);
300+ if (xml != null){
301+ String info[] = exInfo(xml);
302+ if(info != null){
303+ Context context = this;
304+ AlertDialog.Builder abuilder = new AlertDialog.Builder(context);
305+ LayoutInflater linflater =
306+ (LayoutInflater) context.getSystemService(LAYOUT_INFLATER_SERVICE);
307+ View layout = linflater.inflate(R.layout.info,
308+ (ViewGroup) findViewById(R.id.layout_root));
309+ TextView tv1 = (TextView) layout.findViewById(R.id.textView1);
310+ TextView tv2 = (TextView) layout.findViewById(R.id.textView2);
311+ TextView tv3 = (TextView) layout.findViewById(R.id.textView3);
312+// TextView tv4 = (TextView) layout.findViewById(R.id.textView4);
313+ tv1.setText(getString(R.string.info_entries) + info[0]);
314+ tv2.setText(getString(R.string.info_follows) + info[1]);
315+ tv3.setText(getString(R.string.info_title) + info[2]);
316+// tv4.setText(getString(R.string.info_word) + info[3]);
317+ abuilder.setTitle(word);
318+ abuilder.setCancelable(true);
319+ abuilder.setView(layout);
320+ abuilder.show();
321+ }
322+ } else {
323+ Toast.makeText(getApplicationContext(), R.string.err_fail_get,
324+ Toast.LENGTH_SHORT).show();
325+ }
326+
327+ } catch (UnsupportedEncodingException e) {
328+ // TODO Auto-generated catch block
329+ e.printStackTrace();
330+ }
331+ }
332+
146333 @Override
147334 public Object onRetainNonConfigurationInstance(){
148- final String save = obj;
335+ final String save[] = new String[3];
336+ save[0] = obj;
337+ save[1] = buri;
338+ save[2] = bwrd;
149339 return save;
150340 }
151- public void reLoad(){
152- if (!isConnect(getApplicationContext())){
153- Toast.makeText(getApplicationContext(), R.string.err_no_net,
154- Toast.LENGTH_SHORT).show();
155- } else {
341+ @Override
342+ public boolean dispatchKeyEvent(KeyEvent kev){
343+ if (kev.getAction() == KeyEvent.ACTION_DOWN){
344+ switch (kev.getKeyCode()){
345+ case KeyEvent.KEYCODE_BACK:
346+ if (rltd){
347+ guri = buri;
348+ sbj = bwrd;
349+ buri = null;
350+ bwrd = "";
351+ edttxt.setVisibility(View.VISIBLE);
352+ bttn.setVisibility(View.VISIBLE);
353+ rltd = false;
354+ setTitle(R.string.app_name);
355+ reLoad(guri);
356+ return true;
357+ }
358+ default:
359+ return super.dispatchKeyEvent(kev);
360+ }
361+ } else {
362+ return super.dispatchKeyEvent(kev);
363+ }
364+ }
365+ public void reLoad(String uri){
156366 ProgressDialog pdialog = ProgressDialog.show(this, "",
157367 getString(R.string.on_load), true);
158368 arryadpt.clear();
159- getHttp(uri + "&word=" + sbj);
369+ obj = null;
370+ obj = getHttp(uri);
371+ if (obj != null){
372+ xmlBaker(obj);
373+ } else {
374+ Toast.makeText(getApplicationContext(), R.string.err_fail_get,
375+ Toast.LENGTH_SHORT).show();
376+ }
160377 pdialog.dismiss();
161- }
162378 }
163379 public static boolean isConnect(Context c){
164380 ConnectivityManager cmanager = (ConnectivityManager)
@@ -169,28 +385,35 @@ public class KigoActivity extends Activity {
169385 }
170386 return false;
171387 }
172- public void getHttp(String uri){
173- HttpClient client = new DefaultHttpClient();
174- HttpGet req = new HttpGet(uri.toString());
175- try {
176- res = client.execute(req);
177- } catch (Exception e){
178- Log.e(TAG, e.getMessage());
179- return;
180- }
181- int status = res.getStatusLine().getStatusCode();
182- if (HttpStatus.SC_OK == status){
183- try {
184- ByteArrayOutputStream baop = new ByteArrayOutputStream();
185- res.getEntity().writeTo(baop);
186- obj = baop.toString();
187- xmlBaker(baop.toString());
188- } catch (Exception e){
189- Log.e(TAG, e.getMessage());
190- }
191- } else {
192- Log.d(TAG, "HTTP" + status);
193- }
388+ public String getHttp(String uri){
389+ if (!isConnect(getApplicationContext())){
390+ Toast.makeText(getApplicationContext(), R.string.err_no_net,
391+ Toast.LENGTH_SHORT).show();
392+ return null;
393+ } else {
394+ HttpClient client = new DefaultHttpClient();
395+ HttpGet req = new HttpGet(uri.toString());
396+ try {
397+ res = client.execute(req);
398+ } catch (Exception e){
399+ Log.e(TAG, e.getMessage());
400+ return null;
401+ }
402+ int status = res.getStatusLine().getStatusCode();
403+ if (HttpStatus.SC_OK == status){
404+ try {
405+ ByteArrayOutputStream baop = new ByteArrayOutputStream();
406+ res.getEntity().writeTo(baop);
407+ return baop.toString();
408+ } catch (Exception e){
409+ Log.e(TAG, e.getMessage());
410+ return null;
411+ }
412+ } else {
413+ Log.d(TAG, "HTTP" + status);
414+ return null;
415+ }
416+ }
194417 }
195418 public void xmlBaker(String xml){
196419 try{
@@ -200,10 +423,38 @@ public class KigoActivity extends Activity {
200423 while ((evt = parser.next()) != XmlPullParser.END_DOCUMENT){
201424 if (evt == XmlPullParser.START_TAG && "word".equals(parser.getName())){
202425 arryadpt.add(parser.nextText());
426+ } else if (evt == XmlPullParser.START_TAG && "related_keywords".equals(parser.getName())){
427+ arryadpt.add(parser.nextText());
428+ }
429+ }
430+ } catch (Exception e){
431+ Log.e(TAG, e.getMessage());
432+ }
433+ }
434+ public String[] exInfo(String xml){
435+ try {
436+ String ret[] = new String[4];
437+ XmlPullParser xparser = Xml.newPullParser();
438+ xparser.setInput(new StringReader(xml));
439+ int evt;
440+ while ((evt = xparser.next()) != XmlPullParser.END_DOCUMENT){
441+ if (evt == XmlPullParser.START_TAG && "entry_count".equals(xparser.getName())){
442+ ret[0] = xparser.nextText();
443+ }
444+ if (evt == XmlPullParser.START_TAG && "followers_count".equals(xparser.getName())){
445+ ret[1] = xparser.nextText();
446+ }
447+ if (evt == XmlPullParser.START_TAG && "title".equals(xparser.getName())){
448+ ret[2] = xparser.nextText();
449+ }
450+ if (evt == XmlPullParser.START_TAG && "word".equals(xparser.getName())){
451+ ret[3] = xparser.nextText();
203452 }
204453 }
454+ return ret;
205455 } catch (Exception e){
206456 Log.e(TAG, e.getMessage());
457+ return null;
207458 }
208459 }
209460
@@ -231,12 +482,16 @@ public class KigoActivity extends Activity {
231482 switch (requestCode){
232483 case 2:
233484 readPrefs();
234- reLoad();
485+ reLoad(guri);
235486 break;
236487 }
237488 }
238489 public void readPrefs(){
239490 SharedPreferences sprefs = PreferenceManager.getDefaultSharedPreferences(this);
491+ tpbhvr = Integer.parseInt(sprefs.getString("tap_b", "0"));
240492 fntsz = Integer.parseInt(sprefs.getString("font_size", "16"));
493+ send_to[0] = sprefs.getString("send_to", "");
494+ cc[0] = sprefs.getString("cc", "");
495+ bcc[0] = sprefs.getString("bcc", "");
241496 }
242497 }