2010-12-28 04:11:10 -05:00
|
|
|
package com.fsck.k9.view;
|
|
|
|
|
2012-09-10 11:01:51 -04:00
|
|
|
import android.graphics.Paint;
|
2010-12-28 04:11:10 -05:00
|
|
|
import android.graphics.Path;
|
2012-09-20 23:30:52 -04:00
|
|
|
import android.graphics.RectF;
|
2010-12-28 04:11:10 -05:00
|
|
|
import android.graphics.drawable.ShapeDrawable;
|
|
|
|
import android.graphics.drawable.shapes.PathShape;
|
|
|
|
|
2011-02-06 17:09:48 -05:00
|
|
|
public class ColorChip {
|
2012-09-20 23:30:52 -04:00
|
|
|
private static final Path CIRCULAR_CHIP_PATH = new Path();
|
|
|
|
private static final Path LEFT_POINTING_CHIP_PATH = new Path();
|
|
|
|
private static final Path RIGHT_POINTING_CHIP_PATH = new Path();
|
|
|
|
private static final Path STAR_CHIP_PATH = new Path();
|
2010-12-28 04:11:10 -05:00
|
|
|
|
2011-02-06 17:09:48 -05:00
|
|
|
static {
|
2010-12-28 04:11:10 -05:00
|
|
|
|
2012-09-20 23:30:52 -04:00
|
|
|
CIRCULAR_CHIP_PATH.addCircle(8,8,7f,Path.Direction.CW);
|
|
|
|
CIRCULAR_CHIP_PATH.close();
|
|
|
|
|
2012-09-21 00:12:09 -04:00
|
|
|
RIGHT_POINTING_CHIP_PATH.addArc(new RectF(0f,0f,15f,15f) , 90, 180);
|
2012-09-21 00:50:00 -04:00
|
|
|
RIGHT_POINTING_CHIP_PATH.lineTo(16f,7f);
|
2012-09-20 23:30:52 -04:00
|
|
|
RIGHT_POINTING_CHIP_PATH.lineTo(8f, 15f);
|
|
|
|
RIGHT_POINTING_CHIP_PATH.close();
|
2010-12-28 04:11:10 -05:00
|
|
|
|
2012-09-21 00:12:09 -04:00
|
|
|
LEFT_POINTING_CHIP_PATH.addArc(new RectF(0f,0f,15f,15f) , 270, 180);
|
|
|
|
LEFT_POINTING_CHIP_PATH.moveTo(8f, 0f);
|
2012-09-21 00:50:00 -04:00
|
|
|
LEFT_POINTING_CHIP_PATH.lineTo(0f,7f);
|
2012-09-20 23:30:52 -04:00
|
|
|
LEFT_POINTING_CHIP_PATH.lineTo(8f, 15f);
|
|
|
|
LEFT_POINTING_CHIP_PATH.close();
|
|
|
|
|
|
|
|
STAR_CHIP_PATH.moveTo(8f,0f);
|
|
|
|
STAR_CHIP_PATH.lineTo(11f,5f);
|
|
|
|
STAR_CHIP_PATH.lineTo(16f,6f);
|
|
|
|
STAR_CHIP_PATH.lineTo(12f,10f);
|
|
|
|
STAR_CHIP_PATH.lineTo(14f,16f);
|
|
|
|
STAR_CHIP_PATH.lineTo(8f,13f);
|
|
|
|
STAR_CHIP_PATH.lineTo(2f,16f);
|
|
|
|
STAR_CHIP_PATH.lineTo(4f,10f);
|
|
|
|
STAR_CHIP_PATH.lineTo(0f,6f);
|
|
|
|
STAR_CHIP_PATH.lineTo(5f,5f);
|
|
|
|
STAR_CHIP_PATH.lineTo(8f,0f);
|
|
|
|
STAR_CHIP_PATH.close();
|
|
|
|
|
|
|
|
}
|
2010-12-28 04:11:10 -05:00
|
|
|
|
|
|
|
private ShapeDrawable mDrawable;
|
|
|
|
|
2012-09-20 23:30:52 -04:00
|
|
|
public ColorChip(int color, boolean messageRead, boolean toMe, boolean fromMe, boolean messageFlagged ) {
|
|
|
|
|
|
|
|
if (messageFlagged) {
|
|
|
|
mDrawable = new ShapeDrawable(new PathShape(STAR_CHIP_PATH, 16f, 16f));
|
|
|
|
} else if ( fromMe ) {
|
|
|
|
mDrawable = new ShapeDrawable(new PathShape(LEFT_POINTING_CHIP_PATH, 16f, 16f));
|
|
|
|
} else if ( toMe) {
|
|
|
|
mDrawable = new ShapeDrawable(new PathShape(RIGHT_POINTING_CHIP_PATH, 16f, 16f));
|
|
|
|
} else {
|
|
|
|
mDrawable = new ShapeDrawable(new PathShape(CIRCULAR_CHIP_PATH, 16f, 16f));
|
|
|
|
}
|
2011-01-06 11:55:08 -05:00
|
|
|
|
2012-09-20 23:30:52 -04:00
|
|
|
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);
|
2010-12-28 04:11:10 -05:00
|
|
|
|
|
|
|
|
|
|
|
}
|
2011-01-06 11:55:08 -05:00
|
|
|
|
2011-02-06 17:09:48 -05:00
|
|
|
public ShapeDrawable drawable() {
|
2010-12-28 04:11:10 -05:00
|
|
|
return mDrawable;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|