use of org.odk.collect.android.storage.StoragePathProvider in project collect by opendatakit.
the class FillBlankFormTest method missingFileMessage_shouldBeDisplayedIfExternalFileIsMissing.
@Test
public void missingFileMessage_shouldBeDisplayedIfExternalFileIsMissing() {
String formsDirPath = new StoragePathProvider().getOdkDirPath(StorageSubdirectory.FORMS);
// TestCase55
rule.startAtMainMenu().copyForm("search_and_select.xml").startBlankForm("search_and_select").assertText("File: " + formsDirPath + "/search_and_select-media/nombre.csv is missing.").assertText("File: " + formsDirPath + "/search_and_select-media/nombre2.csv is missing.").swipeToEndScreen().clickSaveAndExit().copyForm("select_one_external.xml").startBlankForm("cascading select test").clickOnText("Texas").swipeToNextQuestion("county").assertText("File: " + formsDirPath + "/select_one_external-media/itemsets.csv is missing.").swipeToNextQuestion("city").assertText("File: " + formsDirPath + "/select_one_external-media/itemsets.csv is missing.").swipeToEndScreen().clickSaveAndExit().copyForm("fieldlist-updates_nocsv.xml").startBlankForm("fieldlist-updates").clickGoToArrow().clickGoUpIcon().clickOnElementInHierarchy(14).clickOnQuestion("Source15").assertText("File: " + formsDirPath + "/fieldlist-updates_nocsv-media/fruits.csv is missing.").swipeToEndScreen().clickSaveAndExit();
}
use of org.odk.collect.android.storage.StoragePathProvider in project collect by opendatakit.
the class DrawActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.draw_layout);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
fabActions = findViewById(R.id.fab_actions);
final FloatingActionButton fabSetColor = findViewById(R.id.fab_set_color);
final CardView cardViewSetColor = findViewById(R.id.cv_set_color);
final FloatingActionButton fabSaveAndClose = findViewById(R.id.fab_save_and_close);
final CardView cardViewSaveAndClose = findViewById(R.id.cv_save_and_close);
final FloatingActionButton fabClear = findViewById(R.id.fab_clear);
final CardView cardViewClear = findViewById(R.id.cv_clear);
fabActions.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
int status = Integer.parseInt(view.getTag().toString());
if (status == 0) {
status = 1;
fabActions.animate().rotation(45).setInterpolator(new AccelerateDecelerateInterpolator()).setDuration(100).start();
AnimationUtils.scaleInAnimation(fabSetColor, 50, 150, new OvershootInterpolator(), true);
AnimationUtils.scaleInAnimation(cardViewSetColor, 50, 150, new OvershootInterpolator(), true);
AnimationUtils.scaleInAnimation(fabSaveAndClose, 100, 150, new OvershootInterpolator(), true);
AnimationUtils.scaleInAnimation(cardViewSaveAndClose, 100, 150, new OvershootInterpolator(), true);
AnimationUtils.scaleInAnimation(fabClear, 150, 150, new OvershootInterpolator(), true);
AnimationUtils.scaleInAnimation(cardViewClear, 150, 150, new OvershootInterpolator(), true);
fabSetColor.show();
cardViewSetColor.setVisibility(View.VISIBLE);
fabSaveAndClose.show();
cardViewSaveAndClose.setVisibility(View.VISIBLE);
fabClear.show();
cardViewClear.setVisibility(View.VISIBLE);
} else {
status = 0;
fabActions.animate().rotation(0).setInterpolator(new AccelerateDecelerateInterpolator()).setDuration(100).start();
fabSetColor.hide();
cardViewSetColor.setVisibility(View.INVISIBLE);
fabSaveAndClose.hide();
cardViewSaveAndClose.setVisibility(View.INVISIBLE);
fabClear.hide();
cardViewClear.setVisibility(View.INVISIBLE);
}
view.setTag(status);
}
});
cardViewClear.setOnClickListener(this::clear);
fabClear.setOnClickListener(this::clear);
cardViewSaveAndClose.setOnClickListener(this::close);
fabSaveAndClose.setOnClickListener(this::close);
cardViewSetColor.setOnClickListener(this::setColor);
fabSetColor.setOnClickListener(this::setColor);
Bundle extras = getIntent().getExtras();
StoragePathProvider storagePathProvider = new StoragePathProvider();
if (extras == null) {
loadOption = OPTION_DRAW;
refImage = null;
savepointImage = new File(storagePathProvider.getTmpImageFilePath());
savepointImage.delete();
output = new File(storagePathProvider.getTmpImageFilePath());
} else {
if (extras.getInt(SCREEN_ORIENTATION) == 1) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
loadOption = extras.getString(OPTION);
if (loadOption == null) {
loadOption = OPTION_DRAW;
}
// refImage can also be present if resuming a drawing
Uri uri = (Uri) extras.get(REF_IMAGE);
if (uri != null) {
refImage = new File(uri.getPath());
}
String savepoint = extras.getString(SAVEPOINT_IMAGE);
if (savepoint != null) {
savepointImage = new File(savepoint);
if (!savepointImage.exists() && refImage != null && refImage.exists()) {
ImageFileUtils.copyImageAndApplyExifRotation(refImage, savepointImage);
}
} else {
savepointImage = new File(storagePathProvider.getTmpImageFilePath());
savepointImage.delete();
if (refImage != null && refImage.exists()) {
ImageFileUtils.copyImageAndApplyExifRotation(refImage, savepointImage);
}
}
uri = (Uri) extras.get(EXTRA_OUTPUT);
if (uri != null) {
output = new File(uri.getPath());
} else {
output = new File(storagePathProvider.getTmpImageFilePath());
}
}
if (OPTION_SIGNATURE.equals(loadOption)) {
alertTitleString = getString(R.string.quit_application, getString(R.string.sign_button));
} else if (OPTION_ANNOTATE.equals(loadOption)) {
alertTitleString = getString(R.string.quit_application, getString(R.string.markup_image));
} else {
alertTitleString = getString(R.string.quit_application, getString(R.string.draw_image));
}
drawView = findViewById(R.id.drawView);
drawView.setupView(OPTION_SIGNATURE.equals(loadOption));
}
use of org.odk.collect.android.storage.StoragePathProvider in project collect by opendatakit.
the class ItemsetDbAdapter method getItemsets.
public Cursor getItemsets(String path) {
String selection = KEY_PATH + "=?";
String[] selectionArgs = { PathUtils.getRelativeFilePath(new StoragePathProvider().getOdkDirPath(StorageSubdirectory.FORMS), path) };
return db.query(ITEMSET_TABLE, null, selection, selectionArgs, null, null, null);
}
use of org.odk.collect.android.storage.StoragePathProvider in project collect by opendatakit.
the class Camera2VideoFragment method setUpMediaRecorder.
private void setUpMediaRecorder() throws IOException {
final Activity activity = getActivity();
if (null == activity) {
return;
}
mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mediaRecorder.setVideoSource(MediaRecorder.VideoSource.SURFACE);
mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
if (nextVideoAbsolutePath == null || nextVideoAbsolutePath.isEmpty()) {
nextVideoAbsolutePath = new StoragePathProvider().getTmpVideoFilePath();
}
mediaRecorder.setOutputFile(nextVideoAbsolutePath);
mediaRecorder.setVideoEncodingBitRate(10000000);
mediaRecorder.setVideoFrameRate(30);
mediaRecorder.setVideoSize(videoSize.getWidth(), videoSize.getHeight());
mediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
switch(sensorOrientation) {
case SENSOR_ORIENTATION_DEFAULT_DEGREES:
mediaRecorder.setOrientationHint(DEFAULT_ORIENTATIONS.get(rotation));
break;
case SENSOR_ORIENTATION_INVERSE_DEGREES:
mediaRecorder.setOrientationHint(INVERSE_ORIENTATIONS.get(rotation));
break;
}
mediaRecorder.prepare();
}
use of org.odk.collect.android.storage.StoragePathProvider in project collect by opendatakit.
the class UserInterfacePreferencesFragment method onActivityResult.
@Override
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
Timber.d("onActivityResult %d %d", requestCode, resultCode);
super.onActivityResult(requestCode, resultCode, intent);
if (resultCode == RESULT_CANCELED) {
// request was canceled, so do nothing
return;
}
if (requestCode == IMAGE_CHOOSER) {
File customImage = new File(new StoragePathProvider().getCustomSplashScreenImagePath());
FileUtils.saveAnswerFileFromUri(intent.getData(), customImage, Collect.getInstance());
setSplashPath(customImage.getAbsolutePath());
}
}
Aggregations