Bug 1066546 - Part 2 - configure tabs panel to use correct layout for new tablet ui (r=lucasr)
authorMartyn Haigh <martyn.haigh@gmail.com>
Fri, 03 Oct 2014 15:49:19 +0100
changeset 208723 9f9ab384033475ccde26d520bd1c049a767c4ba7
parent 208722 4a1cf6241e5fd1f7d8281a40089225a906aa2b7d
child 208724 cd771a5cdfde6ba37fda34df970040cd9f765feb
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewerslucasr
bugs1066546
milestone35.0a1
Bug 1066546 - Part 2 - configure tabs panel to use correct layout for new tablet ui (r=lucasr)
mobile/android/base/resources/layout-large-land-v11/tabs_panel.xml
mobile/android/base/resources/layout-large-land-v11/tabs_panel_sidebar.xml
mobile/android/base/resources/layout/tabs_panel.xml
mobile/android/base/resources/layout/tabs_panel_default.xml
mobile/android/base/resources/values-large-land-v11/layout.xml
mobile/android/base/resources/values/layout.xml
mobile/android/base/tabs/TabsPanel.java
rename from mobile/android/base/resources/layout-large-land-v11/tabs_panel.xml
rename to mobile/android/base/resources/layout-large-land-v11/tabs_panel_sidebar.xml
rename from mobile/android/base/resources/layout/tabs_panel.xml
rename to mobile/android/base/resources/layout/tabs_panel_default.xml
copy from mobile/android/base/resources/values/layout.xml
copy to mobile/android/base/resources/values-large-land-v11/layout.xml
--- a/mobile/android/base/resources/values/layout.xml
+++ b/mobile/android/base/resources/values-large-land-v11/layout.xml
@@ -1,10 +1,8 @@
 <?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/. -->
 
 <resources>
-    <item type="layout" name="tabs_layout_item_view">@layout/tabs_item_row</item>
-    <item type="layout" name="new_tablet_browser_toolbar">@null</item>
-    <item type="layout" name="new_tablet_tab_strip">@null</item>
+    <item type="layout" name="tabs_panel">@layout/tabs_panel_sidebar</item>
 </resources>
--- a/mobile/android/base/resources/values/layout.xml
+++ b/mobile/android/base/resources/values/layout.xml
@@ -1,10 +1,11 @@
 <?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/. -->
 
 <resources>
+    <item type="layout" name="tabs_panel">@layout/tabs_panel_default</item>
     <item type="layout" name="tabs_layout_item_view">@layout/tabs_item_row</item>
     <item type="layout" name="new_tablet_browser_toolbar">@null</item>
     <item type="layout" name="new_tablet_tab_strip">@null</item>
 </resources>
--- a/mobile/android/base/tabs/TabsPanel.java
+++ b/mobile/android/base/tabs/TabsPanel.java
@@ -114,17 +114,17 @@ public class TabsPanel extends LinearLay
         setOrientation(LinearLayout.VERTICAL);
 
         mCurrentPanel = Panel.NORMAL_TABS;
 
         mPopupMenu = new GeckoPopupMenu(context);
         mPopupMenu.inflate(R.menu.tabs_menu);
         mPopupMenu.setOnMenuItemClickListener(this);
 
-        LayoutInflater.from(context).inflate(R.layout.tabs_panel, this);
+        inflateLayout(context);
         initialize();
 
         mAppStateListener = new AppStateListener() {
             @Override
             public void onResume() {
                 if (mPanel == mPanelRemote) {
                     // Refresh the remote panel.
                     mPanelRemote.show();
@@ -136,16 +136,25 @@ public class TabsPanel extends LinearLay
                 // Remote panel is already refreshed by chrome refresh.
             }
 
             @Override
             public void onPause() {}
         };
     }
 
+
+    private void inflateLayout(Context context) {
+        if (NewTabletUI.isEnabled(context)) {
+            LayoutInflater.from(context).inflate(R.layout.tabs_panel_default, this);
+        } else {
+            LayoutInflater.from(context).inflate(R.layout.tabs_panel, this);
+        }
+    }
+
     private void initialize() {
         mHeader = (RelativeLayout) findViewById(R.id.tabs_panel_header);
         mPanelsContainer = (PanelViewContainer) findViewById(R.id.tabs_container);
 
         mPanelNormal = (PanelView) findViewById(R.id.normal_tabs);
         mPanelNormal.setTabsPanel(this);
 
         mPanelPrivate = (PanelView) findViewById(R.id.private_tabs_panel);