1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package com.sweetiepiggy.raspberrybusmalaysia; |
21 |
|
|
22 |
|
import java.text.SimpleDateFormat; |
23 |
|
import java.util.ArrayList; |
24 |
|
import java.util.Calendar; |
25 |
|
import java.util.GregorianCalendar; |
26 |
|
import java.util.HashMap; |
27 |
|
import java.util.Iterator; |
28 |
|
|
29 |
|
import android.app.Activity; |
30 |
|
import android.app.AlertDialog; |
31 |
|
import android.app.DatePickerDialog; |
32 |
|
import android.app.Dialog; |
33 |
|
import android.app.TimePickerDialog; |
34 |
|
import android.content.DialogInterface; |
35 |
|
import android.content.DialogInterface.OnClickListener; |
36 |
|
import android.content.Intent; |
37 |
|
import android.database.Cursor; |
38 |
|
import android.net.Uri; |
39 |
|
import android.os.Bundle; |
40 |
|
import android.provider.MediaStore; |
41 |
|
import android.text.format.DateFormat; |
42 |
|
import android.view.View; |
43 |
|
import android.widget.ArrayAdapter; |
44 |
|
import android.widget.AutoCompleteTextView; |
45 |
|
import android.widget.Button; |
46 |
|
import android.widget.DatePicker; |
47 |
|
import android.widget.EditText; |
48 |
|
import android.widget.ListView; |
49 |
|
import android.widget.TextView; |
50 |
|
import android.widget.TimePicker; |
51 |
|
|
|
|
| 75,1% |
Uncovered Elements: 199 (798) |
Complexity: 196 |
Complexity Density: 0,37 |
|
52 |
|
public class ComplainActivity extends Activity |
53 |
|
{ |
54 |
|
|
55 |
|
private DataWrapper mData; |
56 |
|
private DbAdapter mDbHelper; |
57 |
|
|
58 |
|
private boolean m_youtube_sent; |
59 |
|
private boolean m_email_sent; |
60 |
|
private boolean m_tweet_sent; |
61 |
|
private boolean m_sms_sent; |
62 |
|
|
63 |
|
private static final int SCHED_DATE_DIALOG_ID = 0; |
64 |
|
private static final int SCHED_TIME_DIALOG_ID = 1; |
65 |
|
|
66 |
|
private static final int ACTIVITY_FROM = 0; |
67 |
|
private static final int ACTIVITY_TO = 1; |
68 |
|
private static final int ACTIVITY_SUBMIT = 2; |
69 |
|
private static final int ACTIVITY_TAKE_PHOTO = 3; |
70 |
|
private static final int ACTIVITY_RECORD_SOUND = 4; |
71 |
|
private static final int ACTIVITY_TAKE_VIDEO = 5; |
72 |
|
|
73 |
|
|
74 |
|
private static final String EMAIL_SUBJECT = "Aduan Bas Ekspres"; |
75 |
|
private static final String TWITTER_ADDRESS1 = "@aduanSPAD"; |
76 |
|
private static final String TWITTER_ADDRESS2 = "@transitmy"; |
77 |
|
private static final String TWITTER_ADDRESS3 = "@myAduan"; |
78 |
|
private static final String SMS_NUMBER = "15888"; |
79 |
|
private static final int MAX_TWEET_LENGTH = 140; |
80 |
|
|
81 |
|
static final String[] EMAIL_ADDRESSES = { |
82 |
|
"aduan@spad.gov.my; ", |
83 |
|
"aduantrafik@jpj.gov.my; e-aduan@kpdnkk.gov.my; info@motour.gov.my; bahria@miti.gov.my; unitpro@pcb.gov.my; ", |
84 |
|
"klangvalley.transit@gmail.com; nccc@nccc.org.my; ", |
85 |
|
"menteri@mot.gov.my; yenyenng@motour.gov.my; najib@1malaysia.com.my; ", |
86 |
|
"editor@thestar.com.my; metro@thestar.com.my; mmnews@mmail.com.my; syedn@nst.com.my; letters@nst.com.my; streets@nst.com.my; letters@thesundaily.com, editor@malaysiakini.com.my; editor@themalaysianinsider.com; ", |
87 |
|
"rmp@rmp.gov.my; " |
88 |
|
}; |
89 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 1 |
|
90 |
|
private class DataWrapper |
91 |
|
{ |
92 |
|
public Calendar sched_time; |
93 |
|
public boolean[] who_selected; |
94 |
|
public boolean[] submit_selected; |
95 |
|
public ArrayList<Uri> photo_uris; |
96 |
|
public ArrayList<Uri> recording_uris; |
97 |
|
public ArrayList<Uri> video_uris; |
98 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
99 |
1
|
public DataWrapper()... |
100 |
|
{ |
101 |
1
|
sched_time = new GregorianCalendar(); |
102 |
|
} |
103 |
|
} |
104 |
|
|
|
|
| 81,8% |
Uncovered Elements: 4 (22) |
Complexity: 3 |
Complexity Density: 0,17 |
|
105 |
1
|
@Override... |
106 |
|
public void onCreate(Bundle savedInstanceState) |
107 |
|
{ |
108 |
1
|
super.onCreate(savedInstanceState); |
109 |
1
|
setContentView(R.layout.complain); |
110 |
|
|
111 |
1
|
mDbHelper = new DbAdapter(); |
112 |
1
|
mDbHelper.open(this); |
113 |
|
|
114 |
1
|
if (savedInstanceState == null) { |
115 |
1
|
mData = (DataWrapper) getLastNonConfigurationInstance(); |
116 |
1
|
if (mData == null) { |
117 |
1
|
mData = new DataWrapper(); |
118 |
1
|
init_vars(mData); |
119 |
1
|
init_selected(mData); |
120 |
1
|
init_entries(); |
121 |
|
} |
122 |
|
} else { |
123 |
0
|
mData = new DataWrapper(); |
124 |
0
|
restore_saved_state(savedInstanceState); |
125 |
|
} |
126 |
|
|
127 |
1
|
init_date_time_buttons(); |
128 |
1
|
init_map_buttons(); |
129 |
1
|
init_camera_recorder_buttons(); |
130 |
1
|
init_cancel_button(); |
131 |
1
|
init_submit_button(); |
132 |
|
} |
133 |
|
|
|
|
| 93,8% |
Uncovered Elements: 1 (16) |
Complexity: 2 |
Complexity Density: 0,14 |
|
134 |
1
|
@Override... |
135 |
|
protected void onDestroy() |
136 |
|
{ |
137 |
1
|
String sched_time = format_time(mData.sched_time); |
138 |
1
|
String agent = ((AutoCompleteTextView) findViewById(R.id.agent_entry)).getText().toString(); |
139 |
1
|
String operator = ((AutoCompleteTextView) findViewById(R.id.operator_entry)).getText().toString(); |
140 |
1
|
String from_city = ((AutoCompleteTextView) findViewById(R.id.from_city_entry)).getText().toString(); |
141 |
1
|
String from_station = ((AutoCompleteTextView) findViewById(R.id.from_station_entry)).getText().toString(); |
142 |
1
|
String to_city = ((AutoCompleteTextView) findViewById(R.id.to_city_entry)).getText().toString(); |
143 |
1
|
String to_station = ((AutoCompleteTextView) findViewById(R.id.to_station_entry)).getText().toString(); |
144 |
1
|
String counter_num = ((AutoCompleteTextView) findViewById(R.id.counter_num_entry)).getText().toString(); |
145 |
1
|
String comment = ((EditText) findViewById(R.id.comment_entry)).getText().toString(); |
146 |
1
|
String reg = ((EditText) findViewById(R.id.reg_entry)).getText().toString(); |
147 |
|
|
148 |
1
|
if (mDbHelper != null) { |
149 |
1
|
mDbHelper.save_tmp_complaint(agent, operator, from_city, |
150 |
|
from_station, to_city, to_station, sched_time, |
151 |
|
counter_num, comment, reg); |
152 |
1
|
mDbHelper.close(); |
153 |
|
} |
154 |
1
|
super.onDestroy(); |
155 |
|
} |
156 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 1 |
Complexity Density: 0,09 |
|
157 |
9
|
@Override... |
158 |
|
public void onSaveInstanceState(Bundle savedInstanceState) |
159 |
|
{ |
160 |
9
|
savedInstanceState.putInt("sched_year", mData.sched_time.get(Calendar.YEAR)); |
161 |
9
|
savedInstanceState.putInt("sched_month", mData.sched_time.get(Calendar.MONTH)); |
162 |
9
|
savedInstanceState.putInt("sched_day", mData.sched_time.get(Calendar.DAY_OF_MONTH)); |
163 |
9
|
savedInstanceState.putInt("sched_hour", mData.sched_time.get(Calendar.HOUR_OF_DAY)); |
164 |
9
|
savedInstanceState.putInt("sched_minute", mData.sched_time.get(Calendar.MINUTE)); |
165 |
9
|
savedInstanceState.putBooleanArray("who_selected", mData.who_selected); |
166 |
9
|
savedInstanceState.putBooleanArray("submit_selected", mData.submit_selected); |
167 |
9
|
savedInstanceState.putStringArrayList("photo_uris", uriarr2strarr(mData.photo_uris)); |
168 |
9
|
savedInstanceState.putStringArrayList("recording_uris", uriarr2strarr(mData.recording_uris)); |
169 |
9
|
savedInstanceState.putStringArrayList("video_uris", uriarr2strarr(mData.video_uris)); |
170 |
|
|
171 |
9
|
super.onSaveInstanceState(savedInstanceState); |
172 |
|
} |
173 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
174 |
0
|
@Override... |
175 |
|
public void onRestoreInstanceState(Bundle savedInstanceState) |
176 |
|
{ |
177 |
0
|
super.onRestoreInstanceState(savedInstanceState); |
178 |
0
|
restore_saved_state(savedInstanceState); |
179 |
|
} |
180 |
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 1 |
Complexity Density: 0,09 |
|
181 |
0
|
private void restore_saved_state(Bundle savedInstanceState)... |
182 |
|
{ |
183 |
0
|
int year = savedInstanceState.getInt("sched_year"); |
184 |
0
|
int month = savedInstanceState.getInt("sched_month"); |
185 |
0
|
int day = savedInstanceState.getInt("sched_day"); |
186 |
0
|
int hour = savedInstanceState.getInt("sched_hour"); |
187 |
0
|
int minute = savedInstanceState.getInt("sched_minute"); |
188 |
0
|
mData.sched_time.set(year, month, day, hour, minute); |
189 |
|
|
190 |
0
|
mData.who_selected = savedInstanceState.getBooleanArray("who_selected"); |
191 |
0
|
mData.submit_selected = savedInstanceState.getBooleanArray("submit_selected"); |
192 |
|
|
193 |
0
|
mData.photo_uris = strarr2uriarr(savedInstanceState.getStringArrayList("photo_uris")); |
194 |
0
|
mData.recording_uris = strarr2uriarr(savedInstanceState.getStringArrayList("recording_uris")); |
195 |
0
|
mData.video_uris = strarr2uriarr(savedInstanceState.getStringArrayList("video_uris")); |
196 |
|
} |
197 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
198 |
0
|
@Override... |
199 |
|
public Object onRetainNonConfigurationInstance() |
200 |
|
{ |
201 |
0
|
return mData; |
202 |
|
} |
203 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0,25 |
|
204 |
2
|
private void init_date_time_buttons()... |
205 |
|
{ |
206 |
2
|
init_date_button(R.id.sched_date_button, SCHED_DATE_DIALOG_ID); |
207 |
2
|
init_time_button(R.id.sched_time_button, SCHED_TIME_DIALOG_ID); |
208 |
|
|
209 |
2
|
update_date_label(R.id.sched_date_button, mData.sched_time); |
210 |
2
|
update_time_label(R.id.sched_time_button, mData.sched_time); |
211 |
|
} |
212 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
213 |
2
|
private void init_date_button(int button_id, final int dialog_id)... |
214 |
|
{ |
215 |
2
|
Button date_button = (Button)findViewById(button_id); |
216 |
2
|
date_button.setOnClickListener(new View.OnClickListener() { |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
217 |
1
|
public void onClick(View v) {... |
218 |
1
|
showDialog(dialog_id); |
219 |
|
} |
220 |
|
}); |
221 |
|
|
222 |
|
} |
223 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
224 |
2
|
private void init_time_button(int button_id, final int dialog_id)... |
225 |
|
{ |
226 |
2
|
Button time_button = (Button)findViewById(button_id); |
227 |
2
|
time_button.setOnClickListener(new View.OnClickListener() { |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
228 |
1
|
public void onClick(View v) {... |
229 |
1
|
showDialog(dialog_id); |
230 |
|
} |
231 |
|
}); |
232 |
|
} |
233 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0,2 |
|
234 |
2
|
private void init_vars(DataWrapper data)... |
235 |
|
{ |
236 |
2
|
Cursor c_sched_time = mDbHelper.fetch_tmp_complaint_sched_time(); |
237 |
2
|
init_time(c_sched_time, data.sched_time); |
238 |
|
|
239 |
2
|
data.photo_uris = new ArrayList<Uri>(); |
240 |
2
|
data.recording_uris = new ArrayList<Uri>(); |
241 |
2
|
data.video_uris = new ArrayList<Uri>(); |
242 |
|
} |
243 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
244 |
1
|
private void init_selected(DataWrapper data)... |
245 |
|
{ |
246 |
|
|
247 |
1
|
data.who_selected = new boolean[] {true, true, true, false, false, false}; |
248 |
1
|
data.submit_selected = new boolean[] {false, true, false, false}; |
249 |
|
} |
250 |
|
|
|
|
| 30% |
Uncovered Elements: 7 (10) |
Complexity: 2 |
Complexity Density: 0,25 |
|
251 |
2
|
private void init_time(Cursor c, Calendar cal)... |
252 |
|
{ |
253 |
|
|
254 |
2
|
if (c.moveToFirst()) { |
255 |
0
|
int year = Integer.parseInt(c.getString(1)); |
256 |
0
|
int month = Integer.parseInt(c.getString(2)) - 1; |
257 |
0
|
int day = Integer.parseInt(c.getString(3)); |
258 |
0
|
int hour = Integer.parseInt(c.getString(4)); |
259 |
0
|
int minute = Integer.parseInt(c.getString(5)); |
260 |
|
|
261 |
0
|
cal.set(year, month, day, hour, minute); |
262 |
|
|
263 |
|
} else { |
264 |
2
|
cal = new GregorianCalendar(); |
265 |
|
} |
266 |
|
} |
267 |
|
|
|
|
| 91,9% |
Uncovered Elements: 3 (37) |
Complexity: 4 |
Complexity Density: 0,13 |
|
268 |
2
|
private void init_entries()... |
269 |
|
{ |
270 |
2
|
update_city_autocomplete(R.id.from_city_entry); |
271 |
2
|
update_city_autocomplete(R.id.to_city_entry); |
272 |
2
|
update_station_autocomplete(R.id.to_station_entry); |
273 |
2
|
update_station_autocomplete(R.id.from_station_entry); |
274 |
2
|
update_agent_autocomplete(R.id.agent_entry); |
275 |
2
|
update_operator_autocomplete(R.id.operator_entry); |
276 |
2
|
update_counter_num_autocomplete(R.id.counter_num_entry); |
277 |
|
|
278 |
2
|
String from_city = mDbHelper.fetch_tmp_complaint(DbAdapter.KEY_FROM_CITY); |
279 |
2
|
String from_station = mDbHelper.fetch_tmp_complaint(DbAdapter.KEY_FROM_STN); |
280 |
2
|
String to_city = mDbHelper.fetch_tmp_complaint(DbAdapter.KEY_TO_CITY); |
281 |
2
|
String to_station = mDbHelper.fetch_tmp_complaint(DbAdapter.KEY_TO_STN); |
282 |
2
|
String agent = mDbHelper.fetch_tmp_complaint(DbAdapter.KEY_AGENT); |
283 |
2
|
String operator = mDbHelper.fetch_tmp_complaint(DbAdapter.KEY_OPERATOR); |
284 |
2
|
String counter_num = mDbHelper.fetch_tmp_complaint(DbAdapter.KEY_CTR); |
285 |
2
|
String comment = mDbHelper.fetch_tmp_complaint(DbAdapter.KEY_COMMENT); |
286 |
2
|
String reg = mDbHelper.fetch_tmp_complaint(DbAdapter.KEY_REG); |
287 |
|
|
288 |
2
|
((AutoCompleteTextView) findViewById(R.id.from_city_entry)).setText(from_city); |
289 |
2
|
((AutoCompleteTextView) findViewById(R.id.from_station_entry)).setText(from_station); |
290 |
2
|
((AutoCompleteTextView) findViewById(R.id.to_city_entry)).setText(to_city); |
291 |
2
|
((AutoCompleteTextView) findViewById(R.id.to_station_entry)).setText(to_station); |
292 |
2
|
((AutoCompleteTextView) findViewById(R.id.agent_entry)).setText(agent); |
293 |
2
|
((AutoCompleteTextView) findViewById(R.id.operator_entry)).setText(operator); |
294 |
2
|
((AutoCompleteTextView) findViewById(R.id.counter_num_entry)).setText(counter_num); |
295 |
|
|
296 |
2
|
((EditText) findViewById(R.id.comment_entry)).setText(comment); |
297 |
2
|
((EditText) findViewById(R.id.reg_entry)).setText(reg); |
298 |
|
|
299 |
2
|
String photo_size = mData.photo_uris.size() > 0 ? Integer.toString(mData.photo_uris.size()) : ""; |
300 |
2
|
String video_size = mData.video_uris.size() > 0 ? Integer.toString(mData.video_uris.size()) : ""; |
301 |
2
|
String recording_size = mData.recording_uris.size() > 0 ? Integer.toString(mData.recording_uris.size()) : ""; |
302 |
|
|
303 |
2
|
((TextView) findViewById(R.id.camera_label)).setText(photo_size); |
304 |
2
|
((TextView) findViewById(R.id.recorder_label)).setText(recording_size); |
305 |
2
|
((TextView) findViewById(R.id.video_label)).setText(video_size); |
306 |
|
} |
307 |
|
|
|
|
| 92,3% |
Uncovered Elements: 1 (13) |
Complexity: 3 |
Complexity Density: 0,33 |
|
308 |
4
|
private void update_city_autocomplete(int id)... |
309 |
|
{ |
310 |
4
|
ArrayAdapter<String> cities = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line); |
311 |
4
|
Cursor c = mDbHelper.fetch_cities(); |
312 |
4
|
if (c.moveToFirst()) do { |
313 |
308
|
cities.add(c.getString(c.getColumnIndex(DbAdapter.KEY_CITY))); |
314 |
308
|
} while (c.moveToNext()); |
315 |
4
|
c.close(); |
316 |
4
|
AutoCompleteTextView cities_entry = (AutoCompleteTextView) findViewById(id); |
317 |
4
|
cities_entry.setThreshold(2); |
318 |
4
|
cities_entry.setAdapter(cities); |
319 |
|
} |
320 |
|
|
|
|
| 92,3% |
Uncovered Elements: 1 (13) |
Complexity: 3 |
Complexity Density: 0,33 |
|
321 |
4
|
private void update_station_autocomplete(int id)... |
322 |
|
{ |
323 |
4
|
ArrayAdapter<String> stations = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line); |
324 |
4
|
Cursor c = mDbHelper.fetch_stations(); |
325 |
4
|
if (c.moveToFirst()) do { |
326 |
372
|
stations.add(c.getString(c.getColumnIndex(DbAdapter.KEY_STN))); |
327 |
372
|
} while (c.moveToNext()); |
328 |
4
|
c.close(); |
329 |
4
|
AutoCompleteTextView stations_entry = (AutoCompleteTextView) findViewById(id); |
330 |
4
|
stations_entry.setThreshold(1); |
331 |
4
|
stations_entry.setAdapter(stations); |
332 |
|
} |
333 |
|
|
|
|
| 92,3% |
Uncovered Elements: 1 (13) |
Complexity: 3 |
Complexity Density: 0,33 |
|
334 |
2
|
private void update_agent_autocomplete(int id)... |
335 |
|
{ |
336 |
2
|
ArrayAdapter<String> agents = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line); |
337 |
2
|
Cursor c = mDbHelper.fetch_agents(); |
338 |
2
|
if (c.moveToFirst()) do { |
339 |
50
|
agents.add(c.getString(c.getColumnIndex(DbAdapter.KEY_AGENT))); |
340 |
50
|
} while (c.moveToNext()); |
341 |
2
|
c.close(); |
342 |
2
|
AutoCompleteTextView agents_entry = (AutoCompleteTextView) findViewById(id); |
343 |
2
|
agents_entry.setThreshold(1); |
344 |
2
|
agents_entry.setAdapter(agents); |
345 |
|
} |
346 |
|
|
|
|
| 92,3% |
Uncovered Elements: 1 (13) |
Complexity: 3 |
Complexity Density: 0,33 |
|
347 |
2
|
private void update_operator_autocomplete(int id)... |
348 |
|
{ |
349 |
2
|
ArrayAdapter<String> operators = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line); |
350 |
2
|
Cursor c = mDbHelper.fetch_operators(); |
351 |
2
|
if (c.moveToFirst()) do { |
352 |
38
|
operators.add(c.getString(c.getColumnIndex(DbAdapter.KEY_OPERATOR))); |
353 |
38
|
} while (c.moveToNext()); |
354 |
2
|
c.close(); |
355 |
2
|
AutoCompleteTextView operators_entry = (AutoCompleteTextView) findViewById(id); |
356 |
2
|
operators_entry.setThreshold(1); |
357 |
2
|
operators_entry.setAdapter(operators); |
358 |
|
} |
359 |
|
|
|
|
| 92,3% |
Uncovered Elements: 1 (13) |
Complexity: 3 |
Complexity Density: 0,33 |
|
360 |
2
|
private void update_counter_num_autocomplete(int id)... |
361 |
|
{ |
362 |
2
|
ArrayAdapter<String> counter_nums = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line); |
363 |
2
|
Cursor c = mDbHelper.fetch_counter_nums(); |
364 |
2
|
if (c.moveToFirst()) do { |
365 |
40
|
counter_nums.add(c.getString(c.getColumnIndex(DbAdapter.KEY_CTR))); |
366 |
40
|
} while (c.moveToNext()); |
367 |
2
|
c.close(); |
368 |
2
|
AutoCompleteTextView counter_nums_entry = (AutoCompleteTextView) findViewById(id); |
369 |
2
|
counter_nums_entry.setThreshold(1); |
370 |
2
|
counter_nums_entry.setAdapter(counter_nums); |
371 |
|
} |
372 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0,33 |
|
373 |
4
|
private void update_date_label(int button_id, Calendar cal)... |
374 |
|
{ |
375 |
4
|
Button date_button = (Button) findViewById(button_id); |
376 |
|
|
377 |
4
|
String date = translate_day_of_week(DateFormat.format("EEEE", cal.getTime()).toString()) + |
378 |
|
" " + DateFormat.getLongDateFormat(getApplicationContext()).format(cal.getTime()); |
379 |
4
|
date_button.setText(date); |
380 |
|
} |
381 |
|
|
382 |
|
|
|
|
| 63,3% |
Uncovered Elements: 11 (30) |
Complexity: 8 |
Complexity Density: 0,5 |
|
383 |
4
|
private String translate_day_of_week(String day)... |
384 |
|
{ |
385 |
4
|
String ret = day; |
386 |
4
|
if (day.equals("Monday")) { |
387 |
0
|
ret = getResources().getString(R.string.monday); |
388 |
4
|
} else if (day.equals("Tuesday")) { |
389 |
2
|
ret = getResources().getString(R.string.tuesday); |
390 |
2
|
} else if (day.equals("Wednesday")) { |
391 |
0
|
ret = getResources().getString(R.string.wednesday); |
392 |
2
|
} else if (day.equals("Thursday")) { |
393 |
0
|
ret = getResources().getString(R.string.thursday); |
394 |
2
|
} else if (day.equals("Friday")) { |
395 |
0
|
ret = getResources().getString(R.string.friday); |
396 |
2
|
} else if (day.equals("Saturday")) { |
397 |
0
|
ret = getResources().getString(R.string.saturday); |
398 |
2
|
} else if (day.equals("Sunday")) { |
399 |
2
|
ret = getResources().getString(R.string.sunday); |
400 |
|
} |
401 |
4
|
return ret; |
402 |
|
} |
403 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0,33 |
|
404 |
4
|
private void update_time_label(int button_id, Calendar cal)... |
405 |
|
{ |
406 |
4
|
Button time_button = (Button)findViewById(button_id); |
407 |
4
|
String time = DateFormat.getTimeFormat(getApplicationContext()).format(cal.getTime()); |
408 |
4
|
time_button.setText(time); |
409 |
|
} |
410 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
411 |
1
|
private void init_submit_button()... |
412 |
|
{ |
413 |
1
|
Button submit_button = (Button) findViewById(R.id.submit_button); |
414 |
1
|
submit_button.setOnClickListener(new View.OnClickListener() { |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
415 |
2
|
public void onClick(View v) {... |
416 |
2
|
submit_menu(); |
417 |
|
} |
418 |
|
}); |
419 |
|
} |
420 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0,25 |
|
421 |
1
|
private void init_map_buttons()... |
422 |
|
{ |
423 |
1
|
Button from_map_button = (Button) findViewById(R.id.from_map_button); |
424 |
1
|
from_map_button.setOnClickListener(new View.OnClickListener() { |
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0,2 |
|
425 |
1
|
public void onClick(View v) {... |
426 |
1
|
Intent intent = new Intent(getApplicationContext(), RbmMapActivity.class); |
427 |
1
|
Bundle b = new Bundle(); |
428 |
1
|
b.putBoolean("set_result", true); |
429 |
1
|
intent.putExtras(b); |
430 |
1
|
startActivityForResult(intent, ACTIVITY_FROM); |
431 |
|
} |
432 |
|
}); |
433 |
|
|
434 |
1
|
Button to_map_button = (Button) findViewById(R.id.to_map_button); |
435 |
1
|
to_map_button.setOnClickListener(new View.OnClickListener() { |
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0,2 |
|
436 |
1
|
public void onClick(View v) {... |
437 |
1
|
Intent intent = new Intent(getApplicationContext(), RbmMapActivity.class); |
438 |
1
|
Bundle b = new Bundle(); |
439 |
1
|
b.putBoolean("set_result", true); |
440 |
1
|
intent.putExtras(b); |
441 |
1
|
startActivityForResult(intent, ACTIVITY_TO); |
442 |
|
} |
443 |
|
}); |
444 |
|
} |
445 |
|
|
|
|
| 66,7% |
Uncovered Elements: 7 (21) |
Complexity: 5 |
Complexity Density: 0,33 |
|
446 |
1
|
private void init_camera_recorder_buttons()... |
447 |
|
{ |
448 |
1
|
Button camera_button = (Button) findViewById(R.id.camera_button); |
449 |
1
|
Button vidcam_button = (Button) findViewById(R.id.vidcam_button); |
450 |
1
|
Button recorder_button = (Button) findViewById(R.id.recorder_button); |
451 |
|
|
452 |
|
|
453 |
|
|
454 |
1
|
boolean has_camera = true; |
455 |
1
|
boolean has_microphone = true; |
456 |
|
|
457 |
1
|
if (has_camera) { |
458 |
1
|
camera_button.setOnClickListener(new View.OnClickListener() { |
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
459 |
1
|
@Override... |
460 |
|
public void onClick(View v) { |
461 |
1
|
Intent photo_intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); |
462 |
1
|
startActivityForResult(Intent.createChooser(photo_intent, |
463 |
|
getResources().getString(R.string.take_photo)), |
464 |
|
ACTIVITY_TAKE_PHOTO); |
465 |
|
} |
466 |
|
}); |
467 |
|
|
468 |
1
|
vidcam_button.setOnClickListener(new View.OnClickListener() { |
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
469 |
1
|
@Override... |
470 |
|
public void onClick(View v) { |
471 |
1
|
Intent video_intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE); |
472 |
1
|
startActivityForResult(Intent.createChooser(video_intent, |
473 |
|
getResources().getString(R.string.record_video)), |
474 |
|
ACTIVITY_TAKE_VIDEO); |
475 |
|
} |
476 |
|
}); |
477 |
|
} else { |
478 |
0
|
camera_button.setVisibility(View.GONE); |
479 |
0
|
vidcam_button.setVisibility(View.GONE); |
480 |
|
} |
481 |
|
|
482 |
1
|
if (has_microphone) { |
483 |
1
|
recorder_button.setOnClickListener(new View.OnClickListener() { |
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
484 |
2
|
@Override... |
485 |
|
public void onClick(View v) { |
486 |
2
|
Intent recorder_intent = new Intent(MediaStore.Audio.Media.RECORD_SOUND_ACTION); |
487 |
2
|
startActivityForResult(Intent.createChooser(recorder_intent, |
488 |
|
getResources().getString(R.string.record_sound)), |
489 |
|
ACTIVITY_RECORD_SOUND); |
490 |
|
} |
491 |
|
}); |
492 |
|
} else { |
493 |
0
|
recorder_button.setVisibility(View.GONE); |
494 |
|
} |
495 |
|
|
496 |
1
|
if (!has_camera && !has_microphone) { |
497 |
0
|
((TextView) findViewById(R.id.record_label)).setVisibility(View.GONE); |
498 |
|
} |
499 |
|
} |
500 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
501 |
1
|
private void init_cancel_button()... |
502 |
|
{ |
503 |
1
|
Button cancel_button = (Button)findViewById(R.id.cancel_button); |
504 |
1
|
cancel_button.setOnClickListener(new View.OnClickListener() { |
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0,2 |
|
505 |
1
|
public void onClick(View v) {... |
506 |
1
|
mDbHelper.clear_tmp_complaint_table(); |
507 |
1
|
init_vars(mData); |
508 |
|
|
509 |
1
|
mData.sched_time = new GregorianCalendar(); |
510 |
1
|
init_entries(); |
511 |
1
|
init_date_time_buttons(); |
512 |
|
} |
513 |
|
}); |
514 |
|
} |
515 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (31) |
Complexity: 9 |
Complexity Density: 0,39 |
|
516 |
5
|
private void submit()... |
517 |
|
{ |
518 |
5
|
String sched_time = format_time(mData.sched_time); |
519 |
5
|
String agent = ((AutoCompleteTextView) findViewById(R.id.agent_entry)).getText().toString(); |
520 |
5
|
String operator = ((AutoCompleteTextView) findViewById(R.id.operator_entry)).getText().toString(); |
521 |
5
|
String from_city = ((AutoCompleteTextView) findViewById(R.id.from_city_entry)).getText().toString(); |
522 |
5
|
String from_station = ((AutoCompleteTextView) findViewById(R.id.from_station_entry)).getText().toString(); |
523 |
5
|
String to_city = ((AutoCompleteTextView) findViewById(R.id.to_city_entry)).getText().toString(); |
524 |
5
|
String to_station = ((AutoCompleteTextView) findViewById(R.id.to_station_entry)).getText().toString(); |
525 |
5
|
String counter_num = ((AutoCompleteTextView) findViewById(R.id.counter_num_entry)).getText().toString(); |
526 |
5
|
String comment = ((EditText) findViewById(R.id.comment_entry)).getText().toString(); |
527 |
5
|
String reg = ((EditText) findViewById(R.id.reg_entry)).getText().toString(); |
528 |
|
|
529 |
5
|
String msg = format_msg(agent, operator, from_city, |
530 |
|
from_station, to_city, to_station, |
531 |
|
sched_time, counter_num, comment, reg); |
532 |
|
|
533 |
|
|
534 |
5
|
boolean sms_checked = mData.submit_selected[0]; |
535 |
5
|
boolean email_checked = mData.submit_selected[1]; |
536 |
5
|
boolean tweet_checked = mData.submit_selected[2]; |
537 |
5
|
boolean youtube_checked = mData.submit_selected[3]; |
538 |
|
|
539 |
|
|
540 |
|
|
541 |
5
|
if (sms_checked && !m_sms_sent) { |
542 |
1
|
send_sms(msg); |
543 |
4
|
} else if (email_checked && !m_email_sent) { |
544 |
1
|
send_email(msg, reg); |
545 |
3
|
} else if (tweet_checked && !m_tweet_sent) { |
546 |
1
|
send_tweet(agent, operator, from_city, from_station, |
547 |
|
to_city, to_station, sched_time, |
548 |
|
comment, reg); |
549 |
2
|
} else if (youtube_checked && !m_youtube_sent) { |
550 |
1
|
send_youtube(msg); |
551 |
|
} |
552 |
|
} |
553 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (13) |
Complexity: 2 |
Complexity Density: 0,18 |
|
554 |
2
|
private void submit_menu()... |
555 |
|
{ |
556 |
2
|
final String[] submit_choices = new String[] { |
557 |
|
getResources().getString(R.string.sms), |
558 |
|
getResources().getString(R.string.email), |
559 |
|
getResources().getString(R.string.tweet), |
560 |
|
getResources().getString(R.string.youtube), |
561 |
|
}; |
562 |
|
|
563 |
2
|
AlertDialog.Builder builder = new AlertDialog.Builder(this); |
564 |
2
|
builder.setTitle(R.string.select_submit); |
565 |
2
|
builder.setMultiChoiceItems(submit_choices, |
566 |
|
mData.submit_selected, new DialogInterface.OnMultiChoiceClickListener() { |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
567 |
3
|
public void onClick(DialogInterface dialog, int which, boolean is_checked) {... |
568 |
3
|
mData.submit_selected[which] = is_checked; |
569 |
|
} |
570 |
|
}); |
571 |
2
|
builder.setPositiveButton(android.R.string.ok, new OnClickListener() { |
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0,2 |
|
572 |
1
|
@Override... |
573 |
|
public void onClick(DialogInterface dialog, int which) { |
574 |
1
|
m_youtube_sent = false; |
575 |
1
|
m_email_sent = false; |
576 |
1
|
m_tweet_sent = false; |
577 |
1
|
m_sms_sent = false; |
578 |
1
|
submit(); |
579 |
|
} |
580 |
|
}); |
581 |
2
|
builder.setNegativeButton(android.R.string.cancel, new OnClickListener() { |
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
582 |
1
|
@Override... |
583 |
|
public void onClick(DialogInterface dialog, int which) { |
584 |
|
} |
585 |
|
}); |
586 |
|
|
587 |
2
|
AlertDialog alert = builder.create(); |
588 |
2
|
ListView list = alert.getListView(); |
589 |
10
|
for (int i=0; i < mData.submit_selected.length; ++i) { |
590 |
8
|
list.setItemChecked(i, mData.submit_selected[i]); |
591 |
|
} |
592 |
|
|
593 |
2
|
alert.show(); |
594 |
|
} |
595 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0,14 |
|
596 |
1
|
private void send_sms(String msg)... |
597 |
|
{ |
598 |
1
|
String sms_msg = EMAIL_SUBJECT + " " + msg; |
599 |
1
|
Intent intent = new Intent(Intent.ACTION_VIEW); |
600 |
|
|
601 |
1
|
intent.putExtra("address", |
602 |
|
SMS_NUMBER); |
603 |
1
|
intent.putExtra("sms_body", sms_msg); |
604 |
|
|
605 |
1
|
intent.setType("vnd.android-dir/mms-sms"); |
606 |
1
|
m_sms_sent = true; |
607 |
1
|
startActivityForResult(intent, ACTIVITY_SUBMIT); |
608 |
|
} |
609 |
|
|
|
|
| 70,6% |
Uncovered Elements: 5 (17) |
Complexity: 4 |
Complexity Density: 0,36 |
|
610 |
1
|
private void send_youtube(String msg)... |
611 |
|
{ |
612 |
1
|
String action = mData.video_uris.size() > 1 ? |
613 |
|
Intent.ACTION_SEND_MULTIPLE : Intent.ACTION_SEND; |
614 |
1
|
Intent youtube_intent = new Intent(action); |
615 |
1
|
youtube_intent.putExtra(Intent.EXTRA_SUBJECT, EMAIL_SUBJECT); |
616 |
1
|
youtube_intent.putExtra(Intent.EXTRA_TEXT, msg); |
617 |
1
|
youtube_intent.setType("video/*"); |
618 |
|
|
619 |
1
|
if (mData.video_uris.size() == 1) { |
620 |
0
|
youtube_intent.putExtra(Intent.EXTRA_STREAM, |
621 |
|
mData.video_uris.get(mData.video_uris.size()-1)); |
622 |
1
|
} else if (mData.video_uris.size() > 1) { |
623 |
0
|
youtube_intent.putExtra(Intent.EXTRA_STREAM, mData.video_uris); |
624 |
|
} |
625 |
|
|
626 |
1
|
m_youtube_sent = true; |
627 |
1
|
startActivityForResult(Intent.createChooser(youtube_intent, |
628 |
|
getResources().getString(R.string.send_youtube)), |
629 |
|
ACTIVITY_SUBMIT); |
630 |
|
} |
631 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (13) |
Complexity: 2 |
Complexity Density: 0,18 |
|
632 |
1
|
private void send_email(final String msg, final String reg)... |
633 |
|
{ |
634 |
1
|
AlertDialog.Builder builder = new AlertDialog.Builder(this); |
635 |
1
|
builder.setTitle(R.string.who_email); |
636 |
1
|
builder.setMultiChoiceItems(R.array.email_choices, |
637 |
|
mData.who_selected, new DialogInterface.OnMultiChoiceClickListener() { |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
638 |
0
|
public void onClick(DialogInterface dialog, int which, boolean is_checked) {... |
639 |
0
|
mData.who_selected[which] = is_checked; |
640 |
|
} |
641 |
|
}); |
642 |
1
|
builder.setPositiveButton(android.R.string.ok, new OnClickListener() { |
|
|
| 0% |
Uncovered Elements: 28 (28) |
Complexity: 5 |
Complexity Density: 0,25 |
|
643 |
0
|
@Override... |
644 |
|
public void onClick(DialogInterface dialog, int which) { |
645 |
0
|
String email_msg = getResources().getString(R.string.email_intro) + "\n" + msg; |
646 |
0
|
String email_addresses = ""; |
647 |
|
|
648 |
|
|
649 |
|
|
650 |
0
|
for (int i=0; i < mData.who_selected.length; ++i) { |
651 |
0
|
if (mData.who_selected[i]) { |
652 |
0
|
email_addresses += EMAIL_ADDRESSES[i]; |
653 |
|
} |
654 |
|
} |
655 |
|
|
656 |
0
|
String subj = EMAIL_SUBJECT; |
657 |
0
|
if (reg.length() != 0) { |
658 |
0
|
subj += ' ' + reg; |
659 |
|
} |
660 |
|
|
661 |
0
|
Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE); |
662 |
|
|
663 |
0
|
ArrayList<Uri> uris = new ArrayList<Uri>(); |
664 |
0
|
uris.addAll(mData.photo_uris); |
665 |
0
|
uris.addAll(mData.recording_uris); |
666 |
0
|
uris.addAll(mData.video_uris); |
667 |
|
|
668 |
0
|
if (uris.size() > 0) { |
669 |
0
|
intent.putExtra(Intent.EXTRA_STREAM, uris); |
670 |
|
} |
671 |
|
|
672 |
0
|
intent.putExtra(Intent.EXTRA_EMAIL, new String[] {email_addresses} ); |
673 |
0
|
intent.putExtra(Intent.EXTRA_SUBJECT, subj); |
674 |
0
|
intent.putExtra(Intent.EXTRA_TEXT, email_msg); |
675 |
0
|
intent.setType("text/plain"); |
676 |
0
|
startActivity(Intent.createChooser(intent, getResources().getString(R.string.send_email))); |
677 |
|
} |
678 |
|
}); |
679 |
|
|
680 |
1
|
builder.setNeutralButton(R.string.who_details, new OnClickListener() { |
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0,2 |
|
681 |
0
|
@Override... |
682 |
|
public void onClick(DialogInterface dialog, int which) { |
683 |
0
|
Intent intent = new Intent(getApplicationContext(), TextViewActivity.class); |
684 |
0
|
Bundle b = new Bundle(); |
685 |
0
|
b.putString("text", getResources().getString(R.string.email_details)); |
686 |
0
|
intent.putExtras(b); |
687 |
0
|
startActivityForResult(intent, ACTIVITY_SUBMIT); |
688 |
|
} |
689 |
|
}); |
690 |
|
|
691 |
1
|
builder.setNegativeButton(android.R.string.cancel, new OnClickListener() { |
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
692 |
1
|
@Override... |
693 |
|
public void onClick(DialogInterface dialog, int which) { |
694 |
1
|
m_email_sent = true; |
695 |
1
|
submit(); |
696 |
|
} |
697 |
|
}); |
698 |
|
|
699 |
1
|
AlertDialog alert = builder.create(); |
700 |
1
|
ListView list = alert.getListView(); |
701 |
7
|
for (int i=0; i < mData.who_selected.length; ++i) { |
702 |
6
|
list.setItemChecked(i, mData.who_selected[i]); |
703 |
|
} |
704 |
|
|
705 |
1
|
alert.show(); |
706 |
|
} |
707 |
|
|
|
|
| 72,7% |
Uncovered Elements: 3 (11) |
Complexity: 2 |
Complexity Density: 0,22 |
|
708 |
1
|
private void send_tweet(String agent, String operator,... |
709 |
|
String from_city, String from_station, String to_city, |
710 |
|
String to_station, String sched_time, |
711 |
|
String comment, String reg) |
712 |
|
{ |
713 |
1
|
String msg = format_tweet(agent, operator, from_city, |
714 |
|
from_station, to_city, to_station, |
715 |
|
sched_time, comment, reg); |
716 |
1
|
Intent intent = new Intent(Intent.ACTION_SEND); |
717 |
1
|
intent.putExtra(Intent.EXTRA_TEXT, msg); |
718 |
1
|
if (!mData.photo_uris.isEmpty()) { |
719 |
0
|
intent.putExtra(Intent.EXTRA_STREAM, |
720 |
|
mData.photo_uris.get(mData.photo_uris.size()-1)); |
721 |
0
|
intent.setType("image/*"); |
722 |
|
} else { |
723 |
1
|
intent.setType("text/plain"); |
724 |
|
} |
725 |
|
|
726 |
1
|
m_tweet_sent = true; |
727 |
1
|
startActivityForResult(Intent.createChooser(intent, |
728 |
|
getResources().getString(R.string.send_tweet)), |
729 |
|
ACTIVITY_SUBMIT); |
730 |
|
} |
731 |
|
|
|
|
| 68,1% |
Uncovered Elements: 23 (72) |
Complexity: 21 |
Complexity Density: 0,44 |
|
732 |
1
|
private String format_tweet(String agent, String operator,... |
733 |
|
String from_city, String from_station, String to_city, |
734 |
|
String to_station, String sched_time, |
735 |
|
String comment, String reg) |
736 |
|
{ |
737 |
|
|
738 |
|
|
739 |
1
|
HashMap<String, Boolean> map = new HashMap<String, Boolean>(); |
740 |
1
|
map.put("twitter_address1", true); |
741 |
1
|
map.put("twitter_address2", false); |
742 |
1
|
map.put("twitter_address3", false); |
743 |
1
|
map.put("sched_time", false); |
744 |
1
|
map.put("reg", reg.length() != 0); |
745 |
1
|
map.put("operator",false); |
746 |
1
|
map.put("agent", false); |
747 |
1
|
map.put("from_city", false); |
748 |
1
|
map.put("from_station", false); |
749 |
1
|
map.put("to_city", false); |
750 |
1
|
map.put("to_station", false); |
751 |
|
|
752 |
1
|
int max_length = MAX_TWEET_LENGTH; |
753 |
1
|
if (mData.photo_uris.size() > 0) { |
754 |
0
|
max_length -= 21; |
755 |
|
} |
756 |
|
|
757 |
1
|
map.put("comment", true); |
758 |
1
|
if (comment.length() == 0 || build_tweet(map, operator, agent, |
759 |
|
from_city, from_station, to_city, |
760 |
|
to_station, sched_time, comment, |
761 |
|
reg).length() > |
762 |
|
max_length) { |
763 |
0
|
map.put("comment", false); |
764 |
|
} |
765 |
|
|
766 |
1
|
map.put("operator", true); |
767 |
1
|
if (comment.length() == 0 || build_tweet(map, operator, agent, |
768 |
|
from_city, from_station, to_city, |
769 |
|
to_station, sched_time, comment, |
770 |
|
reg).length() > |
771 |
|
max_length) { |
772 |
0
|
map.put("operator", false); |
773 |
|
} |
774 |
|
|
775 |
1
|
map.put("from_station", true); |
776 |
1
|
if (from_station.length() == 0 || build_tweet(map, operator, |
777 |
|
agent, from_city, from_station, |
778 |
|
to_city, to_station, sched_time, |
779 |
|
comment, reg).length() > |
780 |
|
max_length) { |
781 |
0
|
map.put("from_station", false); |
782 |
|
} |
783 |
|
|
784 |
1
|
map.put("to_station", true); |
785 |
1
|
if (to_station.length() == 0 || build_tweet(map, operator, |
786 |
|
agent, from_city, from_station, |
787 |
|
to_city, to_station, sched_time, |
788 |
|
comment, reg).length() > |
789 |
|
max_length) { |
790 |
0
|
map.put("to_station", false); |
791 |
|
} |
792 |
|
|
793 |
1
|
map.put("from_city", true); |
794 |
1
|
if (from_city.length() == 0 || build_tweet(map, operator, |
795 |
|
agent, from_city, from_station, |
796 |
|
to_city, to_station, sched_time, |
797 |
|
comment, reg).length() > |
798 |
|
max_length) { |
799 |
0
|
map.put("from_city", false); |
800 |
|
} |
801 |
|
|
802 |
1
|
map.put("to_city", true); |
803 |
1
|
if (to_city.length() == 0 || build_tweet(map, operator, |
804 |
|
agent, from_city, from_station, |
805 |
|
to_city, to_station, sched_time, |
806 |
|
comment, reg).length() > |
807 |
|
max_length) { |
808 |
0
|
map.put("to_city", false); |
809 |
|
} |
810 |
|
|
811 |
1
|
map.put("twitter_address2", true); |
812 |
1
|
if (build_tweet(map, operator, agent, from_city, from_station, |
813 |
|
to_city, to_station, sched_time, |
814 |
|
comment, reg).length() > |
815 |
|
max_length) { |
816 |
0
|
map.put("twitter_address2", false); |
817 |
|
} |
818 |
|
|
819 |
1
|
map.put("sched_time", true); |
820 |
1
|
if (sched_time.length() == 0 || build_tweet(map, operator, |
821 |
|
agent, from_city, from_station, |
822 |
|
to_city, to_station, sched_time, |
823 |
|
comment, reg).length() > |
824 |
|
max_length) { |
825 |
0
|
map.put("sched_time", false); |
826 |
|
} |
827 |
|
|
828 |
1
|
map.put("agent", true); |
829 |
1
|
if (comment.length() == 0 || build_tweet(map, operator, |
830 |
|
agent, from_city, from_station, |
831 |
|
to_city, to_station, sched_time, |
832 |
|
comment, reg).length() > |
833 |
|
max_length) { |
834 |
0
|
map.put("agent", false); |
835 |
|
} |
836 |
|
|
837 |
1
|
map.put("twitter_address3", true); |
838 |
1
|
if (build_tweet(map, operator, agent, from_city, from_station, |
839 |
|
to_city, to_station, sched_time, |
840 |
|
comment, reg).length() > |
841 |
|
max_length) { |
842 |
0
|
map.put("twitter_address3", false); |
843 |
|
} |
844 |
|
|
845 |
|
|
846 |
|
|
847 |
|
|
848 |
1
|
if (comment.length() != 0) { |
849 |
1
|
map.put("comment", true); |
850 |
|
} |
851 |
|
|
852 |
1
|
return build_tweet(map, operator, agent, from_city, |
853 |
|
from_station, to_city, to_station, sched_time, |
854 |
|
comment, reg); |
855 |
|
} |
856 |
|
|
|
|
| 69,8% |
Uncovered Elements: 35 (116) |
Complexity: 39 |
Complexity Density: 0,67 |
|
857 |
11
|
private String build_tweet(HashMap<String, Boolean> map, String operator,... |
858 |
|
String agent, String from_city, String from_station, |
859 |
|
String to_city, String to_station, String sched_time, |
860 |
|
String comment, String reg) |
861 |
|
{ |
862 |
11
|
String ret = ""; |
863 |
|
|
864 |
11
|
if (map.get("twitter_address1")) { |
865 |
11
|
ret += TWITTER_ADDRESS1; |
866 |
|
} |
867 |
|
|
868 |
11
|
if (map.get("sched_time")) { |
869 |
4
|
if (ret.length() != 0) { |
870 |
4
|
ret += ' '; |
871 |
|
} |
872 |
4
|
ret += sched_time; |
873 |
|
} |
874 |
|
|
875 |
11
|
if (map.get("reg")) { |
876 |
11
|
if (ret.length() != 0) { |
877 |
11
|
ret += ' '; |
878 |
|
} |
879 |
11
|
ret += reg; |
880 |
|
} |
881 |
|
|
882 |
11
|
if (map.get("operator")) { |
883 |
10
|
if (ret.length() != 0) { |
884 |
10
|
ret += ' '; |
885 |
|
} |
886 |
10
|
ret += operator; |
887 |
|
} |
888 |
|
|
889 |
11
|
if (map.get("agent")) { |
890 |
3
|
if (map.get("operator")) { |
891 |
3
|
ret += ", "; |
892 |
0
|
} else if (ret.length() != 0) { |
893 |
0
|
ret += ' '; |
894 |
|
} |
895 |
3
|
ret += agent; |
896 |
|
} |
897 |
|
|
898 |
11
|
if (map.get("from_city") || map.get("from_station")) { |
899 |
9
|
if (map.get("operator") || map.get("agent")) { |
900 |
9
|
ret += ", "; |
901 |
0
|
} else if (ret.length() != 0) { |
902 |
0
|
ret += ' '; |
903 |
|
} |
904 |
9
|
if (map.get("from_station")) { |
905 |
9
|
ret += from_station; |
906 |
|
} |
907 |
9
|
if (map.get("from_city") && !from_city.equals(from_station)) { |
908 |
0
|
if (map.get("from_station")) { |
909 |
0
|
ret += ", "; |
910 |
|
} |
911 |
0
|
ret += from_city; |
912 |
|
} |
913 |
|
} |
914 |
|
|
915 |
11
|
if (map.get("to_city") || map.get("to_station")) { |
916 |
8
|
if (ret.length() != 0) { |
917 |
8
|
ret += ' '; |
918 |
|
} |
919 |
8
|
if (map.get("from_station") || map.get("from_city")) { |
920 |
8
|
ret += "-> "; |
921 |
|
} |
922 |
8
|
if (map.get("to_station")) { |
923 |
8
|
ret += to_station; |
924 |
|
} |
925 |
8
|
if (map.get("to_city") && !to_city.equals(to_station)) { |
926 |
0
|
if (map.get("to_station")) { |
927 |
0
|
ret += ", "; |
928 |
|
} |
929 |
0
|
ret += to_city; |
930 |
|
} |
931 |
|
} |
932 |
|
|
933 |
11
|
if (map.get("comment")) { |
934 |
11
|
if (map.get("from_city") || map.get("from_station") || |
935 |
|
map.get("to_city") || |
936 |
|
map.get("to_station")) { |
937 |
9
|
ret += ','; |
938 |
|
} |
939 |
11
|
if (ret.length() != 0) { |
940 |
11
|
ret += ' '; |
941 |
|
} |
942 |
11
|
ret += comment; |
943 |
|
} |
944 |
|
|
945 |
11
|
if (map.get("twitter_address2")) { |
946 |
5
|
if (ret.length() != 0) { |
947 |
5
|
ret += ' '; |
948 |
|
} |
949 |
5
|
ret += TWITTER_ADDRESS2; |
950 |
|
} |
951 |
|
|
952 |
11
|
if (map.get("twitter_address3")) { |
953 |
2
|
if (ret.length() != 0) { |
954 |
2
|
ret += ' '; |
955 |
|
} |
956 |
2
|
ret += TWITTER_ADDRESS3; |
957 |
|
} |
958 |
|
|
959 |
11
|
return ret; |
960 |
|
} |
961 |
|
|
|
|
| 62,1% |
Uncovered Elements: 22 (58) |
Complexity: 19 |
Complexity Density: 0,63 |
|
962 |
5
|
private String format_msg(String agent, String operator,... |
963 |
|
String from_city, String from_station, String to_city, |
964 |
|
String to_station, String sched_time, |
965 |
|
String counter, String comment, String reg) |
966 |
|
{ |
967 |
5
|
String msg = ""; |
968 |
|
|
969 |
5
|
if (sched_time.length() != 0) { |
970 |
5
|
msg += '\n' + sched_time; |
971 |
|
} |
972 |
|
|
973 |
5
|
if (reg.length() != 0) { |
974 |
5
|
msg += '\n' + getResources().getString(R.string.email_reg) + ": " + reg; |
975 |
|
} |
976 |
|
|
977 |
5
|
if (from_city.length() != 0 || from_station.length() != 0) { |
978 |
5
|
msg += '\n' + getResources().getString(R.string.email_from) + ": "; |
979 |
5
|
if (from_station.length() != 0) { |
980 |
5
|
msg += from_station; |
981 |
|
} |
982 |
5
|
if (from_city.length() != 0 && !from_city.equals(from_station)) { |
983 |
0
|
if (from_station.length() != 0) { |
984 |
0
|
msg += ", "; |
985 |
|
} |
986 |
0
|
msg += from_city; |
987 |
|
} |
988 |
|
} |
989 |
|
|
990 |
5
|
if (to_city.length() != 0 || to_station.length() != 0) { |
991 |
5
|
msg += '\n' + getResources().getString(R.string.email_to) + ": "; |
992 |
5
|
if (to_station.length() != 0) { |
993 |
5
|
msg += to_station; |
994 |
|
} |
995 |
5
|
if (to_city.length() != 0 && !to_city.equals(to_station)) { |
996 |
0
|
if (to_station.length() != 0) { |
997 |
0
|
msg += ", "; |
998 |
|
} |
999 |
0
|
msg += to_city; |
1000 |
|
} |
1001 |
|
} |
1002 |
|
|
1003 |
5
|
if (agent.length() != 0) { |
1004 |
5
|
msg += '\n' + getResources().getString(R.string.email_agent) + ": " + agent; |
1005 |
|
} |
1006 |
|
|
1007 |
5
|
if (counter.length() != 0) { |
1008 |
5
|
msg += '\n' + getResources().getString(R.string.email_counter) + ": " + counter; |
1009 |
|
} |
1010 |
|
|
1011 |
5
|
if (operator.length() != 0) { |
1012 |
5
|
msg += '\n' + getResources().getString(R.string.email_operator) + ": " + operator; |
1013 |
|
} |
1014 |
|
|
1015 |
5
|
if (comment.length() != 0) { |
1016 |
5
|
msg += '\n' + getResources().getString(R.string.email_offence) + ": " + comment; |
1017 |
|
} |
1018 |
|
|
1019 |
5
|
return msg; |
1020 |
|
} |
1021 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1022 |
6
|
private String format_time(Calendar cal)... |
1023 |
|
{ |
1024 |
6
|
return new SimpleDateFormat("yyyy-MM-dd HH:mm").format(cal.getTime()); |
1025 |
|
} |
1026 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0,4 |
|
1027 |
0
|
private ArrayList<Uri> strarr2uriarr(ArrayList<String> str_arr)... |
1028 |
|
{ |
1029 |
0
|
ArrayList<Uri> ret = new ArrayList<Uri>(); |
1030 |
0
|
Iterator<String> itr = str_arr.iterator(); |
1031 |
0
|
while (itr.hasNext()) { |
1032 |
0
|
ret.add(Uri.parse(itr.next())); |
1033 |
|
} |
1034 |
0
|
return ret; |
1035 |
|
} |
1036 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 2 |
Complexity Density: 0,4 |
|
1037 |
27
|
private ArrayList<String> uriarr2strarr(ArrayList<Uri> uri_arr)... |
1038 |
|
{ |
1039 |
27
|
ArrayList<String> ret = new ArrayList<String>(); |
1040 |
27
|
Iterator<Uri> itr = uri_arr.iterator(); |
1041 |
30
|
while (itr.hasNext()) { |
1042 |
3
|
ret.add(itr.next().toString()); |
1043 |
|
} |
1044 |
27
|
return ret; |
1045 |
|
} |
1046 |
|
|
|
|
| 87,5% |
Uncovered Elements: 1 (8) |
Complexity: 3 |
Complexity Density: 0,38 |
|
1047 |
2
|
@Override... |
1048 |
|
protected Dialog onCreateDialog(int id) |
1049 |
|
{ |
1050 |
2
|
DatePickerDialog.OnDateSetListener sched_date_listener = |
1051 |
|
new DatePickerDialog.OnDateSetListener() { |
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
1052 |
2
|
public void onDateSet(DatePicker view, int year,... |
1053 |
|
int monthOfYear, int dayOfMonth) { |
1054 |
2
|
mData.sched_time.set(year, monthOfYear, dayOfMonth); |
1055 |
2
|
update_date_label(R.id.sched_date_button, |
1056 |
|
mData.sched_time); |
1057 |
|
} |
1058 |
|
}; |
1059 |
|
|
1060 |
2
|
TimePickerDialog.OnTimeSetListener sched_time_listener = |
1061 |
|
new TimePickerDialog.OnTimeSetListener() { |
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0,2 |
|
1062 |
2
|
public void onTimeSet(TimePicker view,... |
1063 |
|
int hourOfDay, int minute) { |
1064 |
2
|
int year = mData.sched_time.get(Calendar.YEAR); |
1065 |
2
|
int month = mData.sched_time.get(Calendar.MONTH); |
1066 |
2
|
int day = mData.sched_time.get(Calendar.DAY_OF_MONTH); |
1067 |
2
|
mData.sched_time.set(year, month, day, hourOfDay, minute); |
1068 |
2
|
update_time_label(R.id.sched_time_button, |
1069 |
|
mData.sched_time); |
1070 |
|
} |
1071 |
|
}; |
1072 |
|
|
1073 |
2
|
switch (id) { |
1074 |
1
|
case SCHED_DATE_DIALOG_ID: |
1075 |
1
|
return new DatePickerDialog(this, sched_date_listener, |
1076 |
|
mData.sched_time.get(Calendar.YEAR), |
1077 |
|
mData.sched_time.get(Calendar.MONTH), |
1078 |
|
mData.sched_time.get(Calendar.DAY_OF_MONTH)); |
1079 |
1
|
case SCHED_TIME_DIALOG_ID: |
1080 |
1
|
return new TimePickerDialog(this, sched_time_listener, |
1081 |
|
mData.sched_time.get(Calendar.HOUR_OF_DAY), |
1082 |
|
mData.sched_time.get(Calendar.MINUTE), |
1083 |
|
false); |
1084 |
|
} |
1085 |
|
|
1086 |
0
|
return null; |
1087 |
|
} |
1088 |
|
|
|
|
| 80,8% |
Uncovered Elements: 10 (52) |
Complexity: 14 |
Complexity Density: 0,37 |
|
1089 |
9
|
@Override... |
1090 |
|
protected void onActivityResult(int request_code, int result_code, Intent data) |
1091 |
|
{ |
1092 |
9
|
super.onActivityResult(request_code, result_code, data); |
1093 |
|
|
1094 |
9
|
switch (request_code) { |
1095 |
1
|
case ACTIVITY_FROM: |
1096 |
1
|
if (result_code == RESULT_OK) { |
1097 |
1
|
Bundle b = data.getExtras(); |
1098 |
1
|
if (b != null) { |
1099 |
1
|
String station = b.getString("station"); |
1100 |
1
|
String city = b.getString("city"); |
1101 |
1
|
((AutoCompleteTextView) findViewById(R.id.from_city_entry)).setText(city); |
1102 |
1
|
((AutoCompleteTextView) findViewById(R.id.from_station_entry)).setText(station); |
1103 |
|
} |
1104 |
|
} |
1105 |
1
|
break; |
1106 |
1
|
case ACTIVITY_TO: |
1107 |
1
|
if (result_code == RESULT_OK) { |
1108 |
1
|
Bundle b = data.getExtras(); |
1109 |
1
|
if (b != null) { |
1110 |
1
|
String station = b.getString("station"); |
1111 |
1
|
String city = b.getString("city"); |
1112 |
1
|
((AutoCompleteTextView) findViewById(R.id.to_city_entry)).setText(city); |
1113 |
1
|
((AutoCompleteTextView) findViewById(R.id.to_station_entry)).setText(station); |
1114 |
|
} |
1115 |
|
} |
1116 |
1
|
break; |
1117 |
1
|
case ACTIVITY_TAKE_PHOTO: |
1118 |
1
|
if (result_code == RESULT_OK) { |
1119 |
0
|
mData.photo_uris.add(data.getData()); |
1120 |
0
|
((TextView)findViewById(R.id.camera_label)).setText(Integer.toString(mData.photo_uris.size())); |
1121 |
|
} |
1122 |
1
|
break; |
1123 |
1
|
case ACTIVITY_TAKE_VIDEO: |
1124 |
1
|
if (result_code == RESULT_OK) { |
1125 |
0
|
mData.video_uris.add(data.getData()); |
1126 |
0
|
((TextView)findViewById(R.id.video_label)).setText(Integer.toString(mData.video_uris.size())); |
1127 |
|
} |
1128 |
1
|
break; |
1129 |
2
|
case ACTIVITY_RECORD_SOUND: |
1130 |
2
|
if (result_code == RESULT_OK) { |
1131 |
1
|
mData.recording_uris.add(data.getData()); |
1132 |
1
|
((TextView)findViewById(R.id.recorder_label)).setText(Integer.toString(mData.recording_uris.size())); |
1133 |
|
} |
1134 |
2
|
break; |
1135 |
3
|
case ACTIVITY_SUBMIT: |
1136 |
|
|
1137 |
3
|
submit(); |
1138 |
3
|
break; |
1139 |
|
} |
1140 |
|
} |
1141 |
|
} |
1142 |
|
|