Search in sources :

Example 1 with StoragePathProvider

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();
}
Also used : StoragePathProvider(org.odk.collect.android.storage.StoragePathProvider) Test(org.junit.Test)

Example 2 with StoragePathProvider

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));
}
Also used : StoragePathProvider(org.odk.collect.android.storage.StoragePathProvider) OvershootInterpolator(android.view.animation.OvershootInterpolator) Bundle(android.os.Bundle) CardView(androidx.cardview.widget.CardView) FloatingActionButton(com.google.android.material.floatingactionbutton.FloatingActionButton) AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator) DrawView(org.odk.collect.android.views.DrawView) View(android.view.View) AdapterView(android.widget.AdapterView) CardView(androidx.cardview.widget.CardView) ListView(android.widget.ListView) ColorPickerView(com.rarepebble.colorpicker.ColorPickerView) File(java.io.File) Uri(android.net.Uri)

Example 3 with StoragePathProvider

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);
}
Also used : StoragePathProvider(org.odk.collect.android.storage.StoragePathProvider)

Example 4 with StoragePathProvider

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();
}
Also used : StoragePathProvider(org.odk.collect.android.storage.StoragePathProvider) Activity(android.app.Activity)

Example 5 with StoragePathProvider

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());
    }
}
Also used : StoragePathProvider(org.odk.collect.android.storage.StoragePathProvider) File(java.io.File)

Aggregations

StoragePathProvider (org.odk.collect.android.storage.StoragePathProvider)19 File (java.io.File)10 Test (org.junit.Test)5 FileOutputStream (java.io.FileOutputStream)3 Bitmap (android.graphics.Bitmap)2 Activity (android.app.Activity)1 Instrumentation (android.app.Instrumentation)1 ContentValues (android.content.ContentValues)1 Cursor (android.database.Cursor)1 Paint (android.graphics.Paint)1 Path (android.graphics.Path)1 Uri (android.net.Uri)1 Bundle (android.os.Bundle)1 View (android.view.View)1 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)1 OvershootInterpolator (android.view.animation.OvershootInterpolator)1 AdapterView (android.widget.AdapterView)1 ListView (android.widget.ListView)1 CardView (androidx.cardview.widget.CardView)1 FloatingActionButton (com.google.android.material.floatingactionbutton.FloatingActionButton)1