android.graphics.ColorFilter Java Examples

The following examples show how to use android.graphics.ColorFilter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BaseFragment.java    From arcusandroid with Apache License 2.0 6 votes vote down vote up
/**
 * update background color based on the current device connectivity
 */
public void updateBackground(boolean isConnected) {
    try {
        ColorMatrix cm = new ColorMatrix();
        cm.setSaturation(0f);
        final ColorFilter filter = new ColorMatrixColorFilter(cm);
        final ColorFilter filterOnline = getOnlineColorFilter();
        final View bgView = ImageManager.getWallpaperView();
        if (bgView != null) {
            final Drawable bgDrawable = bgView.getBackground();
            if (bgDrawable != null) {
                bgDrawable.setColorFilter(isConnected ? filterOnline : filter);
            }
        }
        if(this instanceof ArcusProductFragment) {
            final ArcusProductFragment fragment = (ArcusProductFragment) this;
            fragment.setEnabled(isConnected);
        }
        if(callback != null) {
            callback.backgroundUpdated();
        }
    }catch (Exception e){
        logger.error("Can't change background color filter: {}", e);
    }
}
 
Example #2
Source File: ScrollBarDrawable.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@Override
public void setColorFilter(ColorFilter colorFilter) {
    mColorFilter = colorFilter;
    mHasSetColorFilter = true;

    if (mVerticalTrack != null) {
        mVerticalTrack.setColorFilter(colorFilter);
    }
    if (mVerticalThumb != null) {
        mVerticalThumb.setColorFilter(colorFilter);
    }
    if (mHorizontalTrack != null) {
        mHorizontalTrack.setColorFilter(colorFilter);
    }
    if (mHorizontalThumb != null) {
        mHorizontalThumb.setColorFilter(colorFilter);
    }
}
 
Example #3
Source File: ArcusProductFragment.java    From arcusandroid with Apache License 2.0 6 votes vote down vote up
/**
 * convert the current screen color to grey
 * @param apply apply grey scale or not
 */
private void applyGreyScale(final boolean apply){

    ColorMatrix cm = new ColorMatrix();
    cm.setSaturation(0f);
    final ColorFilter filter = new ColorMatrixColorFilter(cm);

    if (apply) {
        if (deviceImage != null) this.deviceImage.setColorFilter(filter);
        if (this.leftNav != null) this.leftNav.setColorFilter(null);
        if (this.rightNav != null) this.rightNav.setColorFilter(null);
        if (this.bottomView != null && !isBottomViewAlerting) this.bottomView.getBackground().setColorFilter(filter);
    } else {
        if (deviceImage != null) this.deviceImage.setColorFilter(null);
        if (this.leftNav != null) this.leftNav.setColorFilter(null);
        if (this.rightNav != null) this.rightNav.setColorFilter(null);
        if (this.bottomView != null && !isBottomViewAlerting) this.bottomView.getBackground().setColorFilter(null);
    }
}
 
Example #4
Source File: HaloFragment.java    From arcusandroid with Apache License 2.0 6 votes vote down vote up
@Override protected ColorFilter getOnlineColorFilter() {
    if (haloModel == null || mView == null) {
        return null;
    }

    View colorOverlayView = mView.findViewById(R.id.color_overlay);
    if (colorOverlayView == null) {
        return null;
    }

    boolean applyFilter = haloModel.isOnline() && isVisible();
    colorOverlayView.setVisibility(applyFilter ? View.VISIBLE : View.GONE);

    if(applyFilter) {
        float [] colorHSV = new float[]{ haloModel.getHue(), (haloModel.getSaturation() / 100f), 1f};
        colorOverlayView.setBackgroundColor(Color.HSVToColor(25, colorHSV));

        ColorMatrix cm = new ColorMatrix();
        cm.setSaturation(0f);
        return new ColorMatrixColorFilter(cm);
    }

    return null;
}
 
Example #5
Source File: DimmerFragment.java    From arcusandroid with Apache License 2.0 6 votes vote down vote up
@Override
protected ColorFilter getOnlineColorFilter() {
    View colorOverlayView = mView.findViewById(R.id.color_overlay);
    if(getDeviceModel() != null && isVisible() && Light.COLORMODE_COLOR.equals(getDeviceModel().get(Light.ATTR_COLORMODE)) && !DeviceConnection.STATE_OFFLINE.equals(getDeviceModel().get(DeviceConnection.ATTR_STATE))) {
        int colorOverlay = getColorFilterValue();
        if(colorOverlay != 0) {
            colorOverlayView.setVisibility(View.VISIBLE);
            colorOverlayView.setBackgroundColor(colorOverlay);
            //colorOverlayView.getBackground().setColorFilter(new PorterDuffColorFilter(colorOverlay, PorterDuff.Mode.SRC_OVER));
        }
        ColorMatrix cm = new ColorMatrix();
        cm.setSaturation(0f);
        return new ColorMatrixColorFilter(cm);
    }
    else {
        colorOverlayView.setVisibility(View.GONE);
    }
    return null;
}
 
Example #6
Source File: HueFallbackFragment.java    From arcusandroid with Apache License 2.0 6 votes vote down vote up
@Override
public void updateBackground(boolean isConnected) {
    try {
        ColorMatrix cm = new ColorMatrix();
        cm.setSaturation(0f);
        final ColorFilter filter = new ColorMatrixColorFilter(cm);
        final View bgView = ImageManager.getWallpaperView();
        if (bgView != null) {
            final Drawable bgDrawable = bgView.getBackground();
            if (bgDrawable != null) {
                bgDrawable.setColorFilter(filter);
            }
        }
    }catch (Exception e){
        logger.error("Can't change background color filter: {}", e);
    }
}
 
