diff --git a/mobile/android/base/AwesomeBar.java b/mobile/android/base/AwesomeBar.java index 9ff75f999e5..cc1686f6608 100644 --- a/mobile/android/base/AwesomeBar.java +++ b/mobile/android/base/AwesomeBar.java @@ -220,6 +220,15 @@ public class AwesomeBar extends GeckoActivity implements GeckoEventListener { } }); + mText.setOnFocusChangeListener(new View.OnFocusChangeListener() { + public void onFocusChange(View v, boolean hasFocus) { + if (!hasFocus) { + InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); + imm.hideSoftInputFromWindow(v.getWindowToken(), 0); + } + } + }); + registerForContextMenu(mAwesomeTabs.findViewById(R.id.all_pages_list)); registerForContextMenu(mAwesomeTabs.findViewById(R.id.bookmarks_list)); registerForContextMenu(mAwesomeTabs.findViewById(R.id.history_list)); diff --git a/mobile/android/base/AwesomeBarTabs.java b/mobile/android/base/AwesomeBarTabs.java index 5cc80c9ffd2..5e6799f7c5b 100644 --- a/mobile/android/base/AwesomeBarTabs.java +++ b/mobile/android/base/AwesomeBarTabs.java @@ -68,6 +68,7 @@ public class AwesomeBarTabs extends TabHost { private boolean mInflated; private LayoutInflater mInflater; private OnUrlOpenListener mUrlOpenListener; + private View.OnTouchListener mListTouchListener; private ContentResolver mContentResolver; private ContentObserver mContentObserver; private SearchEngine mSuggestEngine; @@ -886,6 +887,14 @@ public class AwesomeBarTabs extends TabHost { // to the TabHost. setup(); + mListTouchListener = new View.OnTouchListener() { + public boolean onTouch(View view, MotionEvent event) { + if (event.getAction() == MotionEvent.ACTION_DOWN) + hideSoftInput(view); + return false; + } + }; + addAllPagesTab(); addBookmarksTab(); addHistoryTab(); @@ -974,6 +983,7 @@ public class AwesomeBarTabs extends TabHost { }); allPagesList.setAdapter(mAllPagesCursorAdapter); + allPagesList.setOnTouchListener(mListTouchListener); } private void addBookmarksTab() { @@ -984,6 +994,7 @@ public class AwesomeBarTabs extends TabHost { R.id.bookmarks_list); ListView bookmarksList = (ListView) findViewById(R.id.bookmarks_list); + bookmarksList.setOnTouchListener(mListTouchListener); // Only load bookmark list when tab is actually used. // See OnTabChangeListener above. @@ -997,6 +1008,7 @@ public class AwesomeBarTabs extends TabHost { R.id.history_list); ListView historyList = (ListView) findViewById(R.id.history_list); + historyList.setOnTouchListener(mListTouchListener); // Only load history list when tab is actually used. // See OnTabChangeListener above. @@ -1224,16 +1236,4 @@ public class AwesomeBarTabs extends TabHost { public boolean isInReadingList() { return mInReadingList; } - - @Override - public boolean onInterceptTouchEvent(MotionEvent ev) { - // we should only have to hide the soft keyboard once - when the user - // initially touches the screen - if (ev.getAction() == MotionEvent.ACTION_DOWN) - hideSoftInput(this); - - // the android docs make no sense, but returning false will cause this and other - // motion events to be sent to the view the user tapped on - return false; - } }