From 467ebc59ffb81f51242b496605acdae7b358463f Mon Sep 17 00:00:00 2001 From: Mas Azalya Date: Fri, 18 Jul 2025 14:23:19 +0800 Subject: [PATCH 1/2] androidx migration --- .../build.gradle | 4 +- .../bluetoothManagerExample/build.gradle | 17 +- ShimmerAndroidInstrumentDriver/build.gradle | 6 +- .../efficientDataArrayExample/build.gradle | 18 +- .../gradle/wrapper/gradle-wrapper.properties | 3 +- .../build.gradle | 22 +- .../shimmer3BLEBasicExample/build.gradle | 18 +- .../shimmer3DOrientationExample/build.gradle | 9 +- .../Shimmer3DOrientationExample.java | 17 +- .../shimmerBasicExample/build.gradle | 19 +- .../shimmerConnectionTest/build.gradle | 18 +- .../shimmerLegacyExample/build.gradle | 15 +- .../src/main/AndroidManifest.xml | 3 +- .../shimmerServiceExample/build.gradle | 18 +- .../src/main/AndroidManifest.xml | 2 +- .../shimmercapture/MainActivity.java | 460 +++++++++--------- .../src/main/res}/layout/checkbox.xml | 0 .../shimmerspeedtest/build.gradle | 15 +- .../verisenseBLEBasicExample/build.gradle | 21 +- 19 files changed, 359 insertions(+), 326 deletions(-) rename ShimmerAndroidInstrumentDriver/{ShimmerAndroidInstrumentDriver/src/main/res/layouts/fragments => shimmerServiceExample/src/main/res}/layout/checkbox.xml (100%) diff --git a/ShimmerAndroidInstrumentDriver/ShimmerAndroidInstrumentDriver/build.gradle b/ShimmerAndroidInstrumentDriver/ShimmerAndroidInstrumentDriver/build.gradle index 71ac92bf..6fbcb1bc 100644 --- a/ShimmerAndroidInstrumentDriver/ShimmerAndroidInstrumentDriver/build.gradle +++ b/ShimmerAndroidInstrumentDriver/ShimmerAndroidInstrumentDriver/build.gradle @@ -5,6 +5,7 @@ apply plugin: 'com.android.library' apply plugin: 'maven-publish' android { + namespace 'com.shimmerresearch.androidinstrumentdriver' compileSdkVersion 33 lintOptions { @@ -106,6 +107,7 @@ dependencies { implementation files('libs/ShimmerBiophysicalProcessingLibrary_Rev_0_11.jar') implementation files('libs/AndroidBluetoothLibrary.jar') api files('libs/androidplot-core-0.5.0-release.jar') - implementation 'com.android.support:appcompat-v7:26.1.0' + implementation 'androidx.appcompat:appcompat:1.7.0' implementation 'com.github.Jasonchenlijian:FastBle:2.4.0' + implementation 'androidx.documentfile:documentfile:1.0.1' } diff --git a/ShimmerAndroidInstrumentDriver/bluetoothManagerExample/build.gradle b/ShimmerAndroidInstrumentDriver/bluetoothManagerExample/build.gradle index 6cbc3d63..200b8d97 100644 --- a/ShimmerAndroidInstrumentDriver/bluetoothManagerExample/build.gradle +++ b/ShimmerAndroidInstrumentDriver/bluetoothManagerExample/build.gradle @@ -1,7 +1,8 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 33 + namespace 'com.shimmerresearch.bluetoothmanagerexample' + compileSdkVersion 34 compileOptions { sourceCompatibility 1.8 @@ -11,8 +12,8 @@ android { defaultConfig { multiDexEnabled true applicationId "com.shimmerresearch.bluetoothmanagerexample" - minSdkVersion 14 - targetSdkVersion 33 + minSdkVersion 21 + targetSdkVersion 34 versionCode 1 versionName "1.0" @@ -50,10 +51,10 @@ android { dependencies { implementation project(':ShimmerAndroidInstrumentDriver') implementation fileTree(dir: 'libs', include: ['*.jar']) - androidTestImplementation ('com.android.support.test.espresso:espresso-core:2.2.2', { - exclude group: 'com.android.support', module: 'support-annotations' - }) - implementation 'com.android.support.constraint:constraint-layout:1.0.2' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' + implementation 'androidx.constraintlayout:constraintlayout:2.2.0' testImplementation 'junit:junit:4.12' - implementation 'com.android.support:multidex:1.0.3' + implementation 'androidx.multidex:multidex:2.0.1' + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" } diff --git a/ShimmerAndroidInstrumentDriver/build.gradle b/ShimmerAndroidInstrumentDriver/build.gradle index 36e17974..68429b8a 100644 --- a/ShimmerAndroidInstrumentDriver/build.gradle +++ b/ShimmerAndroidInstrumentDriver/build.gradle @@ -1,7 +1,7 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.3.40' + ext.kotlin_version = '1.9.23' repositories { google() mavenCentral() @@ -9,7 +9,7 @@ buildscript { } dependencies { //classpath 'com.android.tools.build:gradle:3.5.4' - classpath 'com.android.tools.build:gradle:7.0.4' // Compatible with JDK 11 + classpath "com.android.tools.build:gradle:8.2.2" classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" //classpath('org.jfrog.buildinfo:build-info-extractor-gradle:4.21.0') @@ -76,7 +76,7 @@ allprojects { dependencies { implementation 'com.google.guava:guava:20.0' implementation 'java3d:vecmath:1.3.1' - implementation 'com.android.support:appcompat-v7:26.1.0' + implementation 'androidx.appcompat:appcompat:1.7.0' implementation 'com.github.Jasonchenlijian:FastBle:2.4.0' implementation (group: 'com.shimmerresearch', name: 'shimmerbluetoothmanager', version:'0.11.4_beta'){ diff --git a/ShimmerAndroidInstrumentDriver/efficientDataArrayExample/build.gradle b/ShimmerAndroidInstrumentDriver/efficientDataArrayExample/build.gradle index 303c1c49..304e0146 100644 --- a/ShimmerAndroidInstrumentDriver/efficientDataArrayExample/build.gradle +++ b/ShimmerAndroidInstrumentDriver/efficientDataArrayExample/build.gradle @@ -1,14 +1,15 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 33 + namespace 'com.shimmerresearch.efficientdataarrayexample' + compileSdkVersion 34 defaultConfig { applicationId "com.shimmerresearch.efficientdataarrayexample" - minSdkVersion 14 - targetSdkVersion 33 + minSdkVersion 21 + targetSdkVersion 34 versionCode 1 versionName "1.0" multiDexEnabled true @@ -48,10 +49,13 @@ android { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation 'com.android.support.constraint:constraint-layout:1.0.2' - androidTestImplementation 'com.android.support:support-annotations:25.3.1' + implementation 'androidx.constraintlayout:constraintlayout:2.2.0' + androidTestImplementation 'androidx.annotation:annotation:1.7.1' testImplementation 'junit:junit:4.12' - androidTestImplementation 'com.android.support.test:runner:1.0.1' - androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' + androidTestImplementation 'androidx.test:runner:1.5.2' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' + implementation 'androidx.documentfile:documentfile:1.0.1' + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" implementation project(path: ':ShimmerAndroidInstrumentDriver') } diff --git a/ShimmerAndroidInstrumentDriver/gradle/wrapper/gradle-wrapper.properties b/ShimmerAndroidInstrumentDriver/gradle/wrapper/gradle-wrapper.properties index 3542b438..ca483133 100644 --- a/ShimmerAndroidInstrumentDriver/gradle/wrapper/gradle-wrapper.properties +++ b/ShimmerAndroidInstrumentDriver/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip + diff --git a/ShimmerAndroidInstrumentDriver/multiverisenseblebasicexample/build.gradle b/ShimmerAndroidInstrumentDriver/multiverisenseblebasicexample/build.gradle index 65ebc636..488b26a2 100644 --- a/ShimmerAndroidInstrumentDriver/multiverisenseblebasicexample/build.gradle +++ b/ShimmerAndroidInstrumentDriver/multiverisenseblebasicexample/build.gradle @@ -3,13 +3,14 @@ plugins { } android { + namespace 'shimmerresearch.com.multiverisenseblebasicexample' //buildToolsVersion '23.0.1' - compileSdkVersion 33 + compileSdkVersion 34 defaultConfig { applicationId "shimmerresearch.com.multiverisenseblebasicexample" - minSdkVersion 14 - targetSdkVersion 33 + minSdkVersion 21 + targetSdkVersion 34 versionCode 1 versionName "1.0" multiDexEnabled true @@ -47,16 +48,15 @@ dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation project(path: ':ShimmerAndroidInstrumentDriver') - androidTestImplementation 'com.android.support:support-annotations:25.3.1' - //compile(group: 'com.shimmersensing', name: 'ShimmerAndroidInstrumentDriver', version: '3.0.71Beta', ext: 'aar') - implementation 'com.android.support.constraint:constraint-layout:1.0.2' + implementation 'androidx.constraintlayout:constraintlayout:2.2.0' + androidTestImplementation 'androidx.annotation:annotation:1.7.1' testImplementation 'junit:junit:4.12' - androidTestImplementation 'com.android.support.test:runner:1.0.1' - androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - implementation 'com.android.support.constraint:constraint-layout:1.0.2' + androidTestImplementation 'androidx.test:runner:1.5.2' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" testImplementation 'junit:junit:4.12' - implementation 'com.android.support:multidex:1.0.3' + implementation 'androidx.multidex:multidex:2.0.1' } repositories { mavenCentral() diff --git a/ShimmerAndroidInstrumentDriver/shimmer3BLEBasicExample/build.gradle b/ShimmerAndroidInstrumentDriver/shimmer3BLEBasicExample/build.gradle index 09e75a6a..509b552b 100644 --- a/ShimmerAndroidInstrumentDriver/shimmer3BLEBasicExample/build.gradle +++ b/ShimmerAndroidInstrumentDriver/shimmer3BLEBasicExample/build.gradle @@ -3,12 +3,13 @@ plugins { } android { - compileSdkVersion 33 + namespace 'shimmerresearch.com.shimmer3blebasicexample' + compileSdkVersion 34 defaultConfig { applicationId "shimmerresearch.com.shimmer3blebasicexample" - minSdkVersion 17 - targetSdkVersion 33 + minSdkVersion 21 + targetSdkVersion 34 versionCode 1 versionName "1.0" multiDexEnabled true @@ -45,10 +46,11 @@ android { dependencies { implementation project(path: ':ShimmerAndroidInstrumentDriver') - - implementation 'com.android.support:support-annotations:25.3.1' - implementation 'com.android.support.constraint:constraint-layout:2.0.4' + implementation 'androidx.constraintlayout:constraintlayout:2.2.0' + implementation 'androidx.annotation:annotation:1.7.1' testImplementation 'junit:junit:4.13.2' - androidTestImplementation 'com.android.support.test:runner:1.0.2' - androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' + androidTestImplementation 'androidx.test:runner:1.5.2' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" } \ No newline at end of file diff --git a/ShimmerAndroidInstrumentDriver/shimmer3DOrientationExample/build.gradle b/ShimmerAndroidInstrumentDriver/shimmer3DOrientationExample/build.gradle index 4302b9a9..f42d5334 100644 --- a/ShimmerAndroidInstrumentDriver/shimmer3DOrientationExample/build.gradle +++ b/ShimmerAndroidInstrumentDriver/shimmer3DOrientationExample/build.gradle @@ -1,13 +1,14 @@ apply plugin: 'com.android.application' android { + namespace 'com.shimmerresearch.shimmer3dexample' // compileSdkVersion 23 - compileSdkVersion 33 + compileSdkVersion 34 defaultConfig { applicationId "com.shimmerresearch.shimmer3dexample" - minSdkVersion 14 - targetSdkVersion 33 + minSdkVersion 21 + targetSdkVersion 34 multiDexEnabled true } @@ -41,4 +42,6 @@ dependencies { implementation files('../ShimmerAndroidInstrumentDriver/libs/ShimmerBiophysicalProcessingLibrary_Rev_0_11.jar') implementation files('../ShimmerAndroidInstrumentDriver/libs/androidplot-core-0.5.0-release.jar') implementation 'com.google.guava:guava:19.0' + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" } \ No newline at end of file diff --git a/ShimmerAndroidInstrumentDriver/shimmer3DOrientationExample/src/main/java/com/shimmerresearch/orientationexample/Shimmer3DOrientationExample.java b/ShimmerAndroidInstrumentDriver/shimmer3DOrientationExample/src/main/java/com/shimmerresearch/orientationexample/Shimmer3DOrientationExample.java index 2b67428b..eb528432 100644 --- a/ShimmerAndroidInstrumentDriver/shimmer3DOrientationExample/src/main/java/com/shimmerresearch/orientationexample/Shimmer3DOrientationExample.java +++ b/ShimmerAndroidInstrumentDriver/shimmer3DOrientationExample/src/main/java/com/shimmerresearch/orientationexample/Shimmer3DOrientationExample.java @@ -288,30 +288,25 @@ public boolean onCreateOptionsMenu(Menu menu) { @Override public boolean onOptionsItemSelected(MenuItem item) { Intent serverIntent; - switch (item.getItemId()) { - - case R.id.itemConnect: + int id = item.getItemId(); + if(id == R.id.itemConnect){ serverIntent = new Intent(this, DeviceListActivity.class); - startActivityForResult(serverIntent, REQUEST_CONNECT_SHIMMER); - + startActivityForResult(serverIntent, REQUEST_CONNECT_SHIMMER); return true; - - case R.id.itemDisconnect: + }else if(id == R.id.itemDisconnect){ mShimmerDevice1.stop(); return true; - case R.id.itemConfigure: + }else if(id == R.id.itemConfigure){ serverIntent = new Intent(this, ConfigureActivity.class); serverIntent.putExtra("LowPowerMag",mShimmerDevice1.isLowPowerMagEnabled()); serverIntent.putExtra("GyroOnTheFlyCal",mShimmerDevice1.isGyroOnTheFlyCalEnabled()); startActivityForResult(serverIntent, REQUEST_CONFIGURE_SHIMMER); return true; - default: + }else{ return super.onOptionsItemSelected(item); } } - - public void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { diff --git a/ShimmerAndroidInstrumentDriver/shimmerBasicExample/build.gradle b/ShimmerAndroidInstrumentDriver/shimmerBasicExample/build.gradle index a3b53ac4..2b306c37 100644 --- a/ShimmerAndroidInstrumentDriver/shimmerBasicExample/build.gradle +++ b/ShimmerAndroidInstrumentDriver/shimmerBasicExample/build.gradle @@ -1,14 +1,15 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 33 + namespace 'shimmerresearch.com.shimmerbasicexample' + compileSdkVersion 34 defaultConfig { applicationId "shimmerresearch.com.shimmerbasicexample" - minSdkVersion 17 - targetSdkVersion 33 + minSdkVersion 21 + targetSdkVersion 34 versionCode 1 versionName "1.0" multiDexEnabled true @@ -48,13 +49,15 @@ android { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation 'com.android.support:support-v4:+' - androidTestImplementation 'com.android.support:support-annotations:25.3.1' + implementation 'androidx.legacy:legacy-support-v4:1.0.0' implementation(group: 'com.shimmerresearch', name: 'shimmerandroidinstrumentdriver', version: '3.2.2_beta', ext: 'aar') - implementation 'com.android.support.constraint:constraint-layout:1.0.2' + implementation 'androidx.constraintlayout:constraintlayout:2.2.0' + androidTestImplementation 'androidx.annotation:annotation:1.7.1' testImplementation 'junit:junit:4.12' - androidTestImplementation 'com.android.support.test:runner:1.0.1' - androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' + androidTestImplementation 'androidx.test:runner:1.5.2' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" } repositories { diff --git a/ShimmerAndroidInstrumentDriver/shimmerConnectionTest/build.gradle b/ShimmerAndroidInstrumentDriver/shimmerConnectionTest/build.gradle index 4ca18823..33687f92 100644 --- a/ShimmerAndroidInstrumentDriver/shimmerConnectionTest/build.gradle +++ b/ShimmerAndroidInstrumentDriver/shimmerConnectionTest/build.gradle @@ -1,14 +1,15 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 33 + namespace 'shimmerresearch.com.shimmerconnectiontest' + compileSdkVersion 34 defaultConfig { applicationId "shimmerresearch.com.shimmerconnectiontest" - minSdkVersion 17 - targetSdkVersion 33 + minSdkVersion 21 + targetSdkVersion 34 versionCode 1 versionName "1.0" multiDexEnabled true @@ -48,14 +49,15 @@ android { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - androidTestImplementation 'com.android.support:support-annotations:25.3.1' + androidTestImplementation 'androidx.annotation:annotation:1.7.1' //compile(group: 'com.shimmersensing', name: 'ShimmerAndroidInstrumentDriver', version: '3.0.71Beta', ext: 'aar') implementation project(':ShimmerAndroidInstrumentDriver') - implementation 'com.android.support.constraint:constraint-layout:1.0.2' + implementation 'androidx.constraintlayout:constraintlayout:2.2.0' testImplementation 'junit:junit:4.12' - androidTestImplementation 'com.android.support.test:runner:1.0.1' - androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + androidTestImplementation 'androidx.test:runner:1.5.2' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" } repositories { mavenCentral() diff --git a/ShimmerAndroidInstrumentDriver/shimmerLegacyExample/build.gradle b/ShimmerAndroidInstrumentDriver/shimmerLegacyExample/build.gradle index b9e55b4e..8b8ad0d4 100644 --- a/ShimmerAndroidInstrumentDriver/shimmerLegacyExample/build.gradle +++ b/ShimmerAndroidInstrumentDriver/shimmerLegacyExample/build.gradle @@ -1,13 +1,14 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 33 + namespace 'com.shimmerresearch.shimmerlegacyexample' + compileSdkVersion 34 buildToolsVersion '26.0.2' defaultConfig { applicationId "com.shimmerresearch.shimmerlegacyexample" - minSdkVersion 14 - targetSdkVersion 33 + minSdkVersion 21 + targetSdkVersion 34 versionCode 1 versionName "1.0" multiDexEnabled true @@ -48,9 +49,9 @@ android { dependencies { implementation project(':ShimmerAndroidInstrumentDriver') implementation fileTree(dir: 'libs', include: ['*.jar']) - androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', { - exclude group: 'com.android.support', module: 'support-annotations' - }) - implementation 'com.android.support.constraint:constraint-layout:1.0.2' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' + implementation 'androidx.constraintlayout:constraintlayout:2.2.0' testImplementation 'junit:junit:4.12' + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" } diff --git a/ShimmerAndroidInstrumentDriver/shimmerLegacyExample/src/main/AndroidManifest.xml b/ShimmerAndroidInstrumentDriver/shimmerLegacyExample/src/main/AndroidManifest.xml index bd43d4b7..9f485007 100644 --- a/ShimmerAndroidInstrumentDriver/shimmerLegacyExample/src/main/AndroidManifest.xml +++ b/ShimmerAndroidInstrumentDriver/shimmerLegacyExample/src/main/AndroidManifest.xml @@ -5,7 +5,8 @@ - + diff --git a/ShimmerAndroidInstrumentDriver/shimmerServiceExample/build.gradle b/ShimmerAndroidInstrumentDriver/shimmerServiceExample/build.gradle index 20502a51..3d057353 100644 --- a/ShimmerAndroidInstrumentDriver/shimmerServiceExample/build.gradle +++ b/ShimmerAndroidInstrumentDriver/shimmerServiceExample/build.gradle @@ -1,11 +1,12 @@ apply plugin: 'com.android.application' android { + namespace 'com.shimmerresearch.shimmercapture' compileSdkVersion 34 defaultConfig { applicationId "com.shimmersensing.shimmerconnect" - minSdkVersion 14 + minSdkVersion 21 targetSdkVersion 35 versionCode 30 versionName "1.2" @@ -22,6 +23,11 @@ android { } configurations.all { resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9' + resolutionStrategy.eachDependency { details -> + if (details.requested.name == 'constraintlayout-core') { + details.useVersion '1.1.0' // or whatever version works with 2.2.0 + } + } } dexOptions { @@ -48,10 +54,10 @@ android { dependencies { implementation project(':ShimmerAndroidInstrumentDriver') implementation fileTree(dir: 'libs', include: ['*.jar']) - androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', { - exclude group: 'com.android.support', module: 'support-annotations' - }) - implementation 'com.android.support.constraint:constraint-layout:1.0.2' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' + implementation 'androidx.constraintlayout:constraintlayout:2.2.0' testImplementation 'junit:junit:4.12' - implementation 'com.android.support:multidex:1.0.3' + implementation 'androidx.multidex:multidex:2.0.1' + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" } diff --git a/ShimmerAndroidInstrumentDriver/shimmerServiceExample/src/main/AndroidManifest.xml b/ShimmerAndroidInstrumentDriver/shimmerServiceExample/src/main/AndroidManifest.xml index d4d142ca..8b6e6360 100644 --- a/ShimmerAndroidInstrumentDriver/shimmerServiceExample/src/main/AndroidManifest.xml +++ b/ShimmerAndroidInstrumentDriver/shimmerServiceExample/src/main/AndroidManifest.xml @@ -19,7 +19,7 @@ diff --git a/ShimmerAndroidInstrumentDriver/shimmerServiceExample/src/main/java/com/shimmerresearch/shimmercapture/MainActivity.java b/ShimmerAndroidInstrumentDriver/shimmerServiceExample/src/main/java/com/shimmerresearch/shimmercapture/MainActivity.java index aa560e49..ac89a1ab 100644 --- a/ShimmerAndroidInstrumentDriver/shimmerServiceExample/src/main/java/com/shimmerresearch/shimmercapture/MainActivity.java +++ b/ShimmerAndroidInstrumentDriver/shimmerServiceExample/src/main/java/com/shimmerresearch/shimmercapture/MainActivity.java @@ -280,267 +280,275 @@ public boolean onPrepareOptionsMenu(Menu menu) { public boolean onOptionsItemSelected(MenuItem item) { // Handle item selection final Toast otherTaskOngoingToast = Toast.makeText(this, "Please wait until current task is finished", Toast.LENGTH_LONG); - switch (item.getItemId()) { - case R.id.connect_device: - Intent pairedDevicesIntent = new Intent(getApplicationContext(), ShimmerBluetoothDialog.class); - startActivityForResult(pairedDevicesIntent, REQUEST_CONNECT_SHIMMER); - return true; - case R.id.start_streaming: - if(selectedDeviceAddress != null) { - - ShimmerDevice mDevice = mService.getShimmer(selectedDeviceAddress); - if (mDevice instanceof ShimmerBluetooth) { - //Disable PC timestamps for better performance. Disabling this takes the timestamps on every full packet received instead of on every byte received. - ((ShimmerBluetooth) mDevice).enablePCTimeStamps(false); - //Disable timers for better performance. - ((ShimmerBluetooth) mDevice).stopAllTimers(); + int id = item.getItemId(); + if(id == R.id.connect_device){ + Intent pairedDevicesIntent = new Intent(getApplicationContext(), ShimmerBluetoothDialog.class); + startActivityForResult(pairedDevicesIntent, REQUEST_CONNECT_SHIMMER); + return true; + }else if(id == R.id.start_streaming){ + if(selectedDeviceAddress != null) { + + ShimmerDevice mDevice = mService.getShimmer(selectedDeviceAddress); + if (mDevice instanceof ShimmerBluetooth) { + //Disable PC timestamps for better performance. Disabling this takes the timestamps on every full packet received instead of on every byte received. + ((ShimmerBluetooth) mDevice).enablePCTimeStamps(false); + //Disable timers for better performance. + ((ShimmerBluetooth) mDevice).stopAllTimers(); + } + try { + mDevice.startStreaming(); + mViewPager.setCurrentItem(mDevice instanceof VerisenseDevice ? 5 : 4); + } catch (ShimmerException e) { + if(e.getMessage() == "A task is still ongoing"){ + otherTaskOngoingToast.show(); } - try { - mDevice.startStreaming(); - mViewPager.setCurrentItem(mDevice instanceof VerisenseDevice ? 5 : 4); - } catch (ShimmerException e) { - if(e.getMessage() == "A task is still ongoing"){ - otherTaskOngoingToast.show(); - } - e.printStackTrace(); - } - signalsToPlotFragment.buildSignalsToPlotList(this, mService, selectedDeviceAddress, dynamicPlot); + e.printStackTrace(); } - return true; - case R.id.stop_streaming: - if(selectedDeviceAddress != null) { - ShimmerDevice mDevice = mService.getShimmer(selectedDeviceAddress); - try { - mDevice.stopStreaming(); - } catch (ShimmerException e) { - if(e.getMessage() == "A task is still ongoing"){ - otherTaskOngoingToast.show(); - } - e.printStackTrace(); + signalsToPlotFragment.buildSignalsToPlotList(this, mService, selectedDeviceAddress, dynamicPlot); + } + return true; + + } else if(id == R.id.stop_streaming){ + if(selectedDeviceAddress != null) { + ShimmerDevice mDevice = mService.getShimmer(selectedDeviceAddress); + try { + mDevice.stopStreaming(); + } catch (ShimmerException e) { + if(e.getMessage() == "A task is still ongoing"){ + otherTaskOngoingToast.show(); } + e.printStackTrace(); } - return true; - case R.id.data_sync: - if(selectedDeviceAddress != null) { - mViewPager.setCurrentItem(5); - } - return true; - case R.id.disable_logging: - if(selectedDeviceAddress != null) { - VerisenseDevice mDevice = (VerisenseDevice)mService.getShimmer(selectedDeviceAddress); - VerisenseDevice mDeviceClone = mDevice.deepClone(); - boolean logging = !mDevice.isRecordingEnabled(); - mDeviceClone.setRecordingEnabled(logging); - byte[] opConfig = mDeviceClone.configBytesGenerate(true, COMMUNICATION_TYPE.BLUETOOTH); - try { - mDevice.getMapOfVerisenseProtocolByteCommunication().get(COMMUNICATION_TYPE.BLUETOOTH).writeAndReadOperationalConfig(opConfig); - Toast.makeText(this, logging?"Logging Enabled":"Logging Disabled", Toast.LENGTH_SHORT).show(); - } catch (ShimmerException e) { - if(e.getMessage() == "A task is still ongoing"){ - otherTaskOngoingToast.show(); - } - e.printStackTrace(); + } + return true; + + }else if(id == R.id.data_sync){ + if(selectedDeviceAddress != null) { + mViewPager.setCurrentItem(5); + } + return true; + + }else if(id == R.id.disable_logging){ + if(selectedDeviceAddress != null) { + VerisenseDevice mDevice = (VerisenseDevice)mService.getShimmer(selectedDeviceAddress); + VerisenseDevice mDeviceClone = mDevice.deepClone(); + boolean logging = !mDevice.isRecordingEnabled(); + mDeviceClone.setRecordingEnabled(logging); + byte[] opConfig = mDeviceClone.configBytesGenerate(true, COMMUNICATION_TYPE.BLUETOOTH); + try { + mDevice.getMapOfVerisenseProtocolByteCommunication().get(COMMUNICATION_TYPE.BLUETOOTH).writeAndReadOperationalConfig(opConfig); + Toast.makeText(this, logging?"Logging Enabled":"Logging Disabled", Toast.LENGTH_SHORT).show(); + } catch (ShimmerException e) { + if(e.getMessage() == "A task is still ongoing"){ + otherTaskOngoingToast.show(); } + e.printStackTrace(); } - return true; - case R.id.erase_data: - if(selectedDeviceAddress != null) { - final VerisenseDevice mDevice = (VerisenseDevice)mService.getShimmer(selectedDeviceAddress); - final ProgressDialog progress = new ProgressDialog(this); - progress.setTitle("Erasing data"); - progress.setMessage("Please wait for the operation to complete..."); - progress.setCancelable(false); // disable dismiss by tapping outside of the dialog - progress.show(); - new Thread(){ - public void run(){ - try { - mDevice.getMapOfVerisenseProtocolByteCommunication().get(COMMUNICATION_TYPE.BLUETOOTH).eraseDataTask().waitForCompletion(60, TimeUnit.SECONDS); - progress.dismiss(); - } catch (ShimmerException | InterruptedException e) { - progress.dismiss(); - if(e.getMessage() == "A task is still ongoing"){ - otherTaskOngoingToast.show(); - } - e.printStackTrace(); + } + return true; + + }else if(id == R.id.erase_data){ + if(selectedDeviceAddress != null) { + final VerisenseDevice mDevice = (VerisenseDevice)mService.getShimmer(selectedDeviceAddress); + final ProgressDialog progress = new ProgressDialog(this); + progress.setTitle("Erasing data"); + progress.setMessage("Please wait for the operation to complete..."); + progress.setCancelable(false); // disable dismiss by tapping outside of the dialog + progress.show(); + new Thread(){ + public void run(){ + try { + mDevice.getMapOfVerisenseProtocolByteCommunication().get(COMMUNICATION_TYPE.BLUETOOTH).eraseDataTask().waitForCompletion(60, TimeUnit.SECONDS); + progress.dismiss(); + } catch (ShimmerException | InterruptedException e) { + progress.dismiss(); + if(e.getMessage() == "A task is still ongoing"){ + otherTaskOngoingToast.show(); } + e.printStackTrace(); } - }.start(); - } - return true; - case R.id.disconnect_all_devices: - mService.disconnectAllDevices(); - connectedShimmersListFragment.buildShimmersConnectedListView(null, getApplicationContext()); - mViewPager.setCurrentItem(0); - selectedDeviceAddress = null; - selectedDeviceName = null; - connectedShimmersListFragment.removeSelectedDevice(); - return true; - case R.id.enable_write_to_csv: - Intent intent =new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE); + } + }.start(); + } + return true; - startActivityForResult(intent, PERMISSION_FILE_REQUEST_SHIMMER); + }else if(id == R.id.disconnect_all_devices){ + mService.disconnectAllDevices(); + connectedShimmersListFragment.buildShimmersConnectedListView(null, getApplicationContext()); + mViewPager.setCurrentItem(0); + selectedDeviceAddress = null; + selectedDeviceName = null; + connectedShimmersListFragment.removeSelectedDevice(); + return true; + }else if(id == R.id.enable_write_to_csv){ + Intent intent =new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE); - mService.setEnableLogging(true); - return true; - case R.id.disable_write_to_csv: - mService.setEnableLogging(false); - return true; - case R.id.set_sampling_rate: + startActivityForResult(intent, PERMISSION_FILE_REQUEST_SHIMMER); - // Create an AlertDialog Builder - AlertDialog.Builder builder = new AlertDialog.Builder(this); - builder.setTitle("Enter Sampling Rate"); + mService.setEnableLogging(true); + return true; - // Inflate the dialog layout - final EditText editTextSamplingRate = new EditText(this); - if (selectedDeviceAddress==null){ - return true; - } - ShimmerBluetooth device = (ShimmerBluetooth) mService.getShimmer(selectedDeviceAddress); - editTextSamplingRate.setText(Double.toString(device.getSamplingRateShimmer())); - builder.setView(editTextSamplingRate); - // Add OK button - builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - String samplingRateStr = editTextSamplingRate.getText().toString(); - // Convert the input to integer - double samplingRate = Double.parseDouble(samplingRateStr); - - // Call a method to write sampling rate or do whatever you need - ShimmerDevice clone = device.deepClone(); - clone.setSamplingRateShimmer(samplingRate); - AssembleShimmerConfig.generateSingleShimmerConfig(clone, COMMUNICATION_TYPE.BLUETOOTH); - mService.configureShimmer(clone); - //device.writeShimmerAndSensorsSamplingRate(samplingRate); + }else if(id == R.id.disable_write_to_csv){ + mService.setEnableLogging(false); + return true; + }else if(id == R.id.set_sampling_rate){ + // Create an AlertDialog Builder + AlertDialog.Builder builder = new AlertDialog.Builder(this); + builder.setTitle("Enter Sampling Rate"); + + // Inflate the dialog layout + final EditText editTextSamplingRate = new EditText(this); + if (selectedDeviceAddress==null){ + return true; + } + ShimmerBluetooth device = (ShimmerBluetooth) mService.getShimmer(selectedDeviceAddress); + editTextSamplingRate.setText(Double.toString(device.getSamplingRateShimmer())); + builder.setView(editTextSamplingRate); + // Add OK button + builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + String samplingRateStr = editTextSamplingRate.getText().toString(); + // Convert the input to integer + double samplingRate = Double.parseDouble(samplingRateStr); + + // Call a method to write sampling rate or do whatever you need + ShimmerDevice clone = device.deepClone(); + clone.setSamplingRateShimmer(samplingRate); + AssembleShimmerConfig.generateSingleShimmerConfig(clone, COMMUNICATION_TYPE.BLUETOOTH); + mService.configureShimmer(clone); + //device.writeShimmerAndSensorsSamplingRate(samplingRate); - } - }); + } + }); - // Add Cancel button - builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - dialog.dismiss(); - } - }); + // Add Cancel button + builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + dialog.dismiss(); + } + }); - builder.show(); + builder.show(); + return true; + }else if(id == R.id.low_power_mode){ + if (selectedDeviceAddress==null){ return true; - case R.id.low_power_mode: - if (selectedDeviceAddress==null){ - return true; - } - ShimmerDevice shimmerDevice = mService.getShimmer(selectedDeviceAddress); - ShimmerDevice clone = shimmerDevice.deepClone(); + } + ShimmerDevice shimmerDevice = mService.getShimmer(selectedDeviceAddress); + ShimmerDevice clone = shimmerDevice.deepClone(); - View checkBoxView = View.inflate(this, R.layout.checkbox, null); - CheckBox cbMagLPMode = (CheckBox) checkBoxView.findViewById(R.id.cbMagLPMode); - cbMagLPMode.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + View checkBoxView = View.inflate(this, R.layout.checkbox, null); + CheckBox cbMagLPMode = (CheckBox) checkBoxView.findViewById(R.id.cbMagLPMode); + cbMagLPMode.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { - clone.setConfigValueUsingConfigLabel(Configuration.Shimmer3.SENSOR_ID.SHIMMER_LIS3MDL_MAG_ALT, SensorLIS3MDL.GuiLabelConfig.LIS3MDL_ALT_MAG_LP, isChecked); - } - }); - cbMagLPMode.setText("Enable Mag LP Mode"); - boolean isLowPowerMagEnabled = Boolean.valueOf(clone.getConfigGuiValueUsingConfigLabel(Configuration.Shimmer3.SENSOR_ID.SHIMMER_LIS3MDL_MAG_ALT, SensorLIS3MDL.GuiLabelConfig.LIS3MDL_ALT_MAG_LP)); - cbMagLPMode.setChecked(isLowPowerMagEnabled); + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + clone.setConfigValueUsingConfigLabel(Configuration.Shimmer3.SENSOR_ID.SHIMMER_LIS3MDL_MAG_ALT, SensorLIS3MDL.GuiLabelConfig.LIS3MDL_ALT_MAG_LP, isChecked); + } + }); + cbMagLPMode.setText("Enable Mag LP Mode"); + boolean isLowPowerMagEnabled = Boolean.valueOf(clone.getConfigGuiValueUsingConfigLabel(Configuration.Shimmer3.SENSOR_ID.SHIMMER_LIS3MDL_MAG_ALT, SensorLIS3MDL.GuiLabelConfig.LIS3MDL_ALT_MAG_LP)); + cbMagLPMode.setChecked(isLowPowerMagEnabled); - CheckBox cbWRAccelLPMode = (CheckBox) checkBoxView.findViewById(R.id.cbWRAccelLPMode); - cbWRAccelLPMode.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + CheckBox cbWRAccelLPMode = (CheckBox) checkBoxView.findViewById(R.id.cbWRAccelLPMode); + cbWRAccelLPMode.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { - clone.setConfigValueUsingConfigLabel(Configuration.Shimmer3.SENSOR_ID.SHIMMER_LIS2DW12_ACCEL_WR, SensorLIS2DW12.GuiLabelConfig.LIS2DW12_ACCEL_LPM, isChecked); - } - }); - cbWRAccelLPMode.setText("Enable WR Accel LP Mode"); - boolean isLowPowerWRAccelEnabled = Boolean.valueOf(clone.getConfigGuiValueUsingConfigLabel(Configuration.Shimmer3.SENSOR_ID.SHIMMER_LIS2DW12_ACCEL_WR, SensorLIS2DW12.GuiLabelConfig.LIS2DW12_ACCEL_LPM)); - cbWRAccelLPMode.setChecked(isLowPowerWRAccelEnabled); + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + clone.setConfigValueUsingConfigLabel(Configuration.Shimmer3.SENSOR_ID.SHIMMER_LIS2DW12_ACCEL_WR, SensorLIS2DW12.GuiLabelConfig.LIS2DW12_ACCEL_LPM, isChecked); + } + }); + cbWRAccelLPMode.setText("Enable WR Accel LP Mode"); + boolean isLowPowerWRAccelEnabled = Boolean.valueOf(clone.getConfigGuiValueUsingConfigLabel(Configuration.Shimmer3.SENSOR_ID.SHIMMER_LIS2DW12_ACCEL_WR, SensorLIS2DW12.GuiLabelConfig.LIS2DW12_ACCEL_LPM)); + cbWRAccelLPMode.setChecked(isLowPowerWRAccelEnabled); - CheckBox cbGyroLPMode = (CheckBox) checkBoxView.findViewById(R.id.cbGyroLPMode); - cbGyroLPMode.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + CheckBox cbGyroLPMode = (CheckBox) checkBoxView.findViewById(R.id.cbGyroLPMode); + cbGyroLPMode.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { - clone.setConfigValueUsingConfigLabel(Configuration.Shimmer3.SENSOR_ID.SHIMMER_LSM6DSV_GYRO, SensorLSM6DSV.GuiLabelConfig.LSM6DSV_GYRO_LPM, isChecked); - } - }); - cbGyroLPMode.setText("Enable LN Accel and Gyro LP Mode"); - if(clone.getHardwareVersion() == ShimmerVerDetails.HW_ID.SHIMMER_3R){ - cbGyroLPMode.setText("Enable LN Accel and Gyro LP Mode"); - }else{ - cbGyroLPMode.setText("Enable Gyro LP Mode"); + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + clone.setConfigValueUsingConfigLabel(Configuration.Shimmer3.SENSOR_ID.SHIMMER_LSM6DSV_GYRO, SensorLSM6DSV.GuiLabelConfig.LSM6DSV_GYRO_LPM, isChecked); } - boolean isLowPowerGyroEnabled = Boolean.valueOf(clone.getConfigGuiValueUsingConfigLabel(Configuration.Shimmer3.SENSOR_ID.SHIMMER_LSM6DSV_GYRO, SensorLSM6DSV.GuiLabelConfig.LSM6DSV_GYRO_LPM)); - cbGyroLPMode.setChecked(isLowPowerGyroEnabled); - - AlertDialog.Builder builderLPMode = new AlertDialog.Builder(this); - builderLPMode.setTitle("Low Power Mode"); - builderLPMode.setView(checkBoxView) - .setCancelable(false) - .setPositiveButton("OK", new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int id) { - if (clone != null) { - - List cloneList = new ArrayList(); - cloneList.add(0, clone); - //TODO: Change this when AssembleShimmerConfig has been updated: - AssembleShimmerConfig.generateMultipleShimmerConfig(cloneList, Configuration.COMMUNICATION_TYPE.BLUETOOTH); - - if (shimmerDevice instanceof Shimmer || shimmerDevice instanceof VerisenseDevice || shimmerDevice instanceof Shimmer3BLEAndroid) { - mService.getBluetoothManager().configureShimmer(clone); - } else if (shimmerDevice instanceof Shimmer4Android) { - - } + }); + cbGyroLPMode.setText("Enable LN Accel and Gyro LP Mode"); + if(clone.getHardwareVersion() == ShimmerVerDetails.HW_ID.SHIMMER_3R){ + cbGyroLPMode.setText("Enable LN Accel and Gyro LP Mode"); + }else{ + cbGyroLPMode.setText("Enable Gyro LP Mode"); + } + boolean isLowPowerGyroEnabled = Boolean.valueOf(clone.getConfigGuiValueUsingConfigLabel(Configuration.Shimmer3.SENSOR_ID.SHIMMER_LSM6DSV_GYRO, SensorLSM6DSV.GuiLabelConfig.LSM6DSV_GYRO_LPM)); + cbGyroLPMode.setChecked(isLowPowerGyroEnabled); + + AlertDialog.Builder builderLPMode = new AlertDialog.Builder(this); + builderLPMode.setTitle("Low Power Mode"); + builderLPMode.setView(checkBoxView) + .setCancelable(false) + .setPositiveButton("OK", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + if (clone != null) { + + List cloneList = new ArrayList(); + cloneList.add(0, clone); + //TODO: Change this when AssembleShimmerConfig has been updated: + AssembleShimmerConfig.generateMultipleShimmerConfig(cloneList, Configuration.COMMUNICATION_TYPE.BLUETOOTH); + + if (shimmerDevice instanceof Shimmer || shimmerDevice instanceof VerisenseDevice || shimmerDevice instanceof Shimmer3BLEAndroid) { + mService.getBluetoothManager().configureShimmer(clone); + } else if (shimmerDevice instanceof Shimmer4Android) { + } } - }) - .setNegativeButton("Cancel", new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int id) { - dialog.dismiss(); - } - }).show(); + } + }) + .setNegativeButton("Cancel", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + dialog.dismiss(); + } + }).show(); + return true; + + }else if(id == R.id.start_sd_logging){ + if (selectedDeviceAddress==null){ return true; - case R.id.start_sd_logging: - if (selectedDeviceAddress==null){ - return true; - } - mService.startLogging(selectedDeviceAddress); + } + mService.startLogging(selectedDeviceAddress); + return true; + }else if(id == R.id.stop_sd_logging){ + if (selectedDeviceAddress==null){ return true; - case R.id.stop_sd_logging: - if (selectedDeviceAddress==null){ - return true; - } - mService.stopLogging(selectedDeviceAddress); + } + mService.stopLogging(selectedDeviceAddress); + return true; + }else if(id == R.id.device_info){ + if (selectedDeviceAddress==null){ return true; - case R.id.device_info: - if (selectedDeviceAddress==null){ - return true; - } - ShimmerDevice shimmerTemp = mService.getShimmer(selectedDeviceAddress); - String shimmerVersion= shimmerTemp.getHardwareVersionParsed(); - String FWName = shimmerTemp.getFirmwareVersionParsed(); - if(FWName.equals("")) - FWName = "Unknown"; + } + ShimmerDevice shimmerTemp = mService.getShimmer(selectedDeviceAddress); + String shimmerVersion= shimmerTemp.getHardwareVersionParsed(); + String FWName = shimmerTemp.getFirmwareVersionParsed(); + if(FWName.equals("")) + FWName = "Unknown"; - AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this).create(); - alertDialog.setTitle("Device Info"); - alertDialog.setMessage("Shimmer Version: "+shimmerVersion + "\n\nFirmware Version: "+FWName); - alertDialog.show(); + AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this).create(); + alertDialog.setTitle("Device Info"); + alertDialog.setMessage("Shimmer Version: "+shimmerVersion + "\n\nFirmware Version: "+FWName); + alertDialog.show(); - return true; - case R.id.privacy_policy: - startActivity(new Intent(Intent.ACTION_VIEW,Uri.parse("https://www.shimmersensing.com/privacy/"))); + return true; - return true; - default: - return super.onOptionsItemSelected(item); + }else if(id == R.id.privacy_policy){ + startActivity(new Intent(Intent.ACTION_VIEW,Uri.parse("https://www.shimmersensing.com/privacy/"))); + return true; + + }else{ + return super.onOptionsItemSelected(item); } + } @Override diff --git a/ShimmerAndroidInstrumentDriver/ShimmerAndroidInstrumentDriver/src/main/res/layouts/fragments/layout/checkbox.xml b/ShimmerAndroidInstrumentDriver/shimmerServiceExample/src/main/res/layout/checkbox.xml similarity index 100% rename from ShimmerAndroidInstrumentDriver/ShimmerAndroidInstrumentDriver/src/main/res/layouts/fragments/layout/checkbox.xml rename to ShimmerAndroidInstrumentDriver/shimmerServiceExample/src/main/res/layout/checkbox.xml diff --git a/ShimmerAndroidInstrumentDriver/shimmerspeedtest/build.gradle b/ShimmerAndroidInstrumentDriver/shimmerspeedtest/build.gradle index bd96a0ca..9fc687a4 100644 --- a/ShimmerAndroidInstrumentDriver/shimmerspeedtest/build.gradle +++ b/ShimmerAndroidInstrumentDriver/shimmerspeedtest/build.gradle @@ -3,12 +3,13 @@ plugins { } android { - compileSdkVersion 33 + namespace 'com.shimmerresearch.shimmerspeedtest' + compileSdkVersion 34 defaultConfig { applicationId "com.shimmerresearch.shimmerspeedtest" - minSdkVersion 14 - targetSdkVersion 33 + minSdkVersion 21 + targetSdkVersion 34 versionCode 1 versionName "1.0" multiDexEnabled true @@ -43,10 +44,12 @@ android { dependencies { implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation project(':ShimmerAndroidInstrumentDriver') - implementation 'com.android.support.constraint:constraint-layout:2.0.4' implementation 'android.arch.navigation:navigation-fragment:1.0.0' implementation 'android.arch.navigation:navigation-ui:1.0.0' testImplementation 'junit:junit:4.13.2' - androidTestImplementation 'com.android.support.test:runner:1.0.2' - androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' + androidTestImplementation 'androidx.test:runner:1.5.2' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' + implementation 'androidx.constraintlayout:constraintlayout:2.2.0' + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" } \ No newline at end of file diff --git a/ShimmerAndroidInstrumentDriver/verisenseBLEBasicExample/build.gradle b/ShimmerAndroidInstrumentDriver/verisenseBLEBasicExample/build.gradle index 60e1c7be..c2a7cc70 100644 --- a/ShimmerAndroidInstrumentDriver/verisenseBLEBasicExample/build.gradle +++ b/ShimmerAndroidInstrumentDriver/verisenseBLEBasicExample/build.gradle @@ -1,14 +1,15 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 33 + namespace 'shimmerresearch.com.verisenseblebasicexample' + compileSdkVersion 34 defaultConfig { applicationId "shimmerresearch.com.verisenseblebasicexample" - minSdkVersion 17 - targetSdkVersion 33 + minSdkVersion 21 + targetSdkVersion 34 versionCode 1 versionName "1.0" multiDexEnabled true @@ -50,16 +51,16 @@ dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation project(path: ':ShimmerAndroidInstrumentDriver') - androidTestImplementation 'com.android.support:support-annotations:25.3.1' + androidTestImplementation 'androidx.annotation:annotation:1.7.1' //compile(group: 'com.shimmersensing', name: 'ShimmerAndroidInstrumentDriver', version: '3.0.71Beta', ext: 'aar') - implementation 'com.android.support.constraint:constraint-layout:1.0.2' + androidTestImplementation 'androidx.test:runner:1.5.2' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' + implementation 'androidx.constraintlayout:constraintlayout:2.2.0' testImplementation 'junit:junit:4.12' - androidTestImplementation 'com.android.support.test:runner:1.0.1' - androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' - implementation 'com.android.support.constraint:constraint-layout:1.0.2' - testImplementation 'junit:junit:4.12' - implementation 'com.android.support:multidex:1.0.3' + implementation 'androidx.multidex:multidex:2.0.1' + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" } repositories { mavenCentral() From fea583d3112aea1a70647ddd6939351120861dcb Mon Sep 17 00:00:00 2001 From: Mas Azalya Date: Wed, 10 Sep 2025 13:53:17 +0800 Subject: [PATCH 2/2] fix --- .../java/com/shimmerresearch/shimmercapture/MainActivity.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ShimmerAndroidInstrumentDriver/shimmerServiceExample/src/main/java/com/shimmerresearch/shimmercapture/MainActivity.java b/ShimmerAndroidInstrumentDriver/shimmerServiceExample/src/main/java/com/shimmerresearch/shimmercapture/MainActivity.java index faa01bb9..e97edee0 100644 --- a/ShimmerAndroidInstrumentDriver/shimmerServiceExample/src/main/java/com/shimmerresearch/shimmercapture/MainActivity.java +++ b/ShimmerAndroidInstrumentDriver/shimmerServiceExample/src/main/java/com/shimmerresearch/shimmercapture/MainActivity.java @@ -525,8 +525,9 @@ public void onClick(DialogInterface dialog, int id) { mService.stopLogging(selectedDeviceAddress); return true; }else if(id == R.id.device_info){ - if (selectedDeviceAddress==null){ + if (selectedDeviceAddress==null) { return true; + } ShimmerDevice shimmerTemp = mService.getShimmer(selectedDeviceAddress); double chargePercentage = shimmerTemp.getEstimatedChargePercentage();