Merge fx-team to m-c
authorWes Kocher <wkocher@mozilla.com>
Tue, 22 Apr 2014 18:26:23 -0700
changeset 180076 35737ab92f9eb9b860ab7aa188ba3416bf174254
parent 180071 02515cf4fcfd1512e5f5e747062c7023e0d37a44 (current diff)
parent 180075 4c8ee55dbdd1e3b08e585ba7f2cab8ce44cd0bab (diff)
child 180085 ac376a4e817437778ce4365189e53b1152f7e7c7
push id272
push userpvanderbeken@mozilla.com
push dateMon, 05 May 2014 16:31:18 +0000
milestone31.0a1
Merge fx-team to m-c
--- a/mobile/android/base/home/PinSiteDialog.java
+++ b/mobile/android/base/home/PinSiteDialog.java
@@ -104,21 +104,23 @@ class PinSiteDialog extends DialogFragme
             @Override
             public boolean onKey(View v, int keyCode, KeyEvent event) {
                 if (keyCode != KeyEvent.KEYCODE_ENTER || mOnSiteSelectedListener == null) {
                     return false;
                 }
 
                 // If the user manually entered a search term or URL, wrap the value in
                 // a special URI until we can get a valid URL for this bookmark.
-                final String text = mSearch.getText().toString();
-                final String url = TopSitesPanel.encodeUserEnteredUrl(text);
-                mOnSiteSelectedListener.onSiteSelected(url, text);
+                final String text = mSearch.getText().toString().trim();
+                if (!TextUtils.isEmpty(text)) {
+                    final String url = TopSitesPanel.encodeUserEnteredUrl(text);
+                    mOnSiteSelectedListener.onSiteSelected(url, text);
+                    dismiss();
+                }
 
-                dismiss();
                 return true;
             }
         });
 
         mSearch.setOnFocusChangeListener(new View.OnFocusChangeListener() {
             @Override
             public void onFocusChange(View v, boolean hasFocus) {
                 if (hasFocus) {
--- a/mobile/android/base/home/TopSitesGridItemView.java
+++ b/mobile/android/base/home/TopSitesGridItemView.java
@@ -103,16 +103,23 @@ public class TopSitesGridItemView extend
     /**
      * @return true, if this view is pinned, false otherwise.
      */
     public boolean isPinned() {
         return mIsPinned;
     }
 
     /**
+     * @return true, if this view has no content to show.
+     */
+    public boolean isEmpty() {
+        return mIsEmpty;
+    }
+
+    /**
      * @param title The title for this view.
      */
     public void setTitle(String title) {
         if (mTitle != null && mTitle.equals(title)) {
             return;
         }
 
         mTitle = title;
--- a/mobile/android/base/home/TopSitesGridView.java
+++ b/mobile/android/base/home/TopSitesGridView.java
@@ -120,17 +120,18 @@ public class TopSitesGridView extends Gr
             }
         });
 
         setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
             @Override
             public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
                 Cursor cursor = (Cursor) parent.getItemAtPosition(position);
 
-                if (cursor == null) {
+                TopSitesGridItemView gridView = (TopSitesGridItemView) view;
+                if (cursor == null || gridView.isEmpty()) {
                     mContextMenuInfo = null;
                     return false;
                 }
 
                 mContextMenuInfo = new TopSitesGridContextMenuInfo(view, position, id);
                 updateContextMenuFromCursor(mContextMenuInfo, cursor);
                 return showContextMenuForChild(TopSitesGridView.this);
             }