diff --git a/mobile/android/base/BrowserApp.java b/mobile/android/base/BrowserApp.java index 02af39818c57d840d954d53a5643c80abbb35005..9bdce98d9506d97780ede10366e70cea6db3834e 100644 --- a/mobile/android/base/BrowserApp.java +++ b/mobile/android/base/BrowserApp.java @@ -3027,6 +3027,7 @@ public class BrowserApp extends GeckoApp bookmark.setVisible(!inGuestMode); bookmark.setCheckable(true); bookmark.setChecked(tab.isBookmark()); + bookmark.setIcon(resolveBookmarkIconID(tab.isBookmark())); bookmark.setTitle(resolveBookmarkTitleID(tab.isBookmark())); reader.setEnabled(isAboutReader || !AboutPages.isAboutPage(tab.getURL())); @@ -3034,14 +3035,9 @@ public class BrowserApp extends GeckoApp reader.setCheckable(true); final boolean isPageInReadingList = tab.isInReadingList(); reader.setChecked(isPageInReadingList); + reader.setIcon(resolveReadingListIconID(isPageInReadingList)); reader.setTitle(resolveReadingListTitleID(isPageInReadingList)); - if (Versions.feature11Plus) { - // We don't use icons on GB builds so not resolving icons might conserve resources. - bookmark.setIcon(resolveBookmarkIconID(tab.isBookmark())); - reader.setIcon(resolveReadingListIconID(isPageInReadingList)); - } - back.setEnabled(tab.canDoBack()); forward.setEnabled(tab.canDoForward()); desktopMode.setChecked(tab.getDesktopMode()); @@ -3233,19 +3229,13 @@ public class BrowserApp extends GeckoApp if (item.isChecked()) { Telemetry.sendUIEvent(TelemetryContract.Event.UNSAVE, TelemetryContract.Method.MENU, "bookmark"); tab.removeBookmark(); + item.setIcon(resolveBookmarkIconID(false)); item.setTitle(resolveBookmarkTitleID(false)); - if (Versions.feature11Plus) { - // We don't use icons on GB builds so not resolving icons might conserve resources. - item.setIcon(resolveBookmarkIconID(false)); - } } else { Telemetry.sendUIEvent(TelemetryContract.Event.SAVE, TelemetryContract.Method.MENU, "bookmark"); tab.addBookmark(); + item.setIcon(resolveBookmarkIconID(true)); item.setTitle(resolveBookmarkTitleID(true)); - if (Versions.feature11Plus) { - // We don't use icons on GB builds so not resolving icons might conserve resources. - item.setIcon(resolveBookmarkIconID(true)); - } } } return true; @@ -3257,19 +3247,13 @@ public class BrowserApp extends GeckoApp if (item.isChecked()) { Telemetry.sendUIEvent(TelemetryContract.Event.UNSAVE, TelemetryContract.Method.MENU, "reading_list"); tab.removeFromReadingList(); + item.setIcon(resolveReadingListIconID(false)); item.setTitle(resolveReadingListTitleID(false)); - if (Versions.feature11Plus) { - // We don't use icons on GB builds so not resolving icons might conserve resources. - item.setIcon(resolveReadingListIconID(false)); - } } else { Telemetry.sendUIEvent(TelemetryContract.Event.SAVE, TelemetryContract.Method.MENU, "reading_list"); tab.addToReadingList(); + item.setIcon(resolveReadingListIconID(true)); item.setTitle(resolveReadingListTitleID(true)); - if (Versions.feature11Plus) { - // We don't use icons on GB builds so not resolving icons might conserve resources. - item.setIcon(resolveReadingListIconID(true)); - } } } return true; diff --git a/mobile/android/base/GeckoApp.java b/mobile/android/base/GeckoApp.java index cc98ecca861fb1ddfcbb10604c3c5fae31c3cbcc..4071678ce226fa30b7d7140b7fd8be58247de390 100644 --- a/mobile/android/base/GeckoApp.java +++ b/mobile/android/base/GeckoApp.java @@ -348,7 +348,11 @@ public abstract class GeckoApp @Override public MenuInflater getMenuInflater() { - return new GeckoMenuInflater(this); + if (Versions.feature11Plus) { + return new GeckoMenuInflater(this); + } else { + return super.getMenuInflater(); + } } public MenuPanel getMenuPanel() { @@ -399,7 +403,7 @@ public abstract class GeckoApp @Override public View onCreatePanelView(int featureId) { - if (featureId == Window.FEATURE_OPTIONS_PANEL) { + if (Versions.feature11Plus && featureId == Window.FEATURE_OPTIONS_PANEL) { if (mMenuPanel == null) { mMenuPanel = new MenuPanel(this, null); } else { @@ -415,7 +419,7 @@ public abstract class GeckoApp @Override public boolean onCreatePanelMenu(int featureId, Menu menu) { - if (featureId == Window.FEATURE_OPTIONS_PANEL) { + if (Versions.feature11Plus && featureId == Window.FEATURE_OPTIONS_PANEL) { if (mMenuPanel == null) { mMenuPanel = (MenuPanel) onCreatePanelView(featureId); } @@ -434,7 +438,7 @@ public abstract class GeckoApp @Override public boolean onPreparePanel(int featureId, View view, Menu menu) { - if (featureId == Window.FEATURE_OPTIONS_PANEL) { + if (Versions.feature11Plus && featureId == Window.FEATURE_OPTIONS_PANEL) { return onPrepareOptionsMenu(menu); } @@ -448,7 +452,7 @@ public abstract class GeckoApp GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("FullScreen:Exit", null)); } - if (featureId == Window.FEATURE_OPTIONS_PANEL) { + if (Versions.feature11Plus && featureId == Window.FEATURE_OPTIONS_PANEL) { if (mMenu == null) { // getMenuPanel() will force the creation of the menu as well MenuPanel panel = getMenuPanel(); @@ -513,8 +517,10 @@ public abstract class GeckoApp @Override public void onOptionsMenuClosed(Menu menu) { - mMenuPanel.removeAllViews(); - mMenuPanel.addView((GeckoMenu) mMenu); + if (Versions.feature11Plus) { + mMenuPanel.removeAllViews(); + mMenuPanel.addView((GeckoMenu) mMenu); + } } @Override diff --git a/mobile/android/base/resources/drawable-hdpi-v11/ic_menu_back.png b/mobile/android/base/resources/drawable-hdpi/ic_menu_back.png similarity index 100% rename from mobile/android/base/resources/drawable-hdpi-v11/ic_menu_back.png rename to mobile/android/base/resources/drawable-hdpi/ic_menu_back.png diff --git a/mobile/android/base/resources/drawable-hdpi/ic_menu_bookmark_add.png b/mobile/android/base/resources/drawable-hdpi/ic_menu_bookmark_add.png new file mode 100644 index 0000000000000000000000000000000000000000..03a57c998cbf1c1060d09b0094ef3b0e2e574bbb Binary files /dev/null and b/mobile/android/base/resources/drawable-hdpi/ic_menu_bookmark_add.png differ diff --git a/mobile/android/base/resources/drawable-hdpi/ic_menu_bookmark_remove.png b/mobile/android/base/resources/drawable-hdpi/ic_menu_bookmark_remove.png new file mode 100644 index 0000000000000000000000000000000000000000..9e23244e2691906078732018e834458aa075bfe5 Binary files /dev/null and b/mobile/android/base/resources/drawable-hdpi/ic_menu_bookmark_remove.png differ diff --git a/mobile/android/base/resources/drawable-hdpi/ic_menu_forward.png b/mobile/android/base/resources/drawable-hdpi/ic_menu_forward.png new file mode 100644 index 0000000000000000000000000000000000000000..99138a56b96cc09b5fb50700e2056707f77c3a68 Binary files /dev/null and b/mobile/android/base/resources/drawable-hdpi/ic_menu_forward.png differ diff --git a/mobile/android/base/resources/drawable-hdpi/ic_menu_new_private_tab.png b/mobile/android/base/resources/drawable-hdpi/ic_menu_new_private_tab.png new file mode 100644 index 0000000000000000000000000000000000000000..496ff3517df516bade75d9229cef5d37a14754db Binary files /dev/null and b/mobile/android/base/resources/drawable-hdpi/ic_menu_new_private_tab.png differ diff --git a/mobile/android/base/resources/drawable-hdpi/ic_menu_new_tab.png b/mobile/android/base/resources/drawable-hdpi/ic_menu_new_tab.png new file mode 100644 index 0000000000000000000000000000000000000000..d7c6dfa117f8d36e91324afad86e529ca1308932 Binary files /dev/null and b/mobile/android/base/resources/drawable-hdpi/ic_menu_new_tab.png differ diff --git a/mobile/android/base/resources/drawable-hdpi/ic_menu_reload.png b/mobile/android/base/resources/drawable-hdpi/ic_menu_reload.png new file mode 100644 index 0000000000000000000000000000000000000000..24026f9c070ad71f4686629cb5af99d78ebb6528 Binary files /dev/null and b/mobile/android/base/resources/drawable-hdpi/ic_menu_reload.png differ diff --git a/mobile/android/base/resources/drawable-xhdpi-v11/ic_menu_back.png b/mobile/android/base/resources/drawable-xhdpi/ic_menu_back.png similarity index 100% rename from mobile/android/base/resources/drawable-xhdpi-v11/ic_menu_back.png rename to mobile/android/base/resources/drawable-xhdpi/ic_menu_back.png diff --git a/mobile/android/base/resources/drawable-xhdpi/ic_menu_bookmark_add.png b/mobile/android/base/resources/drawable-xhdpi/ic_menu_bookmark_add.png new file mode 100644 index 0000000000000000000000000000000000000000..042dee803279815ebc8e93a7d849ec32d1a5e98a Binary files /dev/null and b/mobile/android/base/resources/drawable-xhdpi/ic_menu_bookmark_add.png differ diff --git a/mobile/android/base/resources/drawable-xhdpi/ic_menu_bookmark_remove.png b/mobile/android/base/resources/drawable-xhdpi/ic_menu_bookmark_remove.png new file mode 100644 index 0000000000000000000000000000000000000000..50d992e7395a89043752f486305bfc5c95d58f96 Binary files /dev/null and b/mobile/android/base/resources/drawable-xhdpi/ic_menu_bookmark_remove.png differ diff --git a/mobile/android/base/resources/drawable-xhdpi/ic_menu_forward.png b/mobile/android/base/resources/drawable-xhdpi/ic_menu_forward.png new file mode 100644 index 0000000000000000000000000000000000000000..51fea1bc49250dbc4d670f0a2f124cdb771286f1 Binary files /dev/null and b/mobile/android/base/resources/drawable-xhdpi/ic_menu_forward.png differ diff --git a/mobile/android/base/resources/drawable-xhdpi/ic_menu_new_private_tab.png b/mobile/android/base/resources/drawable-xhdpi/ic_menu_new_private_tab.png new file mode 100644 index 0000000000000000000000000000000000000000..0ca97ab7ed5152eb9c17e0835816000f8e3a5da1 Binary files /dev/null and b/mobile/android/base/resources/drawable-xhdpi/ic_menu_new_private_tab.png differ diff --git a/mobile/android/base/resources/drawable-xhdpi/ic_menu_new_tab.png b/mobile/android/base/resources/drawable-xhdpi/ic_menu_new_tab.png new file mode 100644 index 0000000000000000000000000000000000000000..3b2622ec767c66787b040cdf3ae396f2e10fd55e Binary files /dev/null and b/mobile/android/base/resources/drawable-xhdpi/ic_menu_new_tab.png differ diff --git a/mobile/android/base/resources/drawable-xhdpi/ic_menu_reload.png b/mobile/android/base/resources/drawable-xhdpi/ic_menu_reload.png new file mode 100644 index 0000000000000000000000000000000000000000..712916f45d07295d1a55a07095ebdc3df9348bd6 Binary files /dev/null and b/mobile/android/base/resources/drawable-xhdpi/ic_menu_reload.png differ diff --git a/mobile/android/base/resources/drawable/ic_menu_bookmark_add.xml b/mobile/android/base/resources/drawable/ic_menu_bookmark_add.xml deleted file mode 100644 index 2afadaf5e23bb89d92fa9d6f6f43a5209719709e..0000000000000000000000000000000000000000 --- a/mobile/android/base/resources/drawable/ic_menu_bookmark_add.xml +++ /dev/null @@ -1,9 +0,0 @@ -<?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/. --> - -<!-- This asset is properly available in large-* dirs so this null - reference exists for build time on API 9 builds. --> -<bitmap xmlns:android="http://schemas.android.com/apk/res/android" - android:src="@null"/> diff --git a/mobile/android/base/resources/drawable/ic_menu_bookmark_remove.xml b/mobile/android/base/resources/drawable/ic_menu_bookmark_remove.xml deleted file mode 100644 index 2afadaf5e23bb89d92fa9d6f6f43a5209719709e..0000000000000000000000000000000000000000 --- a/mobile/android/base/resources/drawable/ic_menu_bookmark_remove.xml +++ /dev/null @@ -1,9 +0,0 @@ -<?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/. --> - -<!-- This asset is properly available in large-* dirs so this null - reference exists for build time on API 9 builds. --> -<bitmap xmlns:android="http://schemas.android.com/apk/res/android" - android:src="@null"/> diff --git a/mobile/android/base/resources/drawable/ic_menu_reader_add.xml b/mobile/android/base/resources/drawable/ic_menu_reader_add.xml index d3e7c79172523043b4448592a25c3748ef9c3205..9832a22039647a4418dc08fb94c42ea4223cd0a0 100644 --- a/mobile/android/base/resources/drawable/ic_menu_reader_add.xml +++ b/mobile/android/base/resources/drawable/ic_menu_reader_add.xml @@ -3,5 +3,9 @@ - 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/. --> -<bitmap xmlns:android="http://schemas.android.com/apk/res/android" - android:src="@null"/> +<shape xmlns:android="http://schemas.android.com/apk/res/android" + android:shape="rectangle"> + + <solid android:color="@android:color/transparent"/> + +</shape> diff --git a/mobile/android/base/resources/drawable/ic_menu_reader_remove.xml b/mobile/android/base/resources/drawable/ic_menu_reader_remove.xml index d3e7c79172523043b4448592a25c3748ef9c3205..9832a22039647a4418dc08fb94c42ea4223cd0a0 100644 --- a/mobile/android/base/resources/drawable/ic_menu_reader_remove.xml +++ b/mobile/android/base/resources/drawable/ic_menu_reader_remove.xml @@ -3,5 +3,9 @@ - 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/. --> -<bitmap xmlns:android="http://schemas.android.com/apk/res/android" - android:src="@null"/> +<shape xmlns:android="http://schemas.android.com/apk/res/android" + android:shape="rectangle"> + + <solid android:color="@android:color/transparent"/> + +</shape> diff --git a/mobile/android/base/resources/layout-large-v11/browser_toolbar.xml b/mobile/android/base/resources/layout-large-v11/browser_toolbar.xml index 77a968369f03cb7ac68f5e109ea6da372cebfefa..ae75032b0230a20f432101e8815296be5de5ba99 100644 --- a/mobile/android/base/resources/layout-large-v11/browser_toolbar.xml +++ b/mobile/android/base/resources/layout-large-v11/browser_toolbar.xml @@ -124,7 +124,8 @@ android:layout_toLeftOf="@id/menu_margin" android:layout_alignWithParentIfMissing="true" android:contentDescription="@string/menu" - android:background="@drawable/browser_toolbar_action_bar_button"> + android:background="@drawable/browser_toolbar_action_bar_button" + android:visibility="gone"> <org.mozilla.gecko.widget.themed.ThemedImageView android:id="@+id/menu_icon" diff --git a/mobile/android/base/resources/layout/browser_toolbar.xml b/mobile/android/base/resources/layout/browser_toolbar.xml index 17d70e1384660ee9f1f47ba98085616b14c5de53..496d096001bdb428ef70ef5dd196d00759043008 100644 --- a/mobile/android/base/resources/layout/browser_toolbar.xml +++ b/mobile/android/base/resources/layout/browser_toolbar.xml @@ -41,7 +41,8 @@ style="@style/UrlBar.ImageButton" android:layout_alignParentRight="true" android:contentDescription="@string/menu" - android:background="@drawable/shaped_button"> + android:background="@drawable/shaped_button" + android:visibility="gone"> <org.mozilla.gecko.widget.themed.ThemedImageView android:id="@+id/menu_icon" diff --git a/mobile/android/base/resources/layout/tabs_panel_default.xml b/mobile/android/base/resources/layout/tabs_panel_default.xml index 20e210391ef70dc178956bd8d1faa24c000f4b0e..7a15b4f03a907f489def90b6d40385024deeca25 100644 --- a/mobile/android/base/resources/layout/tabs_panel_default.xml +++ b/mobile/android/base/resources/layout/tabs_panel_default.xml @@ -53,7 +53,8 @@ style="@style/UrlBar.ImageButton" android:layout_width="@dimen/tabs_panel_button_width" android:background="@drawable/action_bar_button_inverse" - android:contentDescription="@string/menu"> + android:contentDescription="@string/menu" + android:visibility="gone"> <ImageButton style="@style/UrlBar.ImageButton" diff --git a/mobile/android/base/resources/menu/browser_app_menu.xml b/mobile/android/base/resources/menu/browser_app_menu.xml index 85fa1ec3e3fba4bb9bf4398632507caf669b76db..fd1aed745ce74c8314e53bfe1608f8b94e8852db 100644 --- a/mobile/android/base/resources/menu/browser_app_menu.xml +++ b/mobile/android/base/resources/menu/browser_app_menu.xml @@ -6,24 +6,28 @@ <menu xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/reload" + android:icon="@drawable/ic_menu_reload" android:title="@string/reload"/> - <!-- We keep the reference so calls to findView don't fail. Hide - to avoid taking up real estate on the users' screen. --> <item android:id="@+id/back" + android:icon="@drawable/ic_menu_back" android:title="@string/back" android:visible="false"/> <item android:id="@+id/forward" + android:icon="@drawable/ic_menu_forward" android:title="@string/forward"/> <item android:id="@+id/bookmark" + android:icon="@drawable/ic_menu_bookmark_add" android:title="@string/bookmark"/> <item android:id="@+id/new_tab" + android:icon="@drawable/ic_menu_new_tab" android:title="@string/new_tab"/> <item android:id="@+id/new_private_tab" + android:icon="@drawable/ic_menu_new_private_tab" android:title="@string/new_private_tab"/> <item android:id="@+id/share" @@ -32,6 +36,13 @@ <item android:id="@+id/reading_list" android:title="@string/overlay_share_reading_list_btn_label" /> + <item android:id="@+id/save_as_pdf" + android:title="@string/save_as_pdf" /> + + <item android:id="@+id/print" + android:visible="false" + android:title="@string/print" /> + <item android:id="@+id/find_in_page" android:title="@string/find_in_page" /> @@ -39,47 +50,14 @@ android:title="@string/desktop_mode" android:checkable="true" /> - <item android:id="@+id/page" - android:title="@string/page"> - - <menu> - <item android:id="@+id/subscribe" - android:title="@string/contextmenu_subscribe"/> + <item android:id="@+id/addons" + android:title="@string/addons"/> - <item android:id="@+id/save_as_pdf" - android:title="@string/save_as_pdf"/> + <item android:id="@+id/downloads" + android:title="@string/downloads"/> - <item android:id="@+id/print" - android:title="@string/print"/> - - <item android:id="@+id/add_search_engine" - android:title="@string/contextmenu_add_search_engine"/> - - <item android:id="@+id/add_to_launcher" - android:title="@string/contextmenu_add_to_launcher"/> - </menu> - - </item> - - <item android:id="@+id/tools" - android:title="@string/tools"> - - <menu> - <item android:id="@+id/downloads" - android:title="@string/downloads"/> - <item android:id="@+id/addons" - android:title="@string/addons"/> - <item android:id="@+id/logins" - android:title="@string/logins"/> - <item android:id="@+id/new_guest_session" - android:visible="false" - android:title="@string/new_guest_session"/> - <item android:id="@+id/exit_guest_session" - android:visible="false" - android:title="@string/exit_guest_session"/> - </menu> - - </item> + <item android:id="@+id/logins" + android:title="@string/logins"/> <item android:id="@+id/char_encoding" android:visible="false" @@ -91,6 +69,14 @@ <item android:id="@+id/help" android:title="@string/help_menu" /> + <item android:id="@+id/new_guest_session" + android:visible="false" + android:title="@string/new_guest_session"/> + + <item android:id="@+id/exit_guest_session" + android:visible="false" + android:title="@string/exit_guest_session"/> + <!-- Android will eliminate v11+ resource files from pre-11 builds. Those files are the only place in which certain IDs are defined. This causes compilation errors. @@ -101,4 +87,13 @@ android:visible="false" android:enabled="false" /> + <item android:id="@+id/page" + android:visible="false" + android:enabled="false" + android:title="@string/page" /> + + <item android:id="@+id/tools" + android:visible="false" + android:enabled="false" + android:title="@string/tools" /> </menu> diff --git a/mobile/android/base/tabs/TabsPanel.java b/mobile/android/base/tabs/TabsPanel.java index b072cde465f9c7cd7dfadb9ca594182f75ccfc30..c9617f5603fc8b965405b889f670cc8623b9fde3 100644 --- a/mobile/android/base/tabs/TabsPanel.java +++ b/mobile/android/base/tabs/TabsPanel.java @@ -367,8 +367,13 @@ public class TabsPanel extends LinearLayout mAddTab.setVisibility(View.VISIBLE); - mMenuButton.setEnabled(true); - mPopupMenu.setAnchor(mMenuButton); + if (!HardwareUtils.hasMenuButton()) { + mMenuButton.setVisibility(View.VISIBLE); + mMenuButton.setEnabled(true); + mPopupMenu.setAnchor(mMenuButton); + } else { + mPopupMenu.setAnchor(mAddTab); + } } public int getVerticalPanelHeight() { diff --git a/mobile/android/base/toolbar/BrowserToolbar.java b/mobile/android/base/toolbar/BrowserToolbar.java index 2fdbfaba850bf905f81186c9deab58b8ceef1a7d..69fb6f95b17736b7c3829217b8fb9e60e70f7a24 100644 --- a/mobile/android/base/toolbar/BrowserToolbar.java +++ b/mobile/android/base/toolbar/BrowserToolbar.java @@ -129,6 +129,7 @@ public abstract class BrowserToolbar extends ThemedRelativeLayout private OnStopEditingListener stopEditingListener; protected final BrowserApp activity; + protected boolean hasSoftMenuButton; protected UIMode uiMode; protected TabHistoryController tabHistoryController; @@ -193,6 +194,7 @@ public abstract class BrowserToolbar extends ThemedRelativeLayout menuButton = (ThemedFrameLayout) findViewById(R.id.menu); menuIcon = (ThemedImageView) findViewById(R.id.menu_icon); + hasSoftMenuButton = !HardwareUtils.hasMenuButton(); // The focusOrder List should be filled by sub-classes. focusOrder = new ArrayList<View>(); @@ -319,14 +321,17 @@ public abstract class BrowserToolbar extends ThemedRelativeLayout }); tabsButton.setImageLevel(0); - menuButton.setOnClickListener(new Button.OnClickListener() { - @Override - public void onClick(View view) { - // Drop the soft keyboard. - urlEditLayout.clearFocus(); - activity.openOptionsMenu(); - } - }); + if (hasSoftMenuButton) { + menuButton.setVisibility(View.VISIBLE); + menuButton.setOnClickListener(new Button.OnClickListener() { + @Override + public void onClick(View view) { + // Drop the soft keyboard. + urlEditLayout.clearFocus(); + activity.openOptionsMenu(); + } + }); + } } @Override @@ -655,7 +660,7 @@ public abstract class BrowserToolbar extends ThemedRelativeLayout public void setToolBarButtonsAlpha(float alpha) { ViewHelper.setAlpha(tabsCounter, alpha); - if (!HardwareUtils.isTablet()) { + if (hasSoftMenuButton && !HardwareUtils.isTablet()) { ViewHelper.setAlpha(menuIcon, alpha); } } @@ -850,6 +855,10 @@ public abstract class BrowserToolbar extends ThemedRelativeLayout } public boolean openOptionsMenu() { + if (!hasSoftMenuButton) { + return false; + } + // Initialize the popup. if (menuPopup == null) { View panel = activity.getMenuPanel(); @@ -873,6 +882,10 @@ public abstract class BrowserToolbar extends ThemedRelativeLayout } public boolean closeOptionsMenu() { + if (!hasSoftMenuButton) { + return false; + } + if (menuPopup != null && menuPopup.isShowing()) { menuPopup.dismiss(); } diff --git a/mobile/android/base/toolbar/BrowserToolbarPhone.java b/mobile/android/base/toolbar/BrowserToolbarPhone.java index a5fc57f1adcba9760ca948b7bb50d4907faa0bd3..962771c825d84e761a181f8e105e3a0b163db973 100644 --- a/mobile/android/base/toolbar/BrowserToolbarPhone.java +++ b/mobile/android/base/toolbar/BrowserToolbarPhone.java @@ -118,11 +118,15 @@ class BrowserToolbarPhone extends BrowserToolbarPhoneBase { animator.attach(tabsCounter, PropertyAnimator.Property.TRANSLATION_X, curveTranslation); - animator.attach(menuButton, - PropertyAnimator.Property.TRANSLATION_X, - curveTranslation); - animator.attach(menuIcon, - PropertyAnimator.Property.TRANSLATION_X, - curveTranslation); + + if (!HardwareUtils.hasMenuButton()) { + animator.attach(menuButton, + PropertyAnimator.Property.TRANSLATION_X, + curveTranslation); + + animator.attach(menuIcon, + PropertyAnimator.Property.TRANSLATION_X, + curveTranslation); + } } } diff --git a/mobile/android/base/toolbar/BrowserToolbarPhoneBase.java b/mobile/android/base/toolbar/BrowserToolbarPhoneBase.java index 9056ff94e5e56da0a0cb4f319676f9b9fb556274..117b133292d9d5efa814816bf7ef704db0e714de 100644 --- a/mobile/android/base/toolbar/BrowserToolbarPhoneBase.java +++ b/mobile/android/base/toolbar/BrowserToolbarPhoneBase.java @@ -127,18 +127,24 @@ abstract class BrowserToolbarPhoneBase extends BrowserToolbar { public void triggerTabsPanelTransition(final PropertyAnimator animator, final boolean areTabsShown) { if (areTabsShown) { ViewHelper.setAlpha(tabsCounter, 0.0f); - ViewHelper.setAlpha(menuIcon, 0.0f); + if (hasSoftMenuButton) { + ViewHelper.setAlpha(menuIcon, 0.0f); + } return; } final PropertyAnimator buttonsAnimator = new PropertyAnimator(animator.getDuration(), buttonsInterpolator); + buttonsAnimator.attach(tabsCounter, PropertyAnimator.Property.ALPHA, 1.0f); - buttonsAnimator.attach(menuIcon, - PropertyAnimator.Property.ALPHA, - 1.0f); + if (hasSoftMenuButton) { + buttonsAnimator.attach(menuIcon, + PropertyAnimator.Property.ALPHA, + 1.0f); + } + buttonsAnimator.start(); } diff --git a/mobile/android/base/toolbar/BrowserToolbarPreHC.java b/mobile/android/base/toolbar/BrowserToolbarPreHC.java index 11d38c3b7f24f34e44fa5b8b16ed5eb9a1186937..454c9a63524dcf3eaf678421ce0588d4a0db4ece 100644 --- a/mobile/android/base/toolbar/BrowserToolbarPreHC.java +++ b/mobile/android/base/toolbar/BrowserToolbarPreHC.java @@ -54,12 +54,17 @@ class BrowserToolbarPreHC extends BrowserToolbarPhoneBase { // Prevent taps through the editing mode cancel button (bug 1001243). tabsButton.setEnabled(!isEditing); - menuButton.setEnabled(!isEditing); ViewHelper.setTranslationX(urlBarTranslatingEdge, entryTranslation); ViewHelper.setTranslationX(tabsButton, curveTranslation); ViewHelper.setTranslationX(tabsCounter, curveTranslation); - ViewHelper.setTranslationX(menuButton, curveTranslation); - ViewHelper.setTranslationX(menuIcon, curveTranslation); + + if (!HardwareUtils.hasMenuButton()) { + // Prevent tabs through the editing mode cancel button (bug 1001243). + menuButton.setEnabled(!isEditing); + + ViewHelper.setTranslationX(menuButton, curveTranslation); + ViewHelper.setTranslationX(menuIcon, curveTranslation); + } } } diff --git a/mobile/android/base/toolbar/BrowserToolbarTabletBase.java b/mobile/android/base/toolbar/BrowserToolbarTabletBase.java index 5b2363754529cb5b329b83710b57afe4b85038ac..75e665e787d18e267567950a6d1681b1f6a7e2f5 100644 --- a/mobile/android/base/toolbar/BrowserToolbarTabletBase.java +++ b/mobile/android/base/toolbar/BrowserToolbarTabletBase.java @@ -69,7 +69,7 @@ abstract class BrowserToolbarTabletBase extends BrowserToolbar { ColorUtils.getColor(context, R.color.tabs_tray_icon_grey), PorterDuff.Mode.SRC_IN); menuButtonMarginView = findViewById(R.id.menu_margin); - if (menuButtonMarginView != null) { + if (menuButtonMarginView != null && !HardwareUtils.hasMenuButton()) { menuButtonMarginView.setVisibility(View.VISIBLE); } } diff --git a/mobile/android/base/util/HardwareUtils.java b/mobile/android/base/util/HardwareUtils.java index d1dafbe856df7c82c3c0fb106b06fb6a56135442..c9a2598cac65f641fdd6613816bdf678210c7be8 100644 --- a/mobile/android/base/util/HardwareUtils.java +++ b/mobile/android/base/util/HardwareUtils.java @@ -36,6 +36,7 @@ public final class HardwareUtils { private static volatile boolean sIsLargeTablet; private static volatile boolean sIsSmallTablet; private static volatile boolean sIsTelevision; + private static volatile boolean sHasMenuButton; private HardwareUtils() { } @@ -50,16 +51,23 @@ public final class HardwareUtils { // Pre-populate common flags from the context. final int screenLayoutSize = context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK; if (Build.VERSION.SDK_INT >= 11) { + sHasMenuButton = false; if (screenLayoutSize == Configuration.SCREENLAYOUT_SIZE_XLARGE) { sIsLargeTablet = true; } else if (screenLayoutSize == Configuration.SCREENLAYOUT_SIZE_LARGE) { sIsSmallTablet = true; } - if (Build.VERSION.SDK_INT >= 16) { - if (context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEVISION)) { - sIsTelevision = true; + if (Build.VERSION.SDK_INT >= 14) { + sHasMenuButton = ViewConfiguration.get(context).hasPermanentMenuKey(); + + if (Build.VERSION.SDK_INT >= 16) { + if (context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEVISION)) { + sIsTelevision = true; + } } } + } else { + sHasMenuButton = true; } sInited = true; @@ -81,6 +89,10 @@ public final class HardwareUtils { return sIsTelevision; } + public static boolean hasMenuButton() { + return sHasMenuButton; + } + public static int getMemSize() { return SysInfo.getMemSize(); } diff --git a/mobile/android/services/src/main/java/org/mozilla/gecko/fxa/activities/FxAccountStatusFragment.java b/mobile/android/services/src/main/java/org/mozilla/gecko/fxa/activities/FxAccountStatusFragment.java index 65520265b24d0c1703a39b75a5855f4198a4bda3..e3cce22e90a7cac451ab9d2c2a67671fd7306943 100644 --- a/mobile/android/services/src/main/java/org/mozilla/gecko/fxa/activities/FxAccountStatusFragment.java +++ b/mobile/android/services/src/main/java/org/mozilla/gecko/fxa/activities/FxAccountStatusFragment.java @@ -213,6 +213,10 @@ public class FxAccountStatusFragment syncNowPreference = ensureFindPreference("sync_now"); syncNowPreference.setEnabled(true); syncNowPreference.setOnPreferenceClickListener(this); + + if (HardwareUtils.hasMenuButton()) { + syncCategory.removePreference(morePreference); + } } /** diff --git a/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/components/AppMenuComponent.java b/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/components/AppMenuComponent.java index 3f00a97247545d916e103be6c60515a2a1623546..30b7be953a89341a25f97f13b01a1942a43cd4ed 100644 --- a/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/components/AppMenuComponent.java +++ b/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/components/AppMenuComponent.java @@ -11,13 +11,13 @@ import static org.mozilla.gecko.tests.helpers.AssertionHelper.fAssertTrue; import java.util.List; -import org.mozilla.gecko.AppConstants; import org.mozilla.gecko.R; import org.mozilla.gecko.menu.MenuItemActionBar; import org.mozilla.gecko.menu.MenuItemDefault; import org.mozilla.gecko.tests.UITestContext; import org.mozilla.gecko.tests.helpers.DeviceHelper; import org.mozilla.gecko.tests.helpers.WaitHelper; +import org.mozilla.gecko.util.HardwareUtils; import android.text.TextUtils; import android.view.View; @@ -31,7 +31,7 @@ import com.jayway.android.robotium.solo.Solo; * A class representing any interactions that take place on the app menu. */ public class AppMenuComponent extends BaseComponent { - private static final long MAX_WAITTIME_FOR_MENU_UPDATE_IN_MS = 7500L; + private static final long MAX_WAITTIME_FOR_MENU_UPDATE_IN_MS = 1000L; private Boolean hasLegacyMenu = null; @@ -243,9 +243,9 @@ public class AppMenuComponent extends BaseComponent { private void openAppMenu() { assertMenuIsNotOpen(); - // This is a hack needed for tablets & GB where the OverflowMenuButton is always in the GONE state, + // This is a hack needed for tablets where the OverflowMenuButton is always in the GONE state, // so we press the menu key instead. - if (DeviceHelper.isTablet() || AppConstants.Versions.preHC) { + if (HardwareUtils.hasMenuButton() || DeviceHelper.isTablet()) { mSolo.sendKey(Solo.MENU); } else { pressOverflowMenuButton(); @@ -283,14 +283,12 @@ public class AppMenuComponent extends BaseComponent { } /** - * Determines whether the app menu is open by searching for items in the menu. + * Determines whether the app menu is open by searching for the text "New tab". * * @return true if app menu is open. */ private boolean isMenuOpen() { - // We choose these options because New Tab is near the top of the menu and Page is near the middle/bottom. - // Intermittently, the menu doesn't scroll to top so we can't just use the first item in the list. - return isMenuOpen(MenuItem.NEW_TAB.getString(mSolo)) || isMenuOpen(MenuItem.PAGE.getString(mSolo)); + return isMenuOpen(MenuItem.NEW_TAB.getString(mSolo)); } private boolean isLegacyMoreMenuOpen() {