|
14 | 14 | import android.support.v7.app.AppCompatActivity;
|
15 | 15 | import android.os.Bundle;
|
16 | 16 | import android.telephony.SmsManager;
|
| 17 | +import android.text.Editable; |
17 | 18 | import android.text.InputFilter;
|
18 | 19 | import android.text.Spanned;
|
| 20 | +import android.text.TextWatcher; |
19 | 21 | import android.util.Log;
|
20 | 22 | import android.view.LayoutInflater;
|
21 | 23 | import android.view.Menu;
|
@@ -98,8 +100,30 @@ protected void onCreate(Bundle savedInstanceState) {
|
98 | 100 |
|
99 | 101 | for(int i = 0; i < inputs.length; i++) {
|
100 | 102 | inputs[i] = (EditText) findViewById(inputIDs[i]);
|
| 103 | + |
| 104 | + //tick the box to include data when there is, and untick it when it's not |
| 105 | + final CheckBox cb = checkBoxes[i]; |
| 106 | + inputs[i].addTextChangedListener(new TextWatcher() { |
| 107 | + @Override |
| 108 | + public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } |
| 109 | + |
| 110 | + @Override |
| 111 | + public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { } |
| 112 | + |
| 113 | + @Override |
| 114 | + public void afterTextChanged(Editable editable) { |
| 115 | + if(editable.length() == 0 && cb.isChecked()) { |
| 116 | + cb.setChecked(false); |
| 117 | + } |
| 118 | + else if(editable.length() > 0 && !cb.isChecked()) { |
| 119 | + cb.setChecked(true); |
| 120 | + } |
| 121 | + } |
| 122 | + }); |
101 | 123 | }
|
102 | 124 |
|
| 125 | + |
| 126 | + |
103 | 127 | //for BG input, only allow 2 digits before the decimal place, and 1 after
|
104 | 128 | //Log.i(TAG, "existing filters: "+inputs[0].getFilters().length);
|
105 | 129 | inputs[0].setFilters(new InputFilter[]{new DecimalDigitsInputFilter(2,1)});
|
@@ -171,18 +195,17 @@ public void clickRecordButton() {
|
171 | 195 | String csvFormatLine = sdf.format(new Date(instantOpened));
|
172 | 196 |
|
173 | 197 | //select which fields have been ticked
|
174 |
| - String out = "Diabetic Diary ENTRY @ "+ DateTime.get(instantOpened, |
175 |
| - DateTime.TimeFormat.MINUTES)+" {"; |
| 198 | + String out = DateTime.get(instantOpened, |
| 199 | + DateTime.TimeFormat.MINUTES, DateFormat.BRIEF_WITH_DAY)+": "; |
176 | 200 | boolean anyTicked = false;
|
177 | 201 | for(int i = 0; i < checkBoxes.length; i++) {
|
178 | 202 | csvFormatLine += ",";
|
179 | 203 | if(checkBoxes[i].isChecked()) {
|
180 | 204 | anyTicked = true;
|
181 |
| - out += names[i]+":"+inputs[i].getText()+"; "; |
| 205 | + out += names[i]+":"+inputs[i].getText()+", "; |
182 | 206 | csvFormatLine += inputs[i].getText();
|
183 | 207 | }
|
184 | 208 | }
|
185 |
| - out += "}"; |
186 | 209 | //csvFormatLine = csvFormatLine.substring(1);
|
187 | 210 | Log.i(TAG, out);
|
188 | 211 |
|
@@ -418,8 +441,8 @@ public void onClick(View view) {
|
418 | 441 | @Override
|
419 | 442 | public void onClick(View view) {
|
420 | 443 | SharedPreferences.Editor editor = sp.edit();
|
421 |
| - //bizarrely, there doesn't seem to a method in ArrayAdapters |
422 |
| - // to get all the data out in one go |
| 444 | + //bizarrely, there doesn't seem to be a method in ArrayAdapters, |
| 445 | + // to get all the data out in one go. eg ArrayAdapter.getArray() |
423 | 446 | ArrayAdapter<String> adapter = (ArrayAdapter<String>)listView.getAdapter();
|
424 | 447 | Set<String> newData = new HashSet<String>(adapter.getCount());
|
425 | 448 | String numbersAsString = "";
|
|
0 commit comments