Bug 1155819 - Set anchor as back button for tablets. r=ally
authorChenxia Liu <liuche@mozilla.com>
Fri, 17 Apr 2015 17:56:10 -0700
changeset 240157 4bda09d4350c7a44f80f4538fbe31f1ba286eb31
parent 240156 ab85ee309a19e7c57c5633c5083d43c386372a52
child 240158 f942503602b641c52554a0639fd9d0f47bf27d29
push id58752
push usercbook@mozilla.com
push dateTue, 21 Apr 2015 10:39:00 +0000
treeherdermozilla-inbound@b8d59286a581 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersally
bugs1155819
milestone40.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 1155819 - Set anchor as back button for tablets. r=ally
mobile/android/base/toolbar/BrowserToolbarTabletBase.java
mobile/android/base/widget/AnchoredPopup.java
--- a/mobile/android/base/toolbar/BrowserToolbarTabletBase.java
+++ b/mobile/android/base/toolbar/BrowserToolbarTabletBase.java
@@ -122,16 +122,21 @@ abstract class BrowserToolbarTabletBase 
         backButton.setPrivateMode(isPrivate);
         forwardButton.setPrivateMode(isPrivate);
         for (int i = 0; i < actionItemBar.getChildCount(); ++i) {
             final MenuItemActionBar child = (MenuItemActionBar) actionItemBar.getChildAt(i);
             child.setPrivateMode(isPrivate);
         }
     }
 
+    @Override
+    public View getDoorHangerAnchor() {
+        return backButton;
+    }
+
     protected boolean canDoBack(final Tab tab) {
         return (tab.canDoBack() && !isEditing());
     }
 
     protected boolean canDoForward(final Tab tab) {
         return (tab.canDoForward() && !isEditing());
     }
 
--- a/mobile/android/base/widget/AnchoredPopup.java
+++ b/mobile/android/base/widget/AnchoredPopup.java
@@ -95,16 +95,20 @@ public abstract class AnchoredPopup exte
             offsetY = mContext.getResources().getDimensionPixelOffset(R.dimen.doorhanger_GB_offsetY);
             if (mAnchor == null) {
               mAnchor = decorView;
             }
             showAsDropDown(mAnchor, 0, -offsetY);
             return;
         }
 
-        // If the anchor is null or out of the window bounds, just show the popup at the top of the
-        // root view.
-        final boolean validAnchor = (mAnchor != null) && (anchorLocation[1] > 0);
-        final View anchor = validAnchor ? mAnchor : decorView;
+        if (HardwareUtils.isTablet()) {
+            showAsDropDown(mAnchor, 0, 0);
+        } else {
+            // If the anchor is null or out of the window bounds, just show the popup at the top of the
+            // root view.
+            final boolean validAnchor = (mAnchor != null) && (anchorLocation[1] > 0);
+            final View anchor = validAnchor ? mAnchor : decorView;
 
-        showAtLocation(anchor, Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, offsetY);
+            showAtLocation(anchor, Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, offsetY);
+        }
     }
 }