Skip to content

Commit

Permalink
writing semicolon values in xml almost working correctly #103
Browse files Browse the repository at this point in the history
  • Loading branch information
hallahan committed Jan 6, 2016
1 parent 8f103bb commit 4a2237c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public boolean hasCheckedTagValues() {
return false;
}

public String getSemiColonDelimitedTagValues() {
public String getSemiColonDelimitedTagValues(String customValues) {
String values = null;
boolean firstVal = true;
for (CheckBox cb : checkBoxes) {
Expand All @@ -111,6 +111,16 @@ public String getSemiColonDelimitedTagValues() {
}
}
}
if (customValues != null) {
customValues = customValues.trim();
if (customValues.length() > 0) {
if (firstVal) {
values = customValues;
} else {
values += ';' + customValues;
}
}
}
return values;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ private void setupWidgets() {

@SuppressWarnings("ResourceType")
private void setupCheckBoxes() {
tagEdit.setCheckBoxMode(true);
final LinearLayout checkboxLinearLayout = (LinearLayout)rootView.findViewById(R.id.checkboxLinearLayout);
final Activity activity = getActivity();
ODKTag odkTag = tagEdit.getODKTag();
Expand Down Expand Up @@ -150,6 +149,7 @@ public void onClick(View view) {
}
}
});
tagEdit.setupEditCheckbox(editTextCheckBox, editText);

LinearLayout customLinearLayout = new LinearLayout(activity);
customLinearLayout.setOrientation(LinearLayout.HORIZONTAL);
Expand Down
17 changes: 15 additions & 2 deletions app/src/main/java/org/redcross/openmapkit/tagswipe/TagEdit.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.redcross.openmapkit.tagswipe;

import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.RadioButton;
Expand Down Expand Up @@ -39,6 +40,12 @@ public class TagEdit {
private int idx = -1;
private EditText editText;
private RadioGroup radioGroup;

/**
* For CheckBox mode.
*/
private CheckBox editTextCheckBox;
private EditText checkBoxEditText;

public static List<TagEdit> buildTagEdits() {
int idx = 0;
Expand Down Expand Up @@ -137,8 +144,10 @@ public void setRadioGroup(RadioGroup radioGroup) {
this.radioGroup = radioGroup;
}

public void setCheckBoxMode(boolean bool) {
public void setupEditCheckbox(CheckBox cb, EditText et) {
checkBoxMode = true;
editTextCheckBox = cb;
checkBoxEditText = et;
}

public ODKTag getODKTag() {
Expand All @@ -149,7 +158,11 @@ private void updateTagInOSMElement() {
// check boxes
if (odkTag != null && checkBoxMode) {
if (odkTag.hasCheckedTagValues()) {
tagVal = odkTag.getSemiColonDelimitedTagValues();
if (editTextCheckBox.isChecked()) {
tagVal = odkTag.getSemiColonDelimitedTagValues(checkBoxEditText.getText().toString());
} else {
tagVal = odkTag.getSemiColonDelimitedTagValues(null);
}
osmElement.addOrEditTag(tagKey, tagVal);
} else {
osmElement.deleteTag(tagKey);
Expand Down

0 comments on commit 4a2237c

Please sign in to comment.