Java Code Examples for android.view.WindowInsets#replaceSystemWindowInsets()

The following examples show how to use android.view.WindowInsets#replaceSystemWindowInsets() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DrawerLayoutContainer.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@SuppressLint("NewApi")
private void applyMarginInsets(MarginLayoutParams lp, Object insets, int drawerGravity, boolean topOnly)
{
    WindowInsets wi = (WindowInsets) insets;
    if (drawerGravity == Gravity.LEFT)
    {
        wi = wi.replaceSystemWindowInsets(wi.getSystemWindowInsetLeft(), wi.getSystemWindowInsetTop(), 0, wi.getSystemWindowInsetBottom());
    }
    else if (drawerGravity == Gravity.RIGHT)
    {
        wi = wi.replaceSystemWindowInsets(0, wi.getSystemWindowInsetTop(), wi.getSystemWindowInsetRight(), wi.getSystemWindowInsetBottom());
    }
    lp.leftMargin = wi.getSystemWindowInsetLeft();
    lp.topMargin = topOnly ? 0 : wi.getSystemWindowInsetTop();
    lp.rightMargin = wi.getSystemWindowInsetRight();
    lp.bottomMargin = wi.getSystemWindowInsetBottom();
}
 
Example 2
Source File: DrawerLayoutContainer.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@SuppressLint("NewApi")
private void applyMarginInsets(MarginLayoutParams lp, Object insets, int drawerGravity, boolean topOnly)
{
    WindowInsets wi = (WindowInsets) insets;
    if (drawerGravity == Gravity.LEFT)
    {
        wi = wi.replaceSystemWindowInsets(wi.getSystemWindowInsetLeft(), wi.getSystemWindowInsetTop(), 0, wi.getSystemWindowInsetBottom());
    }
    else if (drawerGravity == Gravity.RIGHT)
    {
        wi = wi.replaceSystemWindowInsets(0, wi.getSystemWindowInsetTop(), wi.getSystemWindowInsetRight(), wi.getSystemWindowInsetBottom());
    }
    lp.leftMargin = wi.getSystemWindowInsetLeft();
    lp.topMargin = topOnly ? 0 : wi.getSystemWindowInsetTop();
    lp.rightMargin = wi.getSystemWindowInsetRight();
    lp.bottomMargin = wi.getSystemWindowInsetBottom();
}
 
Example 3
Source File: HostLayout.java    From Sofia with Apache License 2.0 6 votes vote down vote up
@Override
public final WindowInsets onApplyWindowInsets(WindowInsets insets) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        int paddingSize = insets.getSystemWindowInsetBottom();
        int barSize = mNavigationView.getDefaultBarSize();
        paddingSize = paddingSize == barSize ? 0 : paddingSize;
        mContentLayout.setPaddingRelative(0, 0, 0, paddingSize);
        RelativeLayout.LayoutParams layoutParams = (LayoutParams) mContentLayout.getLayoutParams();
        if (paddingSize > 0 && !mNavigationView.isLandscape()) {
            layoutParams.bottomMargin = -barSize;
        } else {
            layoutParams.bottomMargin = 0;
        }
        return super.onApplyWindowInsets(insets.replaceSystemWindowInsets(0, 0, 0, 0));
    } else {
        return insets;
    }
}
 
Example 4
Source File: DrawerLayoutCompatApi21.java    From u2020 with Apache License 2.0 5 votes vote down vote up
public static void applyMarginInsets(ViewGroup.MarginLayoutParams lp, Object insets,
    int gravity) {
  WindowInsets wi = (WindowInsets) insets;
  if (gravity == Gravity.LEFT) {
    wi = wi.replaceSystemWindowInsets(wi.getSystemWindowInsetLeft(),
        wi.getSystemWindowInsetTop(), 0, wi.getSystemWindowInsetBottom());
  } else if (gravity == Gravity.RIGHT) {
    wi = wi.replaceSystemWindowInsets(0, wi.getSystemWindowInsetTop(),
        wi.getSystemWindowInsetRight(), wi.getSystemWindowInsetBottom());
  }
  lp.leftMargin = wi.getSystemWindowInsetLeft();
  lp.topMargin = wi.getSystemWindowInsetTop();
  lp.rightMargin = wi.getSystemWindowInsetRight();
  lp.bottomMargin = wi.getSystemWindowInsetBottom();
}
 
