Search in sources :

Example 11 with Outline

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);
}
Also used : Outline(android.graphics.Outline) LayoutlibDelegate(com.android.tools.layoutlib.annotations.LayoutlibDelegate)

Example 12 with Outline

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

Example 13 with Outline

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

Example 14 with Outline

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);
}
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 Outline

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);
    }
}
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)

Aggregations

Outline (android.graphics.Outline)37 View (android.view.View)26 ViewOutlineProvider (android.view.ViewOutlineProvider)26 TextView (android.widget.TextView)16 TargetApi (android.annotation.TargetApi)8 ImageView (android.widget.ImageView)7 LayoutlibDelegate (com.android.tools.layoutlib.annotations.LayoutlibDelegate)5 ColorStateList (android.content.res.ColorStateList)3 ColorDrawable (android.graphics.drawable.ColorDrawable)3 RippleDrawable (android.graphics.drawable.RippleDrawable)3 Animator (android.animation.Animator)2 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)2 AnimatorSet (android.animation.AnimatorSet)2 ObjectAnimator (android.animation.ObjectAnimator)2 Rect (android.graphics.Rect)2 Drawable (android.graphics.drawable.Drawable)2 StateListDrawable (android.graphics.drawable.StateListDrawable)2 ViewGroup (android.view.ViewGroup)2 Interpolator (android.view.animation.Interpolator)2 AdapterView (android.widget.AdapterView)2