Search in sources :

Example 11 with ViewOutlineProvider

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);
}
Also used : Outline(android.graphics.Outline) ViewOutlineProvider(android.view.ViewOutlineProvider) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView)

Example 12 with ViewOutlineProvider

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);
    }
}
Also used : PorterDuffXfermode(android.graphics.PorterDuffXfermode) Outline(android.graphics.Outline) Resources(android.content.res.Resources) ViewOutlineProvider(android.view.ViewOutlineProvider) TargetApi(android.annotation.TargetApi) View(android.view.View)

Example 13 with ViewOutlineProvider

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();
}
Also used : Outline(android.graphics.Outline) ViewOutlineProvider(android.view.ViewOutlineProvider) View(android.view.View) TextView(android.widget.TextView)

Example 14 with ViewOutlineProvider

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);
}
Also used : Outline(android.graphics.Outline) ViewOutlineProvider(android.view.ViewOutlineProvider) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView)

Example 15 with ViewOutlineProvider

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) {
        }
    });
}
Also used : TypedArray(android.content.res.TypedArray) Outline(android.graphics.Outline) ViewOutlineProvider(android.view.ViewOutlineProvider) View(android.view.View)

Aggregations

View (android.view.View)27 ViewOutlineProvider (android.view.ViewOutlineProvider)27 Outline (android.graphics.Outline)26 TextView (android.widget.TextView)16 TargetApi (android.annotation.TargetApi)8 ImageView (android.widget.ImageView)7 ColorDrawable (android.graphics.drawable.ColorDrawable)4 Animator (android.animation.Animator)3 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)3 AnimatorSet (android.animation.AnimatorSet)3 ObjectAnimator (android.animation.ObjectAnimator)3 ColorStateList (android.content.res.ColorStateList)3 Rect (android.graphics.Rect)3 Drawable (android.graphics.drawable.Drawable)3 RippleDrawable (android.graphics.drawable.RippleDrawable)3 ViewGroup (android.view.ViewGroup)3 Interpolator (android.view.animation.Interpolator)3 StateListDrawable (android.graphics.drawable.StateListDrawable)2 AdapterView (android.widget.AdapterView)2 PropertyValuesHolder (android.animation.PropertyValuesHolder)1