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

Commit 61b9c4e

Browse files
authored
Merge pull request #27 from opendatakit/demo
merge demo to master
2 parents fe9480d + 0e4b71b commit 61b9c4e

File tree

14 files changed

+96
-32
lines changed

14 files changed

+96
-32
lines changed

build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22
buildscript {
33
repositories {
4-
jcenter()
54
google()
5+
jcenter()
66
}
77
dependencies {
8-
classpath 'com.android.tools.build:gradle:3.1.4'
8+
classpath 'com.android.tools.build:gradle:3.2.1'
99
classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:4.7.0'
1010
}
1111
}
1212

1313
allprojects {
1414
repositories {
15-
jcenter()
1615
google()
16+
jcenter()
1717
ivy {
1818
url 'http://cwe.cs.washington.edu:8082/artifactory/libs-demo/'
1919
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Thu Mar 29 16:05:43 PDT 2018
1+
#Thu Sep 27 16:04:41 PDT 2018
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip

sensorsframework_app/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ android {
2424
minSdkVersion(minVersion)
2525
targetSdkVersion(targetVersion)
2626
versionCode(releaseVersionCode)
27-
versionName(versionCodeName)
27+
versionName(versionCodeName + " ALPHA")
2828
testInstrumentationRunner(instrumentationRunner)
2929
}
3030

@@ -103,8 +103,8 @@ configurations.all {
103103

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

109109
if (libraryProjectPath.exists() && gradle.useLocal) { // Local project is favoured
110110
implementation project(libraryProjectName)
@@ -144,7 +144,7 @@ dependencies {
144144
androidTestImplementation 'com.android.support.test:runner:1.0.2'
145145
androidTestImplementation'com.android.support.test:rules:1.0.2'
146146
androidTestImplementation 'junit:junit:4.12'
147-
androidTestImplementation 'com.android.support:support-annotations:27.1.1'
147+
androidTestImplementation 'com.android.support:support-annotations:28.0.0'
148148
}
149149

150150
task grantPermissionForODKApp () {

sensorsframework_app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
66
<uses-permission android:name="android.permission.BLUETOOTH" />
77
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
8+
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
89

910
<!-- this is defined in org.opendatakit.services -->
1011
<uses-permission android:name="org.opendatakit.database.RUN_DATABASE" />

sensorsframework_app/src/main/java/org/opendatakit/sensors/manager/DatabaseManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ private static class DatabaseHelper extends SQLiteOpenHelper {
112112
db.execSQL("CREATE TABLE " + InternalSensorTable.TABLE_NAME + " (" +
113113
InternalSensorTable.ID + " TEXT PRIMARY KEY," +
114114
InternalSensorTable.APP_NAME + " TEXT," +
115-
ExternalSensorTable.DB_TRANSFER + " TEXT" + ");");
115+
InternalSensorTable.DB_TRANSFER + " TEXT" + ");");
116116

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

616616
// query columns
617617
String[] cols = { ExternalSensorTable.ID, ExternalSensorTable.NAME, ExternalSensorTable.TYPE,
618-
ExternalSensorTable.STATE, ExternalSensorTable.APP_NAME };
618+
ExternalSensorTable.STATE, ExternalSensorTable.APP_NAME, ExternalSensorTable.DB_TRANSFER };
619619
String[] args = { type.name() };
620620

621621
// run query

sensorsframework_app/src/main/java/org/opendatakit/sensors/ui/activity/AddSensorActivity.java

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,22 @@
1515
*/
1616
package org.opendatakit.sensors.ui.activity;
1717

18+
import android.Manifest;
1819
import android.app.Activity;
20+
import android.content.DialogInterface;
1921
import android.content.Intent;
22+
import android.content.pm.PackageManager;
2023
import android.os.Bundle;
24+
import android.support.annotation.NonNull;
25+
import android.support.v4.app.ActivityCompat;
2126
import android.util.Log;
2227
import android.view.View;
28+
import android.widget.Toast;
2329
import org.opendatakit.sensors.Constants;
2430
import org.opendatakit.sensors.R;
2531
import org.opendatakit.sensors.SensorsSingleton;
2632
import org.opendatakit.sensors.ServiceConstants;
33+
import org.opendatakit.utilities.RuntimePermissionUtils;
2734

2835
/**
2936
@@ -33,6 +40,15 @@ public class AddSensorActivity extends Activity {
3340

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

43+
protected static final String[] REQUIRED_PERMISSIONS = new String[] {
44+
Manifest.permission.BLUETOOTH_ADMIN,
45+
Manifest.permission.BLUETOOTH,
46+
Manifest.permission.WRITE_EXTERNAL_STORAGE,
47+
Manifest.permission.ACCESS_COARSE_LOCATION
48+
};
49+
50+
protected static final int PERMISSION_REQ_CODE = 5;
51+
3652
private static final int RESULT_OK_BT = 1;
3753
private static final int RESULT_OK_USB = 2;
3854

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

60+
if (!RuntimePermissionUtils.checkSelfAllPermission(this, REQUIRED_PERMISSIONS)) {
61+
ActivityCompat.requestPermissions(
62+
this,
63+
REQUIRED_PERMISSIONS,
64+
PERMISSION_REQ_CODE
65+
);
66+
}
67+
4468
Intent intent = getIntent();
4569
String tmpAppName = intent.getStringExtra(ServiceConstants.APP_NAME_KEY);
4670
if (tmpAppName == null) {
@@ -92,4 +116,39 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
92116
}
93117
}
94118

119+
@Override
120+
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
121+
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
122+
123+
if (requestCode != PERMISSION_REQ_CODE) {
124+
return;
125+
}
126+
127+
boolean granted = true;
128+
if (grantResults.length > 0) {
129+
for (int i = 0; i < grantResults.length; i++) {
130+
if (grantResults[0] != PackageManager.PERMISSION_GRANTED) {
131+
granted = false;
132+
}
133+
}
134+
135+
if (granted)
136+
return;
137+
138+
if (RuntimePermissionUtils.shouldShowAnyPermissionRationale(this, permissions)) {
139+
RuntimePermissionUtils.createPermissionRationaleDialog(this, requestCode, permissions).setMessage(R.string.write_external_storage_rationale)
140+
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
141+
@Override public void onClick(DialogInterface dialog, int which) {
142+
dialog.cancel();
143+
setResult(Activity.RESULT_CANCELED);
144+
finish();
145+
}
146+
}).show();
147+
} else {
148+
Toast.makeText(this, R.string.write_external_perm_denied, Toast.LENGTH_LONG).show();
149+
setResult(Activity.RESULT_CANCELED);
150+
finish();
151+
}
152+
}
153+
}
95154
}

sensorsframework_app/src/main/res/layout/add_sensor.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
android:onClick="addUSBAction"
1313
android:layout_marginTop="5dp"
1414
android:padding="20dp"
15-
android:text="@+string/add_usb_device"
15+
android:text="@string/add_usb_device"
1616
android:textSize="21sp" />
1717

1818
<Button
@@ -21,7 +21,7 @@
2121
android:onClick="addBluetoothAction"
2222
android:layout_marginTop="5dp"
2323
android:padding="20dp"
24-
android:text="@+string/add_bluetooth_device"
24+
android:text="@string/add_bluetooth_device"
2525
android:textSize="21sp" />
2626

2727
</LinearLayout>

sensorsframework_app/src/main/res/layout/metadata_dialog.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
android:id="@+id/meta_name_title"
99
android:layout_width="fill_parent"
1010
android:layout_height="wrap_content"
11-
android:text="@+string/select_sensor_type"
11+
android:text="@string/select_sensor_type"
1212
android:textStyle="bold"
1313
android:textSize="21sp"
1414
/>

sensorsframework_app/src/main/res/layout/register.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
android:layout_height="wrap_content"
1313
android:layout_marginTop="5dp"
1414
android:padding="20dp"
15-
android:text="@+string/register_sensor"
15+
android:text="@string/register_sensor"
1616
android:textSize="21sp" >
1717
</Button>
1818

sensorsframework_app/src/main/res/layout/selection_help.xml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,22 @@
2121
android:layout_height="0dip"
2222
android:layout_weight="1"
2323
android:singleLine="true"
24-
android:text="@+string/sensor_ready"
24+
android:text="@string/sensor_ready"
2525
/>
2626
<TextView
2727
android:layout_width="fill_parent"
2828
android:layout_height="0dip"
2929
android:layout_weight="1"
3030
android:singleLine="true"
31-
android:text="@+string/record_from_sensor"
31+
android:text="@string/record_from_sensor"
3232
android:textSize="21sp"
3333
/>
3434
<TextView
3535
android:layout_width="fill_parent"
3636
android:layout_height="0dip"
3737
android:layout_weight="1"
3838
android:singleLine="true"
39-
android:text="@+string/update_metadata"
39+
android:text="@string/update_metadata"
4040
android:textSize="21sp"
4141
/>
4242
</LinearLayout>
@@ -59,23 +59,23 @@
5959
android:layout_height="0dip"
6060
android:layout_weight="1"
6161
android:singleLine="true"
62-
android:text="@+string/sensor_out_of_range"
62+
android:text="@string/sensor_out_of_range"
6363
android:textSize="21sp"
6464
/>
6565
<TextView
6666
android:layout_width="fill_parent"
6767
android:layout_height="0dip"
6868
android:layout_weight="1"
6969
android:singleLine="true"
70-
android:text="@+string/open_record"
70+
android:text="@string/open_record"
7171
android:textSize="21sp"
7272
/>
7373
<TextView
7474
android:layout_width="fill_parent"
7575
android:layout_height="0dip"
7676
android:layout_weight="1"
7777
android:singleLine="true"
78-
android:text="@+string/update_metadata"
78+
android:text="@string/update_metadata"
7979
android:textSize="21sp"
8080
/>
8181
</LinearLayout>
@@ -98,23 +98,23 @@
9898
android:layout_height="0dip"
9999
android:layout_weight="1"
100100
android:singleLine="true"
101-
android:text="@+string/register_sensor"
101+
android:text="@string/register_sensor"
102102
android:textSize="21sp"
103103
/>
104104
<TextView
105105
android:layout_width="fill_parent"
106106
android:layout_height="0dip"
107107
android:layout_weight="1"
108108
android:singleLine="true"
109-
android:text="@+string/register"
109+
android:text="@string/register"
110110
android:textSize="16sp"
111111
/>
112112
<TextView
113113
android:layout_width="fill_parent"
114114
android:layout_height="0dip"
115115
android:layout_weight="1"
116116
android:singleLine="true"
117-
android:text="@+string/update_metadata"
117+
android:text="@string/update_metadata"
118118
android:textSize="21sp"
119119
/>
120120
</LinearLayout>
@@ -145,15 +145,15 @@
145145
android:layout_height="0dip"
146146
android:layout_weight="1"
147147
android:singleLine="true"
148-
android:text="@+string/pair_device_with_phone"
148+
android:text="@string/pair_device_with_phone"
149149
android:textSize="21sp"
150150
/>
151151
<TextView
152152
android:layout_width="fill_parent"
153153
android:layout_height="0dip"
154154
android:layout_weight="1"
155155
android:singleLine="true"
156-
android:text="@+string/long_click_no_action"
156+
android:text="@string/long_click_no_action"
157157
android:textSize="21sp"
158158
/>
159159
</LinearLayout>
@@ -176,23 +176,23 @@
176176
android:layout_height="0dip"
177177
android:layout_weight="1"
178178
android:singleLine="true"
179-
android:text="@+string/not_a_sensor"
179+
android:text="@string/not_a_sensor"
180180
android:textSize="21sp"
181181
/>
182182
<TextView
183183
android:layout_width="fill_parent"
184184
android:layout_height="0dip"
185185
android:layout_weight="1"
186186
android:singleLine="true"
187-
android:text="@+string/single_click_no_action"
187+
android:text="@string/single_click_no_action"
188188
android:textSize="21sp"
189189
/>
190190
<TextView
191191
android:layout_width="fill_parent"
192192
android:layout_height="0dip"
193193
android:layout_weight="1"
194194
android:singleLine="true"
195-
android:text="@+string/update_metadata"
195+
android:text="@string/update_metadata"
196196
android:textSize="21sp"
197197
/>
198198
</LinearLayout>

0 commit comments

Comments
 (0)