Skip to content

Commit

Permalink
Merge pull request #190 from odk-x/development
Browse files Browse the repository at this point in the history
prepare for pre-release
  • Loading branch information
wbrunette authored Oct 18, 2021
2 parents c7cb16c + 9b37955 commit 6dbb212
Show file tree
Hide file tree
Showing 11 changed files with 120 additions and 156 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,20 @@ Quick description of the content in the root folder:
|-- tables -- The most relevant Java code lives here

|-- androidTest -- Source tree for Android implementation tests




## How to contribute
If you’re new to ODK-X you can check out the documentation:
- [https://docs.odk-x.org](https://docs.odk-x.org)

Once you’re up and running, you can choose an issue to start working on from here: 
- [https://github.com/odk-x/tool-suite-X/issues](https://github.com/odk-x/tool-suite-X/issues)

Issues tagged as [good first issue](https://github.com/odk-x/tool-suite-X/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22) should be a good place to start.

Pull requests are welcome, though please submit them against the development branch. We prefer verbose descriptions of the change you are submitting. If you are fixing a bug please provide steps to reproduce it or a link to a an issue that provides that information. If you are submitting a new feature please provide a description of the need or a link to a forum discussion about it.

## Links for users
This document is aimed at helping developers and technical contributors. For information on how to get started as a user of ODK-X, see our [online documentation](https://docs.odk-x.org), or to learn more about the Open Data Kit project, visit [https://odk-x.org](https://odk-x.org).
11 changes: 5 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,20 @@
buildscript {
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.3'
classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:4.9.8'
classpath 'com.google.gms:google-services:4.3.5'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.5.2'
classpath 'com.android.tools.build:gradle:4.2.2'
classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:4.23.4'
classpath 'com.google.gms:google-services:4.3.10'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.7.1'
}
}

allprojects {
repositories {
google()
jcenter()
mavenCentral()
maven {
url "https://jitpack.io"
}
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip
18 changes: 5 additions & 13 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
gradle.ext.gradleConfigVersion = 150

if ( !gradle.ext.has('workspacePath') ) {
def env = System.getProperties();
logger.warn("tables/settings.gradle System.getProperties().stringPropertyNames(): " + env.stringPropertyNames());
def path = System.getProperty('com.android.studio.gradle.project.path');
if ( path != null ) {
logger.warn("tables/settings.gradle Found value for System.getProperty('com.android.studio.gradle.project.path')");
gradle.ext.workspacePath = (new File(path)).getParentFile().getAbsolutePath();
} else {
logger.warn("tables/settings.gradle No value found for System.getProperty('com.android.studio.gradle.project.path')");
gradle.ext.workspacePath = new File("..").getAbsolutePath();
}
gradle.ext.gradleConfigVersion = 153

if (!gradle.ext.has('workspacePath')) {
logger.warn("rootDir: " + rootDir.getAbsolutePath());
gradle.ext.workspacePath = rootDir.getParentFile().getAbsolutePath();
}

logger.warn('tables/settings.gradle -- gradle.ext.workspacePath: ' + gradle.ext.workspacePath)
Expand Down
29 changes: 13 additions & 16 deletions tables_app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ android {

testApplicationId(groupId + tablesName + testNameSuffix)
testInstrumentationRunner(instrumentationRunner)

multiDexEnabled true
}

flavorDimensions "stage", "testing"
Expand Down Expand Up @@ -126,17 +124,16 @@ allprojects {
dependencies {
implementation 'androidx.annotation:annotation:1.2.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.fragment:fragment:1.3.2'
implementation 'androidx.fragment:fragment:1.3.6'
implementation 'androidx.preference:preference:1.1.1'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'com.github.wbrunette:ProgressWheel:3.4'

implementation 'com.google.firebase:firebase-analytics:18.0.2'
implementation 'com.google.firebase:firebase-crashlytics:17.4.1'
implementation 'com.google.firebase:firebase-analytics:19.0.2'
implementation 'com.google.firebase:firebase-crashlytics:18.2.3'

implementation 'androidx.multidex:multidex:2.0.1'

if (libraryProjectPath.exists() && gradle.useLocal) { // Local project is favoured
implementation project(libraryProjectName)
Expand All @@ -160,15 +157,15 @@ dependencies {
classifier: snapshotRelease, version: latestVersion, ext: 'aar')
}

implementation 'com.google.android.gms:play-services-maps:17.0.0'
implementation 'com.google.android.gms:play-services-maps:17.0.1'

//for Espresso
androidTestUitestImplementation 'androidx.test:runner:1.3.0'
androidTestUitestImplementation 'androidx.test:rules:1.3.0'
androidTestUitestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
androidTestUitestImplementation 'androidx.test.espresso:espresso-intents:3.3.0'
androidTestUitestImplementation 'androidx.test.espresso:espresso-web:3.3.0'
androidTestUitestImplementation 'androidx.test.espresso:espresso-contrib:3.3.0'
androidTestUitestImplementation 'androidx.test:runner:1.4.0'
androidTestUitestImplementation 'androidx.test:rules:1.4.0'
androidTestUitestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestUitestImplementation 'androidx.test.espresso:espresso-intents:3.4.0'
androidTestUitestImplementation 'androidx.test.espresso:espresso-web:3.4.0'
androidTestUitestImplementation 'androidx.test.espresso:espresso-contrib:3.4.0'
androidTestUitestImplementation 'androidx.annotation:annotation:1.2.0'

//for UI Automator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,13 @@
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;

import androidx.annotation.RequiresApi;
import androidx.core.content.ContextCompat;

import android.provider.DocumentsContract;
import android.text.InputType;
import android.view.View;
import android.view.View.OnClickListener;
Expand All @@ -30,6 +35,8 @@
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;

import org.opendatakit.activities.utils.FilePickerUtil;
import org.opendatakit.consts.IntentConsts;
import org.opendatakit.logging.WebLogger;
import org.opendatakit.tables.R;
Expand All @@ -39,6 +46,7 @@
import org.opendatakit.tables.tasks.ImportTask;
import org.opendatakit.tables.utils.TableFileUtils;
import org.opendatakit.utilities.ODKFileUtils;
import org.opendatakit.utilities.ODKXFileUriUtils;

import java.io.File;

Expand All @@ -56,13 +64,16 @@ public class ImportCSVActivity extends AbsBaseActivity {
// The button to import a table.
private Button mImportButton;

private Uri csvUri;

/**
* Sets the app name and sets the view (what clicking the buttons should do, etc..)
*
* @param savedInstanceState a bundle containing the state if it was suspended, used only by
* this classes parents
*/
public void onCreate(Bundle savedInstanceState) {
csvUri = null;
ImportExportDialogFragment.fragman = getSupportFragmentManager();
super.onCreate(savedInstanceState);
appName = getIntent().getStringExtra(IntentConsts.INTENT_KEY_APP_NAME);
Expand Down Expand Up @@ -137,13 +148,15 @@ private View getView() {
*/
private void importSubmission() {

String filenamePath = filenameValField.getText().toString().trim();
if (csvUri == null) {
Toast.makeText(this, "Invalid csv filename: " + filenameValField.getText(), Toast.LENGTH_LONG)
.show();
return;
}

ImportRequest request = null;
String assetsCsvRelativePath = ODKFileUtils
.asRelativePath(appName, new File(ODKFileUtils.getAssetsCsvFolder(appName)));
if (filenamePath.startsWith(assetsCsvRelativePath)) {
String remainingPath = filenamePath.substring(assetsCsvRelativePath.length() + 1);

String remainingPath = ODKXFileUriUtils.ODKXRemainingPath(appName, csvUri);
String[] terms = remainingPath.split("\\.");
if (terms.length == 2 && terms[1].equals("csv")) {
String tableId = terms[0];
Expand All @@ -164,7 +177,6 @@ private void importSubmission() {
String fileQualifier = terms[1];
request = new ImportRequest(tableId, fileQualifier);
}
}

if (request == null) {
Toast.makeText(this, "Invalid csv filename: " + filenameValField.getText(), Toast.LENGTH_LONG)
Expand Down Expand Up @@ -194,54 +206,46 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {

if (resultCode == RESULT_CANCELED) {
return;
}
Uri fileUri = data.getData();
String filepath = fileUri.getPath();
File csvFile = new File(filepath);
// We have to first hand this off to account for the difference in
// external storage directories on different versions of android.
String relativePath;
try {
relativePath = ODKFileUtils.asRelativePath(appName, csvFile);
} catch (IllegalArgumentException iae) {
WebLogger.getLogger(getAppName()).printStackTrace(iae);
Toast.makeText(this,
getString(R.string.file_not_under_app_dir, ODKFileUtils.getAppFolder(getAppName())),
Toast.LENGTH_LONG).show();
return;
} else if (FilePickerUtil.isSuccessfulFilePickerResponse(requestCode, resultCode)) {
Uri resultUri = FilePickerUtil.getUri(data);

}
WebLogger.getLogger(appName).d(TAG, "relative path of import file: " + relativePath);
File assetCsv = new File(ODKFileUtils.getAssetsCsvFolder(appName));
String assetRelativePath = ODKFileUtils.asRelativePath(appName, assetCsv);
if (relativePath.startsWith(assetRelativePath)) {
String name = csvFile.getName();
String[] terms = name.split("\\.");
if (terms.length < 2 || terms.length > 4) {
Toast.makeText(this,
"Import filename must be of the form tableId.csv, tableId.definition.csv, tableId.properties.csv or tableId.qualifier.csv",
Toast.LENGTH_LONG).show();
return;
} else {
if (!"csv".equals(terms[terms.length - 1])) {
Toast.makeText(this, "Import filename must end in .csv", Toast.LENGTH_LONG).show();
return;
}
if (terms.length == 4 && !("properties".equals(terms[2]) || "definition"
.equals(terms[2]))) {
WebLogger.getLogger(appName).d(TAG, "uri of CSV import file: " + resultUri);
String remainingCSVPath = ODKXFileUriUtils.ODKXRemainingPath(appName, resultUri);
if (remainingCSVPath != null) {
String[] terms = remainingCSVPath.split("\\.");
if (terms.length < 2 || terms.length > 4) {
Toast.makeText(this,
"Import filename must be of the form tableId.qualifier.properties.csv or tableId.qualifier.definition.csv",
Toast.LENGTH_LONG).show();
"Import filename must be of the form tableId.csv, tableId.definition.csv, tableId.properties.csv or tableId.qualifier.csv",
Toast.LENGTH_LONG).show();
return;
} else {
if (!"csv".equals(terms[terms.length - 1])) {
Toast.makeText(this, "Import filename must end in .csv", Toast.LENGTH_LONG).show();
return;
}
if (terms.length == 4 && !("properties".equals(terms[2]) || "definition"
.equals(terms[2]))) {
Toast.makeText(this,
"Import filename must be of the form tableId.qualifier.properties.csv or tableId.qualifier.definition.csv",
Toast.LENGTH_LONG).show();
return;
}
}
csvUri = resultUri;
if(csvUri != null) {
filenameValField.setText(csvUri.getPath());
}
} else {
Toast.makeText(this, "Import file must reside in opendatakit folder",
Toast.LENGTH_LONG).show();
}
filenameValField.setText(relativePath);
} else {
Toast.makeText(this, "Import file must reside in " + assetRelativePath + File.separator,
Toast.LENGTH_LONG).show();


}

}


/**
* enables the import button if the database is available
*/
Expand Down Expand Up @@ -280,11 +284,10 @@ private class PickFileButtonListener implements OnClickListener {
*/
@Override
public void onClick(View v) {
Intent intent = new Intent("org.openintents.action.PICK_FILE");
intent.putExtra("org.openintents.extra.TITLE_KEY", title);
intent.putExtra("org.openintents.extra.DIR_PATH", ODKFileUtils.getAssetsCsvFolder(appName));
String startingDirectory = ODKFileUtils.getAssetsCsvFolder(appName);
Intent intent = FilePickerUtil.createFilePickerIntent(title, "*/*", startingDirectory);
try {
startActivityForResult(intent, 1);
startActivityForResult(intent, FilePickerUtil.FILE_PICKER_CODE);
} catch (ActivityNotFoundException e) {
WebLogger.getLogger(getAppName()).printStackTrace(e);
Toast.makeText(ImportCSVActivity.this, getString(R.string.file_picker_not_found),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

import android.content.Context;

import androidx.multidex.MultiDex;

import com.google.firebase.analytics.FirebaseAnalytics;
import org.opendatakit.application.CommonApplication;
import org.opendatakit.tables.R;
Expand Down Expand Up @@ -45,14 +43,7 @@ public static Tables getInstance() {
throw new IllegalStateException("not possible");
return ref.get();
}

@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}



@Override
public int getApkDisplayNameResourceId() {
return R.string.app_name;
Expand Down
Loading

0 comments on commit 6dbb212

Please sign in to comment.