-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/master' into ping/map-view
- Loading branch information
Showing
15 changed files
with
204 additions
and
76 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
collect_app/src/androidTest/assets/forms/external_data_questions.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?xml version="1.0"?> | ||
<h:html | ||
xmlns="http://www.w3.org/2002/xforms" | ||
xmlns:ev="http://www.w3.org/2001/xml-events" | ||
xmlns:h="http://www.w3.org/1999/xhtml" | ||
xmlns:jr="http://openrosa.org/javarosa" | ||
xmlns:odk="http://www.opendatakit.org/xforms" | ||
xmlns:orx="http://openrosa.org/xforms" | ||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"> | ||
<h:head> | ||
<h:title>externalDataQuestions</h:title> | ||
<model> | ||
<instance> | ||
<externalDataQuestions id="externalDataQuestions"> | ||
<q1/> | ||
<q2/> | ||
<meta> | ||
<instanceID/> | ||
</meta> | ||
</externalDataQuestions> | ||
</instance> | ||
<bind nodeset="/externalDataQuestions/q1" type="select1"/> | ||
<bind nodeset="/externalDataQuestions/q2" type="string"/> | ||
<bind jr:preload="uid" nodeset="/externalDataQuestions/meta/instanceID" readonly="true()" type="string"/> | ||
</model> | ||
</h:head> | ||
<h:body> | ||
<select1 appearance="search('fruits')" ref="/externalDataQuestions/q1"> | ||
<label>Search func</label> | ||
<item> | ||
<label>name</label> | ||
<value>name_key</value> | ||
</item> | ||
</select1> | ||
<input query="instance('counties')/root/item[county= "King"]" ref="/externalDataQuestions/q2"> | ||
<label>External csv</label> | ||
</input> | ||
</h:body> | ||
</h:html> |
40 changes: 40 additions & 0 deletions
40
.../src/androidTest/java/org/odk/collect/android/formentry/ExternalDataFileNotFoundTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package org.odk.collect.android.formentry; | ||
|
||
import android.Manifest; | ||
|
||
import androidx.test.espresso.intent.rule.IntentsTestRule; | ||
import androidx.test.rule.GrantPermissionRule; | ||
|
||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.rules.RuleChain; | ||
import org.odk.collect.android.R; | ||
import org.odk.collect.android.activities.FormEntryActivity; | ||
import org.odk.collect.android.espressoutils.pages.FormEntryPage; | ||
import org.odk.collect.android.support.CopyFormRule; | ||
import org.odk.collect.android.support.ResetStateRule; | ||
import org.odk.collect.android.test.FormLoadingUtils; | ||
|
||
public class ExternalDataFileNotFoundTest { | ||
private static final String EXTERNAL_DATA_QUESTIONS = "external_data_questions.xml"; | ||
|
||
@Rule | ||
public IntentsTestRule<FormEntryActivity> activityTestRule = FormLoadingUtils.getFormActivityTestRuleFor(EXTERNAL_DATA_QUESTIONS); | ||
|
||
@Rule | ||
public RuleChain copyFormChain = RuleChain | ||
.outerRule(GrantPermissionRule.grant( | ||
Manifest.permission.READ_EXTERNAL_STORAGE, | ||
Manifest.permission.WRITE_EXTERNAL_STORAGE) | ||
) | ||
.around(new ResetStateRule()) | ||
.around(new CopyFormRule(EXTERNAL_DATA_QUESTIONS)); | ||
|
||
@Test | ||
public void questionsThatUseExternalFiles_ShouldDisplayFriendlyMessageWhenFilesAreMissing() { | ||
new FormEntryPage("externalDataQuestions", activityTestRule) | ||
.checkIsTextDisplayed(activityTestRule.getActivity().getString(R.string.file_missing, "/storage/emulated/0/odk/forms/external_data_questions-media/fruits.csv")) | ||
.swipeToNextQuestion() | ||
.checkIsTextDisplayed(activityTestRule.getActivity().getString(R.string.file_missing, "/storage/emulated/0/odk/forms/external_data_questions-media/itemsets.csv")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
collect_app/src/main/java/org/odk/collect/android/forms/FormUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package org.odk.collect.android.forms; | ||
|
||
import org.javarosa.core.reference.ReferenceManager; | ||
import org.javarosa.core.reference.RootTranslator; | ||
import org.odk.collect.android.application.Collect; | ||
import org.odk.collect.android.logic.FileReferenceFactory; | ||
|
||
import java.io.File; | ||
|
||
public class FormUtils { | ||
|
||
private FormUtils() { | ||
|
||
} | ||
|
||
public static void setupReferenceManagerForForm(ReferenceManager referenceManager, File formMediaDir) { | ||
|
||
// Remove previous forms | ||
referenceManager.clearSession(); | ||
|
||
// This should get moved to the Application Class | ||
if (referenceManager.getFactories().length == 0) { | ||
// this is /sdcard/odk | ||
referenceManager.addReferenceFactory(new FileReferenceFactory(Collect.ODK_ROOT)); | ||
} | ||
|
||
addSessionRootTranslators(formMediaDir.getName(), referenceManager, | ||
"images", "image", "audio", "video", "file"); | ||
} | ||
|
||
private static void addSessionRootTranslators(String formMediaDir, ReferenceManager referenceManager, String... hostStrings) { | ||
// Set jr://... to point to /sdcard/odk/forms/formBasename-media/ | ||
final String translatedPrefix = String.format("jr://file/forms/" + formMediaDir + "/"); | ||
for (String t : hostStrings) { | ||
referenceManager.addSessionRootTranslator(new RootTranslator(String.format("jr://%s/", t), translatedPrefix)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.