Bug 1245655 - Dismiss edit mode with a single back button press, make "x" button clear search text draft
authorMargaret Leibovic <margaret.leibovic@gmail.com>
Tue, 26 Apr 2016 17:34:55 -0700
changeset 356731 e51adae58b82c79a4353eb945456fd60d8bba95c
parent 355404 df4e550128b976a664216e57f78f80c36d78f275
child 519467 c28b40bf070b36f5a99946859a3051ec5b177cd3
push id16583
push usermleibovic@mozilla.com
push dateWed, 27 Apr 2016 00:35:05 +0000
bugs1245655
milestone48.0a1
Bug 1245655 - Dismiss edit mode with a single back button press, make "x" button clear search text MozReview-Commit-ID: 8r6LYzb4e22
mobile/android/base/java/org/mozilla/gecko/toolbar/BrowserToolbarPhoneBase.java
mobile/android/base/java/org/mozilla/gecko/toolbar/ToolbarEditText.java
--- a/mobile/android/base/java/org/mozilla/gecko/toolbar/BrowserToolbarPhoneBase.java
+++ b/mobile/android/base/java/org/mozilla/gecko/toolbar/BrowserToolbarPhoneBase.java
@@ -70,24 +70,18 @@ abstract class BrowserToolbarPhoneBase e
 
     @Override
     public void onAttachedToWindow() {
         super.onAttachedToWindow();
 
         editCancel.setOnClickListener(new OnClickListener() {
             @Override
             public void onClick(View v) {
-                // If we exit editing mode during the animation,
-                // we're put into an inconsistent state (bug 1017276).
-                if (!isAnimating()) {
-                    Telemetry.sendUIEvent(TelemetryContract.Event.CANCEL,
-                            TelemetryContract.Method.ACTIONBAR,
-                            getResources().getResourceEntryName(editCancel.getId()));
-                    cancelEdit();
-                }
+                urlEditLayout.setText("");
+                urlEditLayout.requestFocus();
             }
         });
     }
 
     @Override
     public void setPrivateMode(final boolean isPrivate) {
         super.setPrivateMode(isPrivate);
         editCancel.setPrivateMode(isPrivate);
--- a/mobile/android/base/java/org/mozilla/gecko/toolbar/ToolbarEditText.java
+++ b/mobile/android/base/java/org/mozilla/gecko/toolbar/ToolbarEditText.java
@@ -580,18 +580,17 @@ public class ToolbarEditText extends Cus
                         mCommitListener.onCommit();
                     }
 
                     return true;
                 }
             }
 
             if (keyCode == KeyEvent.KEYCODE_BACK) {
-                // Drop the virtual keyboard.
-                clearFocus();
+                mDismissListener.onDismiss();
                 return true;
             }
 
             return false;
         }
     }
 
     private class KeyListener implements View.OnKeyListener {