2010-12-28 04:11:10 -05:00
|
|
|
package com.fsck.k9.view;
|
|
|
|
|
2014-09-12 00:35:07 -04:00
|
|
|
|
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;
|
|
|
|
|
2014-09-12 00:35:07 -04:00
|
|
|
|
2011-02-06 17:09:48 -05:00
|
|
|
public class ColorChip {
|
2012-09-21 16:44:39 -04:00
|
|
|
public static final Path CIRCULAR = new Path();
|
|
|
|
public static final Path LEFT_POINTING = new Path();
|
|
|
|
public static final Path RIGHT_POINTING = new Path();
|
2012-10-02 20:51:38 -04:00
|
|
|
public static final Path RIGHT_NOTCH = new Path();
|
2012-09-21 16:44:39 -04:00
|
|
|
public static final Path STAR = new Path();
|
2010-12-28 04:11:10 -05:00
|
|
|
|
2012-09-21 16:44:39 -04:00
|
|
|
static {
|
2014-09-12 00:35:07 -04:00
|
|
|
CIRCULAR.addCircle(160, 160, 70f, Path.Direction.CW);
|
2012-09-21 16:44:39 -04:00
|
|
|
CIRCULAR.close();
|
|
|
|
|
2014-09-12 00:35:07 -04:00
|
|
|
RIGHT_POINTING.addArc(new RectF(80f, 80f, 240f, 240f), 90, 180);
|
|
|
|
RIGHT_POINTING.arcTo(new RectF(160f, 0f, 320f, 160f), 180, -90);
|
|
|
|
RIGHT_POINTING.arcTo(new RectF(160f, 160f, 320f, 320f), 270, -90);
|
2012-09-21 16:44:39 -04:00
|
|
|
RIGHT_POINTING.close();
|
|
|
|
|
2014-09-12 00:35:07 -04:00
|
|
|
RIGHT_NOTCH.addArc(new RectF(80f, 80f, 240f, 240f), 90, 180);
|
|
|
|
RIGHT_NOTCH.arcTo(new RectF(160f, 0f, 320f, 160f), 180, -90);
|
|
|
|
RIGHT_NOTCH.arcTo(new RectF(160f, 160f, 320f, 320f), 270, -90);
|
2012-10-02 20:51:38 -04:00
|
|
|
RIGHT_NOTCH.close();
|
|
|
|
|
2014-09-12 00:35:07 -04:00
|
|
|
LEFT_POINTING.addArc(new RectF(80f, 80f, 240f, 240f), 90, -180);
|
|
|
|
LEFT_POINTING.arcTo(new RectF(00f, 00f, 160f, 160f), 0, 90);
|
|
|
|
LEFT_POINTING.arcTo(new RectF(00f, 160f, 160f, 320f), 270, 90);
|
2012-09-21 16:44:39 -04:00
|
|
|
LEFT_POINTING.close();
|
|
|
|
|
2014-09-12 00:35:07 -04:00
|
|
|
STAR.moveTo(140f, 60f);
|
|
|
|
STAR.lineTo(170f, 110f);
|
|
|
|
STAR.lineTo(220f, 120f);
|
|
|
|
STAR.lineTo(180f, 160f);
|
|
|
|
STAR.lineTo(200f, 220f);
|
|
|
|
STAR.lineTo(140f, 190f);
|
|
|
|
STAR.lineTo(80f, 220f);
|
|
|
|
STAR.lineTo(100f, 160f);
|
|
|
|
STAR.lineTo(60f, 120f);
|
|
|
|
STAR.lineTo(110f, 110f);
|
|
|
|
STAR.lineTo(140f, 60f);
|
2012-09-21 16:44:39 -04:00
|
|
|
STAR.close();
|
2012-09-20 23:30:52 -04:00
|
|
|
}
|
2010-12-28 04:11:10 -05:00
|
|
|
|
|
|
|
|
2014-09-12 00:35:07 -04:00
|
|
|
private ShapeDrawable mDrawable;
|
2012-09-20 23:30:52 -04:00
|
|
|
|
2012-09-21 16:44:39 -04:00
|
|
|
public ColorChip(int color, boolean messageRead, Path shape) {
|
2012-10-02 20:51:38 -04:00
|
|
|
if (shape.equals(STAR)) {
|
|
|
|
mDrawable = new ShapeDrawable(new PathShape(shape, 280f, 280f));
|
|
|
|
} else {
|
|
|
|
mDrawable = new ShapeDrawable(new PathShape(shape, 320f, 320f));
|
|
|
|
}
|
2014-09-12 00:26:03 -04:00
|
|
|
|
2012-09-10 11:01:51 -04:00
|
|
|
if (messageRead) {
|
|
|
|
// Read messages get an outlined circle
|
|
|
|
mDrawable.getPaint().setStyle(Paint.Style.STROKE);
|
2012-09-24 19:25:34 -04:00
|
|
|
} else {
|
|
|
|
// Unread messages get filled, while retaining the outline, so that they stay the same size
|
|
|
|
mDrawable.getPaint().setStyle(Paint.Style.FILL_AND_STROKE);
|
2012-09-10 11:01:51 -04:00
|
|
|
}
|
2010-12-28 04:11:10 -05:00
|
|
|
|
2014-09-12 00:26:03 -04:00
|
|
|
mDrawable.getPaint().setStrokeWidth(20);
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|