use of android.view.ViewOutlineProvider 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.view.ViewOutlineProvider 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);
}
}
use of android.view.ViewOutlineProvider in project android_frameworks_base by crdroidandroid.
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.view.ViewOutlineProvider in project android_frameworks_base by crdroidandroid.
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.view.ViewOutlineProvider in project Depth-LIB-Android- by danielzeller.
the class DepthLayout method initView.
private void initView(AttributeSet attrs) {
edgePaint.setColor(DEFAULT_EDGE_COLOR);
edgePaint.setAntiAlias(true);
if (attrs != null) {
TypedArray arr = getContext().obtainStyledAttributes(attrs, R.styleable.DepthView);
edgePaint.setColor(arr.getInt(R.styleable.DepthView_edge_color, DEFAULT_EDGE_COLOR));
setIsCircle(arr.getBoolean(R.styleable.DepthView_is_circle, false));
depth = arr.getDimension(R.styleable.DepthView_depth, DEFAULT_THICKNESS * getResources().getDisplayMetrics().density);
customShadowElevation = arr.getDimension(R.styleable.DepthView_custom_elevation, 0);
} else {
edgePaint.setColor(DEFAULT_EDGE_COLOR);
depth = DEFAULT_THICKNESS * getResources().getDisplayMetrics().density;
}
setOutlineProvider(new ViewOutlineProvider() {
@Override
public void getOutline(View view, Outline outline) {
}
});
}
Aggregations