use of org.odk.collect.android.formentry.audit.AuditConfig in project collect by getodk.
the class BackgroundLocationManager method startLocationRequests.
private void startLocationRequests() {
if (helper.currentFormAuditsLocation() && helper.isBackgroundLocationPreferenceEnabled() && helper.arePlayServicesAvailable() && helper.isAndroidLocationPermissionGranted()) {
AuditConfig auditConfig = helper.getCurrentFormAuditConfig();
locationClient.setListener(this);
locationClient.setPriority(auditConfig.getLocationPriority());
locationClient.setUpdateIntervals(auditConfig.getLocationMinInterval(), auditConfig.getLocationMinInterval());
locationClient.start();
currentState = BackgroundLocationState.RECEIVING_LOCATIONS;
}
}
use of org.odk.collect.android.formentry.audit.AuditConfig in project collect by opendatakit.
the class FormController method getSubmissionMetadata.
/**
* Get the OpenRosa required metadata of the portion of the form beng submitted
*/
public InstanceMetadata getSubmissionMetadata() {
FormDef formDef = formEntryController.getModel().getForm();
TreeElement rootElement = formDef.getInstance().getRoot();
TreeElement trueSubmissionElement;
// Determine the information about the submission...
SubmissionProfile p = formDef.getSubmissionProfile();
if (p == null || p.getRef() == null) {
trueSubmissionElement = rootElement;
} else {
IDataReference ref = p.getRef();
trueSubmissionElement = formDef.getInstance().resolveReference(ref);
// resolveReference returns null if the reference is to the root element...
if (trueSubmissionElement == null) {
trueSubmissionElement = rootElement;
}
}
// and find the depth-first meta block in this...
TreeElement e = findDepthFirst(trueSubmissionElement, "meta");
String instanceId = null;
String instanceName = null;
AuditConfig auditConfig = null;
if (e != null) {
List<TreeElement> v;
// instance id...
v = e.getChildrenWithName(INSTANCE_ID);
if (v.size() == 1) {
IAnswerData sa = v.get(0).getValue();
if (sa != null) {
instanceId = sa.getDisplayText();
}
}
// instance name...
v = e.getChildrenWithName(INSTANCE_NAME);
if (v.size() == 1) {
IAnswerData sa = v.get(0).getValue();
if (sa != null) {
instanceName = sa.getDisplayText();
}
}
// timing element...
v = e.getChildrenWithName(AUDIT);
if (v.size() == 1) {
TreeElement auditElement = v.get(0);
String locationPriority = auditElement.getBindAttributeValue(XML_OPENDATAKIT_NAMESPACE, "location-priority");
String locationMinInterval = auditElement.getBindAttributeValue(XML_OPENDATAKIT_NAMESPACE, "location-min-interval");
String locationMaxAge = auditElement.getBindAttributeValue(XML_OPENDATAKIT_NAMESPACE, "location-max-age");
boolean isTrackingChangesEnabled = Boolean.parseBoolean(auditElement.getBindAttributeValue(XML_OPENDATAKIT_NAMESPACE, "track-changes"));
boolean isIdentifyUserEnabled = Boolean.parseBoolean(auditElement.getBindAttributeValue(XML_OPENDATAKIT_NAMESPACE, "identify-user"));
String trackChangesReason = auditElement.getBindAttributeValue(XML_OPENDATAKIT_NAMESPACE, "track-changes-reasons");
auditConfig = new AuditConfig.Builder().setMode(locationPriority).setLocationMinInterval(locationMinInterval).setLocationMaxAge(locationMaxAge).setIsTrackingChangesEnabled(isTrackingChangesEnabled).setIsIdentifyUserEnabled(isIdentifyUserEnabled).setIsTrackChangesReasonEnabled(trackChangesReason != null && trackChangesReason.equals("on-form-edit")).createAuditConfig();
IAnswerData answerData = new StringData();
answerData.setValue(AUDIT_FILE_NAME);
auditElement.setValue(answerData);
}
}
return new InstanceMetadata(instanceId, instanceName, auditConfig);
}
use of org.odk.collect.android.formentry.audit.AuditConfig in project collect by opendatakit.
the class BackgroundLocationManager method startLocationRequests.
private void startLocationRequests() {
if (helper.currentFormAuditsLocation() && helper.isBackgroundLocationPreferenceEnabled() && helper.arePlayServicesAvailable() && helper.isAndroidLocationPermissionGranted()) {
AuditConfig auditConfig = helper.getCurrentFormAuditConfig();
locationClient.setListener(this);
locationClient.setPriority(auditConfig.getLocationPriority());
locationClient.setUpdateIntervals(auditConfig.getLocationMinInterval(), auditConfig.getLocationMinInterval());
locationClient.start();
currentState = BackgroundLocationState.RECEIVING_LOCATIONS;
}
}
use of org.odk.collect.android.formentry.audit.AuditConfig in project collect by getodk.
the class FormController method getSubmissionMetadata.
/**
* Get the OpenRosa required metadata of the portion of the form beng submitted
*/
public InstanceMetadata getSubmissionMetadata() {
FormDef formDef = formEntryController.getModel().getForm();
TreeElement rootElement = formDef.getInstance().getRoot();
TreeElement trueSubmissionElement;
// Determine the information about the submission...
SubmissionProfile p = formDef.getSubmissionProfile();
if (p == null || p.getRef() == null) {
trueSubmissionElement = rootElement;
} else {
IDataReference ref = p.getRef();
trueSubmissionElement = formDef.getInstance().resolveReference(ref);
// resolveReference returns null if the reference is to the root element...
if (trueSubmissionElement == null) {
trueSubmissionElement = rootElement;
}
}
// and find the depth-first meta block in this...
TreeElement e = findDepthFirst(trueSubmissionElement, "meta");
String instanceId = null;
String instanceName = null;
AuditConfig auditConfig = null;
if (e != null) {
List<TreeElement> v;
// instance id...
v = e.getChildrenWithName(INSTANCE_ID);
if (v.size() == 1) {
IAnswerData sa = v.get(0).getValue();
if (sa != null) {
instanceId = sa.getDisplayText();
}
}
// instance name...
v = e.getChildrenWithName(INSTANCE_NAME);
if (v.size() == 1) {
IAnswerData sa = v.get(0).getValue();
if (sa != null) {
instanceName = sa.getDisplayText();
}
}
// timing element...
v = e.getChildrenWithName(AUDIT);
if (v.size() == 1) {
TreeElement auditElement = v.get(0);
String locationPriority = auditElement.getBindAttributeValue(XML_OPENDATAKIT_NAMESPACE, "location-priority");
String locationMinInterval = auditElement.getBindAttributeValue(XML_OPENDATAKIT_NAMESPACE, "location-min-interval");
String locationMaxAge = auditElement.getBindAttributeValue(XML_OPENDATAKIT_NAMESPACE, "location-max-age");
boolean isTrackingChangesEnabled = Boolean.parseBoolean(auditElement.getBindAttributeValue(XML_OPENDATAKIT_NAMESPACE, "track-changes"));
boolean isIdentifyUserEnabled = Boolean.parseBoolean(auditElement.getBindAttributeValue(XML_OPENDATAKIT_NAMESPACE, "identify-user"));
String trackChangesReason = auditElement.getBindAttributeValue(XML_OPENDATAKIT_NAMESPACE, "track-changes-reasons");
auditConfig = new AuditConfig.Builder().setMode(locationPriority).setLocationMinInterval(locationMinInterval).setLocationMaxAge(locationMaxAge).setIsTrackingChangesEnabled(isTrackingChangesEnabled).setIsIdentifyUserEnabled(isIdentifyUserEnabled).setIsTrackChangesReasonEnabled(trackChangesReason != null && trackChangesReason.equals("on-form-edit")).createAuditConfig();
IAnswerData answerData = new StringData();
answerData.setValue(AUDIT_FILE_NAME);
auditElement.setValue(answerData);
}
}
return new InstanceMetadata(instanceId, instanceName, auditConfig);
}
Aggregations