use of android.graphics.ColorFilter in project android_packages_apps_Dialer by MoKee.
the class PseudoEmergencyAnimator method start.
public void start() {
if (mPseudoEmergencyColorAnimator == null) {
Integer colorFrom = Color.BLUE;
Integer colorTo = Color.RED;
mPseudoEmergencyColorAnimator = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo);
mPseudoEmergencyColorAnimator.addUpdateListener(new AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animator) {
try {
int color = (int) animator.getAnimatedValue();
ColorFilter colorFilter = new LightingColorFilter(Color.BLACK, color);
View floatingActionButtonContainer = getView().findViewById(R.id.dialpad_floating_action_button_container);
if (floatingActionButtonContainer != null) {
floatingActionButtonContainer.getBackground().setColorFilter(colorFilter);
}
} catch (Exception e) {
animator.cancel();
}
}
});
mPseudoEmergencyColorAnimator.addListener(new AnimatorListener() {
@Override
public void onAnimationCancel(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
try {
vibrate(VIBRATE_LENGTH_MILLIS);
} catch (Exception e) {
animation.cancel();
}
}
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
try {
View floatingActionButtonContainer = getView().findViewById(R.id.dialpad_floating_action_button_container);
if (floatingActionButtonContainer != null) {
floatingActionButtonContainer.getBackground().clearColorFilter();
}
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
try {
vibrate(VIBRATE_LENGTH_MILLIS);
} catch (Exception e) {
// ignored
}
}
}, ITERATION_LENGTH_MILLIS);
} catch (Exception e) {
animation.cancel();
}
}
});
mPseudoEmergencyColorAnimator.setDuration(VIBRATE_LENGTH_MILLIS);
mPseudoEmergencyColorAnimator.setRepeatMode(ValueAnimator.REVERSE);
mPseudoEmergencyColorAnimator.setRepeatCount(ANIMATION_ITERATION_COUNT);
}
if (!mPseudoEmergencyColorAnimator.isStarted()) {
mPseudoEmergencyColorAnimator.start();
}
}
use of android.graphics.ColorFilter in project xDrip-plus by jamorham.
the class Home method setupCharts.
private void setupCharts() {
bgGraphBuilder = new BgGraphBuilder(this);
updateStuff = false;
chart = (LineChartView) findViewById(R.id.chart);
if (BgGraphBuilder.isXLargeTablet(getApplicationContext())) {
ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) chart.getLayoutParams();
params.topMargin = 130;
chart.setLayoutParams(params);
}
chart.setBackgroundColor(getCol(X.color_home_chart_background));
chart.setZoomType(ZoomType.HORIZONTAL);
// Transmitter Battery Level
final Sensor sensor = Sensor.currentSensor();
// ????????? what about tomato here ?????
if (sensor != null && sensor.latest_battery_level != 0 && !DexCollectionService.getBestLimitterHardwareName().equalsIgnoreCase("BlueReader") && sensor.latest_battery_level <= Dex_Constants.TRANSMITTER_BATTERY_LOW && !Pref.getBoolean("disable_battery_warning", false)) {
Drawable background = new Drawable() {
@Override
public void draw(Canvas canvas) {
DisplayMetrics metrics = getApplicationContext().getResources().getDisplayMetrics();
int px = (int) (30 * (metrics.densityDpi / 160f));
Paint paint = new Paint();
paint.setTextSize(px);
paint.setAntiAlias(true);
paint.setColor(Color.parseColor("#FFFFAA"));
paint.setStyle(Paint.Style.STROKE);
paint.setAlpha(100);
canvas.drawText(getString(R.string.transmitter_battery), 10, chart.getHeight() / 3 - (int) (1.2 * px), paint);
if (sensor.latest_battery_level <= Dex_Constants.TRANSMITTER_BATTERY_EMPTY) {
paint.setTextSize((int) (px * 1.5));
canvas.drawText(getString(R.string.very_low), 10, chart.getHeight() / 3, paint);
} else {
canvas.drawText(getString(R.string.low), 10, chart.getHeight() / 3, paint);
}
}
@Override
public void setAlpha(int alpha) {
}
@Override
public void setColorFilter(ColorFilter cf) {
}
@Override
public int getOpacity() {
// TODO Which pixel format should this be?
return 0;
}
};
chart.setBackground(background);
}
previewChart = (PreviewLineChartView) findViewById(R.id.chart_preview);
chart.setLineChartData(bgGraphBuilder.lineData());
chart.setOnValueTouchListener(bgGraphBuilder.getOnValueSelectTooltipListener(mActivity));
previewChart.setBackgroundColor(getCol(X.color_home_chart_background));
previewChart.setZoomType(ZoomType.HORIZONTAL);
previewChart.setLineChartData(bgGraphBuilder.previewLineData(chart.getLineChartData()));
previewChart.setViewportCalculationEnabled(true);
previewChart.setViewportChangeListener(new ViewportListener());
chart.setViewportCalculationEnabled(true);
chart.setViewportChangeListener(new ChartViewPortListener());
updateStuff = true;
setViewport();
if (small_height) {
previewChart.setVisibility(View.GONE);
// quick test
Viewport moveViewPort = new Viewport(chart.getMaximumViewport());
float tempwidth = (float) moveViewPort.width() / 4;
holdViewport.left = moveViewPort.right - tempwidth;
holdViewport.right = moveViewPort.right + (moveViewPort.width() / 24);
holdViewport.top = moveViewPort.top;
holdViewport.bottom = moveViewPort.bottom;
chart.setCurrentViewport(holdViewport);
previewChart.setCurrentViewport(holdViewport);
} else {
if (homeShelf.get("time_buttons")) {
final long which_hour = PersistentStore.getLong("home-locked-hours");
if (which_hour > 0) {
hours = which_hour;
setHoursViewPort();
} else {
hours = DEFAULT_CHART_HOURS;
}
} else {
hours = DEFAULT_CHART_HOURS;
}
previewChart.setVisibility(homeShelf.get("chart_preview") ? View.VISIBLE : View.GONE);
}
if (insulinset || glucoseset || carbsset || timeset) {
if (chart != null) {
chart.setAlpha((float) 0.10);
// TODO also set buttons alpha
}
}
}
use of android.graphics.ColorFilter in project robolectric by robolectric.
the class ShadowCanvas method describeBitmap.
private void describeBitmap(Bitmap bitmap, Paint paint) {
separateLines();
ShadowBitmap shadowBitmap = Shadow.extract(bitmap);
appendDescription(shadowBitmap.getDescription());
if (paint != null) {
ColorFilter colorFilter = paint.getColorFilter();
if (colorFilter != null) {
if (colorFilter instanceof ColorMatrixColorFilter) {
ColorMatrixColorFilter colorMatrixColorFilter = (ColorMatrixColorFilter) colorFilter;
ShadowColorMatrixColorFilter shadowColorMatrixColorFilter = Shadow.extract(colorMatrixColorFilter);
ColorMatrix colorMatrix = shadowColorMatrixColorFilter.getMatrix();
appendDescription(" with ColorMatrixColorFilter<" + formatColorMatric(colorMatrix) + ">");
} else {
appendDescription(" with " + colorFilter);
}
}
}
}
use of android.graphics.ColorFilter in project glide by bumptech.
the class GifDrawableTest method testSetColorFilterSetsColorFilterOnPaint.
@Test
public void testSetColorFilterSetsColorFilterOnPaint() {
ColorFilter colorFilter = new PorterDuffColorFilter(Color.RED, Mode.ADD);
drawable.setColorFilter(colorFilter);
// Use ArgumentCaptor instead of eq() due to b/73121412 where ShadowPorterDuffColorFilter.equals
// uses a method that can't be found (PorterDuffColorFilter.getColor).
ArgumentCaptor<ColorFilter> captor = ArgumentCaptor.forClass(ColorFilter.class);
verify(paint).setColorFilter(captor.capture());
assertThat(captor.getValue()).isSameAs(colorFilter);
}
use of android.graphics.ColorFilter in project fresco by facebook.
the class ForwardingDrawableTest method testSettersAndGetters.
@Test
public void testSettersAndGetters() {
ColorFilter colorFilterMock = mock(ColorFilter.class);
Rect rectMock = mock(Rect.class);
int alpha = 77;
boolean dither = true;
boolean filterBitmap = false;
boolean visible = false;
boolean restart = false;
// when(mInnerDrawable.setVisible(visible, restart)).thenReturn(true);
when(mInnerDrawable.getOpacity()).thenReturn(11);
Assert.assertEquals(11, mDrawable.getOpacity());
mDrawable.getPadding(rectMock);
mDrawable.setAlpha(alpha);
mDrawable.setDither(dither);
mDrawable.setFilterBitmap(filterBitmap);
mDrawable.setColorFilter(colorFilterMock);
mDrawable.onBoundsChange(rectMock);
mDrawable.setVisible(visible, restart);
verify(mInnerDrawable).getPadding(rectMock);
verify(mInnerDrawable).setAlpha(alpha);
verify(mInnerDrawable).setDither(dither);
verify(mInnerDrawable).setFilterBitmap(filterBitmap);
verify(mInnerDrawable).setColorFilter(colorFilterMock);
verify(mInnerDrawable).setBounds(rectMock);
verify(mInnerDrawable).setVisible(visible, restart);
}
Aggregations