Revert "Fix navbar window fitting on Android. (#235)"

This reverts commit 0927e03687.
This commit is contained in:
Krzysztof Magiera
2019-11-27 22:17:52 +01:00
parent cbc86bb6d8
commit 4f8efd2873
3 changed files with 3 additions and 35 deletions

View File

@@ -1,10 +1,7 @@
package com.swmansion.rnscreens;
import android.content.Context;
import android.view.View;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
@@ -45,15 +42,6 @@ public class ScreenStack extends ScreenContainer<ScreenStackFragment> {
public ScreenStack(Context context) {
super(context);
ViewCompat.setOnApplyWindowInsetsListener(this,
new androidx.core.view.OnApplyWindowInsetsListener() {
@Override
public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) {
setWindowInsets(insets);
return insets;
}
});
}
public void dismiss(ScreenStackFragment screenFragment) {
@@ -75,24 +63,6 @@ public class ScreenStack extends ScreenContainer<ScreenStackFragment> {
throw new IllegalStateException("Stack has no root screen set");
}
private void setWindowInsets(WindowInsetsCompat insets) {
// we allow each screen to handle insets separately as they are all attached to the same parent
// and take up full screen. Therefore we make a copy of each inset object before passing it down
// to views.
boolean consumed = false;
for (int i = mScreenFragments.size() - 1; i >= 0; i--) {
ScreenStackFragment screen = mScreenFragments.get(i);
if (!mDismissed.contains(screen) && screen.getView() != null) {
if (ViewCompat.dispatchApplyWindowInsets(screen.getView(), new WindowInsetsCompat(insets)).isConsumed()) {
consumed = true;
}
}
}
if (consumed) {
insets.consumeSystemWindowInsets();
}
}
@Override
protected ScreenStackFragment adapt(Screen screen) {
return new ScreenStackFragment(screen);
@@ -111,6 +81,7 @@ public class ScreenStack extends ScreenContainer<ScreenStackFragment> {
// longer attached.
fm.popBackStack(BACK_STACK_TAG, FragmentManager.POP_BACK_STACK_INCLUSIVE);
}
}
@Override

View File

@@ -64,22 +64,20 @@ public class ScreenStackFragment extends ScreenFragment {
@Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
CoordinatorLayout view = new CoordinatorLayout(getContext());
view.setFitsSystemWindows(true);
CoordinatorLayout.LayoutParams params = new CoordinatorLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
params.setBehavior(new AppBarLayout.ScrollingViewBehavior());
mScreenView.setLayoutParams(params);
view.addView(mScreenView);
mAppBarLayout = new AppBarLayout(getContext());
mAppBarLayout.setFitsSystemWindows(true);
// By default AppBarLayout will have a background color set but since we cover the whole layout
// with toolbar (that can be semi-transparent) the bar layout background color does not pay a
// role. On top of that it breaks screens animations when alfa offscreen compositing is off
// (which is the default)
mAppBarLayout.setBackgroundColor(Color.TRANSPARENT);
mAppBarLayout.setLayoutParams(new AppBarLayout.LayoutParams(
AppBarLayout.LayoutParams.MATCH_PARENT,
AppBarLayout.LayoutParams.WRAP_CONTENT));
AppBarLayout.LayoutParams.MATCH_PARENT, AppBarLayout.LayoutParams.WRAP_CONTENT));
view.addView(mAppBarLayout);
if (mToolbar != null) {

View File

@@ -47,7 +47,6 @@ public class ScreenStackHeaderConfig extends ViewGroup {
setVisibility(View.GONE);
mToolbar = new Toolbar(context);
mToolbar.setFitsSystemWindows(true);
// set primary color as background by default
TypedValue tv = new TypedValue();