Bug 1000149 - Part 1: Remove go button from toolbar. r=lucasr, a=sledru
authorMichael Comella <michael.l.comella@gmail.com>
Wed, 30 Apr 2014 10:25:33 -0700
changeset 199104 81a9f45f132bab38e71aa97826e9a912af81e94e
parent 199103 57d4cf458844cfc17242490bc5408431cd76c68b
child 199105 24acf0cad6f13769e9d8bf8c79472f7b511f236d
push id3624
push userasasaki@mozilla.com
push dateMon, 09 Jun 2014 21:49:01 +0000
treeherdermozilla-beta@b1a5da15899a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslucasr, sledru
bugs1000149
milestone31.0a2
Bug 1000149 - Part 1: Remove go button from toolbar. r=lucasr, a=sledru
mobile/android/base/resources/drawable-hdpi/ic_url_bar_go.png
mobile/android/base/resources/drawable-mdpi/ic_url_bar_go.png
mobile/android/base/resources/drawable-xhdpi/ic_url_bar_go.png
mobile/android/base/resources/layout/browser_toolbar.xml
mobile/android/base/resources/layout/toolbar_edit_layout.xml
mobile/android/base/tests/components/ToolbarComponent.java
mobile/android/base/toolbar/BrowserToolbar.java
mobile/android/base/toolbar/ToolbarEditLayout.java
deleted file mode 100644
index b0420db296ec485587e749815603c8b340d8856a..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index 8afde62835da63101a1b7bb7bcb7181ea101f201..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index 91fb5f788f0617851a730e6c2fb39f5d4204a93f..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
--- a/mobile/android/base/resources/layout/browser_toolbar.xml
+++ b/mobile/android/base/resources/layout/browser_toolbar.xml
@@ -118,16 +118,17 @@
                                          android:visibility="invisible"/>
 
     <org.mozilla.gecko.toolbar.ToolbarEditLayout android:id="@+id/edit_layout"
                   style="@style/UrlBar.Button"
                   android:layout_toLeftOf="@id/edit_separator"
                   android:layout_marginLeft="4dp"
                   android:layout_marginRight="4dp"
                   android:paddingLeft="8dp"
+                  android:paddingRight="8dp"
                   android:visibility="gone"/>
 
     <org.mozilla.gecko.toolbar.ToolbarDisplayLayout android:id="@+id/display_layout"
                   style="@style/UrlBar.Button"
                   android:layout_toLeftOf="@id/tabs"
                   android:layout_marginRight="-24dp"/>
 
     <ImageView android:id="@+id/shadow"
--- a/mobile/android/base/resources/layout/toolbar_edit_layout.xml
+++ b/mobile/android/base/resources/layout/toolbar_edit_layout.xml
@@ -22,15 +22,9 @@
           android:textCursorDrawable="@null"
           android:inputType="textUri|textNoSuggestions"
           android:imeOptions="actionGo|flagNoExtractUi|flagNoFullscreen"
           android:selectAllOnFocus="true"
           android:singleLine="true"
           android:gravity="center_vertical|left"
           gecko:autoUpdateTheme="false"/>
 
-    <ImageButton android:id="@+id/go"
-                 style="@style/UrlBar.ImageButton.Icon"
-                 android:src="@drawable/ic_url_bar_go"
-                 android:contentDescription="@string/go"
-                 android:visibility="gone"/>
-
 </merge>
--- a/mobile/android/base/tests/components/ToolbarComponent.java
+++ b/mobile/android/base/tests/components/ToolbarComponent.java
@@ -15,16 +15,17 @@ import org.mozilla.gecko.tests.helpers.D
 import org.mozilla.gecko.tests.helpers.WaitHelper;
 
 import android.view.View;
 import android.widget.EditText;
 import android.widget.ImageButton;
 import android.widget.TextView;
 
 import com.jayway.android.robotium.solo.Condition;
