From b697cb48baaef73c8c62793d8f65c83dc52a6f10 Mon Sep 17 00:00:00 2001 From: Wes Johnston Date: Fri, 25 May 2012 14:03:53 -0700 Subject: [PATCH] Bug 750511 - Hide soft keyboard when user touches outside awesomebar. r=mfinkle --- mobile/android/base/AwesomeBar.java | 9 --------- mobile/android/base/AwesomeBarTabs.java | 20 +++++++++----------- 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/mobile/android/base/AwesomeBar.java b/mobile/android/base/AwesomeBar.java index f79b642ba2f..f8b6bcc37b4 100644 --- a/mobile/android/base/AwesomeBar.java +++ b/mobile/android/base/AwesomeBar.java @@ -202,15 +202,6 @@ 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 8c5cdd7cc9c..a3874a50120 100644 --- a/mobile/android/base/AwesomeBarTabs.java +++ b/mobile/android/base/AwesomeBarTabs.java @@ -67,7 +67,6 @@ public class AwesomeBarTabs extends TabHost { private boolean mInflated; private LayoutInflater mInflater; private OnUrlOpenListener mUrlOpenListener; - private View.OnTouchListener mListTouchListener; private JSONArray mSearchEngines; private ContentResolver mContentResolver; private ContentObserver mContentObserver; @@ -738,13 +737,6 @@ public class AwesomeBarTabs extends TabHost { // to the TabHost. setup(); - mListTouchListener = new View.OnTouchListener() { - public boolean onTouch(View view, MotionEvent event) { - hideSoftInput(view); - return false; - } - }; - addAllPagesTab(); addBookmarksTab(); addHistoryTab(); @@ -833,7 +825,6 @@ public class AwesomeBarTabs extends TabHost { }); allPagesList.setAdapter(mAllPagesCursorAdapter); - allPagesList.setOnTouchListener(mListTouchListener); } private void addBookmarksTab() { @@ -844,7 +835,6 @@ 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. @@ -858,7 +848,6 @@ 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. @@ -1013,4 +1002,13 @@ public class AwesomeBarTabs extends TabHost { } }); } + + @Override + public boolean onInterceptTouchEvent(MotionEvent ev) { + 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; + } }