Skip to content

Commit e352929

Browse files
authored
Merge pull request #88 from ShimmerEngineering/DEV-159
DEV-159
2 parents ad445fa + 662ee77 commit e352929

39 files changed

+101
-49
lines changed

ShimmerAndroidInstrumentDriver/ShimmerAndroidInstrumentDriver/src/main/res/layouts/fragments/layout/fragment_plot.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
xmlns:tools="http://schemas.android.com/tools"
44
android:layout_width="match_parent"
55
android:layout_height="match_parent"
6-
tools:context="com.shimmerresearch.shimmerserviceexample.PlotFragment"
6+
tools:context="com.shimmerresearch.shimmercapture.PlotFragment"
77
android:orientation="vertical">
88

99

ShimmerAndroidInstrumentDriver/build.gradle

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ allprojects {
3939
*/
4040
username = project.findProperty("gpr.usr") ?: System.getenv("USERNAME")
4141
password = project.findProperty("gpr.key") ?: System.getenv("TOKEN")
42-
/* should the above not work key in your username and password directly e.g.
43-
username = "username"
44-
password = "password"
42+
/* should the above not work key in your username and password directly e.g.
43+
username = "username"
44+
password = "password"
4545
DO NOT commit your username and password
46-
*/
46+
*/
4747
}
4848
}
4949
maven {
@@ -59,11 +59,11 @@ allprojects {
5959
*/
6060
username = project.findProperty("gpr.usr") ?: System.getenv("USERNAME")
6161
password = project.findProperty("gpr.key") ?: System.getenv("TOKEN")
62-
/* should the above not work key in your username and password directly e.g.
63-
username = "username"
64-
password = "password"
62+
/* should the above not work key in your username and password directly e.g.
63+
username = "username"
64+
password = "password"
6565
DO NOT commit your username and password
66-
*/
66+
*/
6767
}
6868
}
6969
mavenCentral()
@@ -78,15 +78,15 @@ allprojects {
7878
implementation 'java3d:vecmath:1.3.1'
7979
implementation 'com.android.support:appcompat-v7:26.1.0'
8080
implementation 'com.github.Jasonchenlijian:FastBle:2.4.0'
81-
implementation (group: 'com.shimmerresearch', name: 'shimmerbluetoothmanager', version:'0.11.0_beta'){
81+
implementation (group: 'com.shimmerresearch', name: 'shimmerbluetoothmanager', version:'0.11.1_beta'){
8282

8383
// excluding org.json which is provided by Android
8484
exclude group: 'io.netty'
8585
exclude group: 'com.google.protobuf'
8686
exclude group: 'org.apache.commons.math'
8787
}
8888

89-
implementation (group: 'com.shimmerresearch', name: 'shimmerdriver', version:'0.11.0_beta'){
89+
implementation (group: 'com.shimmerresearch', name: 'shimmerdriver', version:'0.11.1_beta'){
9090

9191
// excluding org.json which is provided by Android
9292
exclude group: 'io.netty'

ShimmerAndroidInstrumentDriver/shimmerServiceExample/build.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
apply plugin: 'com.android.application'
22

33
android {
4-
compileSdkVersion 33
4+
compileSdkVersion 34
55

66
defaultConfig {
7-
applicationId "com.shimmerresearch.shimmerserviceexample"
7+
applicationId "com.shimmersensing.shimmerconnect"
88
minSdkVersion 14
9-
targetSdkVersion 33
10-
versionCode 1
11-
versionName "1.0"
9+
targetSdkVersion 34
10+
versionCode 27
11+
versionName "27.0"
1212
multiDexEnabled true
1313

1414
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.shimmerresearch.shimmerserviceexample;
1+
package com.shimmerresearch.shimmercapture;
22

33
import android.content.Context;
44
import android.support.test.InstrumentationRegistry;

ShimmerAndroidInstrumentDriver/shimmerServiceExample/src/main/AndroidManifest.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:tools="http://schemas.android.com/tools"
4-
package="com.shimmerresearch.shimmerserviceexample">
4+
package="com.shimmerresearch.shimmercapture">
55
<uses-permission android:name="android.permission.BLUETOOTH"
66
android:maxSdkVersion="30" />
77
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"
@@ -23,7 +23,7 @@
2323
tools:remove="android:appComponentFactory"
2424
tools:targetApi="p">
2525
<service android:name="com.shimmerresearch.android.shimmerService.ShimmerService" />
26-
<activity android:name=".MainActivity"
26+
<activity android:name="com.shimmerresearch.shimmercapture.MainActivity"
2727
android:screenOrientation="portrait"
2828
android:exported="true">
2929
<intent-filter>
89.2 KB
Loading
Lines changed: 63 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.shimmerresearch.shimmerserviceexample;
1+
package com.shimmerresearch.shimmercapture;
22

33
import android.Manifest;
44

@@ -90,6 +90,12 @@ public class MainActivity extends AppCompatActivity implements ConnectedShimmers
9090
final static String LOG_TAG = "Shimmer";
9191
final static String SERVICE_TAG = "ShimmerService";
9292
final static int REQUEST_CONNECT_SHIMMER = 2;
93+
public static APP_RELEASE_TYPE appReleaseType = APP_RELEASE_TYPE.PUBLIC;
94+
public enum APP_RELEASE_TYPE{
95+
INTERNAL,
96+
PUBLIC,
97+
TESTING
98+
}
9399

94100
ShimmerDialogConfigurations dialog;
95101
BluetoothAdapter btAdapter;
@@ -114,6 +120,37 @@ public class MainActivity extends AppCompatActivity implements ConnectedShimmers
114120
@Override
115121
protected void onCreate(Bundle savedInstanceState) {
116122
super.onCreate(savedInstanceState);
123+
AlertDialog.Builder alertDialog = new AlertDialog.Builder(this);
124+
//alertDialog.setTitle("Device Info");
125+
alertDialog.setMessage("Shimmer Capture App collect Location data to enable Bluetooth devices scanning on Android versions 11 and lower even when the app is closed or not in use.");
126+
alertDialog.setCancelable(false);
127+
alertDialog.setPositiveButton("OK", new DialogInterface.OnClickListener() {
128+
@Override
129+
public void onClick(DialogInterface dialog, int which) {
130+
requestPermissions();
131+
}
132+
});
133+
alertDialog.show();
134+
135+
//Check if Bluetooth is enabled
136+
/*if (!btAdapter.isEnabled()) {
137+
int REQUEST_ENABLE_BT = 1;
138+
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
139+
startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
140+
}
141+
else {*/
142+
143+
//}
144+
145+
146+
/*
147+
if(checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE )!= PackageManager.PERMISSION_GRANTED) {
148+
requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
149+
PERMISSIONS_REQUEST_WRITE_STORAGE);
150+
}*/
151+
}
152+
153+
public void requestPermissions(){
117154

118155
int permissionCheck = ContextCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH_CONNECT);
119156
boolean permissionGranted = true;
@@ -125,6 +162,7 @@ protected void onCreate(Bundle savedInstanceState) {
125162
if (permissionCheck != PackageManager.PERMISSION_GRANTED) {
126163
permissionGranted = false;
127164
}
165+
128166
permissionCheck = ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION);
129167
if (permissionCheck != PackageManager.PERMISSION_GRANTED) {
130168
permissionGranted = false;
@@ -152,25 +190,7 @@ protected void onCreate(Bundle savedInstanceState) {
152190
mViewPager.setOffscreenPageLimit(5); //Ensure none of the fragments has their view destroyed when off-screen
153191
btAdapter = BluetoothAdapter.getDefaultAdapter();
154192
dialog = new ShimmerDialogConfigurations();
155-
156-
//Check if Bluetooth is enabled
157-
/*if (!btAdapter.isEnabled()) {
158-
int REQUEST_ENABLE_BT = 1;
159-
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
160-
startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
161-
}
162-
else {*/
163-
164-
//}
165-
166-
167-
/*
168-
if(checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE )!= PackageManager.PERMISSION_GRANTED) {
169-
requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
170-
PERMISSIONS_REQUEST_WRITE_STORAGE);
171-
}*/
172193
}
173-
174194
@Override
175195
public boolean onCreateOptionsMenu(Menu menu) {
176196
MenuInflater inflater = getMenuInflater();
@@ -201,8 +221,11 @@ protected void startServiceandBTManager(){
201221

202222
@Override
203223
public boolean onPrepareOptionsMenu(Menu menu) {
204-
if(mService != null){
205-
menu.findItem(R.id.connect_device).setEnabled(mService.getListOfConnectedDevices().isEmpty());
224+
225+
if(appReleaseType.equals(APP_RELEASE_TYPE.PUBLIC)){
226+
if(mService != null){
227+
menu.findItem(R.id.connect_device).setEnabled(mService.getListOfConnectedDevices().isEmpty());
228+
}
206229
}
207230
MenuItem item1 = menu.findItem(R.id.data_sync);
208231
MenuItem item2 = menu.findItem(R.id.disable_logging);
@@ -214,6 +237,7 @@ public boolean onPrepareOptionsMenu(Menu menu) {
214237
MenuItem item8 = menu.findItem(R.id.start_sd_logging);
215238
MenuItem item9 = menu.findItem(R.id.stop_sd_logging);
216239
MenuItem item10 = menu.findItem(R.id.device_info);
240+
MenuItem item11 = menu.findItem(R.id.privacy_policy);
217241
if(selectedDeviceAddress != null){
218242
ShimmerDevice device = mService.getShimmer(selectedDeviceAddress);
219243
if(device instanceof VerisenseDevice) {
@@ -227,6 +251,7 @@ public boolean onPrepareOptionsMenu(Menu menu) {
227251
item8.setVisible(false);
228252
item9.setVisible(false);
229253
item10.setVisible(false);
254+
item11.setVisible(false);
230255
if (((VerisenseDevice)device).isRecordingEnabled()){
231256
item2.setTitle("Disable Logging");
232257
return true;
@@ -241,6 +266,7 @@ public boolean onPrepareOptionsMenu(Menu menu) {
241266
item8.setVisible(true);
242267
item9.setVisible(true);
243268
item10.setVisible(true);
269+
item11.setVisible(true);
244270
}
245271
}
246272
item1.setVisible(false);
@@ -506,6 +532,10 @@ public void onClick(DialogInterface dialog, int id) {
506532
alertDialog.setMessage("Shimmer Version: "+shimmerVersion + "\n\nFirmware Version: "+FWName);
507533
alertDialog.show();
508534

535+
return true;
536+
case R.id.privacy_policy:
537+
startActivity(new Intent(Intent.ACTION_VIEW,Uri.parse("https://www.shimmersensing.com/privacy/")));
538+
509539
return true;
510540
default:
511541
return super.onOptionsItemSelected(item);
@@ -531,8 +561,9 @@ public void onServiceConnected(ComponentName className, IBinder service) {
531561
Log.d(SERVICE_TAG, "Shimmer Service Bound");
532562

533563
//if there is a device connected display it on the fragment
534-
connectedShimmersListFragment.buildShimmersConnectedListView(mService.getListOfConnectedDevices(), getApplicationContext());
535-
564+
if(connectedShimmersListFragment!=null) {
565+
connectedShimmersListFragment.buildShimmersConnectedListView(mService.getListOfConnectedDevices(), getApplicationContext());
566+
}
536567
}
537568

538569
public void onServiceDisconnected(ComponentName className) {
@@ -620,8 +651,11 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
620651
if (deviceName.contains(VerisenseDevice.VERISENSE_PREFIX)){
621652

622653
} else {
623-
showBtTypeConnectionOption();
624-
654+
if(appReleaseType.equals(APP_RELEASE_TYPE.PUBLIC)){
655+
preferredBtType = ShimmerBluetoothManagerAndroid.BT_TYPE.BT_CLASSIC;
656+
}else{
657+
showBtTypeConnectionOption();
658+
}
625659
}
626660
mService.connectShimmer(macAdd,deviceName,preferredBtType,this); //Connect to the selected device, and set context to show progress dialog when pairing
627661
//mService.connectShimmer(macAdd,this); //Connect to the selected device, and set context to show progress dialog when pairing
@@ -640,7 +674,6 @@ public class SectionsPagerAdapter1 extends FragmentStatePagerAdapter {
640674

641675
public SectionsPagerAdapter1(FragmentManager fm) {
642676
super(fm);
643-
dataSyncFragment = DataSyncFragment.newInstance();
644677
connectedShimmersListFragment = ConnectedShimmersListFragment.newInstance();
645678
sensorsEnabledFragment = SensorsEnabledFragment.newInstance(null, null);
646679
deviceConfigFragment = DeviceConfigFragment.newInstance();
@@ -652,7 +685,10 @@ public SectionsPagerAdapter1(FragmentManager fm) {
652685
add(deviceConfigFragment, "Device Configuration");
653686
add(plotFragment, "Plot");
654687
add(signalsToPlotFragment, "Signals to Plot");
655-
add(dataSyncFragment, "Verisense Sync");
688+
if(!(appReleaseType.equals(APP_RELEASE_TYPE.PUBLIC))){
689+
dataSyncFragment = DataSyncFragment.newInstance();
690+
add(dataSyncFragment, "Verisense Sync");
691+
}
656692
}
657693

658694
@Override

ShimmerAndroidInstrumentDriver/shimmerServiceExample/src/main/res/layout/activity_main.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
xmlns:app="http://schemas.android.com/apk/res-auto"
55
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
66
android:layout_height="match_parent"
7-
tools:context="com.shimmerresearch.shimmerserviceexample.MainActivity"
7+
tools:context="com.shimmerresearch.shimmercapture.MainActivity"
88
android:orientation="vertical"
99
android:id="@+id/content_frame">
1010

ShimmerAndroidInstrumentDriver/shimmerServiceExample/src/main/res/menu/menu.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,6 @@
4444
android:id="@+id/stop_sd_logging"></item>
4545
<item android:title="Device Info"
4646
android:id="@+id/device_info"></item>
47+
<item android:title="Privacy Policy"
48+
android:id="@+id/privacy_policy"></item>
4749
</menu>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
3+
<background android:drawable="@color/ic_launcher_background"/>
4+
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
5+
</adaptive-icon>

0 commit comments

Comments
 (0)