Example 5
Source File: DrawerLayoutContainer.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@SuppressLint("NewApi")
private void applyMarginInsets(MarginLayoutParams lp, Object insets, int drawerGravity, boolean topOnly) {
    WindowInsets wi = (WindowInsets) insets;
    if (drawerGravity == Gravity.LEFT) {
        wi = wi.replaceSystemWindowInsets(wi.getSystemWindowInsetLeft(), wi.getSystemWindowInsetTop(), 0, wi.getSystemWindowInsetBottom());
    } else if (drawerGravity == Gravity.RIGHT) {
        wi = wi.replaceSystemWindowInsets(0, wi.getSystemWindowInsetTop(), wi.getSystemWindowInsetRight(), wi.getSystemWindowInsetBottom());
    }
    lp.leftMargin = wi.getSystemWindowInsetLeft();
    lp.topMargin = topOnly ? 0 : wi.getSystemWindowInsetTop();
    lp.rightMargin = wi.getSystemWindowInsetRight();
    lp.bottomMargin = wi.getSystemWindowInsetBottom();
}
 
Example 6
Source File: DrawerLayoutCompatApi21.java    From u2020 with Apache License 2.0 5 votes vote down vote up
public static void dispatchChildInsets(View child, Object insets, int gravity) {
  WindowInsets wi = (WindowInsets) insets;
  if (gravity == Gravity.LEFT) {
    wi = wi.replaceSystemWindowInsets(wi.getSystemWindowInsetLeft(),
        wi.getSystemWindowInsetTop(), 0, wi.getSystemWindowInsetBottom());
  } else if (gravity == Gravity.RIGHT) {
    wi = wi.replaceSystemWindowInsets(0, wi.getSystemWindowInsetTop(),
        wi.getSystemWindowInsetRight(), wi.getSystemWindowInsetBottom());
  }
  child.dispatchApplyWindowInsets(wi);
}
 
Example 7
Source File: DrawerLayoutContainer.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@SuppressLint("NewApi")
private void applyMarginInsets(MarginLayoutParams lp, Object insets, int drawerGravity, boolean topOnly) {
    WindowInsets wi = (WindowInsets) insets;
    if (drawerGravity == Gravity.LEFT) {
        wi = wi.replaceSystemWindowInsets(wi.getSystemWindowInsetLeft(), wi.getSystemWindowInsetTop(), 0, wi.getSystemWindowInsetBottom());
    } else if (drawerGravity == Gravity.RIGHT) {
        wi = wi.replaceSystemWindowInsets(0, wi.getSystemWindowInsetTop(), wi.getSystemWindowInsetRight(), wi.getSystemWindowInsetBottom());
    }
    lp.leftMargin = wi.getSystemWindowInsetLeft();
    lp.topMargin = topOnly ? 0 : wi.getSystemWindowInsetTop();
    lp.rightMargin = wi.getSystemWindowInsetRight();
    lp.bottomMargin = wi.getSystemWindowInsetBottom();
}
 
Example 8
Source File: DrawerLayoutContainer.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@SuppressLint("NewApi")
private void dispatchChildInsets(View child, Object insets, int drawerGravity) {
    WindowInsets wi = (WindowInsets) insets;
    if (drawerGravity == Gravity.LEFT) {
        wi = wi.replaceSystemWindowInsets(wi.getSystemWindowInsetLeft(), wi.getSystemWindowInsetTop(), 0, wi.getSystemWindowInsetBottom());
    } else if (drawerGravity == Gravity.RIGHT) {
        wi = wi.replaceSystemWindowInsets(0, wi.getSystemWindowInsetTop(), wi.getSystemWindowInsetRight(), wi.getSystemWindowInsetBottom());
    }
    child.dispatchApplyWindowInsets(wi);
}
 
Example 9
Source File: DrawerLayoutCompatApi21.java    From debugdrawer with Apache License 2.0 5 votes vote down vote up
public static void applyMarginInsets(ViewGroup.MarginLayoutParams lp, Object insets,
                                     int gravity) {
	WindowInsets wi = (WindowInsets) insets;
	if (gravity == Gravity.LEFT) {
		wi = wi.replaceSystemWindowInsets(wi.getSystemWindowInsetLeft(),
				wi.getSystemWindowInsetTop(), 0, wi.getSystemWindowInsetBottom());
	} else if (gravity == Gravity.RIGHT) {
		wi = wi.replaceSystemWindowInsets(0, wi.getSystemWindowInsetTop(),
				wi.getSystemWindowInsetRight(), wi.getSystemWindowInsetBottom());
	}
	lp.leftMargin = wi.getSystemWindowInsetLeft();
	lp.topMargin = wi.getSystemWindowInsetTop();
	lp.rightMargin = wi.getSystemWindowInsetRight();
	lp.bottomMargin = wi.getSystemWindowInsetBottom();
}
 
