Simple Notepad Application for Android OS
Revision | c1a0791ba10d3abf1a8d06126a1818567d540c56 (tree) |
---|---|
Zeit | 2012-08-07 15:20:00 |
Autor | Masahiko, SAWAI <say@user...> |
Commiter | Masahiko, SAWAI |
NotepadActivity の起動時の検索語の扱いを微修正
@@ -120,7 +120,7 @@ public class NotepadActivity extends ListActivity | ||
120 | 120 | * Called when the activity is first created. |
121 | 121 | */ |
122 | 122 | @Override |
123 | - public void onCreate(Bundle savedInstanceState) | |
123 | + protected void onCreate(Bundle savedInstanceState) | |
124 | 124 | { |
125 | 125 | Log.v(LOG_TAG, "Hello"); |
126 | 126 |
@@ -419,10 +419,23 @@ public class NotepadActivity extends ListActivity | ||
419 | 419 | |
420 | 420 | public void onFocusChange(View v, boolean hasFocus) |
421 | 421 | { |
422 | - if (v.getId() == R.id.search_edittext && hasFocus) | |
422 | + Log.v(LOG_TAG, "Hello"); | |
423 | + | |
424 | + if (v.getId() == R.id.search_edittext) | |
423 | 425 | { |
424 | - IMEUtils.showSoftKeyboardWindow(this, v); | |
426 | + if (hasFocus) | |
427 | + { | |
428 | + Log.d(LOG_TAG, "search_edittext has focus."); | |
429 | + IMEUtils.showSoftKeyboardWindow(this, v); | |
430 | + } | |
431 | + else | |
432 | + { | |
433 | + Log.d(LOG_TAG, "search_edittext has focus."); | |
434 | + IMEUtils.hideSoftKeyboardWindow(this, v); | |
435 | + } | |
425 | 436 | } |
437 | + | |
438 | + Log.v(LOG_TAG, "Bye"); | |
426 | 439 | } |
427 | 440 | |
428 | 441 | private void initializeWithIntent(Intent intent) |
@@ -436,6 +449,7 @@ public class NotepadActivity extends ListActivity | ||
436 | 449 | Log.d(LOG_TAG, "intent.scheme => " + intent.getScheme()); |
437 | 450 | Log.d(LOG_TAG, "------------------------------"); |
438 | 451 | |
452 | + String queryString = null; | |
439 | 453 | String action = intent.getAction(); |
440 | 454 | if (ACTION_QUIT.equals(action)) |
441 | 455 | { |
@@ -443,8 +457,7 @@ public class NotepadActivity extends ListActivity | ||
443 | 457 | } |
444 | 458 | else if (Intent.ACTION_SEARCH.equals(action)) |
445 | 459 | { |
446 | - String queryString = intent.getStringExtra(SearchManager.QUERY); | |
447 | - searchEditText.setText(queryString); | |
460 | + queryString = intent.getStringExtra(SearchManager.QUERY); | |
448 | 461 | } |
449 | 462 | else if (Intent.ACTION_VIEW.equals(action)) |
450 | 463 | { |
@@ -465,27 +478,34 @@ public class NotepadActivity extends ListActivity | ||
465 | 478 | { |
466 | 479 | Log.d(LOG_TAG, "open note : data => " + data); |
467 | 480 | String idString = data.getLastPathSegment(); |
468 | - searchEditText.setText("id:" + idString); | |
481 | + queryString = "id:" + idString; | |
469 | 482 | processed = true; |
470 | 483 | } |
471 | 484 | } |
472 | 485 | |
473 | 486 | if (!processed) |
474 | 487 | { |
475 | - String queryString = intent.getStringExtra(SearchManager.QUERY); | |
476 | - searchEditText.setText(queryString); | |
488 | + queryString = intent.getStringExtra(SearchManager.QUERY); | |
477 | 489 | } |
478 | 490 | } |
479 | 491 | } |
480 | 492 | |
481 | - if (TextUtils.isEmpty(searchEditText.getText())) | |
493 | + if (queryString != null) | |
482 | 494 | { |
483 | - searchEditText.setText(null); | |
484 | - setActionMode(ACTION_MODE_NORMAL); | |
495 | + enterSearchMode(); | |
496 | + if (TextUtils.isEmpty(queryString.trim())) | |
497 | + { | |
498 | + searchEditText.setText(null); | |
499 | + } | |
500 | + else | |
501 | + { | |
502 | + searchEditText.setText(queryString); | |
503 | + } | |
485 | 504 | } |
486 | 505 | else |
487 | 506 | { |
488 | - setActionMode(ACTION_MODE_SEARCH); | |
507 | + setActionMode(ACTION_MODE_NORMAL); | |
508 | + searchEditText.setText(null); | |
489 | 509 | } |
490 | 510 | |
491 | 511 | Log.v(LOG_TAG, "Bye"); |
@@ -630,7 +650,6 @@ public class NotepadActivity extends ListActivity | ||
630 | 650 | searchEditText.setText(null); |
631 | 651 | getListView().requestFocus(); |
632 | 652 | setActionMode(ACTION_MODE_NORMAL); |
633 | - IMEUtils.hideSoftKeyboardWindow(this, searchEditText); | |
634 | 653 | } |
635 | 654 | } |
636 | 655 |
@@ -640,7 +659,6 @@ public class NotepadActivity extends ListActivity | ||
640 | 659 | { |
641 | 660 | setActionMode(ACTION_MODE_SEARCH); |
642 | 661 | searchEditText.requestFocus(); |
643 | - IMEUtils.showSoftKeyboardWindow(this, searchEditText); | |
644 | 662 | } |
645 | 663 | } |
646 | 664 |