javatips.net counter

Java Examples for android.graphics.ColorMatrixColorFilter

The following java examples will help you to understand the usage of android.graphics.ColorMatrixColorFilter. These source code samples are taken from different open source projects.

Example 1
Project: i2p.android.base-master  File: BrowserAdapter.java View source code
// Replace the contents of a view (invoked by the layout manager)
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
    final Browser browser = mBrowsers[position];
    holder.mIcon.setImageDrawable(browser.icon);
    holder.mLabel.setText(browser.label);
    if (browser.isKnown) {
        if (browser.isRecommended && browser.isInstalled) {
            holder.mStatus.setImageDrawable(mCtx.getResources().getDrawable(R.drawable.ic_stars_white_24dp));
            holder.mStatus.setVisibility(View.VISIBLE);
        } else if (browser.isSupported && !browser.isInstalled) {
            holder.mStatus.setImageDrawable(mCtx.getResources().getDrawable(R.drawable.ic_shop_white_24dp));
            holder.mStatus.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View view) {
                    String uriMarket = "market://search?q=pname:" + browser.packageName;
                    Uri uri = Uri.parse(uriMarket);
                    Intent intent = new Intent(Intent.ACTION_VIEW, uri);
                    mCtx.startActivity(intent);
                }
            });
            holder.mStatus.setVisibility(View.VISIBLE);
        } else if (!browser.isSupported) {
            // Make the icon gray-scale to show it is unsupported
            ColorMatrix matrix = new ColorMatrix();
            matrix.setSaturation(0);
            ColorMatrixColorFilter filter = new ColorMatrixColorFilter(matrix);
            holder.mIcon.setColorFilter(filter);
            holder.mLabel.setTextColor(mCtx.getResources().getColor(R.color.primary_text_disabled_material_dark));
        }
    }
    holder.itemView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            mListener.onBrowserSelected(browser);
        }
    });
}
Example 2
Project: osmdroid-master  File: SampleWhackyColorFilter.java View source code
@Override
public void addOverlays() {
    //p.s. there's a ton of examples here
    //http://stackoverflow.com/questions/4354939/understanding-the-use-of-colormatrix-and-colormatrixcolorfilter-to-modify-a-draw
    //http://developer.android.com/reference/android/graphics/ColorMatrix.html
    //this will make things look pinkish
    //this.mMapView.getOverlayManager().getTilesOverlay().setColorFilter(adjustHue(160));
    ColorMatrix cm = new ColorMatrix();
    // reduce color's by 50%. i.e. just make it darker
    float brightness = .5f;
    cm.set(new float[] { //red
    brightness, //red
    0, //red
    0, //red
    0, //red
    0, //green
    0, //green
    brightness, //green
    0, //green
    0, //green
    0, //blue
    0, //blue
    0, //blue
    brightness, //blue
    0, //blue
    0, 0, 0, 0, 1, //alpha
    0 });
    this.mMapView.getOverlayManager().getTilesOverlay().setColorFilter(new ColorMatrixColorFilter(cm));
//pro tip, set the color filter to null to reset to normal viewing
}
Example 3
Project: Android-Terminal-Emulator-master  File: Bitmap4x8FontRenderer.java View source code
private void setColorMatrix(int foreColor, int backColor) {
    if ((foreColor != mCurrentForeColor) || (backColor != mCurrentBackColor) || (mColorMatrix == null)) {
        mCurrentForeColor = foreColor;
        mCurrentBackColor = backColor;
        if (mColorMatrix == null) {
            mColorMatrix = new float[20];
            // Just copy Alpha
            mColorMatrix[18] = 1.0f;
        }
        for (int component = 0; component < 3; component++) {
            int rightShift = (2 - component) << 3;
            int fore = 0xff & (foreColor >> rightShift);
            int back = 0xff & (backColor >> rightShift);
            int delta = back - fore;
            mColorMatrix[component * 6] = delta * BYTE_SCALE;
            mColorMatrix[component * 5 + 4] = fore;
        }
        mPaint.setColorFilter(new ColorMatrixColorFilter(mColorMatrix));
    }
}
Example 4
Project: android_packages_apps-master  File: MusicUtils.java View source code
static void setBackground(View v, Bitmap bm) {
    if (bm == null) {
        v.setBackgroundResource(0);
        return;
    }
    int vwidth = v.getWidth();
    int vheight = v.getHeight();
    int bwidth = bm.getWidth();
    int bheight = bm.getHeight();
    float scalex = (float) vwidth / bwidth;
    float scaley = (float) vheight / bheight;
    float scale = Math.max(scalex, scaley) * 1.3f;
    Bitmap.Config config = Bitmap.Config.ARGB_8888;
    Bitmap bg = Bitmap.createBitmap(vwidth, vheight, config);
    Canvas c = new Canvas(bg);
    Paint paint = new Paint();
    paint.setAntiAlias(true);
    paint.setFilterBitmap(true);
    ColorMatrix greymatrix = new ColorMatrix();
    greymatrix.setSaturation(0);
    ColorMatrix darkmatrix = new ColorMatrix();
    darkmatrix.setScale(.3f, .3f, .3f, 1.0f);
    greymatrix.postConcat(darkmatrix);
    ColorFilter filter = new ColorMatrixColorFilter(greymatrix);
    paint.setColorFilter(filter);
    Matrix matrix = new Matrix();
    // move bitmap center to origin
    matrix.setTranslate(-bwidth / 2, -bheight / 2);
    matrix.postRotate(10);
    matrix.postScale(scale, scale);
    // Move bitmap center to view center
    matrix.postTranslate(vwidth / 2, vheight / 2);
    c.drawBitmap(bm, matrix, paint);
    v.setBackgroundDrawable(new BitmapDrawable(bg));
}
Example 5
Project: android-sdk-sources-for-api-level-23-master  File: PrintHelperKitkat.java View source code
private Bitmap convertBitmapForColorMode(Bitmap original, int colorMode) {
    if (colorMode != COLOR_MODE_MONOCHROME) {
        return original;
    }
    // Create a grayscale bitmap
    Bitmap grayscale = Bitmap.createBitmap(original.getWidth(), original.getHeight(), Config.ARGB_8888);
    Canvas c = new Canvas(grayscale);
    Paint p = new Paint();
    ColorMatrix cm = new ColorMatrix();
    cm.setSaturation(0);
    ColorMatrixColorFilter f = new ColorMatrixColorFilter(cm);
    p.setColorFilter(f);
    c.drawBitmap(original, 0, 0, p);
    c.setBitmap(null);
    return grayscale;
}
Example 6
Project: WallpaperPicker-master  File: FastBitmapDrawable.java View source code
private void updateFilter() {
    if (mGhostModeEnabled) {
        if (sGhostModeMatrix == null) {
            sGhostModeMatrix = new ColorMatrix();
            sGhostModeMatrix.setSaturation(0);
            // For ghost mode, set the color range to [GHOST_MODE_MIN_COLOR_RANGE, 255]
            float range = (255 - GHOST_MODE_MIN_COLOR_RANGE) / 255.0f;
            sTempMatrix.set(new float[] { range, 0, 0, 0, GHOST_MODE_MIN_COLOR_RANGE, 0, range, 0, 0, GHOST_MODE_MIN_COLOR_RANGE, 0, 0, range, 0, GHOST_MODE_MIN_COLOR_RANGE, 0, 0, 0, 1, 0 });
            sGhostModeMatrix.preConcat(sTempMatrix);
        }
        if (mBrightness == 0) {
            mPaint.setColorFilter(new ColorMatrixColorFilter(sGhostModeMatrix));
        } else {
            setBrightnessMatrix(sTempMatrix, mBrightness);
            sTempMatrix.postConcat(sGhostModeMatrix);
            mPaint.setColorFilter(new ColorMatrixColorFilter(sTempMatrix));
        }
    } else if (mBrightness != 0) {
        ColorFilter filter = sCachedBrightnessFilter.get(mBrightness);
        if (filter == null) {
            filter = new PorterDuffColorFilter(Color.argb(mBrightness, 255, 255, 255), PorterDuff.Mode.SRC_ATOP);
            sCachedBrightnessFilter.put(mBrightness, filter);
        }
        mPaint.setColorFilter(filter);
    } else {
        mPaint.setColorFilter(null);
    }
}
Example 7
Project: android-transition-master  File: SlidingUpPanelActivity.java View source code
@UiThread
public void updateTransition(View v, boolean animate) {
    if (animate) {
        mUnifiedAdapter.setReverseAnimation(true);
        mUnifiedAdapter.startAnimation();
    }
    //TODO removeAllTransitions() has to be called *after* mAnimationAdapter.resetAnimation(), this subtle order of execution requirement should be removed
    mUnifiedAdapter.removeAllTransitions();
    mLastSelection = v;
    boolean enableAnimationMenu = true;
    //configure a builder with properties shared by all instances and just clone it for future use
    //since adapter(ITransitionAdapter) is set, simply call buildFor(mUnifiedAdapter) would add the resultant ViewTransition to the adapter
    ViewTransitionBuilder baseBuilder = ViewTransitionBuilder.transit(mToolbar).interpolator(mInterpolator);
    ViewTransitionBuilder builder;
    ((ImageView) findViewById(R.id.content_bg)).setColorFilter(null);
    boolean setHalfHeight = false;
    switch(v.getId()) {
        //TODO visual artifact on Android 5.1 (Nexus 7 2013) when rotationX is ~45, why???
        case R.id.rotate_slide:
            builder = baseBuilder.clone();
            builder.scale(0.8f).rotationX(40).translationYAsFractionOfHeight(-1f).buildFor(mUnifiedAdapter);
            builder = baseBuilder.clone().target(findViewById(R.id.content_bg)).rotationX(42f).scale(0.8f).translationYAsFractionOfHeight(-0.5f);
            builder.buildFor(mUnifiedAdapter);
            builder.target(findViewById(R.id.content)).buildFor(mUnifiedAdapter);
            builder = baseBuilder.clone().target(findViewById(R.id.content));
            Cascade cascade = new Cascade(Cascade.STAGGERED, 0.6f).reverse();
            builder.transitViewGroup(new ViewTransitionBuilder.ViewGroupTransition() {

                @Override
                public void transit(ViewTransitionBuilder builder, ViewTransitionBuilder.ViewGroupTransitionConfig config) {
                    builder.translationYAsFractionOfHeight(config.parentViewGroup, 1f).buildFor(mUnifiedAdapter);
                }
            }, cascade);
            enableAnimationMenu = false;
            break;
        case R.id.sliding_actionbar_view:
            baseBuilder.clone().translationYAsFractionOfHeight(-1f).buildFor(mUnifiedAdapter);
            builder = baseBuilder.clone().target(findViewById(R.id.content)).translationYAsFractionOfHeight(-0.5f);
            builder.buildFor(mUnifiedAdapter);
            //apply the exact same transition to another view
            builder.target(findViewById(R.id.content_bg2)).buildFor(mUnifiedAdapter);
            break;
        case R.id.change_actionbar_color:
            baseBuilder.clone().backgroundColorResource(getResources(), R.color.primary, R.color.accent).buildFor(mUnifiedAdapter);
            break;
        case R.id.change_actionbar_color_hsv:
            baseBuilder.clone().backgroundColorResourceHSV(getResources(), R.color.primary, R.color.drawer_opened).buildFor(mUnifiedAdapter);
            break;
        case R.id.fading_actionbar:
            baseBuilder.clone().alpha(1f, 0f).buildFor(mUnifiedAdapter);
            break;
        case R.id.rotating_actionbar:
            baseBuilder.clone().delayTranslationYAsFractionOfHeight(-0.5f).delayRotationX(90f).scale(0.8f).buildFor(mUnifiedAdapter);
            break;
        case R.id.grayscale_bg:
            //Uses a CustomTransitionController that applies a ColorMatrixColorFilter to the background view
            baseBuilder.clone().addTransitionHandler(new ScaledTransitionHandler() {

                ColorMatrix matrix = new ColorMatrix();

                ImageView bg;

                @Override
                public void onUpdateScaledProgress(TransitionController controller, View target, float progress) {
                    matrix.setSaturation(1 - progress);
                    ColorMatrixColorFilter filter = new ColorMatrixColorFilter(matrix);
                    if (bg == null) {
                        bg = (ImageView) findViewById(R.id.content_bg);
                    }
                    bg.setColorFilter(filter);
                }
            }).range(0f, 1f).buildFor(mUnifiedAdapter);
            setHalfHeight = true;
            break;
        case R.id.cascade_fading:
            builder = baseBuilder.clone().target(findViewById(R.id.content));
            cascade = new Cascade(Cascade.STAGGERED, 0.54f).reverse();
            builder.transitViewGroup(new ViewTransitionBuilder.ViewGroupTransition() {

                @Override
                public void transit(ViewTransitionBuilder builder, ViewTransitionBuilder.ViewGroupTransitionConfig config) {
                    builder.alpha(0f).buildFor(mUnifiedAdapter);
                }
            }, cascade);
            break;
        case R.id.cascade_rolling:
            builder = baseBuilder.clone().target(findViewById(R.id.content));
            cascade = new Cascade(Cascade.SEQUENTIAL, 0.64f).reverse();
            builder.transitViewGroup(new ViewTransitionBuilder.ViewGroupTransition() {

                @Override
                public void transit(ViewTransitionBuilder builder, ViewTransitionBuilder.ViewGroupTransitionConfig config) {
                    builder.rotationX(90f).buildFor(mUnifiedAdapter);
                }
            }, cascade);
            break;
    }
    //only show animate MenuItem when it's not the first option
    if (mMenu != null) {
        mMenu.findItem(R.id.menu_animate).setEnabled(enableAnimationMenu);
    }
    setSlidingUpPanelHeight(setHalfHeight);
}
Example 8
Project: FoldingLayout-master  File: FoldingLayoutActivity.java View source code
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_fold);
    mImageView = (ImageView) findViewById(R.id.image_view);
    mImageView.setPadding(ANTIALIAS_PADDING, ANTIALIAS_PADDING, ANTIALIAS_PADDING, ANTIALIAS_PADDING);
    mImageView.setScaleType(ImageView.ScaleType.FIT_XY);
    mImageView.setImageDrawable(getResources().getDrawable(R.drawable.image));
    mTextureView = new TextureView(this);
    mTextureView.setSurfaceTextureListener(mSurfaceTextureListener);
    mAnchorSeekBar = (SeekBar) findViewById(R.id.anchor_seek_bar);
    mFoldLayout = (FoldingLayout) findViewById(R.id.fold_view);
    mFoldLayout.setBackgroundColor(Color.BLACK);
    mFoldLayout.setFoldListener(mOnFoldListener);
    mTouchSlop = ViewConfiguration.get(this).getScaledTouchSlop();
    mAnchorSeekBar.setOnSeekBarChangeListener(mSeekBarChangeListener);
    mScrollGestureDetector = new GestureDetector(this, new ScrollGestureDetector());
    mItemSelectedListener = new ItemSelectedListener();
    mDefaultPaint = new Paint();
    mSepiaPaint = new Paint();
    ColorMatrix m1 = new ColorMatrix();
    ColorMatrix m2 = new ColorMatrix();
    m1.setSaturation(0);
    m2.setScale(1f, .95f, .82f, 1.0f);
    m1.setConcat(m2, m1);
    mSepiaPaint.setColorFilter(new ColorMatrixColorFilter(m1));
}
Example 9
Project: property-db-master  File: BeanBag.java View source code
private void pickBean() {
    int beanId = pickInt(BEANS);
    if (randfrange(0, 1) <= LUCKY) {
        beanId = R.drawable.jandycane;
    }
    BitmapDrawable bean = (BitmapDrawable) getContext().getResources().getDrawable(beanId);
    Bitmap beanBits = bean.getBitmap();
    h = beanBits.getHeight();
    w = beanBits.getWidth();
    if (DEBUG) {
        bean.setAlpha(0x80);
    }
    this.setImageDrawable(bean);
    Paint pt = new Paint();
    final int color = pickInt(COLORS);
    ColorMatrix CM = new ColorMatrix();
    float[] M = CM.getArray();
    // we assume the color information is in the red channel
    /* R */
    M[0] = (float) ((color & 0x00FF0000) >> 16) / 0xFF;
    /* G */
    M[5] = (float) ((color & 0x0000FF00) >> 8) / 0xFF;
    /* B */
    M[10] = (float) ((color & 0x000000FF)) / 0xFF;
    pt.setColorFilter(new ColorMatrixColorFilter(M));
    setLayerType(View.LAYER_TYPE_HARDWARE, (beanId == R.drawable.jandycane) ? null : pt);
}
Example 10
Project: sdk-support-master  File: PrintHelperKitkat.java View source code
private Bitmap convertBitmapForColorMode(Bitmap original, int colorMode) {
    if (colorMode != COLOR_MODE_MONOCHROME) {
        return original;
    }
    // Create a grayscale bitmap
    Bitmap grayscale = Bitmap.createBitmap(original.getWidth(), original.getHeight(), Config.ARGB_8888);
    Canvas c = new Canvas(grayscale);
    Paint p = new Paint();
    ColorMatrix cm = new ColorMatrix();
    cm.setSaturation(0);
    ColorMatrixColorFilter f = new ColorMatrixColorFilter(cm);
    p.setColorFilter(f);
    c.drawBitmap(original, 0, 0, p);
    c.setBitmap(null);
    return grayscale;
}
Example 11
Project: AcDisplay-master  File: NotificationActions.java View source code
@Nullable
protected Drawable onCreateActionIcon(@NonNull Drawable icon) {
    int size = getResources().getDimensionPixelSize(R.dimen.notification_action_icon_size);
    icon = icon.mutate();
    icon.setBounds(0, 0, size, size);
    // The matrix is stored in a single array, and its treated as follows:
    // [ a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t ]
    // When applied to a color [r, g, b, a], the resulting color is computed as (after clamping)
    //   R' = a*R + b*G + c*B + d*A + e;
    //   G' = f*R + g*G + h*B + i*A + j;
    //   B' = k*R + l*G + m*B + n*A + o;
    //   A' = p*R + q*G + r*B + s*A + t;
    ColorFilter colorFilter = new ColorMatrixColorFilter(new float[] { // Red
    0, // Red
    0, // Red
    0, // Red
    0, // Red
    255, // Green
    0, // Green
    0, // Green
    0, // Green
    0, // Green
    255, // Blue
    0, // Blue
    0, // Blue
    0, // Blue
    0, // Blue
    255, //    Alpha
    0, //    Alpha
    0, //    Alpha
    0, //    Alpha
    1, //    Alpha
    0 });
    // force white color
    icon.setColorFilter(colorFilter);
    return icon;
}
Example 12
Project: MUtils-master  File: AppUtil.java View source code
public static Drawable toGrey(Drawable drawable) {
    int w = drawable.getMinimumWidth();
    int h = drawable.getMinimumHeight();
    if (w <= 0 || h <= 0) {
        return drawable;
    }
    Rect bounds = drawable.getBounds();
    Bitmap grey = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
    Canvas c = new Canvas(grey);
    ColorMatrix cm = new ColorMatrix();
    cm.setSaturation(0);
    drawable.setColorFilter(new ColorMatrixColorFilter(cm));
    drawable.setBounds(0, 0, w, h);
    drawable.draw(c);
    drawable.clearColorFilter();
    drawable.setBounds(bounds);
    BitmapDrawable bd = new BitmapDrawable(grey);
    bd.setBounds(0, 0, w, h);
    return bd;
}
Example 13
Project: Fairphone-master  File: AppsCustomizePagedView.java View source code
private Bitmap getShortcutPreview(ResolveInfo info, int maxWidth, int maxHeight) {
    Bitmap tempBitmap = mCachedShortcutPreviewBitmap.get();
    final Canvas c = mCachedShortcutPreviewCanvas.get();
    if (tempBitmap == null || tempBitmap.getWidth() != maxWidth || tempBitmap.getHeight() != maxHeight) {
        tempBitmap = Bitmap.createBitmap(maxWidth, maxHeight, Config.ARGB_8888);
        mCachedShortcutPreviewBitmap.set(tempBitmap);
    } else {
        c.setBitmap(tempBitmap);
        c.drawColor(0, PorterDuff.Mode.CLEAR);
        c.setBitmap(null);
    }
    // Render the icon
    Drawable icon = mIconCache.getFullResIcon(info);
    int paddingTop = getResources().getDimensionPixelOffset(R.dimen.shortcut_preview_padding_top);
    int paddingLeft = getResources().getDimensionPixelOffset(R.dimen.shortcut_preview_padding_left);
    int paddingRight = getResources().getDimensionPixelOffset(R.dimen.shortcut_preview_padding_right);
    int scaledIconWidth = (maxWidth - paddingLeft - paddingRight);
    renderDrawableToBitmap(icon, tempBitmap, paddingLeft, paddingTop, scaledIconWidth, scaledIconWidth);
    Bitmap preview = Bitmap.createBitmap(maxWidth, maxHeight, Config.ARGB_8888);
    c.setBitmap(preview);
    Paint p = mCachedShortcutPreviewPaint.get();
    if (p == null) {
        p = new Paint();
        ColorMatrix colorMatrix = new ColorMatrix();
        colorMatrix.setSaturation(0);
        p.setColorFilter(new ColorMatrixColorFilter(colorMatrix));
        p.setAlpha((int) (255 * 0.06f));
        //float density = 1f;
        //p.setMaskFilter(new BlurMaskFilter(15*density, BlurMaskFilter.Blur.NORMAL));
        mCachedShortcutPreviewPaint.set(p);
    }
    c.drawBitmap(tempBitmap, 0, 0, p);
    c.setBitmap(null);
    renderDrawableToBitmap(icon, preview, 0, 0, mAppIconSize, mAppIconSize);
    return preview;
}
Example 14
Project: WS171-development-master  File: Term.java View source code
private void setColorMatrix(int foreColor, int backColor) {
    if ((foreColor != mCurrentForeColor) || (backColor != mCurrentBackColor) || (mColorMatrix == null)) {
        mCurrentForeColor = foreColor;
        mCurrentBackColor = backColor;
        if (mColorMatrix == null) {
            mColorMatrix = new float[20];
            mColorMatrix[18] = 1.0f;
        }
        for (int component = 0; component < 3; component++) {
            int rightShift = (2 - component) << 3;
            int fore = 0xff & (foreColor >> rightShift);
            int back = 0xff & (backColor >> rightShift);
            int delta = back - fore;
            mColorMatrix[component * 6] = delta * BYTE_SCALE;
            mColorMatrix[component * 5 + 4] = fore;
        }
        mPaint.setColorFilter(new ColorMatrixColorFilter(mColorMatrix));
    }
}
Example 15
Project: packages_apps_Launcher2-master  File: AppsCustomizePagedView.java View source code
private Bitmap getShortcutPreview(ResolveInfo info, int maxWidth, int maxHeight) {
    Bitmap tempBitmap = mCachedShortcutPreviewBitmap.get();
    final Canvas c = mCachedShortcutPreviewCanvas.get();
    if (tempBitmap == null || tempBitmap.getWidth() != maxWidth || tempBitmap.getHeight() != maxHeight) {
        tempBitmap = Bitmap.createBitmap(maxWidth, maxHeight, Config.ARGB_8888);
        mCachedShortcutPreviewBitmap.set(tempBitmap);
    } else {
        c.setBitmap(tempBitmap);
        c.drawColor(0, PorterDuff.Mode.CLEAR);
        c.setBitmap(null);
    }
    // Render the icon
    Drawable icon = mIconCache.getFullResIcon(info);
    int paddingTop = getResources().getDimensionPixelOffset(R.dimen.shortcut_preview_padding_top);
    int paddingLeft = getResources().getDimensionPixelOffset(R.dimen.shortcut_preview_padding_left);
    int paddingRight = getResources().getDimensionPixelOffset(R.dimen.shortcut_preview_padding_right);
    int scaledIconWidth = (maxWidth - paddingLeft - paddingRight);
    renderDrawableToBitmap(icon, tempBitmap, paddingLeft, paddingTop, scaledIconWidth, scaledIconWidth);
    Bitmap preview = Bitmap.createBitmap(maxWidth, maxHeight, Config.ARGB_8888);
    c.setBitmap(preview);
    Paint p = mCachedShortcutPreviewPaint.get();
    if (p == null) {
        p = new Paint();
        ColorMatrix colorMatrix = new ColorMatrix();
        colorMatrix.setSaturation(0);
        p.setColorFilter(new ColorMatrixColorFilter(colorMatrix));
        p.setAlpha((int) (255 * 0.06f));
        //float density = 1f;
        //p.setMaskFilter(new BlurMaskFilter(15*density, BlurMaskFilter.Blur.NORMAL));
        mCachedShortcutPreviewPaint.set(p);
    }
    c.drawBitmap(tempBitmap, 0, 0, p);
    c.setBitmap(null);
    renderDrawableToBitmap(icon, preview, 0, 0, mAppIconSize, mAppIconSize);
    return preview;
}
Example 16
Project: XieDaDeng-master  File: NotificationTemplateViewWrapper.java View source code
protected void fadeGrayscale(final ImageView target, final boolean dark, long delay) {
    startIntensityAnimation(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            updateGrayscaleMatrix((float) animation.getAnimatedValue());
            target.setColorFilter(new ColorMatrixColorFilter(mGrayscaleColorMatrix));
        }
    }, dark, delay, new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            if (!dark) {
                target.setColorFilter(null);
            }
        }
    });
}
Example 17
Project: demo_test-master  File: Utilities.java View source code
private static void initStatics(Context context) {
    final Resources resources = context.getResources();
    final DisplayMetrics metrics = resources.getDisplayMetrics();
    final float density = metrics.density;
    sIconWidth = sIconHeight = (int) resources.getDimension(android.R.dimen.app_icon_size);
    sIconTextureWidth = sIconTextureHeight = sIconWidth + 2;
    sBlurPaint.setMaskFilter(new BlurMaskFilter(5 * density, BlurMaskFilter.Blur.NORMAL));
    sGlowColorPressedPaint.setColor(0xffffc300);
    //TODO: sGlowColorPressedPaint.setMaskFilter(TableMaskFilter.CreateClipTable(0, 30));
    sGlowColorFocusedPaint.setColor(0xffff8e00);
    //TODO: sGlowColorFocusedPaint.setMaskFilter(TableMaskFilter.CreateClipTable(0, 30));
    ColorMatrix cm = new ColorMatrix();
    cm.setSaturation(0.2f);
    sDisabledPaint.setColorFilter(new ColorMatrixColorFilter(cm));
    sDisabledPaint.setAlpha(0x88);
}
Example 18
Project: fruit.launcher-master  File: Utilities.java View source code
private static void initStatics(Context context) {
    final Resources resources = context.getResources();
    final DisplayMetrics metrics = resources.getDisplayMetrics();
    final float density = metrics.density;
    sIconWidth = sIconHeight = (int) resources.getDimension(R.dimen.app_icon_size);
    sIconTextureWidth = sIconTextureHeight = sIconWidth + 2;
    sBlurPaint.setMaskFilter(new BlurMaskFilter(5 * density, BlurMaskFilter.Blur.NORMAL));
    sGlowColorPressedPaint.setColor(0xffffc300);
    sGlowColorPressedPaint.setMaskFilter(TableMaskFilter.CreateClipTable(0, 30));
    sGlowColorFocusedPaint.setColor(0xffff8e00);
    sGlowColorFocusedPaint.setMaskFilter(TableMaskFilter.CreateClipTable(0, 30));
    ColorMatrix cm = new ColorMatrix();
    cm.setSaturation(0.2f);
    sDisabledPaint.setColorFilter(new ColorMatrixColorFilter(cm));
    sDisabledPaint.setAlpha(0x88);
}