Bug 871652 - Disable toolbar's context menu while in editing mode (r=sriram)
authorLucas Rocha <lucasr@mozilla.com>
Wed, 14 Aug 2013 10:55:27 +0100
changeset 143526 7fb187dbff367e01dd819231c8d1953ea9da3376
parent 143525 6cb89142d14b39851237d571897301db65b7af11
child 143527 0db3b6642ad006283ee1ba0075852303b105a759
push id25130
push userlrocha@mozilla.com
push dateWed, 21 Aug 2013 09:41:27 +0000
treeherdermozilla-central@b2486721572e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssriram
bugs871652
milestone26.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 871652 - Disable toolbar's context menu while in editing mode (r=sriram)
mobile/android/base/BrowserToolbar.java
--- a/mobile/android/base/BrowserToolbar.java
+++ b/mobile/android/base/BrowserToolbar.java
@@ -305,16 +305,21 @@ public class BrowserToolbar extends Geck
                     mActivateListener.onActivate();
                 }
             }
         });
 
         setOnCreateContextMenuListener(new View.OnCreateContextMenuListener() {
             @Override
             public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
+                // We don't the context menu while editing
+                if (isEditing()) {
+                    return;
+                }
+
                 MenuInflater inflater = mActivity.getMenuInflater();
                 inflater.inflate(R.menu.titlebar_contextmenu, menu);
 
                 String clipboard = Clipboard.getText();
                 if (TextUtils.isEmpty(clipboard)) {
                     menu.findItem(R.id.pasteandgo).setVisible(false);
                     menu.findItem(R.id.paste).setVisible(false);
                 }
@@ -418,33 +423,23 @@ public class BrowserToolbar extends Geck
             @Override
             public boolean onLongClick(View v) {
                 if (Build.VERSION.SDK_INT >= 11) {
                     CustomEditText text = (CustomEditText) v;
 
                     if (text.getSelectionStart() == text.getSelectionEnd())
                         return false;
 
-                    // mActivity.getActionBar().show();
                     return false;
                 }
 
                 return false;
             }
         });
 
-        mUrlEditText.setOnSelectionChangedListener(new CustomEditText.OnSelectionChangedListener() {
-            @Override
-            public void onSelectionChanged(int selStart, int selEnd) {
-                if (Build.VERSION.SDK_INT >= 11 && selStart == selEnd) {
-                    // mActivity.getActionBar().hide();
-                }
-            }
-        });
-
         mTabs.setOnClickListener(new Button.OnClickListener() {
             @Override
             public void onClick(View v) {
                 toggleTabs();
             }
         });
         mTabs.setImageLevel(0);
 
@@ -766,20 +761,16 @@ public class BrowserToolbar extends Geck
         }
 
         // If the edit text has a composition string, don't call updateGoButton().
         // That method resets IME and composition state will be broken.
         if (!hasCompositionString(s) ||
             InputMethods.isGestureKeyboard(mUrlEditText.getContext())) {
             updateGoButton(text);
         }
-
-        if (Build.VERSION.SDK_INT >= 11) {
-            // mActivity.getActionBar().hide();
-        }
     }
 
     @Override
     public void beforeTextChanged(CharSequence s, int start, int count,
                                   int after) {
         // do nothing
     }