use of org.odk.collect.android.javarosawrapper.FormController in project collect by opendatakit.
the class FormEntryActivity method onSaveInstanceState.
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putString(KEY_FORMPATH, formPath);
FormController formController = getFormController();
if (formController != null) {
if (formController.getInstanceFile() != null) {
outState.putString(KEY_INSTANCEPATH, getAbsoluteInstancePath());
}
outState.putString(KEY_XPATH, formController.getXPath(formController.getFormIndex()));
FormIndex waiting = formController.getIndexWaitingForData();
if (waiting != null) {
outState.putString(KEY_XPATH_WAITING_FOR_DATA, formController.getXPath(waiting));
}
// save the instance to a temp path...
nonblockingCreateSavePointData();
}
outState.putBoolean(NEWFORM, false);
outState.putString(KEY_ERROR, errorMessage);
outState.putString(KEY_SAVE_NAME, saveName);
outState.putBoolean(KEY_AUTO_SAVED, autoSaved);
outState.putBoolean(KEY_READ_PHONE_STATE_PERMISSION_REQUEST_NEEDED, readPhoneStatePermissionRequestNeeded);
outState.putBoolean(KEY_LOCATION_PERMISSIONS_GRANTED, locationPermissionsPreviouslyGranted);
}
use of org.odk.collect.android.javarosawrapper.FormController in project collect by opendatakit.
the class FormEntryActivity method onResume.
@Override
protected void onResume() {
super.onResume();
activityDisplayed();
String navigation = settingsProvider.getUnprotectedSettings().getString(KEY_NAVIGATION);
showNavigationButtons = navigation.contains(ProjectKeys.NAVIGATION_BUTTONS);
findViewById(R.id.buttonholder).setVisibility(showNavigationButtons ? View.VISIBLE : View.GONE);
if (showNavigationButtons) {
updateNavigationButtonVisibility();
}
if (errorMessage != null) {
if (alertDialog != null && !alertDialog.isShowing()) {
createErrorDialog(errorMessage, true);
} else {
return;
}
}
FormController formController = getFormController();
if (formController != null && !formEntryViewModel.isFormControllerSet()) {
Timber.e("FormController set in App but not ViewModel");
}
if (formLoaderTask != null) {
formLoaderTask.setFormLoaderListener(this);
if (formController == null && formLoaderTask.getStatus() == AsyncTask.Status.FINISHED) {
FormController fec = formLoaderTask.getFormController();
if (fec != null) {
if (!readPhoneStatePermissionRequestNeeded) {
loadingComplete(formLoaderTask, formLoaderTask.getFormDef(), null);
}
} else {
DialogFragmentUtils.dismissDialog(FormLoadingDialogFragment.class, getSupportFragmentManager());
FormLoaderTask t = formLoaderTask;
formLoaderTask = null;
t.cancel(true);
t.destroy();
// there is no formController -- fire MainMenu activity?
startActivity(new Intent(this, MainMenuActivity.class));
}
}
} else {
if (formController == null) {
// there is no formController -- fire MainMenu activity?
startActivity(new Intent(this, MainMenuActivity.class));
finish();
return;
}
}
}
use of org.odk.collect.android.javarosawrapper.FormController in project collect by opendatakit.
the class FormHierarchyActivity method jumpToHierarchyStartIndex.
/**
* Goes to the start of the hierarchy view based on where the user came from.
* Backs out until the index is at the beginning of a repeat group or the beginning of the form.
*/
private void jumpToHierarchyStartIndex() {
FormController formController = Collect.getInstance().getFormController();
FormIndex startIndex = formController.getFormIndex();
// If we're not at the first level, we're inside a repeated group so we want to only
// display everything enclosed within that group.
contextGroupRef = null;
// Save the index to the screen itself, before potentially moving into it.
screenIndex = startIndex;
// node to display.
if (formController.isDisplayableGroup(startIndex)) {
contextGroupRef = formController.getFormIndex().getReference();
formController.stepToNextEvent(FormController.STEP_INTO_GROUP);
} else {
FormIndex potentialStartIndex = getPreviousLevel(startIndex);
// Step back until we hit a displayable group or the beginning.
while (!isScreenEvent(formController, potentialStartIndex)) {
potentialStartIndex = getPreviousLevel(potentialStartIndex);
}
screenIndex = potentialStartIndex;
// Otherwise we're at a displayable group.
if (screenIndex == null) {
screenIndex = FormIndex.createBeginningOfFormIndex();
}
formController.jumpToIndex(screenIndex);
// Now test again. This should be true at this point or we're at the beginning.
if (formController.isDisplayableGroup(formController.getFormIndex())) {
contextGroupRef = formController.getFormIndex().getReference();
formController.stepToNextEvent(FormController.STEP_INTO_GROUP);
} else {
// Let contextGroupRef be null.
}
}
}
use of org.odk.collect.android.javarosawrapper.FormController in project collect by opendatakit.
the class FormHierarchyActivity method onBackPressed.
/**
* When the device back button is pressed, go back to the previous activity, NOT the previous
* level in the hierarchy as the "Go Up" button does.
*/
@Override
public void onBackPressed() {
FormController formController = Collect.getInstance().getFormController();
if (formController != null) {
formController.getAuditEventLogger().flush();
navigateToTheLastRelevantIndex(formController);
}
onBackPressedWithoutLogger();
}
use of org.odk.collect.android.javarosawrapper.FormController in project collect by opendatakit.
the class FormHierarchyActivity method goUpLevel.
/**
* Navigates "up" in the form hierarchy.
*/
protected void goUpLevel() {
FormController formController = Collect.getInstance().getFormController();
// we will go back up to the previous screen.
if (shouldShowRepeatGroupPicker()) {
// Exit the picker.
repeatGroupPickerIndex = null;
} else {
// Enter the picker if coming from a repeat group.
int event = formController.getEvent(screenIndex);
if (event == FormEntryController.EVENT_REPEAT || event == FormEntryController.EVENT_PROMPT_NEW_REPEAT) {
repeatGroupPickerIndex = screenIndex;
}
formController.stepToOuterScreenEvent();
}
refreshView(true);
}
Aggregations