securesmartcam / app / src / main / java / org / witness / obscuracam / video / RegionBarArea.java @ 41590feb
History | View | Annotate | Download (2.32 KB)
1 |
package org.witness.obscuracam.video; |
---|---|
2 |
|
3 |
import java.util.Vector; |
4 |
|
5 |
import org.witness.obscuracam.ObscuraApp; |
6 |
|
7 |
import android.content.Context; |
8 |
import android.graphics.Bitmap; |
9 |
import android.graphics.Canvas; |
10 |
import android.graphics.Color; |
11 |
import android.graphics.Paint; |
12 |
import android.util.AttributeSet; |
13 |
import android.view.MotionEvent; |
14 |
import android.widget.ImageView; |
15 |
|
16 |
public class RegionBarArea extends ImageView { |
17 |
|
18 |
public static final String LOGTAG = ObscuraApp.TAG; |
19 |
|
20 |
public static final int COLOR_SELECTED = Color.YELLOW; |
21 |
public static final int COLOR_NOT_SELECTED = Color.BLUE; |
22 |
|
23 |
int backgroundColor = COLOR_NOT_SELECTED;
|
24 |
|
25 |
int width = 0; |
26 |
int height = 0; |
27 |
|
28 |
Vector<ObscureRegion> obscureRegions;
|
29 |
|
30 |
Bitmap RBABmp; |
31 |
Canvas RBACanvas;
|
32 |
Paint RBAPaint;
|
33 |
|
34 |
public RegionBarArea(Context context) { |
35 |
super(context);
|
36 |
} |
37 |
|
38 |
public RegionBarArea(Context context, AttributeSet attrs) { |
39 |
super(context, attrs);
|
40 |
} |
41 |
|
42 |
public RegionBarArea(Context context, AttributeSet attrs, int defStyle) { |
43 |
super(context,attrs,defStyle);
|
44 |
} |
45 |
|
46 |
public void init() { |
47 |
this.setBackgroundColor(backgroundColor);
|
48 |
} |
49 |
|
50 |
@Override
|
51 |
protected void onDraw(Canvas canvas) { |
52 |
super.onDraw(canvas);
|
53 |
|
54 |
Paint paint = new Paint(); |
55 |
paint.setColor(0xFF668800);
|
56 |
paint.setStyle(Paint.Style.FILL);
|
57 |
|
58 |
int numRegions = obscureRegions.size();
|
59 |
if (numRegions > 0) { |
60 |
int regionHeight = getHeight()/numRegions;
|
61 |
int count = 0; |
62 |
/*TODO fix this
|
63 |
for (ObscureRegion region:obscureRegions) {
|
64 |
canvas.drawRect(region.startTime/region.endTime*getWidth(),
|
65 |
count*regionHeight,
|
66 |
region.endTime/region.mediaDuration*getWidth(),
|
67 |
(count+1)*regionHeight, paint);
|
68 |
count++;
|
69 |
}
|
70 |
*/
|
71 |
} |
72 |
//canvas.drawRect(left, top, right, bottom, paint);
|
73 |
//(float)startTime/(float)1000 + "," + (float)endTime/(float)1000
|
74 |
//canvas.drawRect(10,10,width-10,height-10,paint);
|
75 |
|
76 |
|
77 |
//Log.v(LOGTAG,"Just drew " + width + " " + height);
|
78 |
} |
79 |
|
80 |
@Override
|
81 |
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { |
82 |
width = widthMeasureSpec; |
83 |
height = heightMeasureSpec; |
84 |
|
85 |
setMeasuredDimension(widthMeasureSpec,heightMeasureSpec); |
86 |
} |
87 |
|
88 |
@Override
|
89 |
public boolean onTouchEvent(MotionEvent me) { |
90 |
|
91 |
return true; |
92 |
} |
93 |
|
94 |
|
95 |
} |