From 58d0b4eaf48ce1d88270f239acb8144949472ffa Mon Sep 17 00:00:00 2001 From: Chenxia Liu Date: Fri, 17 Apr 2015 17:56:10 -0700 Subject: [PATCH] Bug 1155819 - Set anchor as back button for tablets. r=ally --HG-- extra : rebase_source : 0e877a56a15b14b4cc35c4a6744e17666b745b02 --- .../base/toolbar/BrowserToolbarTabletBase.java | 5 +++++ mobile/android/base/widget/AnchoredPopup.java | 14 +++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/mobile/android/base/toolbar/BrowserToolbarTabletBase.java b/mobile/android/base/toolbar/BrowserToolbarTabletBase.java index 0fdf665412a3..b80bb2173fc4 100644 --- a/mobile/android/base/toolbar/BrowserToolbarTabletBase.java +++ b/mobile/android/base/toolbar/BrowserToolbarTabletBase.java @@ -127,6 +127,11 @@ abstract class BrowserToolbarTabletBase extends BrowserToolbar { } } + @Override + public View getDoorHangerAnchor() { + return backButton; + } + protected boolean canDoBack(final Tab tab) { return (tab.canDoBack() && !isEditing()); } diff --git a/mobile/android/base/widget/AnchoredPopup.java b/mobile/android/base/widget/AnchoredPopup.java index 05631b568457..6cfee365577d 100644 --- a/mobile/android/base/widget/AnchoredPopup.java +++ b/mobile/android/base/widget/AnchoredPopup.java @@ -100,11 +100,15 @@ public abstract class AnchoredPopup extends PopupWindow { 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); + } } }