Bug 762968 - Part 2: Replace onInterceptTouchEvent() with individual listeners. r=wesj

--HG--
extra : rebase_source : 96242a2de53c8df97426e7b9f31acbe01f37aa6f
This commit is contained in:
Brian Nicholson 2012-06-28 11:21:24 -07:00
Родитель 456b3d687f
Коммит 38baf2167f
2 изменённых файлов: 21 добавлений и 12 удалений

Просмотреть файл

@ -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));

Просмотреть файл

@ -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;
}
}