mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-13 05:15:45 +00:00
Bug 895828: Unfocus the URL bar when the soft keyboard is hidden. r=lucasr
This commit is contained in:
parent
30d0a5f68b
commit
193d88e4fe
@ -144,6 +144,7 @@ public class BrowserToolbar extends GeckoRelativeLayout
|
||||
// The user typed part of the autocomplete result
|
||||
private String mAutoCompletePrefix = null;
|
||||
|
||||
private boolean mIsEditing;
|
||||
private boolean mAnimatingEntry;
|
||||
|
||||
private AlphaAnimation mLockFadeIn;
|
||||
@ -187,6 +188,7 @@ public class BrowserToolbar extends GeckoRelativeLayout
|
||||
Tabs.registerOnTabsChangedListener(this);
|
||||
mSwitchingTabs = true;
|
||||
|
||||
mIsEditing = false;
|
||||
mAnimatingEntry = false;
|
||||
mShowUrl = false;
|
||||
|
||||
@ -357,6 +359,11 @@ public class BrowserToolbar extends GeckoRelativeLayout
|
||||
}
|
||||
}
|
||||
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||
clearFocus();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
@ -386,7 +393,12 @@ public class BrowserToolbar extends GeckoRelativeLayout
|
||||
mUrlEditText.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
||||
@Override
|
||||
public void onFocusChange(View v, boolean hasFocus) {
|
||||
if (v == null || hasFocus) {
|
||||
if (v == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
setSelected(hasFocus);
|
||||
if (hasFocus) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1248,8 +1260,12 @@ public class BrowserToolbar extends GeckoRelativeLayout
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether or not the URL bar is in editing mode (url bar is expanded, hiding the new
|
||||
* tab button). Note that selection state is independent of editing mode.
|
||||
*/
|
||||
public boolean isEditing() {
|
||||
return isSelected();
|
||||
return mIsEditing;
|
||||
}
|
||||
|
||||
public void startEditing(String url, PropertyAnimator animator) {
|
||||
@ -1258,10 +1274,10 @@ public class BrowserToolbar extends GeckoRelativeLayout
|
||||
}
|
||||
|
||||
mUrlEditText.setText(url != null ? url : "");
|
||||
mIsEditing = true;
|
||||
|
||||
// This animation doesn't make much sense in a sidebar UI
|
||||
if (HardwareUtils.isTablet()) {
|
||||
setSelected(true);
|
||||
showUrlEditContainer();
|
||||
return;
|
||||
}
|
||||
@ -1272,7 +1288,7 @@ public class BrowserToolbar extends GeckoRelativeLayout
|
||||
final int entryTranslation = getUrlBarEntryTranslation();
|
||||
final int curveTranslation = getUrlBarCurveTranslation();
|
||||
|
||||
// Keep the entry highlighted during the animation
|
||||
// Highlight the toolbar from the start of the animation.
|
||||
setSelected(true);
|
||||
|
||||
// Hide page actions/stop buttons immediately
|
||||
@ -1350,9 +1366,9 @@ public class BrowserToolbar extends GeckoRelativeLayout
|
||||
if (!isEditing()) {
|
||||
return url;
|
||||
}
|
||||
mIsEditing = false;
|
||||
|
||||
if (HardwareUtils.isTablet()) {
|
||||
setSelected(false);
|
||||
hideUrlEditContainer();
|
||||
updateTabCountAndAnimate(Tabs.getInstance().getDisplayCount());
|
||||
return url;
|
||||
@ -1398,8 +1414,6 @@ public class BrowserToolbar extends GeckoRelativeLayout
|
||||
|
||||
@Override
|
||||
public void onPropertyAnimationEnd() {
|
||||
// Turn off selected state on the entry
|
||||
setSelected(false);
|
||||
setShadowVisibility(true);
|
||||
|
||||
PropertyAnimator buttonsAnimator = new PropertyAnimator(300);
|
||||
|
@ -55,16 +55,6 @@ public class HomeListView extends ListView
|
||||
mUrlOpenListener = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(MotionEvent event) {
|
||||
if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
|
||||
// take focus away from awesome bar to hide the keyboard
|
||||
requestFocus();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
Object item = parent.getItemAtPosition(position);
|
||||
|
@ -16,6 +16,7 @@ import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.FragmentStatePagerAdapter;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -179,4 +180,18 @@ public class HomePager extends ViewPager {
|
||||
mPages.remove(mTabs.get(position).page);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(MotionEvent event) {
|
||||
if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
|
||||
// XXX: When an adapter is empty (e.g. Reading List), there are no elements focusable
|
||||
// in touch mode so instead of requestFocus() we use requestFocusFromTouch(). However,
|
||||
// now we may be focusing an object whose focused state is potentially visible to the
|
||||
// user but should not be (e.g. the background), so we clear the focus.
|
||||
requestFocusFromTouch();
|
||||
clearFocus();
|
||||
}
|
||||
|
||||
return super.onInterceptTouchEvent(event);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user