Example 10
Source File: DrawerLayoutCompatApi21.java    From debugdrawer with Apache License 2.0 5 votes vote down vote up
public static void dispatchChildInsets(View child, Object insets, int gravity) {
	WindowInsets wi = (WindowInsets) insets;
	if (gravity == Gravity.LEFT) {
		wi = wi.replaceSystemWindowInsets(wi.getSystemWindowInsetLeft(),
				wi.getSystemWindowInsetTop(), 0, wi.getSystemWindowInsetBottom());
	} else if (gravity == Gravity.RIGHT) {
		wi = wi.replaceSystemWindowInsets(0, wi.getSystemWindowInsetTop(),
				wi.getSystemWindowInsetRight(), wi.getSystemWindowInsetBottom());
	}
	child.dispatchApplyWindowInsets(wi);
}
 
Example 11
Source File: DrawerLayoutCompatApi21.java    From adt-leanback-support with Apache License 2.0 5 votes vote down vote up
public static void applyMarginInsets(ViewGroup.MarginLayoutParams lp, Object insets,
        int gravity) {
    WindowInsets wi = (WindowInsets) insets;
    if (gravity == Gravity.LEFT) {
        wi = wi.replaceSystemWindowInsets(wi.getSystemWindowInsetLeft(),
                wi.getSystemWindowInsetTop(), 0, wi.getSystemWindowInsetBottom());
    } else if (gravity == Gravity.RIGHT) {
        wi = wi.replaceSystemWindowInsets(0, wi.getSystemWindowInsetTop(),
                wi.getSystemWindowInsetRight(), wi.getSystemWindowInsetBottom());
    }
    lp.leftMargin = wi.getSystemWindowInsetLeft();
    lp.topMargin = wi.getSystemWindowInsetTop();
    lp.rightMargin = wi.getSystemWindowInsetRight();
    lp.bottomMargin = wi.getSystemWindowInsetBottom();
}
 
Example 12
Source File: DrawerLayoutCompatApi21.java    From adt-leanback-support with Apache License 2.0 5 votes vote down vote up
public static void dispatchChildInsets(View child, Object insets, int gravity) {
    WindowInsets wi = (WindowInsets) insets;
    if (gravity == Gravity.LEFT) {
        wi = wi.replaceSystemWindowInsets(wi.getSystemWindowInsetLeft(),
                wi.getSystemWindowInsetTop(), 0, wi.getSystemWindowInsetBottom());
    } else if (gravity == Gravity.RIGHT) {
        wi = wi.replaceSystemWindowInsets(0, wi.getSystemWindowInsetTop(),
                wi.getSystemWindowInsetRight(), wi.getSystemWindowInsetBottom());
    }
    child.dispatchApplyWindowInsets(wi);
}
 
Example 13
Source File: DrawerLayout.java    From Dashchan with Apache License 2.0 5 votes vote down vote up
@Override
public void applyMarginInsets(MarginLayoutParams lp, Object insets, int drawerGravity) {
	WindowInsets wi = (WindowInsets) insets;
	if (drawerGravity == Gravity.LEFT) {
		wi = wi.replaceSystemWindowInsets(wi.getSystemWindowInsetLeft(),
				wi.getSystemWindowInsetTop(), 0, wi.getSystemWindowInsetBottom());
	} else if (drawerGravity == Gravity.RIGHT) {
		wi = wi.replaceSystemWindowInsets(0, wi.getSystemWindowInsetTop(),
				wi.getSystemWindowInsetRight(), wi.getSystemWindowInsetBottom());
	}
	lp.leftMargin = wi.getSystemWindowInsetLeft();
	lp.topMargin = wi.getSystemWindowInsetTop();
	lp.rightMargin = wi.getSystemWindowInsetRight();
	lp.bottomMargin = wi.getSystemWindowInsetBottom();
}
 
Example 14
Source File: DrawerLayout.java    From Dashchan with Apache License 2.0 5 votes vote down vote up
@Override
public void dispatchChildInsets(View child, Object insets, int drawerGravity) {
	WindowInsets wi = (WindowInsets) insets;
	if (drawerGravity == Gravity.LEFT) {
		wi = wi.replaceSystemWindowInsets(wi.getSystemWindowInsetLeft(),
				wi.getSystemWindowInsetTop(), 0, wi.getSystemWindowInsetBottom());
	} else if (drawerGravity == Gravity.RIGHT) {
		wi = wi.replaceSystemWindowInsets(0, wi.getSystemWindowInsetTop(),
				wi.getSystemWindowInsetRight(), wi.getSystemWindowInsetBottom());
	}
	child.dispatchApplyWindowInsets(wi);
}
 
