From 8f230e35501f8ad3df30c84759066e8f84963e1a Mon Sep 17 00:00:00 2001 From: Anthony Restaino Date: Wed, 16 Mar 2016 20:57:12 -0400 Subject: [PATCH] Fixed bug when switching between hiding status bar on/off --- .../lightning/activity/BrowserActivity.java | 26 ++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java b/app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java index c437a92..a13cf7e 100644 --- a/app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java +++ b/app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java @@ -7,6 +7,7 @@ package acr.browser.lightning.activity; import android.animation.ArgbEvaluator; import android.animation.ValueAnimator; import android.animation.ValueAnimator.AnimatorUpdateListener; +import android.annotation.TargetApi; import android.app.Activity; import android.content.ClipData; import android.content.ClipboardManager; @@ -58,6 +59,7 @@ import android.view.ViewGroup; import android.view.ViewGroup.LayoutParams; import android.view.ViewTreeObserver; import android.view.Window; +import android.view.WindowInsets; import android.view.WindowManager; import android.view.animation.Animation; import android.view.animation.DecelerateInterpolator; @@ -565,13 +567,27 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements changeToolbarBackground(currentView.getFavicon(), null); } - mToolbarLayout.setTranslationY(0); + // TODO layout transition causing memory leak // mBrowserFrame.setLayoutTransition(new LayoutTransition()); - initializeTabHeight(); + + mToolbarLayout.setTranslationY(0); mBrowserFrame.setTranslationY(0); setFullscreen(mPreferences.getHideStatusBarEnabled(), false); + initializeTabHeight(); + + if(Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT_WATCH) { + mRoot.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() { + @TargetApi(Build.VERSION_CODES.KITKAT_WATCH) + @Override + public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) { + initializeTabHeight(); + return mRoot.onApplyWindowInsets(insets); + } + }); + } + switch (mPreferences.getSearchChoice()) { case 0: mSearchText = mPreferences.getSearchUrl(); @@ -1017,7 +1033,6 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements return true; } - @Override public void onConfigurationChanged(final Configuration newConfig) { super.onConfigurationChanged(newConfig); @@ -1031,6 +1046,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements } initializeTabHeight(); + supportInvalidateOptionsMenu(); doOnLayout(mUiLayout, new Runnable() { @Override @@ -1839,6 +1855,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements * first. */ private void initializeTabHeight() { + Log.d(TAG, "initializeTabHeight"); doOnLayout(mUiLayout, new Runnable() { @Override public void run() { @@ -1875,10 +1892,13 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements * laid out in order to set the correct height. */ private void setTabHeight() { + Log.d(TAG, "setTabHeight"); if (mRoot.getHeight() == 0) { mRoot.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED); } + Log.d(TAG, "UI Layout top: " + mUiLayout.getTop()); + if (mFullScreen) { int height = mRoot.getHeight() - mUiLayout.getTop(); mBrowserFrame.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, height));