From bfa89de4cd45daf22cda8f404317b5307625d267 Mon Sep 17 00:00:00 2001
From: Iiro <iiro.krankka@gmail.com>
Date: Sun, 20 Mar 2016 23:42:19 +0200
Subject: [PATCH] Removed auto hide on tablets.

---
 .../java/com/roughike/bottombar/BottomBar.java     | 40 ++++++++++------------
 bottom-bar/src/main/res/values-sw600dp/bools.xml   |  4 +++
 bottom-bar/src/main/res/values/bools.xml           |  4 +++
 3 files changed, 26 insertions(+), 22 deletions(-)
 create mode 100644 bottom-bar/src/main/res/values-sw600dp/bools.xml
 create mode 100644 bottom-bar/src/main/res/values/bools.xml

diff --git a/bottom-bar/src/main/java/com/roughike/bottombar/BottomBar.java b/bottom-bar/src/main/java/com/roughike/bottombar/BottomBar.java
index d61a01b..47aeda8 100644
--- a/bottom-bar/src/main/java/com/roughike/bottombar/BottomBar.java
+++ b/bottom-bar/src/main/java/com/roughike/bottombar/BottomBar.java
@@ -191,6 +191,24 @@ public static BottomBar attachShy(CoordinatorLayout coordinatorLayout, Bundle sa
         bottomBar.toughChildHood(ViewCompat.getFitsSystemWindows(coordinatorLayout));
         bottomBar.onRestoreInstanceState(savedInstanceState);
 
+        if (!coordinatorLayout.getContext().getResources().getBoolean(R.bool.bb_bottom_bar_is_tablet_mode)) {
+            bottomBar.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
+                @SuppressWarnings("deprecation")
+                @Override
+                public void onGlobalLayout() {
+                    ((CoordinatorLayout.LayoutParams) bottomBar.getLayoutParams())
+                            .setBehavior(new BottomNavigationBehavior(bottomBar.getOuterContainer().getHeight(), 0));
+                    ViewTreeObserver obs = bottomBar.getViewTreeObserver();
+
+                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
+                        obs.removeOnGlobalLayoutListener(this);
+                    } else {
+                        obs.removeGlobalOnLayoutListener(this);
+                    }
+                }
+            });
+        }
+
         coordinatorLayout.addView(bottomBar);
         return bottomBar;
     }
@@ -664,28 +682,6 @@ private void updateItems(BottomBarItemBase[] bottomBarItems) {
             darkThemeMagic();
         }
 
-        if (mIsShy) {
-            if (!mIsTabletMode) {
-                if (!mDrawBehindNavBar && !mIsShiftingMode) {
-                    getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
-                        @SuppressWarnings("deprecation")
-                        @Override
-                        public void onGlobalLayout() {
-                            ((CoordinatorLayout.LayoutParams) getLayoutParams())
-                                    .setBehavior(new BottomNavigationBehavior(getOuterContainer().getHeight(), 0));
-                            ViewTreeObserver obs = getViewTreeObserver();
-
-                            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
-                                obs.removeOnGlobalLayoutListener(this);
-                            } else {
-                                obs.removeGlobalOnLayoutListener(this);
-                            }
-                        }
-                    });
-                }
-            }
-        }
-
         View[] viewsToAdd = new View[bottomBarItems.length];
 
         for (BottomBarItemBase bottomBarItemBase : bottomBarItems) {
diff --git a/bottom-bar/src/main/res/values-sw600dp/bools.xml b/bottom-bar/src/main/res/values-sw600dp/bools.xml
new file mode 100644
index 0000000..9312ba7
--- /dev/null
+++ b/bottom-bar/src/main/res/values-sw600dp/bools.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+    <bool name="bb_bottom_bar_is_tablet_mode">true</bool>
+</resources>
\ No newline at end of file
diff --git a/bottom-bar/src/main/res/values/bools.xml b/bottom-bar/src/main/res/values/bools.xml
new file mode 100644
index 0000000..8b7fb9f
--- /dev/null
+++ b/bottom-bar/src/main/res/values/bools.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+    <bool name="bb_bottom_bar_is_tablet_mode">false</bool>
+</resources>
\ No newline at end of file
