1 |
|
|
2 |
|
|
3 |
|
@author |
4 |
|
|
5 |
|
package pl.magot.vetch.ancal; |
6 |
|
|
7 |
|
import java.util.*; |
8 |
|
|
9 |
|
import pl.magot.vetch.ancal.agenda.*; |
10 |
|
import pl.magot.vetch.ancal.database.*; |
11 |
|
import pl.magot.vetch.ancal.dataview.*; |
12 |
|
import pl.magot.vetch.ancal.views.*; |
13 |
|
import pl.magot.vetch.ancal.reminder.AlarmService; |
14 |
|
import pl.magot.vetch.widgets.*; |
15 |
|
import android.view.MenuItem; |
16 |
|
import android.view.View; |
17 |
|
import android.view.Menu; |
18 |
|
import android.view.ViewGroup.MarginLayoutParams; |
19 |
|
import android.widget.*; |
20 |
|
import android.widget.LinearLayout.*; |
21 |
|
import android.content.Intent; |
22 |
|
import android.os.*; |
23 |
|
import android.content.*; |
24 |
|
|
25 |
|
|
|
|
| 91,4% |
Uncovered Elements: 40 (465) |
Complexity: 110 |
Complexity Density: 0,35 |
|
26 |
|
public class AnCal extends CommonActivity { |
27 |
|
private Calendar dateToday = Calendar.getInstance(); |
28 |
|
private AgendaViewType currentAgendaViewType = AgendaViewType.TODAY; |
29 |
|
|
30 |
|
|
31 |
|
private final int miNewAppt = Menu.FIRST; |
32 |
|
private final int miNewTask = Menu.FIRST + 1; |
33 |
|
private final int miNewNote = Menu.FIRST + 2; |
34 |
|
private final int miShowAllTasks = Menu.FIRST + 3; |
35 |
|
private final int miOptions = Menu.FIRST + 4; |
36 |
|
private final int miAbout = Menu.FIRST + 5; |
37 |
|
|
38 |
|
|
39 |
|
private ScrollView scrollViewAgenda = null; |
40 |
|
protected RelativeLayout rlayAgendaTop = null; |
41 |
|
|
42 |
|
@SuppressWarnings("all") |
43 |
|
protected RelativeLayout rlayAgenda = null; |
44 |
|
|
45 |
|
@SuppressWarnings("all") |
46 |
|
protected RelativeLayout rlayAgendaView = null; |
47 |
|
protected LinearLayout llayAgendaData = null; |
48 |
|
|
49 |
|
|
50 |
|
private AgendaView CurrentAgendaView = null; |
51 |
|
private AgendaViewToday AgendaViewToday = null; |
52 |
|
private AgendaViewDay AgendaViewDay = null; |
53 |
|
private AgendaViewWeek AgendaViewWeek = null; |
54 |
|
private AgendaViewMonth AgendaViewMonth = null; |
55 |
|
|
56 |
|
|
57 |
|
protected DataViewAppointment dataViewAppt = null; |
58 |
|
protected DataViewTask dataViewTask = null; |
59 |
|
protected DataViewNote dataViewNote = null; |
60 |
|
|
61 |
|
|
62 |
|
private Handler handlerUpdateDate = new Handler(); |
63 |
|
private Handler handlerUpdateView = new Handler(); |
64 |
|
private final static int iHandlerUpdateTime = 1000 * 5; |
65 |
|
private int iUpdateDate_minute = 0; |
66 |
|
|
67 |
|
|
68 |
|
protected TextView labWeekStr = null; |
69 |
|
protected TextView labWeekNr = null; |
70 |
|
|
71 |
|
private TextView labSelectViewItem = null; |
72 |
|
private ViewImgButton btnSelectViewItemPrev = null; |
73 |
|
private Button btnSelectViewItemToday = null; |
74 |
|
private ViewImgButton btnSelectViewItemNext = null; |
75 |
|
|
76 |
|
|
77 |
|
private Button btnSetViewToday = null; |
78 |
|
private Button btnSetViewDay = null; |
79 |
|
private Button btnSetViewWeek = null; |
80 |
|
private Button btnSetViewMonth = null; |
81 |
|
|
82 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0,2 |
|
83 |
1
|
@Override... |
84 |
|
public void onCreate(Bundle icicle) { |
85 |
1
|
super.onCreate(icicle); |
86 |
1
|
setContentView(R.layout.agenda); |
87 |
1
|
InitViews(); |
88 |
1
|
InitStateOnce(); |
89 |
1
|
StartReminderService(); |
90 |
|
} |
91 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
92 |
24
|
@Override... |
93 |
|
public void onStart() { |
94 |
24
|
super.onStart(); |
95 |
|
|
96 |
|
} |
97 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
98 |
26
|
@Override... |
99 |
|
public void onResume() { |
100 |
26
|
super.onResume(); |
101 |
|
|
102 |
|
} |
103 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
104 |
26
|
@Override... |
105 |
|
public void onPause() { |
106 |
26
|
super.onPause(); |
107 |
|
|
108 |
|
} |
109 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
110 |
24
|
@Override... |
111 |
|
public void onStop() { |
112 |
24
|
super.onStop(); |
113 |
|
|
114 |
|
} |
115 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
116 |
0
|
@Override... |
117 |
|
public void onDestroy() { |
118 |
0
|
super.onDestroy(); |
119 |
0
|
handlerUpdateDate.removeCallbacks(handlerUpdateDateTask); |
120 |
|
} |
121 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (20) |
Complexity: 1 |
Complexity Density: 0,05 |
|
122 |
1
|
@Override... |
123 |
|
public boolean onCreateOptionsMenu(Menu menu) { |
124 |
1
|
super.onCreateOptionsMenu(menu); |
125 |
|
|
126 |
|
|
127 |
1
|
MenuItem mi = menu.add(0, miNewAppt, 0, R.string.actionNewAppointment); |
128 |
1
|
mi.setShortcut('1', 'a'); |
129 |
1
|
mi.setIcon(R.drawable.menuiconappt); |
130 |
|
|
131 |
1
|
mi = menu.add(0, miNewTask, 1, R.string.actionNewTask); |
132 |
1
|
mi.setShortcut('2', 't'); |
133 |
1
|
mi.setIcon(R.drawable.menuicontask); |
134 |
|
|
135 |
1
|
mi = menu.add(0, miNewNote, 2, R.string.actionNewNote); |
136 |
1
|
mi.setShortcut('3', 'n'); |
137 |
1
|
mi.setIcon(R.drawable.menuiconnote); |
138 |
|
|
139 |
1
|
mi = menu.add(2, miShowAllTasks, 3, R.string.actionShowAllTasks); |
140 |
1
|
mi.setCheckable(true); |
141 |
1
|
mi.setChecked(prefs.bShowAllTasks); |
142 |
1
|
menuItemUpdateIcons(mi); |
143 |
|
|
144 |
1
|
mi = menu.add(4, miOptions, 4, R.string.actionOptions); |
145 |
1
|
mi.setShortcut('5', 'o'); |
146 |
1
|
mi.setIcon(R.drawable.menuiconprefs); |
147 |
|
|
148 |
1
|
mi = menu.add(4, miAbout, 5, R.string.actionAbout); |
149 |
1
|
mi.setIcon(R.drawable.menuiconabout); |
150 |
|
|
151 |
1
|
return true; |
152 |
|
} |
153 |
|
|
|
|
| 87,5% |
Uncovered Elements: 1 (8) |
Complexity: 3 |
Complexity Density: 0,75 |
|
154 |
4
|
public void menuItemUpdateIcons(MenuItem item) {... |
155 |
4
|
if (item.getItemId() == miShowAllTasks) |
156 |
4
|
if (item.isChecked()) { |
157 |
2
|
item.setIcon(R.drawable.menuiconshowtasksdue); |
158 |
|
} else { |
159 |
2
|
item.setIcon(R.drawable.menuiconshowtasks); |
160 |
|
} |
161 |
|
} |
162 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (24) |
Complexity: 7 |
Complexity Density: 0,29 |
|
163 |
9
|
@Override... |
164 |
|
public boolean onOptionsItemSelected(MenuItem item) { |
165 |
9
|
switch (item.getItemId()) { |
166 |
2
|
case miNewAppt: |
167 |
2
|
openActAppointment(-1, -1, -1); |
168 |
2
|
break; |
169 |
1
|
case miNewTask: |
170 |
1
|
openActTask(-1); |
171 |
1
|
break; |
172 |
1
|
case miNewNote: |
173 |
1
|
openActNote(-1); |
174 |
1
|
break; |
175 |
3
|
case miShowAllTasks: { |
176 |
3
|
item.setChecked(!item.isChecked()); |
177 |
3
|
prefs.bShowAllTasks = item.isChecked(); |
178 |
3
|
prefs.Save(); |
179 |
3
|
RefreshData(); |
180 |
3
|
menuItemUpdateIcons(item); |
181 |
3
|
break; |
182 |
|
} |
183 |
1
|
case miOptions: |
184 |
1
|
openActOptions(); |
185 |
1
|
break; |
186 |
1
|
case miAbout: |
187 |
1
|
openActViewAbout(); |
188 |
1
|
break; |
189 |
|
} |
190 |
9
|
return super.onOptionsItemSelected(item); |
191 |
|
} |
192 |
|
|
193 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (29) |
Complexity: 1 |
Complexity Density: 0,03 |
|
194 |
1
|
private void InitViews() {... |
195 |
|
|
196 |
1
|
DateWidget.setStrings(utils.GetResStr(R.string.strDateWidgetSelect), utils |
197 |
|
.GetResStr(R.string.strDateWidgetSelected), utils.GetResStr(R.string.strDateWidgetNone)); |
198 |
|
|
199 |
|
|
200 |
1
|
TimeWidget.setStrings(utils.GetResStr(R.string.strTimeWidgetSelect), utils |
201 |
|
.GetResStr(R.string.strTimeWidgetNone), utils.GetResStr(R.string.strTimeWidgetSet)); |
202 |
|
|
203 |
1
|
rlayAgendaTop = (RelativeLayout) findViewById(R.id.rlayAgendaTop); |
204 |
1
|
rlayAgenda = (RelativeLayout) findViewById(R.id.rlayAgenda); |
205 |
1
|
rlayAgendaView = (RelativeLayout) findViewById(R.id.rlayAgendaView); |
206 |
|
|
207 |
1
|
llayAgendaData = (LinearLayout) findViewById(R.id.llayAgendaData); |
208 |
|
|
209 |
1
|
btnSelectViewItemPrev = (ViewImgButton) findViewById(R.id.btnSelectViewItemPrev); |
210 |
1
|
btnSelectViewItemPrev.SetButtonIcon(R.drawable.btnprev, -1); |
211 |
1
|
btnSelectViewItemPrev.setOnClickListener(new View.OnClickListener() { |
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
212 |
19
|
public void onClick(View v) {... |
213 |
19
|
CurrentAgendaView.SetPrevViewItem(); |
214 |
19
|
RefreshAgendaAfterViewItemChange(); |
215 |
|
} |
216 |
|
}); |
217 |
|
|
218 |
1
|
btnSelectViewItemToday = (Button) findViewById(R.id.btnSelectViewItemToday); |
219 |
1
|
btnSelectViewItemToday.setOnClickListener(new View.OnClickListener() { |
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
220 |
18
|
public void onClick(View v) {... |
221 |
18
|
CurrentAgendaView.SetTodayViewItem(); |
222 |
18
|
RefreshAgendaAfterViewItemChange(); |
223 |
|
} |
224 |
|
}); |
225 |
|
|
226 |
1
|
btnSelectViewItemNext = (ViewImgButton) findViewById(R.id.btnSelectViewItemNext); |
227 |
1
|
btnSelectViewItemNext.SetButtonIcon(R.drawable.btnnext, 0); |
228 |
1
|
btnSelectViewItemNext.setOnClickListener(new View.OnClickListener() { |
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
229 |
21
|
public void onClick(View v) {... |
230 |
21
|
CurrentAgendaView.SetNextViewItem(); |
231 |
21
|
RefreshAgendaAfterViewItemChange(); |
232 |
|
} |
233 |
|
}); |
234 |
|
|
235 |
1
|
labWeekStr = (TextView) findViewById(R.id.labWeekStr); |
236 |
1
|
labWeekNr = (TextView) findViewById(R.id.labWeekNr); |
237 |
|
|
238 |
1
|
labSelectViewItem = (TextView) findViewById(R.id.labSelectViewItem); |
239 |
|
|
240 |
|
|
241 |
1
|
btnSetViewToday = (Button) findViewById(R.id.btnSetViewToday); |
242 |
1
|
btnSetViewToday.setOnClickListener(new View.OnClickListener() { |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
243 |
1
|
public void onClick(View v) {... |
244 |
|
|
245 |
1
|
SetAgendaView(AgendaViewType.TODAY, LatestDateToday()); |
246 |
|
} |
247 |
|
}); |
248 |
|
|
249 |
1
|
btnSetViewDay = (Button) findViewById(R.id.btnSetViewDay); |
250 |
1
|
btnSetViewDay.setOnClickListener(new View.OnClickListener() { |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
251 |
4
|
public void onClick(View v) {... |
252 |
|
|
253 |
4
|
SetAgendaView(AgendaViewType.DAY, LatestDateToday()); |
254 |
|
} |
255 |
|
}); |
256 |
|
|
257 |
1
|
btnSetViewWeek = (Button) findViewById(R.id.btnSetViewWeek); |
258 |
1
|
btnSetViewWeek.setOnClickListener(new View.OnClickListener() { |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
259 |
6
|
public void onClick(View v) {... |
260 |
|
|
261 |
6
|
SetAgendaView(AgendaViewType.WEEK, LatestDateToday()); |
262 |
|
} |
263 |
|
}); |
264 |
|
|
265 |
1
|
btnSetViewMonth = (Button) findViewById(R.id.btnSetViewMonth); |
266 |
1
|
btnSetViewMonth.setOnClickListener(new View.OnClickListener() { |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
267 |
4
|
public void onClick(View v) {... |
268 |
|
|
269 |
4
|
SetAgendaView(AgendaViewType.MONTH, LatestDateToday()); |
270 |
|
} |
271 |
|
}); |
272 |
|
|
273 |
|
|
274 |
1
|
dataViewAppt = new DataViewAppointment(userdb, prefs); |
275 |
1
|
dataViewTask = new DataViewTask(userdb, prefs); |
276 |
1
|
dataViewNote = new DataViewNote(userdb, prefs); |
277 |
|
|
278 |
1
|
InitAgendaViewToday(); |
279 |
|
} |
280 |
|
|
|
|
| 0% |
Uncovered Elements: 18 (18) |
Complexity: 5 |
Complexity Density: 0,5 |
|
281 |
0
|
public void ToggleBottomButtonsState(CompoundButton btnClicked) {... |
282 |
0
|
btnClicked.setEnabled(false); |
283 |
0
|
btnClicked.requestFocus(); |
284 |
|
|
285 |
0
|
if (btnClicked != btnSetViewToday) |
286 |
0
|
btnSetViewToday.setEnabled(true); |
287 |
0
|
if (btnClicked != btnSetViewDay) |
288 |
0
|
btnSetViewDay.setEnabled(true); |
289 |
0
|
if (btnClicked != btnSetViewWeek) |
290 |
0
|
btnSetViewWeek.setEnabled(true); |
291 |
0
|
if (btnClicked != btnSetViewMonth) |
292 |
0
|
btnSetViewMonth.setEnabled(true); |
293 |
|
} |
294 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
295 |
20
|
public void UpdateBottomButtonsStateByCurrentView() {... |
296 |
|
|
297 |
|
|
298 |
|
|
299 |
|
|
300 |
|
|
301 |
|
|
302 |
|
|
303 |
|
|
304 |
|
|
305 |
|
} |
306 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 1 |
Complexity Density: 0,08 |
|
307 |
1
|
public void InitAgendaViewToday() {... |
308 |
|
|
309 |
1
|
AgendaViewToday = new AgendaViewToday(this); |
310 |
1
|
AgendaViewToday.Rebuild(); |
311 |
|
|
312 |
|
|
313 |
1
|
AgendaView.SetItemClick(new AgendaView.OnViewItemClick() { |
|
|
| 88,2% |
Uncovered Elements: 2 (17) |
Complexity: 5 |
Complexity Density: 0,56 |
|
314 |
16
|
public void OnClick(View v, Bundle extras) {... |
315 |
16
|
long lRowId = extras.getLong(CommonActivity.bundleRowId); |
316 |
16
|
if (extras.getString("type").equals(ViewTodayItemHeader.ViewType.Appointments.toString())) { |
317 |
6
|
if (extras.containsKey(CommonActivity.bundleHourOfDay)) { |
318 |
0
|
openActAppointment(lRowId, extras.getInt(CommonActivity.bundleHourOfDay), extras |
319 |
|
.getInt(CommonActivity.bundleMinutes)); |
320 |
|
} else { |
321 |
6
|
openActAppointment(lRowId, -1, -1); |
322 |
|
} |
323 |
|
} |
324 |
16
|
if (extras.getString("type").equals(ViewTodayItemHeader.ViewType.Tasks.toString())) |
325 |
6
|
openActTask(lRowId); |
326 |
16
|
if (extras.getString("type").equals(ViewTodayItemHeader.ViewType.Notes.toString())) |
327 |
4
|
openActNote(lRowId); |
328 |
|
} |
329 |
|
}); |
330 |
|
|
331 |
|
|
332 |
1
|
AgendaViewDay = new AgendaViewDay(AnCal.this); |
333 |
1
|
AgendaViewDay.Rebuild(); |
334 |
|
|
335 |
1
|
AgendaViewWeek = new AgendaViewWeek(AnCal.this); |
336 |
1
|
AgendaViewWeek.Rebuild(); |
337 |
|
|
338 |
1
|
AgendaViewMonth = new AgendaViewMonth(AnCal.this); |
339 |
1
|
AgendaViewMonth.Rebuild(); |
340 |
|
|
341 |
|
|
342 |
1
|
scrollViewAgenda = new ScrollView(this); |
343 |
1
|
LayoutParams layParams = new LayoutParams(android.view.ViewGroup.LayoutParams.FILL_PARENT, |
344 |
|
android.view.ViewGroup.LayoutParams.FILL_PARENT); |
345 |
1
|
scrollViewAgenda.setLayoutParams(layParams); |
346 |
|
} |
347 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0,17 |
|
348 |
1
|
private void InitStateOnce() {... |
349 |
1
|
ReloadAllDataTables(); |
350 |
1
|
SetAgendaView(AgendaViewType.TODAY, LatestDateToday()); |
351 |
|
|
352 |
|
|
353 |
1
|
ForceUpdateLayout(); |
354 |
|
|
355 |
|
|
356 |
1
|
handlerUpdateDate.removeCallbacks(handlerUpdateDateTask); |
357 |
1
|
handlerUpdateDate.postDelayed(handlerUpdateDateTask, iHandlerUpdateTime); |
358 |
|
|
359 |
|
|
360 |
1
|
btnSetViewToday.requestFocus(); |
361 |
|
} |
362 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
363 |
21
|
private void ForceUpdateLayout() {... |
364 |
21
|
handlerUpdateView.removeCallbacks(handlerUpdateViewTask); |
365 |
21
|
handlerUpdateView.postDelayed(handlerUpdateViewTask, 100); |
366 |
|
} |
367 |
|
|
368 |
|
private Runnable handlerUpdateViewTask = new Runnable() { |
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0,25 |
|
369 |
20
|
public void run() {... |
370 |
20
|
rlayAgenda.postInvalidate(); |
371 |
20
|
rlayAgenda.requestLayout(); |
372 |
20
|
rlayAgendaView.postInvalidate(); |
373 |
20
|
rlayAgendaView.requestLayout(); |
374 |
|
} |
375 |
|
}; |
376 |
|
|
377 |
|
private Runnable handlerUpdateDateTask = new Runnable() { |
|
|
| 93,3% |
Uncovered Elements: 1 (15) |
Complexity: 4 |
Complexity Density: 0,44 |
|
378 |
71
|
public void run() {... |
379 |
71
|
try { |
380 |
71
|
UpdateTodayDate(); |
381 |
|
|
382 |
|
|
383 |
71
|
if (iUpdateDate_minute != dateToday.get(Calendar.MINUTE)) { |
384 |
7
|
iUpdateDate_minute = dateToday.get(Calendar.MINUTE); |
385 |
|
|
386 |
|
|
387 |
7
|
if (currentAgendaViewType == AgendaViewType.TODAY) { |
388 |
5
|
if (CurrentAgendaView != null) |
389 |
5
|
CurrentAgendaView.SetViewStartDate(LatestDateToday()); |
390 |
5
|
RefreshData(); |
391 |
|
} |
392 |
|
} |
393 |
|
} finally { |
394 |
71
|
handlerUpdateDate.postDelayed(this, iHandlerUpdateTime); |
395 |
|
} |
396 |
|
} |
397 |
|
}; |
398 |
|
|
399 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
400 |
92
|
public synchronized void UpdateTodayDate() {... |
401 |
92
|
dateToday.setTimeInMillis(System.currentTimeMillis()); |
402 |
92
|
dateToday.setFirstDayOfWeek(prefs.iFirstDayOfWeek); |
403 |
|
} |
404 |
|
|
|
|
| 95,2% |
Uncovered Elements: 1 (21) |
Complexity: 4 |
Complexity Density: 0,27 |
|
405 |
49
|
public synchronized void RefreshData() {... |
406 |
|
|
407 |
49
|
SetActivityTitle(AnCalDateUtils.formatLongDate(this, dateToday)); |
408 |
|
|
409 |
|
|
410 |
49
|
SetWeekNrText(CurrentAgendaView.GetViewStartDate()); |
411 |
|
|
412 |
|
|
413 |
49
|
UpdateWeekNrInfoVisibility(); |
414 |
|
|
415 |
|
|
416 |
49
|
UpdateSelectViewText(currentAgendaViewType); |
417 |
|
|
418 |
|
|
419 |
49
|
UpdateCurrentViewItemDate(); |
420 |
|
|
421 |
|
|
422 |
49
|
if (userdb.DatabaseReady()) { |
423 |
|
|
424 |
49
|
dataViewAppt.FilterData(CurrentAgendaView.GetViewStartDate(), CurrentAgendaView.GetViewType()); |
425 |
49
|
if (currentAgendaViewType == AgendaViewType.TODAY) { |
426 |
25
|
dataViewTask.FilterData(CurrentAgendaView.GetViewStartDate(), CurrentAgendaView.GetViewType()); |
427 |
25
|
dataViewNote.FilterData(CurrentAgendaView.GetViewStartDate(), CurrentAgendaView.GetViewType()); |
428 |
|
} |
429 |
|
|
430 |
49
|
CurrentAgendaView.RebuildViewAppointments(dataViewAppt); |
431 |
49
|
if (currentAgendaViewType == AgendaViewType.TODAY) { |
432 |
25
|
CurrentAgendaView.RebuildViewTasks(dataViewTask); |
433 |
25
|
CurrentAgendaView.RebuildViewNotes(dataViewNote); |
434 |
|
} |
435 |
|
} |
436 |
|
|
437 |
|
|
438 |
49
|
scrollViewAgenda.scrollTo(0, 0); |
439 |
|
} |
440 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0,17 |
|
441 |
58
|
public void RefreshAgendaAfterViewItemChange() {... |
442 |
58
|
btnSelectViewItemToday.setText("..."); |
443 |
58
|
SetWeekNrText(CurrentAgendaView.GetViewStartDate()); |
444 |
58
|
UpdateWeekNrInfoVisibility(); |
445 |
|
|
446 |
|
|
447 |
58
|
dataViewAppt.FilterData(CurrentAgendaView.GetViewStartDate(), CurrentAgendaView.GetViewType()); |
448 |
|
|
449 |
|
|
450 |
58
|
CurrentAgendaView.RebuildViewAppointments(dataViewAppt); |
451 |
|
|
452 |
58
|
UpdateCurrentViewItemDate(); |
453 |
|
} |
454 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 4 |
Complexity Density: 0,33 |
|
455 |
107
|
public void UpdateCurrentViewItemDate() {... |
456 |
107
|
String s = ""; |
457 |
107
|
switch (currentAgendaViewType) { |
458 |
25
|
case DAY: |
459 |
36
|
case WEEK: |
460 |
61
|
s = AnCalDateUtils.formatMediumDate(this, CurrentAgendaView.GetViewStartDate()); |
461 |
61
|
break; |
462 |
21
|
case MONTH: |
463 |
21
|
s = AnCalDateUtils.formatMediumDate(this, CurrentAgendaView.GetCurrentSelectedMonthAsCalendar()); |
464 |
21
|
break; |
465 |
25
|
default: |
466 |
25
|
s = ""; |
467 |
|
} |
468 |
|
|
469 |
107
|
btnSelectViewItemToday.setText(s); |
470 |
|
} |
471 |
|
|
472 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
473 |
78
|
public Calendar getDateToday() {... |
474 |
78
|
dateToday.setFirstDayOfWeek(prefs.iFirstDayOfWeek); |
475 |
78
|
return dateToday; |
476 |
|
} |
477 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
478 |
21
|
public Calendar LatestDateToday() {... |
479 |
21
|
UpdateTodayDate(); |
480 |
21
|
return getDateToday(); |
481 |
|
} |
482 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
483 |
107
|
public void SetWeekNrText(Calendar date) {... |
484 |
107
|
int iNr = date.get(Calendar.WEEK_OF_YEAR); |
485 |
107
|
labWeekNr.setText(Integer.toString(iNr)); |
486 |
|
} |
487 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 2 |
Complexity Density: 0,4 |
|
488 |
107
|
public void UpdateWeekNrInfoVisibility() {... |
489 |
107
|
if (currentAgendaViewType == AgendaViewType.MONTH) { |
490 |
21
|
labWeekStr.setVisibility(View.INVISIBLE); |
491 |
21
|
labWeekNr.setVisibility(View.INVISIBLE); |
492 |
|
} else { |
493 |
86
|
labWeekStr.setVisibility(View.VISIBLE); |
494 |
86
|
labWeekNr.setVisibility(View.VISIBLE); |
495 |
|
} |
496 |
|
} |
497 |
|
|
|
|
| 93,3% |
Uncovered Elements: 1 (15) |
Complexity: 5 |
Complexity Density: 0,71 |
|
498 |
20
|
public void ReloadDataTable(String sTableNameToReload) {... |
499 |
20
|
if (userdb.DatabaseReady()) { |
500 |
20
|
if (sTableNameToReload.equals(Database.sTableNameAppointments)) |
501 |
8
|
dataViewAppt.ReloadTable(); |
502 |
20
|
if (sTableNameToReload.equals(Database.sTableNameTasks)) |
503 |
7
|
dataViewTask.ReloadTable(); |
504 |
20
|
if (sTableNameToReload.equals(Database.sTableNameNotes)) |
505 |
5
|
dataViewNote.ReloadTable(); |
506 |
|
} |
507 |
|
} |
508 |
|
|
|
|
| 83,3% |
Uncovered Elements: 1 (6) |
Complexity: 2 |
Complexity Density: 0,5 |
|
509 |
1
|
public void ReloadAllDataTables() {... |
510 |
1
|
if (userdb.DatabaseReady()) { |
511 |
1
|
dataViewAppt.ReloadTable(); |
512 |
1
|
dataViewTask.ReloadTable(); |
513 |
1
|
dataViewNote.ReloadTable(); |
514 |
|
} |
515 |
|
} |
516 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (14) |
Complexity: 4 |
Complexity Density: 0,5 |
|
517 |
49
|
private void UpdateSelectViewText(AgendaViewType viewType) {... |
518 |
49
|
String s = ""; |
519 |
49
|
if (currentAgendaViewType == AgendaViewType.DAY) |
520 |
12
|
s = utils.GetResStr(R.string.labSelectViewDay); |
521 |
49
|
if (currentAgendaViewType == AgendaViewType.WEEK) |
522 |
8
|
s = utils.GetResStr(R.string.labSelectViewWeek); |
523 |
49
|
if (currentAgendaViewType == AgendaViewType.MONTH) |
524 |
4
|
s = utils.GetResStr(R.string.labSelectViewMonth); |
525 |
49
|
labSelectViewItem.setText(s); |
526 |
|
} |
527 |
|
|
|
|
| 90% |
Uncovered Elements: 3 (30) |
Complexity: 7 |
Complexity Density: 0,39 |
|
528 |
20
|
public synchronized void SetAgendaView(AgendaViewType viewType, Calendar calViewDate) {... |
529 |
20
|
if (userdb.DatabaseReady()) { |
530 |
|
|
531 |
20
|
currentAgendaViewType = viewType; |
532 |
|
|
533 |
20
|
ShowTopControls(currentAgendaViewType != AgendaViewType.TODAY); |
534 |
|
|
535 |
|
|
536 |
20
|
if (currentAgendaViewType == AgendaViewType.TODAY) |
537 |
2
|
CurrentAgendaView = AgendaViewToday; |
538 |
20
|
if (currentAgendaViewType == AgendaViewType.DAY) |
539 |
6
|
CurrentAgendaView = AgendaViewDay; |
540 |
20
|
if (currentAgendaViewType == AgendaViewType.WEEK) |
541 |
8
|
CurrentAgendaView = AgendaViewWeek; |
542 |
20
|
if (currentAgendaViewType == AgendaViewType.MONTH) |
543 |
4
|
CurrentAgendaView = AgendaViewMonth; |
544 |
|
|
545 |
20
|
if (CurrentAgendaView != null) |
546 |
20
|
CurrentAgendaView.SetViewStartDate(calViewDate); |
547 |
|
|
548 |
|
|
549 |
20
|
RefreshData(); |
550 |
|
|
551 |
|
|
552 |
20
|
UpdateBottomButtonsStateByCurrentView(); |
553 |
|
|
554 |
20
|
VisibleLayoutContentRemove(); |
555 |
20
|
VisibleLayoutContentAdd(); |
556 |
|
|
557 |
|
} else { |
558 |
0
|
utils.ShowMsgResStr(Database.GetErrDesc(userdb.TablesCreationResult()), MessageType.ERROR); |
559 |
|
} |
560 |
|
} |
561 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
562 |
20
|
private void VisibleLayoutContentRemove() {... |
563 |
20
|
llayAgendaData.removeAllViews(); |
564 |
20
|
scrollViewAgenda.removeAllViews(); |
565 |
|
} |
566 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (18) |
Complexity: 5 |
Complexity Density: 0,5 |
|
567 |
20
|
private void VisibleLayoutContentAdd() {... |
568 |
20
|
if (currentAgendaViewType == AgendaViewType.TODAY) { |
569 |
2
|
scrollViewAgenda.addView(CurrentAgendaView.GetParentLayout()); |
570 |
2
|
llayAgendaData.addView(scrollViewAgenda); |
571 |
|
} |
572 |
20
|
if (currentAgendaViewType == AgendaViewType.DAY) { |
573 |
6
|
scrollViewAgenda.addView(CurrentAgendaView.GetParentLayout()); |
574 |
6
|
llayAgendaData.addView(scrollViewAgenda); |
575 |
|
} |
576 |
20
|
if (currentAgendaViewType == AgendaViewType.WEEK) { |
577 |
8
|
llayAgendaData.addView(CurrentAgendaView.GetParentLayout()); |
578 |
|
} |
579 |
20
|
if (currentAgendaViewType == AgendaViewType.MONTH) { |
580 |
4
|
llayAgendaData.addView(CurrentAgendaView.GetParentLayout()); |
581 |
|
} |
582 |
|
} |
583 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (26) |
Complexity: 5 |
Complexity Density: 0,28 |
|
584 |
20
|
private void ShowTopControls(boolean bEnable) {... |
585 |
|
|
586 |
20
|
btnSelectViewItemPrev.setEnabled(bEnable); |
587 |
20
|
btnSelectViewItemToday.setEnabled(bEnable); |
588 |
20
|
btnSelectViewItemNext.setEnabled(bEnable); |
589 |
20
|
rlayAgendaTop.setEnabled(bEnable); |
590 |
|
|
591 |
|
|
592 |
20
|
btnSelectViewItemPrev.setFocusable(bEnable); |
593 |
20
|
btnSelectViewItemToday.setFocusable(bEnable); |
594 |
20
|
btnSelectViewItemNext.setFocusable(bEnable); |
595 |
20
|
rlayAgendaTop.setFocusable(bEnable); |
596 |
|
|
597 |
|
|
598 |
20
|
btnSelectViewItemPrev.setVisibility((bEnable) ? View.VISIBLE : View.INVISIBLE); |
599 |
20
|
btnSelectViewItemToday.setVisibility((bEnable) ? View.VISIBLE : View.INVISIBLE); |
600 |
20
|
btnSelectViewItemNext.setVisibility((bEnable) ? View.VISIBLE : View.INVISIBLE); |
601 |
|
|
602 |
|
|
603 |
20
|
MarginLayoutParams mlp = (MarginLayoutParams) rlayAgendaTop.getLayoutParams(); |
604 |
20
|
mlp.setMargins(0, 0, 0, 0); |
605 |
20
|
rlayAgendaTop.getLayoutParams().height = 0; |
606 |
20
|
if (bEnable) { |
607 |
18
|
rlayAgendaTop.getLayoutParams().height = android.view.ViewGroup.LayoutParams.WRAP_CONTENT; |
608 |
18
|
mlp.setMargins(0, 0, 0, 6); |
609 |
|
} |
610 |
|
|
611 |
|
|
612 |
20
|
ForceUpdateLayout(); |
613 |
|
} |
614 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
615 |
0
|
protected void onSizeChanged(int w, int h, int oldw, int oldh) {... |
616 |
|
|
617 |
|
} |
618 |
|
|
|
|
| 75% |
Uncovered Elements: 4 (16) |
Complexity: 4 |
Complexity Density: 0,4 |
|
619 |
8
|
public void openActAppointment(long lRowId, int iHourOfDay, int iMinutes) {... |
620 |
8
|
bundleOtherDataStartup.clear(); |
621 |
8
|
if (lRowId == -1) { |
622 |
6
|
bundleOtherDataStartup.putInt(CommonActivity.bundleAgendaView, CurrentAgendaView.GetViewIndex()); |
623 |
6
|
bundleOtherDataStartup.putLong(CommonActivity.bundleAgendaViewStartDate, CurrentAgendaView |
624 |
|
.GetViewStartDate().getTimeInMillis()); |
625 |
|
|
626 |
6
|
if (iHourOfDay != -1) |
627 |
0
|
bundleOtherDataStartup.putInt(CommonActivity.bundleHourOfDay, iHourOfDay); |
628 |
6
|
if (iMinutes != -1) |
629 |
0
|
bundleOtherDataStartup.putInt(CommonActivity.bundleMinutes, iMinutes); |
630 |
|
|
631 |
6
|
OpenActivity(0, "android.intent.action.AnCal.ACTION_MODE_NEW_APPOINTMENT"); |
632 |
|
} else { |
633 |
2
|
OpenActivity(0, "android.intent.action.AnCal.ACTION_MODE_EDIT_APPOINTMENT", lRowId); |
634 |
|
} |
635 |
|
} |
636 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0,5 |
|
637 |
7
|
public void openActTask(long lRowId) {... |
638 |
7
|
bundleOtherDataStartup.clear(); |
639 |
7
|
if (lRowId == -1) |
640 |
4
|
OpenActivity(0, "android.intent.action.AnCal.ACTION_MODE_NEW_TASK"); |
641 |
|
else |
642 |
3
|
OpenActivity(0, "android.intent.action.AnCal.ACTION_MODE_EDIT_TASK", lRowId); |
643 |
|
} |
644 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0,5 |
|
645 |
5
|
public void openActNote(long lRowId) {... |
646 |
5
|
bundleOtherDataStartup.clear(); |
647 |
5
|
if (lRowId == -1) |
648 |
3
|
OpenActivity(0, "android.intent.action.AnCal.ACTION_MODE_NEW_NOTE"); |
649 |
|
else |
650 |
2
|
OpenActivity(0, "android.intent.action.AnCal.ACTION_MODE_EDIT_NOTE", lRowId); |
651 |
|
} |
652 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
653 |
1
|
public void openActOptions() {... |
654 |
1
|
bundleOtherDataStartup.clear(); |
655 |
1
|
OpenActivity(0, "android.intent.action.AnCal.ACTION_MODE_EDIT_OPTIONS"); |
656 |
|
} |
657 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
658 |
1
|
public void openActViewAbout() {... |
659 |
1
|
bundleOtherDataStartup.clear(); |
660 |
1
|
OpenActivity(0, "android.intent.action.AnCal.ACTION_MODE_VIEW_ABOUT"); |
661 |
|
} |
662 |
|
|
|
|
| 92,3% |
Uncovered Elements: 2 (26) |
Complexity: 6 |
Complexity Density: 0,38 |
|
663 |
22
|
@Override... |
664 |
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) { |
665 |
22
|
super.onActivityResult(requestCode, resultCode, data); |
666 |
|
|
667 |
22
|
Bundle extras = CommonActivity.getIntentExtras(data); |
668 |
22
|
if (extras != null) { |
669 |
21
|
if (resultCode == RESULT_OK) { |
670 |
|
|
671 |
21
|
if (extras.containsKey(CommonActivity.bundleTableUpdated)) { |
672 |
20
|
String sTableNameToReload = extras.getString(CommonActivity.bundleTableUpdated); |
673 |
20
|
ReloadDataTable(sTableNameToReload); |
674 |
20
|
RefreshData(); |
675 |
20
|
UpdateReminderService(this, prefs, CommonActivity.bundleTableUpdated); |
676 |
|
} |
677 |
|
|
678 |
21
|
if (extras.containsKey(CommonActivity.bundleOptionsUpdated)) { |
679 |
1
|
prefs.Load(); |
680 |
1
|
if (CurrentAgendaView.TimeFormatChanged()) |
681 |
1
|
CurrentAgendaView.UpdateTimeFormat(); |
682 |
1
|
CurrentAgendaView.SetTodayViewItem(); |
683 |
1
|
RefreshData(); |
684 |
1
|
UpdateReminderService(this, prefs, CommonActivity.bundleOptionsUpdated); |
685 |
|
} |
686 |
|
} |
687 |
|
} |
688 |
|
} |
689 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
690 |
2
|
public int GetViewSpaceWidth() {... |
691 |
|
|
692 |
2
|
return 320 - 8; |
693 |
|
} |
694 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
695 |
4
|
public int GetViewSpaceHeight() {... |
696 |
|
|
697 |
4
|
return 340; |
698 |
|
} |
699 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
700 |
1
|
public boolean StartReminderService() {... |
701 |
1
|
ComponentName cpn = startService(new Intent(AnCal.this, AlarmService.class)); |
702 |
1
|
return (cpn != null); |
703 |
|
} |
704 |
|
|
705 |
|
|
706 |
|
|
707 |
|
|
708 |
|
|
709 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 1 |
Complexity Density: 0,1 |
|
710 |
24
|
public static boolean UpdateReminderService(Context context, Prefs prefs, String sKey) {... |
711 |
24
|
Bundle args = new Bundle(); |
712 |
24
|
args.putBoolean(sKey, true); |
713 |
|
|
714 |
24
|
args.putBoolean("b24HourMode", prefs.b24HourMode); |
715 |
24
|
args.putInt("iFirstDayOfWeek", prefs.iFirstDayOfWeek); |
716 |
24
|
args.putInt("iSnoozeCount", prefs.iSnoozeCount); |
717 |
24
|
args.putInt("iSnoozeMinutesOverdue", prefs.iSnoozeMinutesOverdue); |
718 |
|
|
719 |
24
|
Intent intent = new Intent(context, AlarmService.class); |
720 |
24
|
intent.putExtras(args); |
721 |
24
|
ComponentName cpn = context.startService(intent); |
722 |
24
|
return (cpn != null); |
723 |
|
} |
724 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
725 |
0
|
@Override... |
726 |
|
protected void restoreStateFromFreeze() { |
727 |
|
|
728 |
|
} |
729 |
|
|
730 |
|
} |