use of android.graphics.Outline in project android_frameworks_base by DirtyUnicorns.
the class ViewGroup_Delegate method drawChild.
/**
* Overrides the original drawChild call in ViewGroup to draw the shadow.
*/
@LayoutlibDelegate
static /*package*/
boolean drawChild(ViewGroup thisVG, Canvas canvas, View child, long drawingTime) {
if (child.getZ() > thisVG.getZ()) {
// The background's bounds are set lazily. Make sure they are set correctly so that
// the outline obtained is correct.
child.setBackgroundBounds();
ViewOutlineProvider outlineProvider = child.getOutlineProvider();
if (outlineProvider != null) {
Outline outline = child.mAttachInfo.mTmpOutline;
outlineProvider.getOutline(child, outline);
if (outline.mPath != null || (outline.mRect != null && !outline.mRect.isEmpty())) {
int restoreTo = transformCanvas(thisVG, canvas, child);
drawShadow(thisVG, canvas, child, outline);
canvas.restoreToCount(restoreTo);
}
}
}
return thisVG.drawChild_Original(canvas, child, drawingTime);
}
use of android.graphics.Outline in project android_frameworks_base by DirtyUnicorns.
the class TaskView method onFinishInflate.
@Override
protected void onFinishInflate() {
// Bind the views
mHeaderView = (TaskViewHeader) findViewById(R.id.task_view_bar);
mThumbnailView = (TaskViewThumbnail) findViewById(R.id.task_view_thumbnail);
mThumbnailView.updateClipToTaskBar(mHeaderView);
mActionButtonView = findViewById(R.id.lock_to_app_fab);
mActionButtonView.setOutlineProvider(new ViewOutlineProvider() {
@Override
public void getOutline(View view, Outline outline) {
// Set the outline to match the FAB background
outline.setOval(0, 0, mActionButtonView.getWidth(), mActionButtonView.getHeight());
outline.setAlpha(0.35f);
}
});
mActionButtonView.setOnClickListener(this);
mActionButtonTranslationZ = mActionButtonView.getTranslationZ();
}
use of android.graphics.Outline in project android_frameworks_base by DirtyUnicorns.
the class TaskCardView method setAsScreenShotView.
private void setAsScreenShotView(Bitmap screenshot, ImageView screenshotView) {
LayoutParams lp = (LayoutParams) screenshotView.getLayoutParams();
lp.width = LayoutParams.MATCH_PARENT;
lp.height = LayoutParams.MATCH_PARENT;
screenshotView.setLayoutParams(lp);
screenshotView.setClipToOutline(true);
screenshotView.setOutlineProvider(new ViewOutlineProvider() {
@Override
public void getOutline(View view, Outline outline) {
outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), mCornerRadius);
}
});
screenshotView.setImageBitmap(screenshot);
}
use of android.graphics.Outline in project android_frameworks_base by AOSPA.
the class TaskCardView method setAsScreenShotView.
private void setAsScreenShotView(Bitmap screenshot, ImageView screenshotView) {
LayoutParams lp = (LayoutParams) screenshotView.getLayoutParams();
lp.width = LayoutParams.MATCH_PARENT;
lp.height = LayoutParams.MATCH_PARENT;
screenshotView.setLayoutParams(lp);
screenshotView.setClipToOutline(true);
screenshotView.setOutlineProvider(new ViewOutlineProvider() {
@Override
public void getOutline(View view, Outline outline) {
outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), mCornerRadius);
}
});
screenshotView.setImageBitmap(screenshot);
}
use of android.graphics.Outline in project TapTargetView by KeepSafe.
the class TapTargetView method applyTargetOptions.
protected void applyTargetOptions(Context context) {
shouldTintTarget = target.tintTarget;
shouldDrawShadow = target.drawShadow;
cancelable = target.cancelable;
if (shouldDrawShadow && Build.VERSION.SDK_INT >= 21) {
outlineProvider = new ViewOutlineProvider() {
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public void getOutline(View view, Outline outline) {
if (outerCircleCenter == null)
return;
outline.setOval((int) (outerCircleCenter[0] - outerCircleRadius), (int) (outerCircleCenter[1] - outerCircleRadius), (int) (outerCircleCenter[0] + outerCircleRadius), (int) (outerCircleCenter[1] + outerCircleRadius));
outline.setAlpha(outerCircleAlpha / 255.0f);
if (Build.VERSION.SDK_INT >= 22) {
outline.offset(0, SHADOW_DIM);
}
}
};
setOutlineProvider(outlineProvider);
setElevation(SHADOW_DIM);
}
if ((shouldDrawShadow && outlineProvider == null) || Build.VERSION.SDK_INT < 18) {
setLayerType(LAYER_TYPE_SOFTWARE, null);
} else {
setLayerType(LAYER_TYPE_HARDWARE, null);
}
final Resources.Theme theme = context.getTheme();
isDark = UiUtil.themeIntAttr(context, "isLightTheme") == 0;
final Integer outerCircleColor = target.outerCircleColorInt(context);
if (outerCircleColor != null) {
outerCirclePaint.setColor(outerCircleColor);
} else if (theme != null) {
outerCirclePaint.setColor(UiUtil.themeIntAttr(context, "colorPrimary"));
} else {
outerCirclePaint.setColor(Color.WHITE);
}
final Integer targetCircleColor = target.targetCircleColorInt(context);
if (targetCircleColor != null) {
targetCirclePaint.setColor(targetCircleColor);
} else {
targetCirclePaint.setColor(isDark ? Color.BLACK : Color.WHITE);
}
if (target.transparentTarget) {
targetCirclePaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
}
targetCirclePulsePaint.setColor(targetCirclePaint.getColor());
final Integer targetDimColor = target.dimColorInt(context);
if (targetDimColor != null) {
dimColor = UiUtil.setAlpha(targetDimColor, 0.3f);
} else {
dimColor = -1;
}
final Integer titleTextColor = target.titleTextColorInt(context);
if (titleTextColor != null) {
titlePaint.setColor(titleTextColor);
} else {
titlePaint.setColor(isDark ? Color.BLACK : Color.WHITE);
}
final Integer descriptionTextColor = target.descriptionTextColorInt(context);
if (descriptionTextColor != null) {
descriptionPaint.setColor(descriptionTextColor);
} else {
descriptionPaint.setColor(titlePaint.getColor());
}
if (target.typeface != null) {
titlePaint.setTypeface(target.typeface);
descriptionPaint.setTypeface(target.typeface);
}
}
Aggregations