1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-08-13 17:03:48 -04:00
k-9/src/com/fsck/k9/view/ColorChip.java

79 lines
2.1 KiB
Java
Raw Normal View History

package com.fsck.k9.view;
2012-09-10 11:01:51 -04:00
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.RectF;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.PathShape;
public class ColorChip {
public static final Path CIRCULAR = new Path();
public static final Path LEFT_POINTING = new Path();
public static final Path RIGHT_POINTING = new Path();
public static final Path STAR = new Path();
public static final Path CHECKMARK = new Path();
static {
CIRCULAR.addCircle(8,8,7f,Path.Direction.CW);
CIRCULAR.close();
RIGHT_POINTING.addArc(new RectF(0f,0f,15f,15f) , 90, 180);
RIGHT_POINTING.lineTo(16f,7f);
RIGHT_POINTING.lineTo(8f, 15f);
RIGHT_POINTING.close();
LEFT_POINTING.addArc(new RectF(0f,0f,15f,15f) , 270, 180);
LEFT_POINTING.moveTo(8f, 0f);
LEFT_POINTING.lineTo(0f,7f);
LEFT_POINTING.lineTo(8f, 15f);
LEFT_POINTING.close();
STAR.moveTo(8f,0f);
STAR.lineTo(11f,5f);
STAR.lineTo(16f,6f);
STAR.lineTo(12f,10f);
STAR.lineTo(14f,16f);
STAR.lineTo(8f,13f);
STAR.lineTo(2f,16f);
STAR.lineTo(4f,10f);
STAR.lineTo(0f,6f);
STAR.lineTo(5f,5f);
STAR.lineTo(8f,0f);
STAR.close();
CHECKMARK.moveTo(0f,10f);
CHECKMARK.lineTo(6f,16f);
CHECKMARK.moveTo(6f,15f);
CHECKMARK.lineTo(16f,2f);
}
private ShapeDrawable mDrawable;
public ColorChip(int color, boolean messageRead, Path shape) {
mDrawable = new ShapeDrawable(new PathShape(shape, 16f, 16f));
2011-01-06 11:55:08 -05:00
if (shape.equals(CHECKMARK)) {
mDrawable.getPaint().setStrokeWidth(3);
} else {
mDrawable.getPaint().setStrokeWidth(1);
}
2012-09-10 11:01:51 -04:00
if (messageRead) {
// Read messages get an outlined circle
mDrawable.getPaint().setStyle(Paint.Style.STROKE);
}
2011-01-06 11:55:08 -05:00
mDrawable.getPaint().setColor(color);
}
2011-01-06 11:55:08 -05:00
public ShapeDrawable drawable() {
return mDrawable;
}
}