blob: 1c6ca871340e83c4b26b66c3c2d17a0fd88a4216 [file] [log] [blame]
Adam Cohena6d04922014-10-23 17:28:30 -07001package com.android.launcher3;
2
3import android.content.Context;
Sunny Goyal0abb36f2015-06-23 10:53:59 -07004import android.graphics.Canvas;
5import android.graphics.Color;
6import android.graphics.Paint;
Adam Cohena6d04922014-10-23 17:28:30 -07007import android.graphics.Rect;
8import android.util.AttributeSet;
9
10public class LauncherRootView extends InsettableFrameLayout {
Sunny Goyal0abb36f2015-06-23 10:53:59 -070011
12 private final Paint mOpaquePaint;
13 private boolean mDrawRightInsetBar;
14
Adam Cohena6d04922014-10-23 17:28:30 -070015 public LauncherRootView(Context context, AttributeSet attrs) {
16 super(context, attrs);
Sunny Goyal0abb36f2015-06-23 10:53:59 -070017
18 mOpaquePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
19 mOpaquePaint.setColor(Color.BLACK);
20 mOpaquePaint.setStyle(Paint.Style.FILL);
Adam Cohena6d04922014-10-23 17:28:30 -070021 }
22
23 @Override
24 protected boolean fitSystemWindows(Rect insets) {
25 setInsets(insets);
Sunny Goyal0abb36f2015-06-23 10:53:59 -070026 mDrawRightInsetBar = mInsets.right > 0 && LauncherAppState
27 .getInstance().getInvariantDeviceProfile().isRightInsetOpaque;
28
Adam Cohena6d04922014-10-23 17:28:30 -070029 return true; // I'll take it from here
30 }
Sunny Goyal0abb36f2015-06-23 10:53:59 -070031
32 @Override
33 protected void dispatchDraw(Canvas canvas) {
34 super.dispatchDraw(canvas);
35
36 // If the right inset is opaque, draw a black rectangle to ensure that is stays opaque.
37 if (mDrawRightInsetBar) {
38 int width = getWidth();
39 canvas.drawRect(width - mInsets.right, 0, width, getHeight(), mOpaquePaint);
40 }
41 }
Adam Cohena6d04922014-10-23 17:28:30 -070042}