Bug 817716 - (Part 2) Add 3-dot menu for tabs tray on tablets. r=bnicholson
--- a/mobile/android/base/menu/MenuPopup.java
+++ b/mobile/android/base/menu/MenuPopup.java
@@ -15,28 +15,30 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
/**
* A popup to show the inflated MenuPanel.
*/
public class MenuPopup extends PopupWindow {
- private LinearLayout mPanel;
+ private final LinearLayout mPanel;
- private int mYOffset;
- private int mPopupWidth;
+ private final int mYOffset;
+ private final int mPopupWidth;
+ private final int mPopupMinHeight;
public MenuPopup(Context context) {
super(context);
setFocusable(true);
mYOffset = context.getResources().getDimensionPixelSize(R.dimen.menu_popup_offset);
mPopupWidth = context.getResources().getDimensionPixelSize(R.dimen.menu_popup_width);
+ mPopupMinHeight = context.getResources().getDimensionPixelSize(R.dimen.menu_item_row_height);
// Setting a null background makes the popup to not close on touching outside.
setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
setWindowLayoutMode(View.MeasureSpec.makeMeasureSpec(mPopupWidth, View.MeasureSpec.AT_MOST),
ViewGroup.LayoutParams.WRAP_CONTENT);
LayoutInflater inflater = LayoutInflater.from(context);
mPanel = (LinearLayout) inflater.inflate(R.layout.menu_popup, null);
@@ -58,11 +60,17 @@ public class MenuPopup extends PopupWind
mPanel.addView(view);
}
/**
* A small little offset.
*/
@Override
public void showAsDropDown(View anchor) {
- showAsDropDown(anchor, 0, -mYOffset);
+ // Set a height, so that the popup will not be displayed below the bottom of the screen.
+ setHeight(mPopupMinHeight);
+
+ // Attempt to align the center of the popup with the center of the anchor. If the anchor is
+ // near the edge of the screen, the popup will just align with the edge of the screen.
+ final int xOffset = anchor.getWidth()/2 - mPopupWidth/2;
+ showAsDropDown(anchor, xOffset, -mYOffset);
}
}
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..af08dc45169a1e4e9a7184783882eae006c0d70b
GIT binary patch
literal 136
zc%17D@N?(olHy`uVBq!ia0vp^Dj>|r3?y%#<GKx`SkfJR9T^xl_H+M9WCijWi-X*q
z7}lMWc?smO1^9%x0_p$%|1Z5c|1OZlR1)MD%rNu6!?PPeo{*=DV+hCf<b(q(XX-ta
c*%xy%h))xL`TUOTB%myVr>mdKI;Vst0O8#xv;Y7A
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..af08dc45169a1e4e9a7184783882eae006c0d70b
GIT binary patch
literal 136
zc%17D@N?(olHy`uVBq!ia0vp^Dj>|r3?y%#<GKx`SkfJR9T^xl_H+M9WCijWi-X*q
z7}lMWc?smO1^9%x0_p$%|1Z5c|1OZlR1)MD%rNu6!?PPeo{*=DV+hCf<b(q(XX-ta
c*%xy%h))xL`TUOTB%myVr>mdKI;Vst0O8#xv;Y7A
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..b0210e7cf2c17d485427671a7139536c115f2105
GIT binary patch
literal 136
zc%17D@N?(olHy`uVBq!ia0vp^5+KaT3?y&uT)!Jgv7|ftIx;Y9?C1WI$O_~$76-XI
zF|0c$^AgBm3-AeX1=9cj|6h7@{#_u8sU*lRm|^CBhi5l{JRwgP#}JO|$q5aOQaUq&
cEZNu?vbVFlaul6g43uT?boFyt=akR{0Of-vjsO4v
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..6fb5853084488393253ce3ade465eca2a33c79bf
GIT binary patch
literal 138
zc%17D@N?(olHy`uVBq!ia0vp^1|ZDH3?y^UWFG-iEa{HEjtmSN`?>!lvI6;x#X;^)
z4C~IxyaaOC0(?STf%O0X|CipJe;3GNDhcunW|;Zk;n@u!PsG#3F+}2Wa>4<=C-ni%
eN=!V)-3<N{6*jA#xMv5HXYh3Ob6Mw<&;$S~d?yzG
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..b0210e7cf2c17d485427671a7139536c115f2105
GIT binary patch
literal 136
zc%17D@N?(olHy`uVBq!ia0vp^5+KaT3?y&uT)!Jgv7|ftIx;Y9?C1WI$O_~$76-XI
zF|0c$^AgBm3-AeX1=9cj|6h7@{#_u8sU*lRm|^CBhi5l{JRwgP#}JO|$q5aOQaUq&
cEZNu?vbVFlaul6g43uT?boFyt=akR{0Of-vjsO4v
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..6fb5853084488393253ce3ade465eca2a33c79bf
GIT binary patch
literal 138
zc%17D@N?(olHy`uVBq!ia0vp^1|ZDH3?y^UWFG-iEa{HEjtmSN`?>!lvI6;x#X;^)
z4C~IxyaaOC0(?STf%O0X|CipJe;3GNDhcunW|;Zk;n@u!PsG#3F+}2Wa>4<=C-ni%
eN=!V)-3<N{6*jA#xMv5HXYh3Ob6Mw<&;$S~d?yzG
--- a/mobile/android/base/resources/layout-large-land-v11/tabs_panel_footer.xml
+++ b/mobile/android/base/resources/layout-large-land-v11/tabs_panel_footer.xml
@@ -1,17 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- 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/. -->
<merge xmlns:android="http://schemas.android.com/apk/res/android">
<ImageButton android:id="@+id/add_tab"
- android:layout_width="fill_parent"
+ android:layout_width="@dimen/browser_toolbar_height"
android:layout_height="@dimen/browser_toolbar_height"
android:padding="14dip"
android:src="@drawable/tab_new_level"
android:contentDescription="@string/new_tab"
- android:background="@drawable/action_bar_button_inverse"
- android:gravity="center"/>
+ android:background="@drawable/action_bar_button_inverse"/>
+
+ <View android:layout_width="0dip"
+ android:layout_height="match_parent"
+ android:layout_weight="1.0"/>
+
+ <ImageButton android:id="@+id/menu"
+ style="@style/UrlBar.ImageButton"
+ android:layout_width="@dimen/browser_toolbar_height"
+ android:layout_height="@dimen/browser_toolbar_height"
+ android:padding="@dimen/browser_toolbar_button_padding"
+ android:src="@drawable/menu_tabs"
+ android:contentDescription="@string/menu"
+ android:background="@drawable/action_bar_button"/>
</merge>
--- a/mobile/android/base/resources/layout/tabs_panel_header.xml
+++ b/mobile/android/base/resources/layout/tabs_panel_header.xml
@@ -25,13 +25,13 @@
android:contentDescription="@string/new_tab"
android:background="@drawable/action_bar_button_inverse"/>
<ImageButton android:id="@+id/menu"
style="@style/UrlBar.ImageButton"
android:layout_width="@dimen/browser_toolbar_height"
android:layout_height="@dimen/browser_toolbar_height"
android:padding="@dimen/browser_toolbar_button_padding"
- android:src="@drawable/menu"
+ android:src="@drawable/menu_tabs"
android:contentDescription="@string/menu"
android:background="@drawable/action_bar_button"/>
</merge>