Bug 908364 - Don't show doorhanger popup while in editing mode. r=bnicholson

This commit is contained in:
Margaret Leibovic 2013-09-13 16:07:17 -07:00
Родитель 83927f1292
Коммит b0407a7cfc
3 изменённых файлов: 69 добавлений и 6 удалений

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

@ -451,6 +451,20 @@ abstract public class BrowserApp extends GeckoApp
} }
}); });
mBrowserToolbar.setOnStartEditingListener(new BrowserToolbar.OnStartEditingListener() {
public void onStartEditing() {
// Temporarily disable doorhanger notifications.
mDoorHangerPopup.disable();
}
});
mBrowserToolbar.setOnStopEditingListener(new BrowserToolbar.OnStopEditingListener() {
public void onStopEditing() {
// Re-enable doorhanger notifications.
mDoorHangerPopup.enable();
}
});
// Intercept key events for gamepad shortcuts // Intercept key events for gamepad shortcuts
mBrowserToolbar.setOnKeyListener(this); mBrowserToolbar.setOnKeyListener(this);
@ -1392,7 +1406,7 @@ abstract public class BrowserApp extends GeckoApp
animator.start(); animator.start();
} }
void commitEditingMode() { private void commitEditingMode() {
if (!mBrowserToolbar.isEditing()) { if (!mBrowserToolbar.isEditing()) {
return; return;
} }
@ -1467,7 +1481,7 @@ abstract public class BrowserApp extends GeckoApp
} }
} }
boolean dismissEditingMode() { private boolean dismissEditingMode() {
if (!mBrowserToolbar.isEditing()) { if (!mBrowserToolbar.isEditing()) {
return false; return false;
} }

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

@ -101,6 +101,14 @@ public class BrowserToolbar extends GeckoRelativeLayout
public void onFilter(String searchText, AutocompleteHandler handler); public void onFilter(String searchText, AutocompleteHandler handler);
} }
public interface OnStartEditingListener {
public void onStartEditing();
}
public interface OnStopEditingListener {
public void onStopEditing();
}
private LayoutParams mAwesomeBarParams; private LayoutParams mAwesomeBarParams;
private View mUrlDisplayContainer; private View mUrlDisplayContainer;
private View mUrlEditContainer; private View mUrlEditContainer;
@ -128,10 +136,13 @@ public class BrowserToolbar extends GeckoRelativeLayout
private LinearLayout mActionItemBar; private LinearLayout mActionItemBar;
private MenuPopup mMenuPopup; private MenuPopup mMenuPopup;
private List<? extends View> mFocusOrder; private List<? extends View> mFocusOrder;
private OnActivateListener mActivateListener; private OnActivateListener mActivateListener;
private OnCommitListener mCommitListener; private OnCommitListener mCommitListener;
private OnDismissListener mDismissListener; private OnDismissListener mDismissListener;
private OnFilterListener mFilterListener; private OnFilterListener mFilterListener;
private OnStartEditingListener mStartEditingListener;
private OnStopEditingListener mStopEditingListener;
final private BrowserApp mActivity; final private BrowserApp mActivity;
private boolean mHasSoftMenuButton; private boolean mHasSoftMenuButton;
@ -1181,6 +1192,14 @@ public class BrowserToolbar extends GeckoRelativeLayout
mFilterListener = listener; mFilterListener = listener;
} }
public void setOnStartEditingListener(OnStartEditingListener listener) {
mStartEditingListener = listener;
}
public void setOnStopEditingListener(OnStopEditingListener listener) {
mStopEditingListener = listener;
}
private void showSoftInput() { private void showSoftInput() {
InputMethodManager imm = InputMethodManager imm =
(InputMethodManager) mActivity.getSystemService(Context.INPUT_METHOD_SERVICE); (InputMethodManager) mActivity.getSystemService(Context.INPUT_METHOD_SERVICE);
@ -1268,6 +1287,10 @@ public class BrowserToolbar extends GeckoRelativeLayout
mUrlEditText.setText(url != null ? url : ""); mUrlEditText.setText(url != null ? url : "");
mIsEditing = true; mIsEditing = true;
if (mStartEditingListener != null) {
mStartEditingListener.onStartEditing();
}
final int entryTranslation = getUrlBarEntryTranslation(); final int entryTranslation = getUrlBarEntryTranslation();
final int curveTranslation = getUrlBarCurveTranslation(); final int curveTranslation = getUrlBarCurveTranslation();
@ -1376,6 +1399,10 @@ public class BrowserToolbar extends GeckoRelativeLayout
} }
mIsEditing = false; mIsEditing = false;
if (mStopEditingListener != null) {
mStopEditingListener.onStopEditing();
}
if (HardwareUtils.isTablet() || Build.VERSION.SDK_INT < 11) { if (HardwareUtils.isTablet() || Build.VERSION.SDK_INT < 11) {
hideUrlEditContainer(); hideUrlEditContainer();

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

@ -30,6 +30,9 @@ public class DoorHangerPopup extends ArrowPopup
// uniquely identified by its tabId and value. // uniquely identified by its tabId and value.
private HashSet<DoorHanger> mDoorHangers; private HashSet<DoorHanger> mDoorHangers;
// Whether or not the doorhanger popup is disabled.
private boolean mDisabled;
DoorHangerPopup(GeckoApp activity, View anchor) { DoorHangerPopup(GeckoApp activity, View anchor) {
super(activity, anchor); super(activity, anchor);
@ -46,6 +49,24 @@ public class DoorHangerPopup extends ArrowPopup
Tabs.unregisterOnTabsChangedListener(this); Tabs.unregisterOnTabsChangedListener(this);
} }
/**
* Temporarily disables the doorhanger popup. If the popup is disabled,
* it will not be shown to the user, but it will continue to process
* calls to add/remove doorhanger notifications.
*/
void disable() {
mDisabled = true;
updatePopup();
}
/**
* Re-enables the doorhanger popup.
*/
void enable() {
mDisabled = false;
updatePopup();
}
@Override @Override
public void handleMessage(String event, JSONObject geckoObject) { public void handleMessage(String event, JSONObject geckoObject) {
try { try {
@ -246,12 +267,13 @@ public class DoorHangerPopup extends ArrowPopup
* *
* This method must be called on the UI thread. * This method must be called on the UI thread.
*/ */
void updatePopup() { private void updatePopup() {
// Bail if the selected tab is null, if there are no active doorhangers, // Bail if the selected tab is null, if there are no active doorhangers,
// or if we haven't inflated the layout yet (this can happen if updatePopup() // if we haven't inflated the layout yet (this can happen if updatePopup()
// is called before the runnable from addDoorHanger() runs). // is called before the runnable from addDoorHanger() runs), or if the
// doorhanger popup is temporarily disabled.
Tab tab = Tabs.getInstance().getSelectedTab(); Tab tab = Tabs.getInstance().getSelectedTab();
if (tab == null || mDoorHangers.size() == 0 || !mInflated) { if (tab == null || mDoorHangers.size() == 0 || !mInflated || mDisabled) {
dismiss(); dismiss();
return; return;
} }