Bug 1216489 - 2. Cleanup width and height calculations in TabsPanel. r?sebastian draft
authorTom Klein <twointofive@gmail.com>
Wed, 30 Nov 2016 17:31:37 -0600
changeset 490545 76ecb8d065958b74f9dc3f9bbf0a77a59b16fc08
parent 490544 9ccedd637fcdfd04a921869ff66410cdaa02f1b6
child 490546 d01e9e8e4cf4123bfec482876e28207d0194d6b1
push id47126
push userbmo:twointofive@gmail.com
push dateTue, 28 Feb 2017 18:21:10 +0000
reviewerssebastian
bugs1216489
milestone54.0a1
Bug 1216489 - 2. Cleanup width and height calculations in TabsPanel. r?sebastian MozReview-Commit-ID: I1chEZDnOyR
mobile/android/base/java/org/mozilla/gecko/tabs/TabsPanel.java
--- a/mobile/android/base/java/org/mozilla/gecko/tabs/TabsPanel.java
+++ b/mobile/android/base/java/org/mozilla/gecko/tabs/TabsPanel.java
@@ -27,16 +27,17 @@ import org.mozilla.gecko.widget.IconTabW
 import android.content.Context;
 import android.content.SharedPreferences;
 import android.content.res.Configuration;
 import android.content.res.Resources;
 import android.support.annotation.UiThread;
 import android.support.v4.content.ContextCompat;
 import android.text.TextUtils;
 import android.util.AttributeSet;
+import android.util.DisplayMetrics;
 import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.Menu;
 import android.view.MenuItem;
 import android.view.View;
 import android.widget.Button;
 import android.widget.FrameLayout;
 import android.widget.ImageButton;
@@ -252,25 +253,16 @@ public class TabsPanel extends LinearLay
 
         if (itemId == R.id.new_tab || itemId == R.id.new_private_tab) {
             hide();
         }
 
         return mActivity.onOptionsItemSelected(item);
     }
 
-    private static int getTabContainerHeight(FrameLayout tabsContainer) {
-        final Resources resources = tabsContainer.getContext().getResources();
-
-        final int screenHeight = resources.getDisplayMetrics().heightPixels;
-        final int actionBarHeight = resources.getDimensionPixelSize(R.dimen.browser_toolbar_height);
-
-        return screenHeight - actionBarHeight;
-    }
-
     @Override
     public void onAttachedToWindow() {
         super.onAttachedToWindow();
         mTheme.addListener(this);
         if (!HardwareUtils.isTablet()) {
             GeckoSharedPrefs.forApp(getContext()).registerOnSharedPreferenceChangeListener(this);
         }
     }
@@ -350,18 +342,18 @@ public class TabsPanel extends LinearLay
         protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
             super.onLayout(changed, left, top, right, bottom);
             onLightweightThemeChanged();
         }
     }
 
     public void show(Panel panelToShow) {
         prepareToShow(panelToShow);
-        int height = getVerticalPanelHeight();
-        dispatchLayoutChange(getWidth(), height);
+        final DisplayMetrics metrics = mContext.getResources().getDisplayMetrics();
+        dispatchLayoutChange(metrics.widthPixels, metrics.heightPixels);
         mHeaderVisible = true;
     }
 
     public void prepareToShow(Panel panelToShow) {
         if (!isShown()) {
             setVisibility(View.VISIBLE);
         }
 
@@ -398,22 +390,16 @@ public class TabsPanel extends LinearLay
         ThreadUtils.postToUiThread(new Runnable() {
             @Override
             public void run() {
                 mPopupMenu.setAnchor(mMenuButton);
             }
         });
     }
 
-    public int getVerticalPanelHeight() {
-        final int actionBarHeight = mContext.getResources().getDimensionPixelSize(R.dimen.browser_toolbar_height);
-        final int height = actionBarHeight + getTabContainerHeight(mTabsContainer);
-        return height;
-    }
-
     public void hide() {
         mHeaderVisible = false;
 
         if (mVisible) {
             mVisible = false;
             mPopupMenu.dismiss();
             dispatchLayoutChange(0, 0);
         }