1 |
|
package pl.magot.vetch.ancal.agenda; |
2 |
|
|
3 |
|
|
4 |
|
import java.util.Calendar; |
5 |
|
import pl.magot.vetch.ancal.AnCal; |
6 |
|
import pl.magot.vetch.ancal.CommonActivity; |
7 |
|
import pl.magot.vetch.ancal.R; |
8 |
|
import pl.magot.vetch.ancal.dataview.DataView; |
9 |
|
import pl.magot.vetch.ancal.views.ViewTodayItemAppointment; |
10 |
|
import pl.magot.vetch.ancal.views.ViewTodayItemTask; |
11 |
|
import pl.magot.vetch.ancal.views.ViewTodayItemNote; |
12 |
|
import pl.magot.vetch.ancal.views.ViewTodayItem; |
13 |
|
import pl.magot.vetch.ancal.views.ViewTodayItemHeader; |
14 |
|
import android.os.*; |
15 |
|
import android.view.*; |
16 |
|
import android.view.ViewGroup.LayoutParams; |
17 |
|
import android.widget.LinearLayout; |
18 |
|
|
19 |
|
|
|
|
| 89,4% |
Uncovered Elements: 17 (161) |
Complexity: 40 |
Complexity Density: 0,39 |
|
20 |
|
public abstract class AgendaView |
21 |
|
{ |
22 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 0 |
Complexity Density: - |
|
23 |
|
public interface OnViewItemClick |
24 |
|
{ |
25 |
|
public void OnClick(View v, Bundle extras); |
26 |
|
} |
27 |
|
|
28 |
|
|
29 |
|
public ViewTodayItemAppointment.OnItemClick onApptItemClick = new ViewTodayItemAppointment.OnItemClick() |
30 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
31 |
2
|
public void OnClick(ViewTodayItem item) {... |
32 |
2
|
doSubItemClick(item, ViewTodayItemHeader.ViewType.Appointments, item.GetRowId()); |
33 |
|
} |
34 |
|
}; |
35 |
|
|
36 |
|
|
37 |
|
public ViewTodayItemTask.OnItemClick onTaskItemClick = new ViewTodayItemTask.OnItemClick() |
38 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
39 |
3
|
public void OnClick(ViewTodayItem item) {... |
40 |
3
|
doSubItemClick(item, ViewTodayItemHeader.ViewType.Tasks, item.GetRowId()); |
41 |
|
} |
42 |
|
}; |
43 |
|
|
44 |
|
|
45 |
|
public ViewTodayItemNote.OnItemClick onNoteItemClick = new ViewTodayItemNote.OnItemClick() |
46 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
47 |
2
|
public void OnClick(ViewTodayItem item) {... |
48 |
2
|
doSubItemClick(item, ViewTodayItemHeader.ViewType.Notes, item.GetRowId()); |
49 |
|
} |
50 |
|
}; |
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
protected AnCal main = null; |
55 |
|
protected LinearLayout llayParent = null; |
56 |
|
protected LinearLayout.LayoutParams lpParent = null; |
57 |
|
protected LinearLayout.LayoutParams lparams = null; |
58 |
|
|
59 |
|
|
60 |
|
protected LinearLayout llayParentAppt = null; |
61 |
|
protected LinearLayout llayParentTask = null; |
62 |
|
protected LinearLayout llayParentNote = null; |
63 |
|
|
64 |
|
|
65 |
|
protected static OnViewItemClick itemAgendaViewClick = null; |
66 |
|
|
67 |
|
|
68 |
|
protected String sTextNone = ""; |
69 |
|
private boolean bLastTimeFormat = false; |
70 |
|
|
71 |
|
|
72 |
|
private Calendar calDateToday = Calendar.getInstance(); |
73 |
|
private Calendar calViewStartDate = Calendar.getInstance(); |
74 |
|
protected Calendar calCurrMonth = Calendar.getInstance(); |
75 |
|
|
76 |
|
|
77 |
|
private int iMonthViewCurrentMonth = -1; |
78 |
|
private int iMonthViewCurrentYear = -1; |
79 |
|
|
80 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (21) |
Complexity: 1 |
Complexity Density: 0,05 |
|
81 |
4
|
AgendaView(AnCal main)... |
82 |
|
{ |
83 |
4
|
this.main = main; |
84 |
|
|
85 |
|
|
86 |
4
|
lpParent = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); |
87 |
4
|
lparams = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); |
88 |
|
|
89 |
|
|
90 |
4
|
llayParent = new LinearLayout(main); |
91 |
4
|
llayParent.setPadding(0, 0, 0, 0); |
92 |
4
|
llayParent.setOrientation(LinearLayout.VERTICAL); |
93 |
4
|
llayParent.setLayoutParams(lpParent); |
94 |
|
|
95 |
|
|
96 |
4
|
llayParentAppt = new LinearLayout(main); |
97 |
4
|
llayParentAppt.setPadding(0, 0, 0, 2); |
98 |
4
|
llayParentAppt.setOrientation(LinearLayout.VERTICAL); |
99 |
4
|
llayParentAppt.setLayoutParams(lparams); |
100 |
|
|
101 |
4
|
llayParentTask = new LinearLayout(main); |
102 |
4
|
llayParentTask.setPadding(0, 0, 0, 2); |
103 |
4
|
llayParentTask.setOrientation(LinearLayout.VERTICAL); |
104 |
4
|
llayParentTask.setLayoutParams(lparams); |
105 |
|
|
106 |
4
|
llayParentNote = new LinearLayout(main); |
107 |
4
|
llayParentNote.setPadding(0, 0, 0, 2); |
108 |
4
|
llayParentNote.setOrientation(LinearLayout.VERTICAL); |
109 |
4
|
llayParentNote.setLayoutParams(lparams); |
110 |
|
|
111 |
|
|
112 |
4
|
sTextNone = main.utils.GetResStr(R.string.labTodayItemNone); |
113 |
|
|
114 |
4
|
bLastTimeFormat = main.prefs.b24HourMode; |
115 |
|
} |
116 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
117 |
1
|
public static void SetItemClick(OnViewItemClick itemClick) ... |
118 |
|
{ |
119 |
1
|
itemAgendaViewClick = itemClick; |
120 |
|
} |
121 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
122 |
20
|
public LinearLayout GetParentLayout()... |
123 |
|
{ |
124 |
20
|
return llayParent; |
125 |
|
} |
126 |
|
|
127 |
|
public abstract void Rebuild(); |
128 |
|
public abstract AgendaViewType GetViewType(); |
129 |
|
public abstract int GetViewIndex(); |
130 |
|
|
|
|
| 85,7% |
Uncovered Elements: 1 (7) |
Complexity: 2 |
Complexity Density: 0,4 |
|
131 |
9
|
public void doHeaderItemClick(View v, ViewTodayItemHeader.ViewType type)... |
132 |
|
{ |
133 |
9
|
if (itemAgendaViewClick != null) |
134 |
|
{ |
135 |
9
|
Bundle extras = new Bundle(); |
136 |
9
|
extras.putString("type", type.toString()); |
137 |
9
|
extras.putLong(CommonActivity.bundleRowId, -1L); |
138 |
9
|
itemAgendaViewClick.OnClick(v, extras); |
139 |
|
} |
140 |
|
} |
141 |
|
|
|
|
| 85,7% |
Uncovered Elements: 1 (7) |
Complexity: 2 |
Complexity Density: 0,4 |
|
142 |
7
|
public void doSubItemClick(View v, ViewTodayItemHeader.ViewType type, long lRowId)... |
143 |
|
{ |
144 |
7
|
if (itemAgendaViewClick != null) |
145 |
|
{ |
146 |
7
|
Bundle extras = new Bundle(); |
147 |
7
|
extras.putString("type", type.toString()); |
148 |
7
|
extras.putLong(CommonActivity.bundleRowId, lRowId); |
149 |
7
|
itemAgendaViewClick.OnClick(v, extras); |
150 |
|
} |
151 |
|
} |
152 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 2 |
Complexity Density: 0,29 |
|
153 |
0
|
public void doHourOfDayClick(View v, ViewTodayItemHeader.ViewType type, int iHourOfDay, int iMinutes)... |
154 |
|
{ |
155 |
0
|
if (itemAgendaViewClick != null) |
156 |
|
{ |
157 |
0
|
Bundle extras = new Bundle(); |
158 |
0
|
extras.putString("type", type.toString()); |
159 |
0
|
extras.putLong(CommonActivity.bundleRowId, -1L); |
160 |
0
|
extras.putInt(CommonActivity.bundleHourOfDay, iHourOfDay); |
161 |
0
|
extras.putInt(CommonActivity.bundleMinutes, iMinutes); |
162 |
0
|
itemAgendaViewClick.OnClick(v, extras); |
163 |
|
} |
164 |
|
} |
165 |
|
|
166 |
|
public abstract void RebuildViewAppointments(DataView dataView); |
167 |
|
public abstract void RebuildViewTasks(DataView dataView); |
168 |
|
public abstract void RebuildViewNotes(DataView dataView); |
169 |
|
|
170 |
|
public abstract void UpdateTimeFormat(); |
171 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (14) |
Complexity: 4 |
Complexity Density: 0,5 |
|
172 |
44
|
public void SetViewStartDate(Calendar date)... |
173 |
|
{ |
174 |
44
|
if (date == null) |
175 |
|
{ |
176 |
19
|
calViewStartDate.setTimeInMillis(System.currentTimeMillis()); |
177 |
|
} else { |
178 |
25
|
calViewStartDate.setTimeInMillis(date.getTimeInMillis()); |
179 |
|
} |
180 |
|
|
181 |
44
|
calViewStartDate.setFirstDayOfWeek(main.prefs.iFirstDayOfWeek); |
182 |
|
|
183 |
44
|
if (GetViewType() == AgendaViewType.WEEK) |
184 |
18
|
UpdateStartDateForWeek(); |
185 |
44
|
if (GetViewType() == AgendaViewType.MONTH) |
186 |
9
|
UpdateStartDateForMonth(); |
187 |
|
} |
188 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
189 |
39
|
private void UpdateStartDateForWeek()... |
190 |
|
{ |
191 |
39
|
int iDay = calViewStartDate.get(Calendar.DAY_OF_WEEK) - main.prefs.iFirstDayOfWeek; |
192 |
39
|
calViewStartDate.add(Calendar.DAY_OF_WEEK, -iDay); |
193 |
|
} |
194 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0,25 |
|
195 |
21
|
private void UpdateStartDateForMonth()... |
196 |
|
{ |
197 |
21
|
iMonthViewCurrentMonth = calViewStartDate.get(Calendar.MONTH); |
198 |
21
|
iMonthViewCurrentYear = calViewStartDate.get(Calendar.YEAR); |
199 |
21
|
calViewStartDate.set(Calendar.DAY_OF_MONTH, 1); |
200 |
21
|
UpdateStartDateForWeek(); |
201 |
|
} |
202 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
203 |
388
|
public Calendar GetViewStartDate()... |
204 |
|
{ |
205 |
388
|
return calViewStartDate; |
206 |
|
} |
207 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (21) |
Complexity: 5 |
Complexity Density: 0,38 |
|
208 |
19
|
public void SetPrevViewItem()... |
209 |
|
{ |
210 |
19
|
if (GetViewType() == AgendaViewType.DAY) |
211 |
6
|
calViewStartDate.add(Calendar.DAY_OF_YEAR, -1); |
212 |
19
|
if (GetViewType() == AgendaViewType.WEEK) |
213 |
6
|
calViewStartDate.add(Calendar.WEEK_OF_YEAR, -1); |
214 |
|
|
215 |
19
|
if (GetViewType() == AgendaViewType.MONTH) |
216 |
|
{ |
217 |
7
|
iMonthViewCurrentMonth--; |
218 |
7
|
if (iMonthViewCurrentMonth == -1) |
219 |
|
{ |
220 |
1
|
iMonthViewCurrentMonth = 11; |
221 |
1
|
iMonthViewCurrentYear--; |
222 |
|
} |
223 |
7
|
calViewStartDate.set(Calendar.DAY_OF_MONTH, 1); |
224 |
7
|
calViewStartDate.set(Calendar.MONTH, iMonthViewCurrentMonth); |
225 |
7
|
calViewStartDate.set(Calendar.YEAR, iMonthViewCurrentYear); |
226 |
|
|
227 |
7
|
UpdateStartDateForMonth(); |
228 |
|
} |
229 |
|
} |
230 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
231 |
19
|
public void SetTodayViewItem()... |
232 |
|
{ |
233 |
19
|
SetViewStartDate(null); |
234 |
|
} |
235 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (21) |
Complexity: 5 |
Complexity Density: 0,38 |
|
236 |
21
|
public void SetNextViewItem()... |
237 |
|
{ |
238 |
21
|
if (GetViewType() == AgendaViewType.DAY) |
239 |
4
|
calViewStartDate.add(Calendar.DAY_OF_YEAR, 1); |
240 |
21
|
if (GetViewType() == AgendaViewType.WEEK) |
241 |
12
|
calViewStartDate.add(Calendar.WEEK_OF_YEAR, 1); |
242 |
|
|
243 |
21
|
if (GetViewType() == AgendaViewType.MONTH) |
244 |
|
{ |
245 |
5
|
iMonthViewCurrentMonth++; |
246 |
5
|
if (iMonthViewCurrentMonth == 12) |
247 |
|
{ |
248 |
1
|
iMonthViewCurrentMonth = 0; |
249 |
1
|
iMonthViewCurrentYear++; |
250 |
|
} |
251 |
5
|
calViewStartDate.set(Calendar.DAY_OF_MONTH, 1); |
252 |
5
|
calViewStartDate.set(Calendar.MONTH, iMonthViewCurrentMonth); |
253 |
5
|
calViewStartDate.set(Calendar.YEAR, iMonthViewCurrentYear); |
254 |
|
|
255 |
5
|
UpdateStartDateForMonth(); |
256 |
|
} |
257 |
|
} |
258 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
259 |
126
|
public int GetCurrentSelectedMonth()... |
260 |
|
{ |
261 |
126
|
return iMonthViewCurrentMonth; |
262 |
|
} |
263 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
264 |
0
|
public int GetCurrentSelectedYear()... |
265 |
|
{ |
266 |
0
|
return iMonthViewCurrentYear; |
267 |
|
} |
268 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0,25 |
|
269 |
21
|
public Calendar GetCurrentSelectedMonthAsCalendar()... |
270 |
|
{ |
271 |
21
|
calCurrMonth.set(Calendar.DAY_OF_MONTH, 1); |
272 |
21
|
calCurrMonth.set(Calendar.MONTH, iMonthViewCurrentMonth); |
273 |
21
|
calCurrMonth.set(Calendar.YEAR, iMonthViewCurrentYear); |
274 |
21
|
return calCurrMonth; |
275 |
|
} |
276 |
|
|
|
|
| 66,7% |
Uncovered Elements: 2 (6) |
Complexity: 2 |
Complexity Density: 0,5 |
|
277 |
1
|
public boolean TimeFormatChanged() ... |
278 |
|
{ |
279 |
1
|
if (bLastTimeFormat == main.prefs.b24HourMode) |
280 |
0
|
return false; |
281 |
1
|
bLastTimeFormat = main.prefs.b24HourMode; |
282 |
1
|
return true; |
283 |
|
} |
284 |
|
|
|
|
| 91,7% |
Uncovered Elements: 1 (12) |
Complexity: 4 |
Complexity Density: 0,67 |
|
285 |
61
|
protected boolean IsViewToday()... |
286 |
|
{ |
287 |
61
|
calDateToday.setTimeInMillis(System.currentTimeMillis()); |
288 |
61
|
if (calDateToday.get(Calendar.YEAR) == calViewStartDate.get(Calendar.YEAR)) |
289 |
52
|
if (calDateToday.get(Calendar.MONTH) == calViewStartDate.get(Calendar.MONTH)) |
290 |
52
|
if (calDateToday.get(Calendar.DAY_OF_MONTH) == calViewStartDate.get(Calendar.DAY_OF_MONTH)) |
291 |
27
|
return true; |
292 |
34
|
return false; |
293 |
|
} |
294 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
295 |
61
|
protected int getTodayCurrentHour()... |
296 |
|
{ |
297 |
61
|
calDateToday.setTimeInMillis(System.currentTimeMillis()); |
298 |
61
|
return calDateToday.get(Calendar.HOUR_OF_DAY); |
299 |
|
} |
300 |
|
|
301 |
|
} |