use of org.odk.collect.android.application.Collect in project collect by opendatakit.
the class QuestionWidget method isWaitingForData.
@Override
public final boolean isWaitingForData() {
Collect collect = Collect.getInstance();
if (collect == null) {
throw new IllegalStateException("Collect application instance is null.");
}
FormController formController = collect.getFormController();
if (formController == null) {
return false;
}
FormIndex index = getFormEntryPrompt().getIndex();
return index.equals(formController.getIndexWaitingForData());
}
use of org.odk.collect.android.application.Collect in project collect by opendatakit.
the class QuestionWidget method waitForData.
// region Data waiting
@Override
public final void waitForData() {
Collect collect = Collect.getInstance();
if (collect == null) {
throw new IllegalStateException("Collect application instance is null.");
}
FormController formController = collect.getFormController();
if (formController == null) {
return;
}
formController.setIndexWaitingForData(getFormEntryPrompt().getIndex());
}
use of org.odk.collect.android.application.Collect in project collect by opendatakit.
the class QuestionWidget method cancelWaitingForData.
@Override
public final void cancelWaitingForData() {
Collect collect = Collect.getInstance();
if (collect == null) {
throw new IllegalStateException("Collect application instance is null.");
}
FormController formController = collect.getFormController();
if (formController == null) {
return;
}
formController.setIndexWaitingForData(null);
}
use of org.odk.collect.android.application.Collect in project collect by opendatakit.
the class AlignedImageWidget method captureImage.
private void captureImage() {
Collect collect = Collect.getInstance();
collect.getActivityLogger().logInstanceAction(this, "captureButton", "click", getFormEntryPrompt().getIndex());
errorTextView.setVisibility(View.GONE);
Intent i = new Intent();
i.setComponent(new ComponentName(ODK_CAMERA_INTENT_PACKAGE, ODK_CAMERA_TAKE_PICTURE_INTENT_COMPONENT));
i.putExtra(FILE_PATH_EXTRA, Collect.CACHE_PATH);
i.putExtra(DIMENSIONS_EXTRA, iarray);
i.putExtra(RETAKE_OPTION_EXTRA, false);
// FormEntyActivity will also need to be updated.
try {
waitForData();
((Activity) getContext()).startActivityForResult(i, RequestCodes.ALIGNED_IMAGE);
} catch (ActivityNotFoundException e) {
Toast.makeText(getContext(), getContext().getString(R.string.activity_not_found, getContext().getString(R.string.aligned_image_capture)), Toast.LENGTH_SHORT).show();
cancelWaitingForData();
}
}
use of org.odk.collect.android.application.Collect in project collect by opendatakit.
the class InstanceServerUploader method getServerSubmissionURL.
private String getServerSubmissionURL() {
Collect app = Collect.getInstance();
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(Collect.getInstance());
String serverBase = settings.getString(PreferenceKeys.KEY_SERVER_URL, app.getString(R.string.default_server_url));
if (serverBase.endsWith(URL_PATH_SEP)) {
serverBase = serverBase.substring(0, serverBase.length() - 1);
}
// NOTE: /submission must not be translated! It is the well-known path on the server.
String submissionPath = settings.getString(PreferenceKeys.KEY_SUBMISSION_URL, app.getString(R.string.default_odk_submission));
if (!submissionPath.startsWith(URL_PATH_SEP)) {
submissionPath = URL_PATH_SEP + submissionPath;
}
return serverBase + submissionPath;
}
Aggregations