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

The following examples show how to use android.view.WindowInsets#getSystemWindowInsetBottom() . 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: PixelWatchFace.java    From PixelWatchFace with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onApplyWindowInsets(WindowInsets insets) {
  super.onApplyWindowInsets(insets);
  Log.d("onApplyWindowInsets",
      "onApplyWindowInsets: " + (insets.isRound() ? "round" : "square"));

  // Load resources that have alternate values for round watches.
  Resources resources = PixelWatchFace.this.getResources();
  mIsRound = insets.isRound();
  mChinSize = insets.getSystemWindowInsetBottom();

  float timeTextSize = resources.getDimension(mIsRound
      ? R.dimen.digital_time_text_size_round : R.dimen.digital_time_text_size);
  float dateTextSize = resources.getDimension(mIsRound
      ? R.dimen.digital_date_text_size_round : R.dimen.digital_date_text_size);

  mTimePaint.setTextSize(timeTextSize);
  mInfoPaint.setTextSize(dateTextSize);


}
 
Example 2
Source File: DrawerLayoutContainer.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void onDraw(Canvas canvas) {
    if (Build.VERSION.SDK_INT >= 21 && lastInsets != null) {
        WindowInsets insets = (WindowInsets) lastInsets;

        if (!SharedConfig.smoothKeyboard) {
            int bottomInset = insets.getSystemWindowInsetBottom();
            if (bottomInset > 0) {
                backgroundPaint.setColor(behindKeyboardColor);
                canvas.drawRect(0, getMeasuredHeight() - bottomInset, getMeasuredWidth(), getMeasuredHeight(), backgroundPaint);
            }
        }

        if (hasCutout) {
            backgroundPaint.setColor(0xff000000);
            int left = insets.getSystemWindowInsetLeft();
            if (left != 0) {
                canvas.drawRect(0, 0, left, getMeasuredHeight(), backgroundPaint);
            }
            int right = insets.getSystemWindowInsetRight();
            if (right != 0) {
                canvas.drawRect(right, 0, getMeasuredWidth(), getMeasuredHeight(), backgroundPaint);
            }
        }
    }
}
 
Example 3
Source File: DrawerLayoutContainer.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void onDraw(Canvas canvas) {
    if (Build.VERSION.SDK_INT >= 21 && lastInsets != null) {
        WindowInsets insets = (WindowInsets) lastInsets;

        if (!SharedConfig.smoothKeyboard) {
            int bottomInset = insets.getSystemWindowInsetBottom();
            if (bottomInset > 0) {
                backgroundPaint.setColor(behindKeyboardColor);
                canvas.drawRect(0, getMeasuredHeight() - bottomInset, getMeasuredWidth(), getMeasuredHeight(), backgroundPaint);
            }
        }

        if (hasCutout) {
            backgroundPaint.setColor(0xff000000);
            int left = insets.getSystemWindowInsetLeft();
            if (left != 0) {
                canvas.drawRect(0, 0, left, getMeasuredHeight(), backgroundPaint);
            }
            int right = insets.getSystemWindowInsetRight();
            if (right != 0) {
                canvas.drawRect(right, 0, getMeasuredWidth(), getMeasuredHeight(), backgroundPaint);
            }
        }
    }
}
 
Example 4
Source File: InsetsDispatcherHelper.java    From insets-dispatcher with Apache License 2.0 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.KITKAT_WATCH)
public WindowInsets onApplyWindowInsets(@Nullable WindowInsets insets) {
    if (insets != null) {
        mInsets = new Rect(insets.getSystemWindowInsetLeft(), insets.getSystemWindowInsetTop(),
                insets.getSystemWindowInsetRight(), insets.getSystemWindowInsetBottom());
    }

    for (int i = 0; i < mView.getChildCount(); i++) {
        final View child = mView.getChildAt(i);

        if (!(child instanceof InsetsDispatchReceiver)) {
            InsetsDispatcherLayoutParamsHelper helper = ((InsetsDispatcherLayoutParams) child.getLayoutParams()).getHelper();
            if (helper != null) {
                applyInsets(mInsets, child, helper.useLeftInset, helper.useTopInset, helper.useRightInset, helper.useBottomInset, helper.insetsUseMargin);
            } else {
                applyInsets(mInsets, child, false, false, false, false, false);
            }
        }
    }

    applyInsets(mInsets, mView, mUseLeftInset, mUseTopInset, mUseRightInset, mUseBottomInset, mInsetsUseMargin);

    ViewCompat.postInvalidateOnAnimation(mView);

    return insets;
}
 
Example 5
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 6
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 7
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 8
Source File: InsetsFrameLayout.java    From Moment with GNU General Public License v3.0 5 votes vote down vote up
@Override
public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
    int b = insets.getSystemWindowInsetBottom();
    int r = insets.getSystemWindowInsetRight();

    pictureInfoLayout.setPadding(
            pictureInfoLayout.getPaddingLeft(),
            pictureInfoLayout.getPaddingTop(),
            pictureInfoLayout.getPaddingRight() + r,
            pictureInfoLayout.getPaddingBottom() + b);

    setOnApplyWindowInsetsListener(null);

    return insets.consumeSystemWindowInsets();
}
 
Example 9
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 10
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 11
Source File: NavigationView.java    From openlauncher 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 inset = insets.getSystemWindowInsetBottom();
        if (inset != 0) {
            ViewGroup.LayoutParams layoutParams = getLayoutParams();
            layoutParams.height = inset;
            setLayoutParams(layoutParams);
            setVisibility(VISIBLE);
        }
    }
    return insets;
}
 
Example 12
Source File: SearchBar.java    From openlauncher 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) {
        bottomInset = insets.getSystemWindowInsetBottom();
        setPadding(0, insets.getSystemWindowInsetTop(), 0, 0);
        return insets;
    }
    return insets;
}
 
Example 13
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 14
Source File: FitsSystemWindowRelativeLayout.java    From ExoMedia with Apache License 2.0 5 votes vote down vote up
@Override
@TargetApi(Build.VERSION_CODES.KITKAT_WATCH)
public WindowInsets onApplyWindowInsets(WindowInsets insets) {
    Rect windowInsets = new Rect(
            insets.getSystemWindowInsetLeft(),
            insets.getSystemWindowInsetTop(),
            insets.getSystemWindowInsetRight(),
            insets.getSystemWindowInsetBottom()
    );

    fitSystemWindows(windowInsets);
    return insets;
}
 
Example 15
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 16
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 17
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 18
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 19
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 20
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();
}