public StatusBarBackgroundLayout(Context context) { super(context); init(context, null, 0); }
public void setStatusBarBackground(Drawable background) { mStatusBarBackground = background; if (Build.VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) { setWillNotDraw(background == null); setFitsSystemWindows(background != null); invalidate(); } }
private void init(Context context, AttributeSet attrs, int defStyleAttr) { final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SuwStatusBarBackgroundLayout, defStyleAttr, 0); final Drawable statusBarBackground = a.getDrawable(R.styleable.SuwStatusBarBackgroundLayout_suwStatusBarBackground); setStatusBarBackground(statusBarBackground); a.recycle(); }
@Override protected void onAttachedToWindow() { super.onAttachedToWindow(); if (Build.VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) { if (mLastInsets == null) { requestApplyInsets(); } } }
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (Build.VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) { if (mLastInsets != null) { final int insetTop = ((WindowInsets) mLastInsets).getSystemWindowInsetTop(); if (insetTop > 0) { mStatusBarBackground.setBounds(0, 0, getWidth(), insetTop); mStatusBarBackground.draw(canvas); } } } }
private void setGlifPatternColor(ColorStateList color) { if (Build.VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) { setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); final View patternBg = findManagedViewById(R.id.suw_pattern_bg); if (patternBg != null) { final GlifPatternDrawable background = new GlifPatternDrawable(color.getDefaultColor()); if (patternBg instanceof StatusBarBackgroundLayout) { ((StatusBarBackgroundLayout) patternBg).setStatusBarBackground(background); } else { patternBg.setBackground(background); } } } }
public StatusBarBackgroundLayout(Context context, AttributeSet attrs) { super(context, attrs); init(context, attrs, 0); }
@TargetApi(VERSION_CODES.HONEYCOMB) public StatusBarBackgroundLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(context, attrs, defStyleAttr); }