Search in sources :

Example 1 with Collect

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());
}
Also used : FormController(org.odk.collect.android.logic.FormController) Collect(org.odk.collect.android.application.Collect) FormIndex(org.javarosa.core.model.FormIndex)

Example 2 with Collect

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());
}
Also used : FormController(org.odk.collect.android.logic.FormController) Collect(org.odk.collect.android.application.Collect)

Example 3 with Collect

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);
}
Also used : FormController(org.odk.collect.android.logic.FormController) Collect(org.odk.collect.android.application.Collect)

Example 4 with Collect

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();
    }
}
Also used : Collect(org.odk.collect.android.application.Collect) ActivityNotFoundException(android.content.ActivityNotFoundException) Activity(android.app.Activity) Intent(android.content.Intent) ComponentName(android.content.ComponentName)

Example 5 with Collect

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;
}
Also used : Collect(org.odk.collect.android.application.Collect) SharedPreferences(android.content.SharedPreferences)

Aggregations

Collect (org.odk.collect.android.application.Collect)10 FormController (org.odk.collect.android.javarosawrapper.FormController)4 FormController (org.odk.collect.android.logic.FormController)3 Activity (android.app.Activity)1 ActivityNotFoundException (android.content.ActivityNotFoundException)1 ComponentName (android.content.ComponentName)1 Intent (android.content.Intent)1 SharedPreferences (android.content.SharedPreferences)1 Nullable (androidx.annotation.Nullable)1 FormIndex (org.javarosa.core.model.FormIndex)1 AppDependencyComponent (org.odk.collect.android.injection.config.AppDependencyComponent)1 DaggerAppDependencyComponent (org.odk.collect.android.injection.config.DaggerAppDependencyComponent)1