はてなハイク・キーワードの検索と入力アプリ
Révision | 3855fd55642622c4aeeffc3c8924c0568b5b2866 (tree) |
---|---|
l'heure | 2012-09-07 22:04:11 |
Auteur | Kodakana <kodakana@linu...> |
Commiter | Kodakana |
項目をタップしたときの動作として「Open」を選択できるようにした。日本語リソースの追加。ハイクのハイクのドメインを選択できるようにした。
@@ -1,11 +1,11 @@ | ||
1 | 1 | <manifest xmlns:android="http://schemas.android.com/apk/res/android" |
2 | 2 | package="org.pulpdust.kigo" |
3 | 3 | android:versionCode="1" |
4 | - android:versionName="0.2" | |
4 | + android:versionName="0.3" | |
5 | 5 | android:installLocation="auto" > |
6 | 6 | |
7 | 7 | <uses-sdk |
8 | - android:minSdkVersion="8" | |
8 | + android:minSdkVersion="4" | |
9 | 9 | android:targetSdkVersion="8" /> |
10 | 10 | <uses-permission android:name="android.permission.INTERNET"/> |
11 | 11 | <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> |
@@ -1,11 +1,11 @@ | ||
1 | 1 | <manifest xmlns:android="http://schemas.android.com/apk/res/android" |
2 | 2 | package="org.pulpdust.kigo" |
3 | 3 | android:versionCode="1" |
4 | - android:versionName="0.2" | |
4 | + android:versionName="0.3" | |
5 | 5 | android:installLocation="auto" > |
6 | 6 | |
7 | 7 | <uses-sdk |
8 | - android:minSdkVersion="8" | |
8 | + android:minSdkVersion="4" | |
9 | 9 | android:targetSdkVersion="8" /> |
10 | 10 | <uses-permission android:name="android.permission.INTERNET"/> |
11 | 11 | <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> |
@@ -11,6 +11,8 @@ public final class R { | ||
11 | 11 | public static final class array { |
12 | 12 | public static final int font_size_labels=0x7f050001; |
13 | 13 | public static final int font_size_values=0x7f050000; |
14 | + public static final int host_l=0x7f050005; | |
15 | + public static final int host_v=0x7f050004; | |
14 | 16 | public static final int tap_b_l=0x7f050003; |
15 | 17 | public static final int tap_b_v=0x7f050002; |
16 | 18 | } |
@@ -49,31 +51,32 @@ public final class R { | ||
49 | 51 | } |
50 | 52 | public static final class string { |
51 | 53 | public static final int app_name=0x7f070000; |
52 | - public static final int bcc=0x7f07000f; | |
54 | + public static final int bcc=0x7f070010; | |
53 | 55 | public static final int button_find=0x7f070004; |
54 | - public static final int cc=0x7f07000e; | |
56 | + public static final int cc=0x7f07000f; | |
55 | 57 | public static final int err_fail_get=0x7f070007; |
56 | 58 | public static final int err_no_net=0x7f070006; |
57 | 59 | public static final int hello_world=0x7f070001; |
58 | 60 | 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; | |
61 | + public static final int info_entries=0x7f070016; | |
62 | + public static final int info_follows=0x7f070017; | |
63 | + public static final int info_title=0x7f070018; | |
64 | + public static final int info_word=0x7f070019; | |
65 | + public static final int menu_copy=0x7f070011; | |
66 | + public static final int menu_info=0x7f070013; | |
67 | + public static final int menu_open=0x7f070012; | |
68 | + public static final int menu_relat=0x7f070014; | |
69 | + public static final int menu_send=0x7f070015; | |
68 | 70 | public static final int menu_settings=0x7f070002; |
69 | 71 | public static final int on_load=0x7f070008; |
70 | 72 | public static final int pref_cat_app=0x7f070009; |
71 | - public static final int pref_cat_templ=0x7f07000c; | |
73 | + public static final int pref_cat_templ=0x7f07000d; | |
72 | 74 | public static final int pref_font=0x7f07000a; |
75 | + public static final int pref_host=0x7f07000c; | |
73 | 76 | public static final int pref_tap=0x7f07000b; |
74 | - public static final int relateds=0x7f070019; | |
77 | + public static final int relateds=0x7f07001a; | |
75 | 78 | public static final int title_activity_kigo=0x7f070003; |
76 | - public static final int to=0x7f07000d; | |
79 | + public static final int to=0x7f07000e; | |
77 | 80 | } |
78 | 81 | public static final class style { |
79 | 82 | public static final int AppTheme=0x7f080000; |
@@ -27,6 +27,7 @@ | ||
27 | 27 | android:id="@+id/button1" |
28 | 28 | android:layout_width="wrap_content" |
29 | 29 | android:layout_height="wrap_content" |
30 | + android:layout_alignBottom="@+id/editText1" | |
30 | 31 | android:layout_alignParentRight="true" |
31 | 32 | android:layout_alignParentTop="true" |
32 | 33 | android:text="@string/button_find" /> |
@@ -0,0 +1,53 @@ | ||
1 | +<?xml version="1.0" encoding="utf-8"?> | |
2 | +<resources> | |
3 | + <string-array name="font_size_values"> | |
4 | + <item>6</item> | |
5 | + <item>8</item> | |
6 | + <item>10</item> | |
7 | + <item>12</item> | |
8 | + <item>14</item> | |
9 | + <item>16</item> | |
10 | + <item>18</item> | |
11 | + <item>20</item> | |
12 | + <item>22</item> | |
13 | + <item>24</item> | |
14 | + <item>26</item> | |
15 | + <item>28</item> | |
16 | + <item>30</item> | |
17 | + <item>32</item> | |
18 | + </string-array> | |
19 | + <string-array name="font_size_labels"> | |
20 | + <item>6</item> | |
21 | + <item>8</item> | |
22 | + <item>10</item> | |
23 | + <item>12</item> | |
24 | + <item>14</item> | |
25 | + <item>16</item> | |
26 | + <item>18</item> | |
27 | + <item>20</item> | |
28 | + <item>22</item> | |
29 | + <item>24</item> | |
30 | + <item>26</item> | |
31 | + <item>28</item> | |
32 | + <item>30</item> | |
33 | + <item>32</item> | |
34 | + </string-array> | |
35 | + <string-array name="tap_b_v"> | |
36 | + <item>0</item> | |
37 | + <item>1</item> | |
38 | + <item>2</item> | |
39 | + </string-array> | |
40 | + <string-array name="tap_b_l"> | |
41 | + <item>コピー</item> | |
42 | + <item>送信</item> | |
43 | + <item>開く</item> | |
44 | + </string-array> | |
45 | + <string-array name="host_v"> | |
46 | + <item>http://h.hatena.ne.jp/</item> | |
47 | + <item>http://h.hatena.com/</item> | |
48 | + </string-array> | |
49 | + <string-array name="host_l"> | |
50 | + <item>日本(.ne.jp)</item> | |
51 | + <item>全世界(.com)</item> | |
52 | + </string-array> | |
53 | +</resources> | |
\ No newline at end of file |
@@ -0,0 +1,31 @@ | ||
1 | +<resources> | |
2 | + | |
3 | + <string name="app_name">Kigo</string> | |
4 | + <string name="hello_world">ほげえええぇぇぇぇぇ</string> | |
5 | + <string name="menu_settings">設定</string> | |
6 | + <string name="title_activity_kigo">Kigo</string> | |
7 | + <string name="button_find">検索</string> | |
8 | + <string name="hint_word">お題を探す</string> | |
9 | + <string name="err_no_net">繋がりません。</string> | |
10 | + <string name="err_fail_get">API から取得できませんでした。</string> | |
11 | + <string name="on_load">読み込み中…</string> | |
12 | + <string name="pref_cat_app">アプリケーションの設定</string> | |
13 | + <string name="pref_font">文字の大きさ</string> | |
14 | + <string name="pref_tap">叩いたとき</string> | |
15 | + <string name="pref_host">ハイクのホスト</string> | |
16 | + <string name="pref_cat_templ">送信の雛形</string> | |
17 | + <string name="to">To:</string> | |
18 | + <string name="cc">CC:</string> | |
19 | + <string name="bcc">BCC:</string> | |
20 | + <string name="menu_copy">コピー</string> | |
21 | + <string name="menu_open">開く</string> | |
22 | + <string name="menu_info">情報</string> | |
23 | + <string name="menu_relat">関連</string> | |
24 | + <string name="menu_send">送信</string> | |
25 | + <string name="info_entries"><b>投句数</b>: </string> | |
26 | + <string name="info_follows"><b>愛好家</b>: </string> | |
27 | + <string name="info_title"><b>標題</b>: </string> | |
28 | + <string name="info_word"><b>実名</b>: </string> | |
29 | + <string name="relateds">関連キーワード</string> | |
30 | + | |
31 | +</resources> | |
\ No newline at end of file |
@@ -35,10 +35,19 @@ | ||
35 | 35 | <string-array name="tap_b_v"> |
36 | 36 | <item>0</item> |
37 | 37 | <item>1</item> |
38 | + <item>2</item> | |
38 | 39 | </string-array> |
39 | 40 | <string-array name="tap_b_l"> |
40 | 41 | <item>Copy</item> |
41 | 42 | <item>Send</item> |
43 | + <item>Open</item> | |
44 | + </string-array> | |
45 | + <string-array name="host_v"> | |
46 | + <item>http://h.hatena.ne.jp/</item> | |
47 | + <item>http://h.hatena.com/</item> | |
48 | + </string-array> | |
49 | + <string-array name="host_l"> | |
50 | + <item>Japan(.ne.jp)</item> | |
51 | + <item>World Wide(.com)</item> | |
42 | 52 | </string-array> |
43 | - | |
44 | 53 | </resources> |
\ No newline at end of file |
@@ -12,6 +12,7 @@ | ||
12 | 12 | <string name="pref_cat_app">Application Settings</string> |
13 | 13 | <string name="pref_font">Font Size</string> |
14 | 14 | <string name="pref_tap">Tap Behavior</string> |
15 | + <string name="pref_host">Haiku Host</string> | |
15 | 16 | <string name="pref_cat_templ">Send To Template</string> |
16 | 17 | <string name="to">To:</string> |
17 | 18 | <string name="cc">CC:</string> |
@@ -14,6 +14,12 @@ | ||
14 | 14 | android:entryValues="@array/font_size_values" |
15 | 15 | android:dialogTitle="@string/pref_font" |
16 | 16 | android:defaultValue="16" /> |
17 | + <ListPreference | |
18 | + android:key="host" | |
19 | + android:title="@string/pref_host" | |
20 | + android:entries="@array/host_l" | |
21 | + android:entryValues="@array/host_v" | |
22 | + android:defaultValue="http://h.hatena.ne.jp/" /> | |
17 | 23 | </PreferenceCategory> |
18 | 24 | <PreferenceCategory android:title="@string/pref_cat_templ"> |
19 | 25 | <EditTextPreference |
@@ -63,9 +63,12 @@ public class KigoActivity extends Activity { | ||
63 | 63 | CharSequence cptxt; |
64 | 64 | String host = "http://h.hatena.ne.jp/"; |
65 | 65 | String base = host + "keyword/"; |
66 | + String kpth = "keyword/"; | |
66 | 67 | String uri = host + |
67 | 68 | "api/keywords/list.xml?without_related_keywords=true"; |
69 | + String lpth = "api/keywords/list.xml?without_related_keywords=true"; | |
68 | 70 | String iuri = host + "api/keywords/show.xml?word="; |
71 | + String ipth = "api/keywords/show.xml?word="; | |
69 | 72 | String guri; |
70 | 73 | String sbj = ""; |
71 | 74 | String obj; |
@@ -114,9 +117,7 @@ public class KigoActivity extends Activity { | ||
114 | 117 | @Override |
115 | 118 | public boolean onEditorAction(TextView v, int aid, KeyEvent kev) { |
116 | 119 | if (aid == EditorInfo.IME_ACTION_SEARCH){ |
117 | - sbj = edttxt.getText().toString().trim(); | |
118 | - guri = uri + "&word=" + sbj; | |
119 | - reLoad(guri); | |
120 | + goFind(); | |
120 | 121 | } |
121 | 122 | return true; |
122 | 123 | } |
@@ -127,9 +128,7 @@ public class KigoActivity extends Activity { | ||
127 | 128 | public boolean onKey(View v, int kcd, KeyEvent kev) { |
128 | 129 | if (kev.getAction() == KeyEvent.ACTION_UP && |
129 | 130 | kcd == KeyEvent.KEYCODE_ENTER){ |
130 | - sbj = edttxt.getText().toString().trim(); | |
131 | - guri = uri + "&word=" + sbj; | |
132 | - reLoad(guri); | |
131 | + goFind(); | |
133 | 132 | return true; |
134 | 133 | } |
135 | 134 | return false; |
@@ -142,9 +141,7 @@ public class KigoActivity extends Activity { | ||
142 | 141 | } else { |
143 | 142 | bttn.setOnClickListener(new OnClickListener(){ |
144 | 143 | public void onClick(View v){ |
145 | - sbj = edttxt.getText().toString().trim(); | |
146 | - guri = uri + "&word=" + sbj; | |
147 | - reLoad(guri); | |
144 | + goFind(); | |
148 | 145 | } |
149 | 146 | }); |
150 | 147 | } |
@@ -164,6 +161,8 @@ public class KigoActivity extends Activity { | ||
164 | 161 | doCopy(((TextView) v).getText()); |
165 | 162 | } else if (tpbhvr == 1){ |
166 | 163 | sendTo(((TextView) v).getText()); |
164 | + } else if (tpbhvr == 2){ | |
165 | + doOpen(((TextView) v).getText()); | |
167 | 166 | } |
168 | 167 | } |
169 | 168 | } |
@@ -197,13 +196,24 @@ public class KigoActivity extends Activity { | ||
197 | 196 | if (save[2] != null){ bwrd = save[2]; } |
198 | 197 | } else { |
199 | 198 | if (rltd == true){ |
200 | - guri = iuri + sbj; | |
199 | + guri = host + ipth + sbj; | |
200 | + reLoad(guri); | |
201 | 201 | } else { |
202 | - guri = uri + "&word=" + sbj; | |
202 | +// guri = host + lpth + "&word=" + sbj; | |
203 | + goFind(); | |
203 | 204 | } |
204 | - reLoad(guri); | |
205 | 205 | } |
206 | 206 | } |
207 | + public void goFind(){ | |
208 | + sbj = edttxt.getText().toString().trim(); | |
209 | + try { | |
210 | + guri = host + lpth + "&word=" + URLEncoder.encode(sbj, "UTF-8").replace("+", "%20"); | |
211 | + } catch (UnsupportedEncodingException e) { | |
212 | + // TODO Auto-generated catch block | |
213 | + e.printStackTrace(); | |
214 | + } | |
215 | + reLoad(guri); | |
216 | + } | |
207 | 217 | public void doCopy(CharSequence text){ |
208 | 218 | ClipboardManager clipbd = (ClipboardManager) |
209 | 219 | getSystemService(Context.CLIPBOARD_SERVICE); |
@@ -235,6 +245,17 @@ public class KigoActivity extends Activity { | ||
235 | 245 | intent.putExtra(Intent.EXTRA_SUBJECT, subject); |
236 | 246 | startActivity(intent); |
237 | 247 | } |
248 | + public void doOpen(CharSequence word){ | |
249 | + String openuri; | |
250 | + try { | |
251 | + openuri = host + kpth + URLEncoder.encode(word.toString(), "UTF-8").replace("+", "%20"); | |
252 | + Intent openi = new Intent(Intent.ACTION_VIEW, Uri.parse(openuri)); | |
253 | + startActivity(openi); | |
254 | + } catch (UnsupportedEncodingException e) { | |
255 | + // TODO Auto-generated catch block | |
256 | + e.printStackTrace(); | |
257 | + } | |
258 | + } | |
238 | 259 | @Override |
239 | 260 | public boolean onContextItemSelected(MenuItem mi){ |
240 | 261 | switch (mi.getItemId()){ |
@@ -245,15 +266,7 @@ public class KigoActivity extends Activity { | ||
245 | 266 | sendTo(cptxt); |
246 | 267 | return true; |
247 | 268 | 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 | - } | |
269 | + doOpen(cptxt); | |
257 | 270 | return true; |
258 | 271 | case R.id.menu_info: |
259 | 272 | echoInfo(cptxt.toString()); |
@@ -278,7 +291,7 @@ public class KigoActivity extends Activity { | ||
278 | 291 | buri = guri; |
279 | 292 | rltd = true; |
280 | 293 | } |
281 | - guri = iuri + URLEncoder.encode(cptxt.toString(), "UTF-8"); | |
294 | + guri = host + ipth + URLEncoder.encode(cptxt.toString(), "UTF-8").replace("+", "%20"); | |
282 | 295 | edttxt.setVisibility(View.GONE); |
283 | 296 | bttn.setVisibility(View.GONE); |
284 | 297 | setTitle(getString(R.string.app_name) + " - " + getString(R.string.relateds)); |
@@ -295,7 +308,7 @@ public class KigoActivity extends Activity { | ||
295 | 308 | } |
296 | 309 | public void echoInfo(String word){ |
297 | 310 | try { |
298 | - String turi = iuri + URLEncoder.encode(word.toString(), "UTF-8"); | |
311 | + String turi = host + ipth + URLEncoder.encode(word.toString(), "UTF-8").replace("+", "%20"); | |
299 | 312 | String xml = getHttp(turi); |
300 | 313 | if (xml != null){ |
301 | 314 | String info[] = exInfo(xml); |
@@ -490,6 +503,7 @@ public class KigoActivity extends Activity { | ||
490 | 503 | SharedPreferences sprefs = PreferenceManager.getDefaultSharedPreferences(this); |
491 | 504 | tpbhvr = Integer.parseInt(sprefs.getString("tap_b", "0")); |
492 | 505 | fntsz = Integer.parseInt(sprefs.getString("font_size", "16")); |
506 | + host = sprefs.getString("host", "http://h.hatena.ne.jp/"); | |
493 | 507 | send_to[0] = sprefs.getString("send_to", ""); |
494 | 508 | cc[0] = sprefs.getString("cc", ""); |
495 | 509 | bcc[0] = sprefs.getString("bcc", ""); |