Skip to content
This repository has been archived by the owner on Feb 17, 2022. It is now read-only.

Commit

Permalink
Merge pull request #27 from opendatakit/demo
Browse files Browse the repository at this point in the history
merge demo to master
  • Loading branch information
wbrunette authored Jan 15, 2019
2 parents fe9480d + 0e4b71b commit 61b9c4e
Show file tree
Hide file tree
Showing 14 changed files with 96 additions and 32 deletions.
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:4.7.0'
}
}

allprojects {
repositories {
jcenter()
google()
jcenter()
ivy {
url 'http://cwe.cs.washington.edu:8082/artifactory/libs-demo/'
}
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Thu Mar 29 16:05:43 PDT 2018
#Thu Sep 27 16:04:41 PDT 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
8 changes: 4 additions & 4 deletions sensorsframework_app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ android {
minSdkVersion(minVersion)
targetSdkVersion(targetVersion)
versionCode(releaseVersionCode)
versionName(versionCodeName)
versionName(versionCodeName + " ALPHA")
testInstrumentationRunner(instrumentationRunner)
}

Expand Down Expand Up @@ -103,8 +103,8 @@ configurations.all {

dependencies {
implementation fileTree(include: '*.jar', dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:preference-v7:27.1.1'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:preference-v7:28.0.0'

if (libraryProjectPath.exists() && gradle.useLocal) { // Local project is favoured
implementation project(libraryProjectName)
Expand Down Expand Up @@ -144,7 +144,7 @@ dependencies {
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation'com.android.support.test:rules:1.0.2'
androidTestImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support:support-annotations:27.1.1'
androidTestImplementation 'com.android.support:support-annotations:28.0.0'
}

task grantPermissionForODKApp () {
Expand Down
1 change: 1 addition & 0 deletions sensorsframework_app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

<!-- this is defined in org.opendatakit.services -->
<uses-permission android:name="org.opendatakit.database.RUN_DATABASE" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ private static class DatabaseHelper extends SQLiteOpenHelper {
db.execSQL("CREATE TABLE " + InternalSensorTable.TABLE_NAME + " (" +
InternalSensorTable.ID + " TEXT PRIMARY KEY," +
InternalSensorTable.APP_NAME + " TEXT," +
ExternalSensorTable.DB_TRANSFER + " TEXT" + ");");
InternalSensorTable.DB_TRANSFER + " TEXT" + ");");

} catch (SQLException e) {
Log.w(LOGTAG, "DatabaseHelper onCreate Failed!");
Expand Down Expand Up @@ -615,7 +615,7 @@ public synchronized List<ExternalSensorData> externalSensorList(CommunicationCha

// query columns
String[] cols = { ExternalSensorTable.ID, ExternalSensorTable.NAME, ExternalSensorTable.TYPE,
ExternalSensorTable.STATE, ExternalSensorTable.APP_NAME };
ExternalSensorTable.STATE, ExternalSensorTable.APP_NAME, ExternalSensorTable.DB_TRANSFER };
String[] args = { type.name() };

// run query
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,22 @@
*/
package org.opendatakit.sensors.ui.activity;

import android.Manifest;
import android.app.Activity;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat;
import android.util.Log;
import android.view.View;
import android.widget.Toast;
import org.opendatakit.sensors.Constants;
import org.opendatakit.sensors.R;
import org.opendatakit.sensors.SensorsSingleton;
import org.opendatakit.sensors.ServiceConstants;
import org.opendatakit.utilities.RuntimePermissionUtils;

/**
* @author [email protected]
Expand All @@ -33,6 +40,15 @@ public class AddSensorActivity extends Activity {

private static final String LOGTAG = AddSensorActivity.class.getSimpleName();

protected static final String[] REQUIRED_PERMISSIONS = new String[] {
Manifest.permission.BLUETOOTH_ADMIN,
Manifest.permission.BLUETOOTH,
Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.ACCESS_COARSE_LOCATION
};

protected static final int PERMISSION_REQ_CODE = 5;

private static final int RESULT_OK_BT = 1;
private static final int RESULT_OK_USB = 2;

Expand All @@ -41,6 +57,14 @@ public class AddSensorActivity extends Activity {
@Override public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

if (!RuntimePermissionUtils.checkSelfAllPermission(this, REQUIRED_PERMISSIONS)) {
ActivityCompat.requestPermissions(
this,
REQUIRED_PERMISSIONS,
PERMISSION_REQ_CODE
);
}

Intent intent = getIntent();
String tmpAppName = intent.getStringExtra(ServiceConstants.APP_NAME_KEY);
if (tmpAppName == null) {
Expand Down Expand Up @@ -92,4 +116,39 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
}
}

@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);

if (requestCode != PERMISSION_REQ_CODE) {
return;
}

boolean granted = true;
if (grantResults.length > 0) {
for (int i = 0; i < grantResults.length; i++) {
if (grantResults[0] != PackageManager.PERMISSION_GRANTED) {
granted = false;
}
}

if (granted)
return;

if (RuntimePermissionUtils.shouldShowAnyPermissionRationale(this, permissions)) {
RuntimePermissionUtils.createPermissionRationaleDialog(this, requestCode, permissions).setMessage(R.string.write_external_storage_rationale)
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
@Override public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
setResult(Activity.RESULT_CANCELED);
finish();
}
}).show();
} else {
Toast.makeText(this, R.string.write_external_perm_denied, Toast.LENGTH_LONG).show();
setResult(Activity.RESULT_CANCELED);
finish();
}
}
}
}
4 changes: 2 additions & 2 deletions sensorsframework_app/src/main/res/layout/add_sensor.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
android:onClick="addUSBAction"
android:layout_marginTop="5dp"
android:padding="20dp"
android:text="@+string/add_usb_device"
android:text="@string/add_usb_device"
android:textSize="21sp" />

<Button
Expand All @@ -21,7 +21,7 @@
android:onClick="addBluetoothAction"
android:layout_marginTop="5dp"
android:padding="20dp"
android:text="@+string/add_bluetooth_device"
android:text="@string/add_bluetooth_device"
android:textSize="21sp" />

</LinearLayout>
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
android:id="@+id/meta_name_title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@+string/select_sensor_type"
android:text="@string/select_sensor_type"
android:textStyle="bold"
android:textSize="21sp"
/>
Expand Down
2 changes: 1 addition & 1 deletion sensorsframework_app/src/main/res/layout/register.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:padding="20dp"
android:text="@+string/register_sensor"
android:text="@string/register_sensor"
android:textSize="21sp" >
</Button>

Expand Down
28 changes: 14 additions & 14 deletions sensorsframework_app/src/main/res/layout/selection_help.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,22 @@
android:layout_height="0dip"
android:layout_weight="1"
android:singleLine="true"
android:text="@+string/sensor_ready"
android:text="@string/sensor_ready"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:singleLine="true"
android:text="@+string/record_from_sensor"
android:text="@string/record_from_sensor"
android:textSize="21sp"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:singleLine="true"
android:text="@+string/update_metadata"
android:text="@string/update_metadata"
android:textSize="21sp"
/>
</LinearLayout>
Expand All @@ -59,23 +59,23 @@
android:layout_height="0dip"
android:layout_weight="1"
android:singleLine="true"
android:text="@+string/sensor_out_of_range"
android:text="@string/sensor_out_of_range"
android:textSize="21sp"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:singleLine="true"
android:text="@+string/open_record"
android:text="@string/open_record"
android:textSize="21sp"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:singleLine="true"
android:text="@+string/update_metadata"
android:text="@string/update_metadata"
android:textSize="21sp"
/>
</LinearLayout>
Expand All @@ -98,23 +98,23 @@
android:layout_height="0dip"
android:layout_weight="1"
android:singleLine="true"
android:text="@+string/register_sensor"
android:text="@string/register_sensor"
android:textSize="21sp"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:singleLine="true"
android:text="@+string/register"
android:text="@string/register"
android:textSize="16sp"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:singleLine="true"
android:text="@+string/update_metadata"
android:text="@string/update_metadata"
android:textSize="21sp"
/>
</LinearLayout>
Expand Down Expand Up @@ -145,15 +145,15 @@
android:layout_height="0dip"
android:layout_weight="1"
android:singleLine="true"
android:text="@+string/pair_device_with_phone"
android:text="@string/pair_device_with_phone"
android:textSize="21sp"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:singleLine="true"
android:text="@+string/long_click_no_action"
android:text="@string/long_click_no_action"
android:textSize="21sp"
/>
</LinearLayout>
Expand All @@ -176,23 +176,23 @@
android:layout_height="0dip"
android:layout_weight="1"
android:singleLine="true"
android:text="@+string/not_a_sensor"
android:text="@string/not_a_sensor"
android:textSize="21sp"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:singleLine="true"
android:text="@+string/single_click_no_action"
android:text="@string/single_click_no_action"
android:textSize="21sp"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:singleLine="true"
android:text="@+string/update_metadata"
android:text="@string/update_metadata"
android:textSize="21sp"
/>
</LinearLayout>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:padding="20dp"
android:text="@+string/help"
android:text="@string/help"
android:textSize="21sp" >
</Button>
</LinearLayout>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
android:layout_weight="1"
android:layout_marginTop="5dp"
android:padding="20dp"
android:text="@+string/help"
android:text="@string/help"
android:textSize="21sp" >
</Button>
</LinearLayout>
Expand Down
4 changes: 4 additions & 0 deletions sensorsframework_app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,8 @@
<string name="long_click_no_action">Long Click: No Action</string>
<string name="single_click_no_action">Single Click: No Action</string>
<string name="not_a_sensor">NOT A SENSOR</string>
<string name="select_sensor_type">Select Sensor Type</string>
<string name="write_external_storage_rationale">ODK Sensors Framework needs to access external
storage to store resources and interact with other ODK apps</string>
<string name="write_external_perm_denied">ODK Sensors Framework cannot function without write access to external storage</string>
</resources>
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
gradle.ext.gradleConfigVersion = 112
gradle.ext.gradleConfigVersion = 116

if (!gradle.ext.has('workspacePath')) {
def env = System.getProperties();
Expand Down

0 comments on commit 61b9c4e

Please sign in to comment.