diff --git a/androidgcs/src/org/openpilot/androidgcs/ObjectEditView.java b/androidgcs/src/org/openpilot/androidgcs/ObjectEditView.java index 7946a357b..401a26978 100644 --- a/androidgcs/src/org/openpilot/androidgcs/ObjectEditView.java +++ b/androidgcs/src/org/openpilot/androidgcs/ObjectEditView.java @@ -22,22 +22,22 @@ public class ObjectEditView extends GridLayout { public List fields; public ObjectEditView(Context context) { - super(context); + super(context); initObjectEditView(); } - public ObjectEditView(Context context, AttributeSet ats, int defaultStyle) { + public ObjectEditView(Context context, AttributeSet ats, int defaultStyle) { super(context, ats); initObjectEditView(); } - public ObjectEditView(Context context, AttributeSet ats) { + public ObjectEditView(Context context, AttributeSet ats) { super(context, ats); initObjectEditView(); } public void initObjectEditView() { - // Set orientation of layout to vertical + // Set orientation of layout to vertical setOrientation(LinearLayout.VERTICAL); setColumnCount(2); fields = new ArrayList(); @@ -51,11 +51,11 @@ public class ObjectEditView extends GridLayout { for (int i = 0; i < field.getNumElements(); i++) addRow(getContext(), field, i); } - - + + public void addRow(Context context, UAVObjectField field, int idx) { int row = getRowCount(); - + TextView fieldName = new TextView(context); if(field.getNumElements() == 1) { fieldName.setText(field.getName()); @@ -65,7 +65,7 @@ public class ObjectEditView extends GridLayout { addView(fieldName, new GridLayout.LayoutParams(spec(row), spec(0))); View fieldValue = null; - switch(field.getType()) + switch(field.getType()) { case FLOAT32: fieldValue = new EditText(context); @@ -93,8 +93,16 @@ public class ObjectEditView extends GridLayout { ((Spinner) fieldValue).setAdapter(adapter); ((Spinner) fieldValue).setSelection((int) field.getDouble(idx)); break; + case BITFIELD: + fieldValue = new EditText(context); + ((EditText)fieldValue).setText(field.getValue(idx).toString()); + ((EditText)fieldValue).setInputType(InputType.TYPE_CLASS_NUMBER); + break; + case STRING: + fieldValue = new EditText(context); + ((EditText)fieldValue).setText(field.getValue(idx).toString()); } - + addView(fieldValue, new GridLayout.LayoutParams(spec(row), spec(1))); fields.add(fieldValue); } diff --git a/androidgcs/src/org/openpilot/uavtalk/UAVObjectField.java b/androidgcs/src/org/openpilot/uavtalk/UAVObjectField.java index d07fdf6fd..7fea950f0 100644 --- a/androidgcs/src/org/openpilot/uavtalk/UAVObjectField.java +++ b/androidgcs/src/org/openpilot/uavtalk/UAVObjectField.java @@ -578,6 +578,12 @@ public class UAVObjectField { ((ArrayList) data).add((byte) 0); } break; + case STRING: + ((ArrayList) data).clear(); + for(int index = 0; index < numElements; ++index) { + ((ArrayList) data).add((byte) 0); + } + break; } } @@ -633,7 +639,7 @@ public class UAVObjectField { numBytesPerElement = 1; break; case STRING: - data = new ArrayList(this.numElements); + data = new ArrayList(this.numElements); numBytesPerElement = 1; break; default: @@ -650,15 +656,9 @@ public class UAVObjectField { */ protected Long bound (Object val) { - switch(type) { - case ENUM: - case STRING: - return 0L; - case FLOAT32: - return ((Number) val).longValue(); - } - - long num = ((Number) val).longValue(); + long num = 0; + if (isNumeric()) + num = ((Number) val).longValue(); switch(type) { case INT8: @@ -703,6 +703,11 @@ public class UAVObjectField { if(num > 255) return (long) 255; return num; + case FLOAT32: + return ((Number) val).longValue(); + case ENUM: + case STRING: + return 0L; } return num;