Clover Coverage Report - AnCal Coverage Report
Coverage timestamp: gio dic 18 2014 12:18:42 EST
../../../../../img/srcFileCovDistChart9.png 40% of files have more coverage
104   244   35   8,67
42   195   0,34   12
12     2,92  
1    
This report was generated with an evaluation server license. Purchase Clover or configure your license.
 
  ViewTodayItemAppointment       Line # 13 104 35 81,6% 0.8164557
 
No Tests
 
1   
2    package pl.magot.vetch.ancal.views;
3   
4   
5    import android.content.Context;
6    import android.graphics.Canvas;
7    import android.graphics.Paint;
8    import android.graphics.Rect;
9    import android.graphics.Typeface;
10    import android.view.*;
11   
12   
 
13    public class ViewTodayItemAppointment extends ViewTodayItem
14    {
15    //fields
16    private final static int iColorTime = 0xFFFF8800;
17    private final static int iColorTimeFocused = 0xFFFFCC66;
18    private final static int iColorMark = 0xFFAA5500;
19    private static final String sStrTime = "00:00";
20    private static final String sStrMinutes = ":00";
21    private static final String sStrUSTimeMark = "mm"; //am/pm
22    private static final String sStrUSTimeAM = "am";
23    private static final String sStrUSTimePM = "pm";
24    private final static Typeface tfMono = Typeface.create(Typeface.MONOSPACE, Typeface.NORMAL);
25   
26    //default hour width, full time width, am/pm width
27    private int iSpaceWidthUSTimeMark = 0;
28    private int iSpaceWidthTimeArea = 0;
29    private int iSpaceWidthTime = 0;
30   
31    //fields
32    private int iHour = 0;
33    private int iMinutes = 0;
34    private boolean b24HourMode = false;
35    private boolean bAlarm = false;
36    private boolean bRepeat = false;
37    private boolean bShowMinutesOnly = false;
38   
39    //methods
 
40  51 toggle public ViewTodayItemAppointment(Context context)
41    {
42  51 super(context);
43    }
44   
 
45  51 toggle public void SetItemData(String sText, boolean bAlarm, boolean bRepeat)
46    {
47  51 SetText(sText);
48  51 this.bAlarm = bAlarm;
49  51 this.bRepeat = bRepeat;
50    }
51   
 
52  51 toggle public void SetItemTime(int iHour, int iMinutes, boolean bShowMinutesOnly, boolean b24HourMode, int iSpaceWidthTime, int iSpaceWidthMinutes, int iSpaceWidthUSTimeMark)
53    {
54  51 this.iHour = iHour;
55  51 this.iMinutes = iMinutes;
56  51 this.b24HourMode = b24HourMode;
57  51 this.bShowMinutesOnly = bShowMinutesOnly;
58  51 this.iSpaceWidthUSTimeMark = (b24HourMode?0:(iFrame + iSpaceWidthUSTimeMark));
59  51 if (bShowMinutesOnly)
60    {
61  24 this.iSpaceWidthTime = iSpaceWidthMinutes;
62    } else {
63  27 this.iSpaceWidthTime = iSpaceWidthTime + (b24HourMode?0:(iFrame + iSpaceWidthUSTimeMark));
64    }
65  51 this.iSpaceWidthTimeArea = iSpace + this.iSpaceWidthTime + iSpace;
66    }
67   
 
68  2 toggle public static int GetSpaceWidthTime(Paint mpt)
69    {
70  2 mpt.setTypeface(tfMono);
71  2 mpt.setTextSize(ViewTodayItem.fTextSize);
72  2 mpt.setFakeBoldText(true);
73  2 return (int)mpt.measureText(sStrTime);
74    }
75   
 
76  2 toggle public static int GetSpaceWidthMinutes(Paint mpt)
77    {
78  2 mpt.setTypeface(tfMono);
79  2 mpt.setTextSize(ViewTodayItem.fTextSize);
80  2 mpt.setFakeBoldText(true);
81  2 return (int)mpt.measureText(sStrMinutes);
82    }
83   
 
84  2 toggle public static int GetSpaceWidthUSTimeMark(Paint mpt)
85    {
86  2 mpt.setTypeface(tfMono);
87  2 mpt.setTextSize(ViewTodayItem.fTextSize);
88  2 mpt.setFakeBoldText(false);
89  2 return (int)mpt.measureText(sStrUSTimeMark);
90    }
91   
 
92  0 toggle @Override
93    protected void onFocusChanged(boolean gainFocus, int direction, Rect previouslyFocusedRect)
94    {
95  0 super.onFocusChanged(gainFocus, direction, previouslyFocusedRect);
96   
97    //refresh parent view for Day View
98  0 ViewParent parent = getParent();
99  0 if (parent != null)
100    {
101  0 if (parent instanceof ViewDayHourItem)
102    {
103  0 try
104    {
105  0 ViewDayHourItem item = (ViewDayHourItem)parent;
106  0 if (item != null)
107  0 item.invalidate();
108    } catch (Exception e) {
109    }
110    }
111    }
112    }
113   
 
114  586 toggle @Override
115    protected void onDraw(Canvas canvas)
116    {
117  586 super.onDraw(canvas);
118   
119  586 mpt.setAntiAlias(true);
120  586 mpt.setTextSize(fTextSize);
121  586 mpt.setTypeface(tfMono);
122  586 mpt.setFakeBoldText(true);
123  586 mpt.setShader(null);
124  586 mpt.setUnderlineText(false);
125   
126  586 final boolean bIsFocused = hasFocus();
127  586 final int iHeight = getHeight() - iFrame;
128  586 final int iWidth = getWidth();
129  586 final int iTimePosY = iMargin - (int)mpt.ascent();
130   
131    //draw time
132  586 DrawTime(canvas, iTimePosY, iWidth, iHeight, bIsFocused);
133   
134    //draw text
135  586 int iTextClipWidth = getWidth() - iSpace;
136  586 if (bAlarm)
137  288 iTextClipWidth -= iIconW;
138  586 if (bRepeat)
139  448 iTextClipWidth -= iIconW;
140   
141  586 final int iHeaderOffsetX = (bShowMinutesOnly?0:ViewTodayItemHeader.GetTextPosX());
142  586 final int iTextPosX = iHeaderOffsetX + iSpaceWidthTimeArea;
143   
144  586 mpt.setTypeface(null);
145  586 DrawItemText(canvas, iTextPosX, iTimePosY, iTextClipWidth, iColorTextActive_enabled);
146   
147    //draw icons
148  586 int iIconX = getWidth();
149  586 int iIconY = (this.getHeight() >> 1) - (iIconH >> 1);
150   
151    //draw icon repeat
152  586 if (bRepeat)
153    {
154  448 iIconX -= iIconW;
155  448 iconRepeat.setBounds(iIconX, iIconY, iIconX + iIconW, iIconY + iIconH);
156  448 iconRepeat.draw(canvas);
157    }
158    //draw icon alarm
159  586 if (bAlarm)
160    {
161  288 iIconX -= iIconW;
162  288 iconAlarm.setBounds(iIconX, iIconY, iIconX + iIconW, iIconY + iIconH);
163  288 iconAlarm.draw(canvas);
164    }
165    }
166   
 
167  586 toggle private String GetTimeString()
168    {
169  586 if (bShowMinutesOnly)
170    {
171  271 return GetMinutesString();
172    } else {
173  315 if (b24HourMode)
174    {
175  0 return Integer.toString(iHour) + GetMinutesString();
176    } else {
177  315 int iDisplayHour = iHour;
178  315 if (iDisplayHour == 0)
179  315 iDisplayHour = 12;
180  315 if (iDisplayHour > 12)
181  0 iDisplayHour -= 12;
182  315 return Integer.toString(iDisplayHour) + GetMinutesString();
183    }
184    }
185    }
186   
 
187  586 toggle private String GetMinutesString()
188    {
189  586 if (iMinutes > 9)
190  0 return ":" + Integer.toString(iMinutes);
191  586 return ":0" + Integer.toString(iMinutes);
192    }
193   
 
194  315 toggle private String GetUSTimeMark()
195    {
196  315 if (iHour >= 12)
197  0 return sStrUSTimePM;
198  315 return sStrUSTimeAM;
199    }
200   
 
201  586 toggle private void DrawTime(Canvas canvas, int iTimePosY, int iWidth, int iHeight, boolean bIsFocused)
202    {
203  586 mpt.setAntiAlias(true);
204  586 mpt.setTextSize(fTextSize);
205  586 mpt.setTypeface(tfMono);
206  586 mpt.setFakeBoldText(true);
207  586 mpt.setShader(null);
208  586 mpt.setUnderlineText(false);
209   
210    //draw time
211  586 final String sTime = GetTimeString();
212  586 final int iStrTimeWidth = (int)mpt.measureText(sTime);
213   
214  586 int iTimePosX = 0;
215  586 if (bShowMinutesOnly)
216    {
217  271 iTimePosX = iSpace;
218    } else {
219  315 iTimePosX = iSpaceWidthTimeArea - iStrTimeWidth - iSpaceWidthUSTimeMark - iSpace;
220  315 iTimePosX += ViewTodayItemHeader.GetTextPosX();
221    }
222   
223  586 mpt.setColor(iColorTime);
224  586 if (bIsFocused)
225  0 mpt.setColor(iColorTimeFocused);
226   
227  586 canvas.drawText(sTime, iTimePosX, iTimePosY, mpt);
228   
229    //draw minutes
230  586 int iMarkPosX = iTimePosX + iStrTimeWidth + iFrame;
231   
232    //draw us time mark
233  586 if ((!b24HourMode) && (!bShowMinutesOnly))
234    {
235  315 mpt.setFakeBoldText(false);
236  315 mpt.setColor(iColorMark);
237  315 if (bIsFocused)
238  0 mpt.setColor(iColorTimeFocused);
239  315 canvas.drawText(GetUSTimeMark(), iMarkPosX, iTimePosY, mpt);
240    }
241    }
242   
243   
244    }