Example #7
Source File: CircleImageView.java    From SmartLoadingView with MIT License 5 votes vote down vote up
@Override
public void setColorFilter(ColorFilter cf) {
    if (cf == mColorFilter) {
        return;
    }

    mColorFilter = cf;
    mBitmapPaint.setColorFilter(mColorFilter);
    invalidate();
}
 
Example #8
Source File: ImageView.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/**
 * Apply an arbitrary colorfilter to the image.
 *
 * @param cf the colorfilter to apply (may be null)
 *
 * @see #getColorFilter()
 */
public void setColorFilter(ColorFilter cf) {
    if (mColorFilter != cf) {
        mColorFilter = cf;
        mHasColorFilter = true;
        mColorMod = true;
        applyColorMod();
        invalidate();
    }
}
 
Example #9
Source File: DoubleCircleBuilder.java    From AndroidWallet with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void setColorFilter(ColorFilter colorFilter)
{
    mStrokePaint.setColorFilter(colorFilter);
}
 
Example #10
Source File: DrawableWrapper.java    From MHViewer with Apache License 2.0 4 votes vote down vote up
public void setColorFilter(ColorFilter cf) {
  this.mDrawable.setColorFilter(cf);
}
 
Example #11
Source File: CombinedDrawable.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void setColorFilter(ColorFilter colorFilter) {
    icon.setColorFilter(colorFilter);
}
 
Example #12
Source File: RotateCircleBuilder.java    From AndroidWallet with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void setColorFilter(ColorFilter colorFilter)
{
    mFullPaint.setColorFilter(colorFilter);
}
 
Example #13
Source File: MaterialProgressDrawable.java    From AlipayPullRefresh with Apache License 2.0 4 votes vote down vote up
public void setColorFilter(ColorFilter filter) {
    mPaint.setColorFilter(filter);
    invalidateSelf();
}
 
Example #14
Source File: DebugDrawable.java    From QNotified with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void setColorFilter(ColorFilter colorFilter) {
}
 
Example #15
Source File: FrameAnimationDrawable.java    From APNG4Android with Apache License 2.0 4 votes vote down vote up
@Override
public void setColorFilter(ColorFilter colorFilter) {
    paint.setColorFilter(colorFilter);
}
 
Example #16
Source File: AlphaBackgroundDrawable.java    From Folivora with Apache License 2.0 4 votes vote down vote up
@Override
public void setColorFilter(@Nullable ColorFilter colorFilter) {
  mPaint.setColorFilter(colorFilter);
}
 
Example #17
Source File: UmbrellaDrawable.java    From Folivora with Apache License 2.0 4 votes vote down vote up
@Override
public void setColorFilter(@Nullable ColorFilter colorFilter) {
  //not supported
}
 
Example #18
Source File: CircularAnimatedDrawable.java    From LoadingButton with MIT License 4 votes vote down vote up
@Override
public void setColorFilter(ColorFilter cf) {
    mPaint.setColorFilter(cf);
}
 
Example #19
Source File: ImageReceiver.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public void setColorFilter(ColorFilter filter) {
    colorFilter = filter;
}
 
Example #20
Source File: StarBuilder.java    From AndroidWallet with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void setColorFilter(ColorFilter colorFilter)
{
    mFullPaint.setColorFilter(colorFilter);
}
 
Example #21
Source File: LeafBuilder.java    From AndroidWallet with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void setColorFilter(ColorFilter colorFilter)
{
    mFullPaint.setColorFilter(colorFilter);
}
 
Example #22
Source File: BaseStateBuilder.java    From AndroidWallet with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void setColorFilter(ColorFilter colorFilter)
{
    mPaint.setColorFilter(colorFilter);
}
 
Example #23
Source File: BaseBallBuilder.java    From AndroidWallet with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void setColorFilter(ColorFilter colorFilter)
{
    mPaint.setColorFilter(colorFilter);
}
 
Example #24
Source File: CircleBuilder.java    From AndroidWallet with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void setColorFilter(ColorFilter colorFilter)
{
    mPaint.setColorFilter(colorFilter);
}
 
Example #25
Source File: TriangleDrawable.java    From MHViewer with Apache License 2.0 4 votes vote down vote up
@Override
public void setColorFilter(ColorFilter colorFilter) {
    mPaint.setColorFilter(colorFilter);
}
 
Example #26
Source File: WrapDrawable.java    From MHViewer with Apache License 2.0 4 votes vote down vote up
@Override
public void setColorFilter(ColorFilter cf) {
    if (mDrawable != null) {
        mDrawable.setColorFilter(cf);
    }
}
 
Example #27
Source File: BatteryDrawable.java    From MHViewer with Apache License 2.0 4 votes vote down vote up
@Override
public void setColorFilter(ColorFilter cf) {
    mPaint.setColorFilter(cf);
}
 
Example #28
Source File: RoundDrawable.java    From MHViewer with Apache License 2.0 4 votes vote down vote up
@Override
public void setColorFilter(ColorFilter colorFilter) {
    mPaint.setColorFilter(colorFilter);
}
 
Example #29
Source File: RoundSideRectDrawable.java    From MHViewer with Apache License 2.0 4 votes vote down vote up
@Override
public void setColorFilter(ColorFilter colorFilter) {
    mPaint.setColorFilter(colorFilter);
}
 
Example #30
Source File: TextDrawable.java    From MHViewer with Apache License 2.0 4 votes vote down vote up
@Override
public void setColorFilter(@Nullable ColorFilter colorFilter) {
  backgroundPaint.setColorFilter(colorFilter);
  textPaint.setColorFilter(colorFilter);
  invalidateSelf();
}