Browse Source

Fixed bug when switching between hiding status bar on/off

master
Anthony Restaino 9 years ago
parent
commit
8f230e3550
  1. 26
      app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java

26
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.ArgbEvaluator;
import android.animation.ValueAnimator; import android.animation.ValueAnimator;
import android.animation.ValueAnimator.AnimatorUpdateListener; import android.animation.ValueAnimator.AnimatorUpdateListener;
import android.annotation.TargetApi;
import android.app.Activity; import android.app.Activity;
import android.content.ClipData; import android.content.ClipData;
import android.content.ClipboardManager; import android.content.ClipboardManager;
@ -58,6 +59,7 @@ import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams; import android.view.ViewGroup.LayoutParams;
import android.view.ViewTreeObserver; import android.view.ViewTreeObserver;
import android.view.Window; import android.view.Window;
import android.view.WindowInsets;
import android.view.WindowManager; import android.view.WindowManager;
import android.view.animation.Animation; import android.view.animation.Animation;
import android.view.animation.DecelerateInterpolator; import android.view.animation.DecelerateInterpolator;
@ -565,13 +567,27 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
changeToolbarBackground(currentView.getFavicon(), null); changeToolbarBackground(currentView.getFavicon(), null);
} }
mToolbarLayout.setTranslationY(0);
// TODO layout transition causing memory leak // TODO layout transition causing memory leak
// mBrowserFrame.setLayoutTransition(new LayoutTransition()); // mBrowserFrame.setLayoutTransition(new LayoutTransition());
initializeTabHeight();
mToolbarLayout.setTranslationY(0);
mBrowserFrame.setTranslationY(0); mBrowserFrame.setTranslationY(0);
setFullscreen(mPreferences.getHideStatusBarEnabled(), false); 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()) { switch (mPreferences.getSearchChoice()) {
case 0: case 0:
mSearchText = mPreferences.getSearchUrl(); mSearchText = mPreferences.getSearchUrl();
@ -1017,7 +1033,6 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
return true; return true;
} }
@Override @Override
public void onConfigurationChanged(final Configuration newConfig) { public void onConfigurationChanged(final Configuration newConfig) {
super.onConfigurationChanged(newConfig); super.onConfigurationChanged(newConfig);
@ -1031,6 +1046,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
} }
initializeTabHeight(); initializeTabHeight();
supportInvalidateOptionsMenu();
doOnLayout(mUiLayout, new Runnable() { doOnLayout(mUiLayout, new Runnable() {
@Override @Override
@ -1839,6 +1855,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
* first. * first.
*/ */
private void initializeTabHeight() { private void initializeTabHeight() {
Log.d(TAG, "initializeTabHeight");
doOnLayout(mUiLayout, new Runnable() { doOnLayout(mUiLayout, new Runnable() {
@Override @Override
public void run() { public void run() {
@ -1875,10 +1892,13 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
* laid out in order to set the correct height. * laid out in order to set the correct height.
*/ */
private void setTabHeight() { private void setTabHeight() {
Log.d(TAG, "setTabHeight");
if (mRoot.getHeight() == 0) { if (mRoot.getHeight() == 0) {
mRoot.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED); mRoot.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
} }
Log.d(TAG, "UI Layout top: " + mUiLayout.getTop());
if (mFullScreen) { if (mFullScreen) {
int height = mRoot.getHeight() - mUiLayout.getTop(); int height = mRoot.getHeight() - mUiLayout.getTop();
mBrowserFrame.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, height)); mBrowserFrame.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, height));

Loading…
Cancel
Save