• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javac++androidlinuxc#objective-cqtwindows誰得cocoapythonphprubygameguibathyscaphec翻訳omegat計画中(planning stage)frameworktwittertestdomvb.netdirectxbtronarduinopreviewerゲームエンジン

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


Commit MetaInfo

Revisionbf1e92d00190bb51818f93cf9ec80873b1949417 (tree)
Time2012-10-29 20:33:25
AuthorKodakana <kodakana@linu...>
CommiterKodakana

Log Message

Dialog を DialogFragment に変更。起動時の接続確認を改善。

Change Summary

Incremental Difference

--- 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"
3- android:versionCode="3"
4- android:versionName="0.51"
3+ android:versionCode="4"
4+ android:versionName="0.55"
55 android:installLocation="auto" >
66
77 <uses-sdk
--- 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"
3- android:versionCode="3"
4- android:versionName="0.51"
3+ android:versionCode="4"
4+ android:versionName="0.55"
55 android:installLocation="auto" >
66
77 <uses-sdk
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 a/bin/classes/org/pulpdust/kigo/KigoActivity$6.class and b/bin/classes/org/pulpdust/kigo/KigoActivity$6.class differ
Binary files a/bin/classes/org/pulpdust/kigo/KigoActivity$7$1.class and b/bin/classes/org/pulpdust/kigo/KigoActivity$7$1.class differ
Binary files a/bin/classes/org/pulpdust/kigo/KigoActivity$7.class and b/bin/classes/org/pulpdust/kigo/KigoActivity$7.class differ
Binary files a/bin/classes/org/pulpdust/kigo/KigoActivity$8$1.class and /dev/null differ
Binary files a/bin/classes/org/pulpdust/kigo/KigoActivity$8.class and /dev/null differ
Binary files /dev/null and b/bin/classes/org/pulpdust/kigo/KigoActivity$InfoDialog.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/resources.ap_ and b/bin/resources.ap_ differ
--- a/res/values-ja/strings.xml
+++ b/res/values-ja/strings.xml
@@ -1,7 +1,7 @@
11 <resources>
22
33 <string name="app_name">Kigo</string>
4- <string name="app_ver">0.51</string>
4+ <string name="app_ver">0.55</string>
55 <string name="app_lic">GNU GPL v3</string>
66 <string name="address">連絡先</string>
77 <string name="app_author">Kodakana&lt;kodakana.hws@gmail.com&gt;</string>
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1,7 +1,7 @@
11 <resources>
22
33 <string name="app_name">Kigo</string>
4- <string name="app_ver">0.51</string>
4+ <string name="app_ver">0.55</string>
55 <string name="app_lic">GNU GPL v3</string>
66 <string name="address">Address</string>
77 <string name="app_author">Kodakana&lt;kodakana.hws@gmail.com&gt;</string>
--- a/src/org/pulpdust/kigo/KigoActivity.java
+++ b/src/org/pulpdust/kigo/KigoActivity.java
@@ -25,10 +25,13 @@ import android.os.Handler;
2525 import android.preference.PreferenceManager;
2626 import android.app.Activity;
2727 import android.app.AlertDialog;
28+import android.app.Dialog;
2829 import android.app.ProgressDialog;
2930 import android.content.Context;
3031 import android.content.Intent;
3132 import android.content.SharedPreferences;
33+import android.support.v4.app.DialogFragment;
34+import android.support.v4.app.FragmentActivity;
3235 import android.text.ClipboardManager;
3336 import android.util.Log;
3437 import android.util.Xml;
@@ -56,23 +59,23 @@ import android.view.inputmethod.EditorInfo;
5659 import android.widget.AdapterView.OnItemClickListener;
5760 import android.widget.AdapterView.OnItemLongClickListener;
5861
59-public class KigoActivity extends Activity {
62+public class KigoActivity extends FragmentActivity {
6063 static final String TAG = "KigoActivity";
6164 static List<String> lst = new ArrayList<String>();
6265 static ArrayAdapter<String> arryadpt;
6366 EditText edttxt;
6467 Button bttn;
6568 ListView lstvw;
66- HttpResponse res = null;
69+ static HttpResponse res = null;
6770 CharSequence cptxt;
68- String host = "http://h.hatena.ne.jp/";
71+ static String host = "http://h.hatena.ne.jp/";
6972 String base = host + "keyword/";
7073 String kpth = "keyword/";
7174 String uri = host +
7275 "api/keywords/list.xml?without_related_keywords=true";
7376 String lpth = "api/keywords/list.xml?without_related_keywords=true";
7477 String iuri = host + "api/keywords/show.xml?word=";
75- String ipth = "api/keywords/show.xml?word=";
78+ static String ipth = "api/keywords/show.xml?word=";
7679 String guri;
7780 String sbj = "";
7881 String obj;
@@ -191,7 +194,8 @@ public class KigoActivity extends Activity {
191194 }
192195 };
193196 lstvw.setAdapter(arryadpt);
194- final String save[] = (String[]) getLastNonConfigurationInstance();
197+// final String save[] = (String[]) getLastNonConfigurationInstance();
198+ final String save[] = (String[]) getLastCustomNonConfigurationInstance();
195199 if (save != null){
196200 if (save[0] != null){
197201 obj = save[0];
@@ -200,7 +204,8 @@ public class KigoActivity extends Activity {
200204 }
201205 if (save[1] != null){ buri = save[1]; }
202206 if (save[2] != null){ bwrd = save[2]; }
203- } else {
207+ } else if (isConnect(this)){
208+ {
204209 if (rltd == true){
205210 guri = host + ipth + sbj;
206211 reLoad(guri);
@@ -209,6 +214,10 @@ public class KigoActivity extends Activity {
209214 goFind();
210215 }
211216 }
217+ } else {
218+ Toast.makeText(this, R.string.err_no_net,
219+ Toast.LENGTH_SHORT).show();
220+ }
212221 }
213222 public void goFind(){
214223 sbj = edttxt.getText().toString().trim();
@@ -275,7 +284,9 @@ public class KigoActivity extends Activity {
275284 doOpen(cptxt);
276285 return true;
277286 case R.id.menu_info:
278- echoInfo(cptxt.toString());
287+ DialogFragment id = InfoDialog.newInstance(this, cptxt.toString());
288+ id.show(getSupportFragmentManager(), "hoge");
289+// echoInfo(cptxt.toString());
279290 return true;
280291 case R.id.menu_relat:
281292 // Intent intent = new Intent(gactn2);
@@ -312,18 +323,34 @@ public class KigoActivity extends Activity {
312323 return false;
313324 }
314325 }
315- public void echoInfo(final String word){
316- final Handler handler = new Handler();
317- final Context context = this;
318- new Thread(new Runnable(){
319- @Override
320- public void run(){
326+ public static class InfoDialog extends DialogFragment{
327+ static Context cx;
328+ public static InfoDialog newInstance(Context c, String w){
329+ InfoDialog id = new InfoDialog();
330+ cx = c;
331+ Bundle args = new Bundle();
332+ args.putString("word", w);
333+ id.setArguments(args);
334+ return id;
335+ }
336+ @Override
337+ public Dialog onCreateDialog(Bundle savedInstanceState){
338+ return echoInfo(cx, getActivity(), getArguments().getString("word"));
339+ }
340+ }
341+ public static AlertDialog echoInfo(Context context, FragmentActivity av, String word){
342+// final Handler handler = new Handler();
343+ AlertDialog ad = null;
344+// final Context context = this;
345+// new Thread(new Runnable(){
346+// @Override
347+// public void run(){
321348 try {
322- String turi = host + ipth + URLEncoder.encode(word.toString(), "UTF-8").replace("+", "%20");
323- final String xml = getHttp(turi);
324- handler.post(new Runnable(){
325- @Override
326- public void run(){
349+ String turi = host + ipth + URLEncoder.encode(word, "UTF-8").replace("+", "%20");
350+ final String xml = getHttp(context, turi);
351+// handler.post(new Runnable(){
352+// @Override
353+// public void run(){
327354 if (xml != null){
328355 String info[] = exInfo(xml);
329356 if(info != null){
@@ -331,37 +358,56 @@ public class KigoActivity extends Activity {
331358 LayoutInflater linflater =
332359 (LayoutInflater) context.getSystemService(LAYOUT_INFLATER_SERVICE);
333360 View layout = linflater.inflate(R.layout.info,
334- (ViewGroup) findViewById(R.id.layout_root));
361+ (ViewGroup) av.findViewById(R.id.layout_root));
335362 TextView tv1 = (TextView) layout.findViewById(R.id.textView1);
336363 TextView tv2 = (TextView) layout.findViewById(R.id.textView2);
337364 TextView tv3 = (TextView) layout.findViewById(R.id.textView3);
338365 // TextView tv4 = (TextView) layout.findViewById(R.id.textView4);
339- tv1.setText(getString(R.string.info_entries) + info[0]);
340- tv2.setText(getString(R.string.info_follows) + info[1]);
341- tv3.setText(getString(R.string.info_title) + info[2]);
366+ tv1.setText(av.getString(R.string.info_entries) + info[0]);
367+ tv2.setText(av.getString(R.string.info_follows) + info[1]);
368+ tv3.setText(av.getString(R.string.info_title) + info[2]);
342369 // tv4.setText(getString(R.string.info_word) + info[3]);
343370 abuilder.setTitle(word);
344371 abuilder.setCancelable(true);
345372 abuilder.setView(layout);
346- abuilder.show();
373+ ad = abuilder.create();
347374 }
348375 } else {
349- Toast.makeText(getApplicationContext(), R.string.err_fail_get,
350- Toast.LENGTH_SHORT).show();
376+ AlertDialog.Builder empty = new AlertDialog.Builder(context);
377+ LayoutInflater linflater =
378+ (LayoutInflater) context.getSystemService(LAYOUT_INFLATER_SERVICE);
379+ View layout = linflater.inflate(R.layout.info,
380+ (ViewGroup) av.findViewById(R.id.layout_root));
381+ TextView tv1 = (TextView) layout.findViewById(R.id.textView1);
382+ tv1.setText(R.string.err_fail_get);
383+ empty.setTitle(word);
384+ empty.setCancelable(true);
385+ empty.setView(layout);
386+ ad = empty.create();
387+// Toast.makeText(context, R.string.err_fail_get,
388+// Toast.LENGTH_SHORT).show();
351389 }
352- }
353- });
390+// }
391+// });
354392
355393 } catch (UnsupportedEncodingException e) {
356394 // TODO Auto-generated catch block
357395 e.printStackTrace();
358396 }
359- }
360- }).start();
397+ return ad;
398+// }
399+// }).start();
361400 }
362401
363- @Override
364- public Object onRetainNonConfigurationInstance(){
402+// @Override
403+// public Object onRetainNonConfigurationInstance(){
404+// final String save[] = new String[3];
405+// save[0] = obj;
406+// save[1] = buri;
407+// save[2] = bwrd;
408+// return save;
409+// }
410+ public Object onRetainCustomNonConfiguratonInstance(){
365411 final String save[] = new String[3];
366412 save[0] = obj;
367413 save[1] = buri;
@@ -401,12 +447,13 @@ public class KigoActivity extends Activity {
401447 public void reLoad(final String uri){
402448 // final Getter getter = new Getter();
403449 final Handler handler = new Handler();
450+ final Context c = getApplicationContext();
404451 new Thread(new Runnable(){
405452 @Override
406453 public void run(){
407454 obj = null;
408455 // obj = getter.getHttp(uri);
409- obj = getHttp(uri);
456+ obj = getHttp(c, uri);
410457 handler.post(new Runnable(){
411458 @Override
412459 public void run(){
@@ -433,9 +480,9 @@ public class KigoActivity extends Activity {
433480 }
434481 return false;
435482 }
436- public String getHttp(final String uri){
437- if (!isConnect(getApplicationContext())){
438- Toast.makeText(getApplicationContext(), R.string.err_no_net,
483+ public static String getHttp(Context context, final String uri){
484+ if (!isConnect(context)){
485+ Toast.makeText(context, R.string.err_no_net,
439486 Toast.LENGTH_SHORT).show();
440487 return null;
441488 } else {
@@ -485,7 +532,7 @@ public class KigoActivity extends Activity {
485532 Log.e(TAG, e.getMessage());
486533 }
487534 }
488- public String[] exInfo(String xml){
535+ public static String[] exInfo(String xml){
489536 try {
490537 String ret[] = new String[4];
491538 XmlPullParser xparser = Xml.newPullParser();