+import com.jayway.android.robotium.solo.Solo;
 
 /**
  * A class representing any interactions that take place on the Toolbar.
  */
 public class ToolbarComponent extends BaseComponent {
     public ToolbarComponent(final UITestContext testContext) {
         super(testContext);
     }
@@ -64,23 +65,16 @@ public class ToolbarComponent extends Ba
     private View getUrlDisplayLayout() {
         return getToolbarView().findViewById(R.id.display_layout);
     }
 
     private TextView getUrlTitleText() {
         return (TextView) getToolbarView().findViewById(R.id.url_bar_title);
     }
 
-    /**
-     * Returns the View for the go button in the browser toolbar.
-     */
-    private ImageButton getGoButton() {
-        return (ImageButton) getToolbarView().findViewById(R.id.go);
-    }
-
     private ImageButton getBackButton() {
         DeviceHelper.assertIsTablet();
         return (ImageButton) getToolbarView().findViewById(R.id.back);
     }
 
     private ImageButton getForwardButton() {
         DeviceHelper.assertIsTablet();
         return (ImageButton) getToolbarView().findViewById(R.id.forward);
@@ -136,17 +130,17 @@ public class ToolbarComponent extends Ba
     }
 
     public ToolbarComponent commitEditingMode() {
         assertIsEditing();
 
         WaitHelper.waitForPageLoad(new Runnable() {
             @Override
             public void run() {
-                mSolo.clickOnView(getGoButton());
+                mSolo.sendKey(Solo.ENTER);
             }
         });
         waitForNotEditing();
 
         return this;
     }
 
     public ToolbarComponent dismissEditingMode() {
--- a/mobile/android/base/toolbar/BrowserToolbar.java
+++ b/mobile/android/base/toolbar/BrowserToolbar.java
@@ -323,16 +323,17 @@ public class BrowserToolbar extends Them
                 // always be sync.
                 setContentDescription(contentDescription);
             }
         });
 
         urlEditLayout.setOnFocusChangeListener(new View.OnFocusChangeListener() {
             @Override
             public void onFocusChange(View v, boolean hasFocus) {
+                // This will select the url bar when entering editing mode.
                 setSelected(hasFocus);
                 if (focusChangeListener != null) {
                     focusChangeListener.onFocusChange(v, hasFocus);
                 }
             }
         });
 
         tabsButton.setOnClickListener(new Button.OnClickListener() {
@@ -845,17 +846,19 @@ public class BrowserToolbar extends Them
         setUrlEditLayoutVisibility(false, null);
     }
 
     private void hideUrlEditLayout(PropertyAnimator animator) {
         setUrlEditLayoutVisibility(false, animator);
     }
 
     private void setUrlEditLayoutVisibility(final boolean showEditLayout, PropertyAnimator animator) {
-        urlEditLayout.prepareAnimation(showEditLayout, animator);
+        if (showEditLayout) {
+            urlEditLayout.prepareShowAnimation(animator);
+        }
 
         final View viewToShow = (showEditLayout ? urlEditLayout : urlDisplayLayout);
         final View viewToHide = (showEditLayout ? urlDisplayLayout : urlEditLayout);
 
         if (animator == null) {
             viewToHide.setVisibility(View.GONE);
             viewToShow.setVisibility(View.VISIBLE);
 
@@ -1016,19 +1019,16 @@ public class BrowserToolbar extends Them
         }
     }
 
     private void showEditingWithPhoneAnimation(final PropertyAnimator animator,
             final int entryTranslation, final int curveTranslation) {
         if (isAnimatingEntry)
             return;
 
-        // Highlight the toolbar from the start of the animation.
-        setSelected(true);
-
         urlDisplayLayout.prepareStartEditingAnimation();
 
         // Slide toolbar elements.
         if (urlBarTranslatingEdge != null) {
             animator.attach(urlBarTranslatingEdge,
                             PropertyAnimator.Property.TRANSLATION_X,
                             entryTranslation);
         }
--- a/mobile/android/base/toolbar/ToolbarEditLayout.java
+++ b/mobile/android/base/toolbar/ToolbarEditLayout.java
@@ -3,75 +3,51 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko.toolbar;
 
 import org.mozilla.gecko.R;
 import org.mozilla.gecko.animation.PropertyAnimator;
 import org.mozilla.gecko.animation.PropertyAnimator.PropertyAnimationListener;
-import org.mozilla.gecko.animation.ViewHelper;
 import org.mozilla.gecko.toolbar.BrowserToolbar.OnCommitListener;
 import org.mozilla.gecko.toolbar.BrowserToolbar.OnDismissListener;
 import org.mozilla.gecko.toolbar.BrowserToolbar.OnFilterListener;
-import org.mozilla.gecko.toolbar.ToolbarEditText.OnTextTypeChangeListener;
-import org.mozilla.gecko.toolbar.ToolbarEditText.TextType;
 import org.mozilla.gecko.widget.ThemedLinearLayout;
 
 import android.content.Context;
 import android.util.AttributeSet;
 import android.view.KeyEvent;
 import android.view.LayoutInflater;
 import android.view.View;
-import android.view.View.OnFocusChangeListener;
 import android.view.inputmethod.InputMethodManager;
-import android.widget.ImageButton;
 
 /**
 * {@code ToolbarEditLayout} is the UI for when the toolbar is in
 * edit state. It controls a text entry ({@code ToolbarEditText})
 * and its matching 'go' button which changes depending on the
 * current type of text in the entry.
 */
 public class ToolbarEditLayout extends ThemedLinearLayout {
 
     private final ToolbarEditText mEditText;
-    private final ImageButton mGo;
 
-    private OnCommitListener mCommitListener;
     private OnFocusChangeListener mFocusChangeListener;
 
     public ToolbarEditLayout(Context context, AttributeSet attrs) {
         super(context, attrs);
 
         setOrientation(HORIZONTAL);
 
         LayoutInflater.from(context).inflate(R.layout.toolbar_edit_layout, this);
-        mGo = (ImageButton) findViewById(R.id.go);
         mEditText = (ToolbarEditText) findViewById(R.id.url_edit_text);
     }
 
     @Override
     public void onAttachedToWindow() {
-        mGo.setOnClickListener(new View.OnClickListener() {
-            @Override
-            public void onClick(View v) {
-                if (mCommitListener != null) {
-                    mCommitListener.onCommit();
-                }
-            }
-        });
-
-        mEditText.setOnTextTypeChangeListener(new OnTextTypeChangeListener() {
-            @Override
-            public void onTextTypeChange(ToolbarEditText editText, TextType textType) {
-                updateGoButton(textType);
-            }
-        });
-
         mEditText.setOnFocusChangeListener(new OnFocusChangeListener() {
             @Override
             public void onFocusChange(View v, boolean hasFocus) {
                 if (mFocusChangeListener != null) {
                     mFocusChangeListener.onFocusChange(ToolbarEditLayout.this, hasFocus);
                 }
             }
         });
@@ -80,107 +56,52 @@ public class ToolbarEditLayout extends T
     @Override
     public void setOnFocusChangeListener(OnFocusChangeListener listener) {
         mFocusChangeListener = listener;
     }
 
     @Override
     public void setEnabled(boolean enabled) {
         super.setEnabled(enabled);
-
-        mGo.setEnabled(enabled);
         mEditText.setEnabled(enabled);
     }
 
     @Override
     public void setPrivateMode(boolean isPrivate) {
         super.setPrivateMode(isPrivate);
         mEditText.setPrivateMode(isPrivate);
     }
 
-    private void updateGoButton(TextType textType) {
-        if (textType == TextType.EMPTY) {
-            mGo.setVisibility(View.GONE);
-            return;
-        }
-
-        mGo.setVisibility(View.VISIBLE);
-
-        final int imageResource;
-        final String contentDescription;
-
-        if (textType == TextType.SEARCH_QUERY) {
-            imageResource = R.drawable.ic_url_bar_search;
-            contentDescription = getContext().getString(R.string.search);
-        } else {
-            imageResource = R.drawable.ic_url_bar_go;
-            contentDescription = getContext().getString(R.string.go);
-        }
-
-        mGo.setImageResource(imageResource);
-        mGo.setContentDescription(contentDescription);
-    }
-
     private void showSoftInput() {
         InputMethodManager imm =
                (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
         imm.showSoftInput(mEditText, InputMethodManager.SHOW_IMPLICIT);
     }
 
-    void prepareAnimation(final boolean showing, final PropertyAnimator animator) {
-        if (showing) {
-            prepareShowAnimation(animator);
-        } else {
-            prepareHideAnimation(animator);
-        }
-    }
-
-    private void prepareShowAnimation(final PropertyAnimator animator) {
+    void prepareShowAnimation(final PropertyAnimator animator) {
         if (animator == null) {
             mEditText.requestFocus();
             showSoftInput();
             return;
         }
 
         animator.addPropertyAnimationListener(new PropertyAnimationListener() {
             @Override
             public void onPropertyAnimationStart() {
-                ViewHelper.setAlpha(mGo, 0.0f);
                 mEditText.requestFocus();
             }
 
             @Override
             public void onPropertyAnimationEnd() {
-                ViewHelper.setAlpha(mGo, 1.0f);
                 showSoftInput();
             }
         });
     }
 
-    private void prepareHideAnimation(final PropertyAnimator animator) {
-        if (animator == null) {
-            return;
-        }
-
-        animator.addPropertyAnimationListener(new PropertyAnimationListener() {
-            @Override
-            public void onPropertyAnimationStart() {
-                ViewHelper.setAlpha(mGo, 0.0f);
-            }
-
-            @Override
-            public void onPropertyAnimationEnd() {
-                // The enclosing view is invisible, so unhide the go button.
-                ViewHelper.setAlpha(mGo, 1.0f);
-            }
-        });
-    }
-
     void setOnCommitListener(OnCommitListener listener) {
-        mCommitListener = listener;
         mEditText.setOnCommitListener(listener);
     }
 
     void setOnDismissListener(OnDismissListener listener) {
         mEditText.setOnDismissListener(listener);
     }
 
     void setOnFilterListener(OnFilterListener listener) {