Example 15
Source File: DrawerLayoutCompatApi21.java    From 920-text-editor-v2 with Apache License 2.0 5 votes vote down vote up
public static void applyMarginInsets(ViewGroup.MarginLayoutParams lp, Object insets,
        int gravity) {
    WindowInsets wi = (WindowInsets) insets;
    if (gravity == Gravity.LEFT) {
        wi = wi.replaceSystemWindowInsets(wi.getSystemWindowInsetLeft(),
                wi.getSystemWindowInsetTop(), 0, wi.getSystemWindowInsetBottom());
    } else if (gravity == Gravity.RIGHT) {
        wi = wi.replaceSystemWindowInsets(0, wi.getSystemWindowInsetTop(),
                wi.getSystemWindowInsetRight(), wi.getSystemWindowInsetBottom());
    }
    lp.leftMargin = wi.getSystemWindowInsetLeft();
    lp.topMargin = wi.getSystemWindowInsetTop();
    lp.rightMargin = wi.getSystemWindowInsetRight();
    lp.bottomMargin = wi.getSystemWindowInsetBottom();
}
 
Example 16
Source File: DrawerLayoutCompatApi21.java    From 920-text-editor-v2 with Apache License 2.0 5 votes vote down vote up
public static void dispatchChildInsets(View child, Object insets, int gravity) {
    WindowInsets wi = (WindowInsets) insets;
    if (gravity == Gravity.LEFT) {
        wi = wi.replaceSystemWindowInsets(wi.getSystemWindowInsetLeft(),
                wi.getSystemWindowInsetTop(), 0, wi.getSystemWindowInsetBottom());
    } else if (gravity == Gravity.RIGHT) {
        wi = wi.replaceSystemWindowInsets(0, wi.getSystemWindowInsetTop(),
                wi.getSystemWindowInsetRight(), wi.getSystemWindowInsetBottom());
    }
    child.dispatchApplyWindowInsets(wi);
}
 
Example 17
Source File: InsetConstraintLayout.java    From intra42 with Apache License 2.0 5 votes vote down vote up
@Override

    public WindowInsets onApplyWindowInsets(WindowInsets insets) {

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
            int insetBottom = insets.getSystemWindowInsetBottom();

            insets = insets.replaceSystemWindowInsets(insets.getSystemWindowInsetLeft(), insets.getSystemWindowInsetTop(), insets.getSystemWindowInsetRight(), 0);

            WindowInsets used = super.onApplyWindowInsets(insets);
            return insets.replaceSystemWindowInsets(used.getSystemWindowInsetLeft(), used.getSystemWindowInsetTop(), used.getSystemWindowInsetRight(), insetBottom);
        }
        return super.onApplyWindowInsets(insets);
    }
 
Example 18
Source File: InsetLinearLayout.java    From intra42 with Apache License 2.0 5 votes vote down vote up
@Override

    public WindowInsets onApplyWindowInsets(WindowInsets insets) {

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
            int insetBottom = insets.getSystemWindowInsetBottom();

            insets = insets.replaceSystemWindowInsets(insets.getSystemWindowInsetLeft(), insets.getSystemWindowInsetTop(), insets.getSystemWindowInsetRight(), 0);

            WindowInsets used = super.onApplyWindowInsets(insets);
            return insets.replaceSystemWindowInsets(used.getSystemWindowInsetLeft(), used.getSystemWindowInsetTop(), used.getSystemWindowInsetRight(), insetBottom);
        }
        return super.onApplyWindowInsets(insets);
    }
 
Example 19
Source File: DrawerLayoutContainer.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@SuppressLint("NewApi")
private void dispatchChildInsets(View child, Object insets, int drawerGravity)
{
    WindowInsets wi = (WindowInsets) insets;
    if (drawerGravity == Gravity.LEFT)
    {
        wi = wi.replaceSystemWindowInsets(wi.getSystemWindowInsetLeft(), wi.getSystemWindowInsetTop(), 0, wi.getSystemWindowInsetBottom());
    }
    else if (drawerGravity == Gravity.RIGHT)
    {
        wi = wi.replaceSystemWindowInsets(0, wi.getSystemWindowInsetTop(), wi.getSystemWindowInsetRight(), wi.getSystemWindowInsetBottom());
    }
    child.dispatchApplyWindowInsets(wi);
}
 
Example 20
Source File: NoInsertLinearLayout.java    From Socket.io-FLSocketIM-Android with MIT License 5 votes vote down vote up
@Override
public WindowInsets onApplyWindowInsets(WindowInsets insets) {

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {

        mInsets[0] = insets.getSystemWindowInsetLeft();
        mInsets[1] = insets.getSystemWindowInsetTop();
        mInsets[2] = insets.getSystemWindowInsetRight();

        return super.onApplyWindowInsets(insets.replaceSystemWindowInsets(0, 0, 0, insets.getSystemWindowInsetBottom()));
    }
    else {
        return super.onApplyWindowInsets(insets);
    }
}