diff --git a/.gitignore b/.gitignore index db1555f0..a8936c3b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,7 @@ .gradle /local.properties -/.idea/workspace.xml -/.idea/dictionaries/*.xml -/.idea/libraries +/.idea +*.iml .DS_Store /build /key* \ No newline at end of file diff --git a/.idea/.name b/.idea/.name deleted file mode 100644 index 41bcebb2..00000000 --- a/.idea/.name +++ /dev/null @@ -1 +0,0 @@ -nRFToolbox \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml deleted file mode 100644 index 217af471..00000000 --- a/.idea/compiler.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - diff --git a/.idea/copyright/BSD.xml b/.idea/copyright/BSD.xml deleted file mode 100644 index 178eefff..00000000 --- a/.idea/copyright/BSD.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml deleted file mode 100644 index 564653ff..00000000 --- a/.idea/copyright/profiles_settings.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml deleted file mode 100644 index f7589596..00000000 --- a/.idea/encodings.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml deleted file mode 100644 index e67a6ec3..00000000 --- a/.idea/gradle.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index fc2d64b2..00000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 0a213726..00000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml deleted file mode 100644 index 7f68460d..00000000 --- a/.idea/runConfigurations.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/scopes/scope_settings.xml b/.idea/scopes/scope_settings.xml deleted file mode 100644 index 922003b8..00000000 --- a/.idea/scopes/scope_settings.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 94a25f7f..00000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/app/app.iml b/app/app.iml deleted file mode 100644 index 5d755e3b..00000000 --- a/app/app.iml +++ /dev/null @@ -1,111 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index a076e26a..e55952a0 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -2,14 +2,14 @@ apply plugin: 'com.android.application' android { compileSdkVersion 23 - buildToolsVersion '23.0.2' + buildToolsVersion '23.0.3' defaultConfig { applicationId "no.nordicsemi.android.nrftoolbox" minSdkVersion 18 targetSdkVersion 23 - versionCode 42 - versionName "1.16.3" + versionCode 43 + versionName "1.16.4" } buildTypes { release { @@ -21,10 +21,10 @@ android { dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) - compile 'com.google.android.gms:play-services-wearable:8.3.0' - compile 'com.android.support:appcompat-v7:23.1.1' - compile 'com.android.support:design:23.1.1' - compile 'no.nordicsemi.android.support.v18:scanner:0.1.1' + compile 'com.google.android.gms:play-services-wearable:9.0.2' + compile 'com.android.support:appcompat-v7:23.4.0' + compile 'com.android.support:design:23.4.0' + compile 'no.nordicsemi.android.support.v18:scanner:0.2.0' compile 'no.nordicsemi.android:log:2.0.0' compile('org.simpleframework:simple-xml:2.7.1') { exclude group: 'stax', module: 'stax-api' diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 859597cf..9f7b47c7 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -233,7 +233,9 @@ android:label="@string/uart_feature_title" /> - + + + diff --git a/app/src/main/java/no/nordicsemi/android/nrftoolbox/uart/UARTActivity.java b/app/src/main/java/no/nordicsemi/android/nrftoolbox/uart/UARTActivity.java index 2625c499..1f8aa3e0 100644 --- a/app/src/main/java/no/nordicsemi/android/nrftoolbox/uart/UARTActivity.java +++ b/app/src/main/java/no/nordicsemi/android/nrftoolbox/uart/UARTActivity.java @@ -128,9 +128,9 @@ public class UARTActivity extends BleProfileServiceReadyActivity + + + + + + + + + + + + Configure button Enter command - Command must not be empty Active Select icon: Disconnect %s is connected. - + + EOL: + CR+LF + LF + CR + UART profile (Universal Asynchronous Receiver and Transmitter) is a Bluetooth Smart implementation of the UART standard. It allows for bidirectional text based communication that is often used for debugging and control. \nEach configuration contains 9 programmable buttons that may send commands to the UART TX characteristic. Click on the EDIT menu item to edit buttons actions. diff --git a/build.gradle b/build.gradle index a6fcfe1f..f6e90731 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:1.5.0' + classpath 'com.android.tools.build:gradle:2.1.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/common/build.gradle b/common/build.gradle index 9937d49d..b63b2316 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -24,7 +24,7 @@ apply plugin: 'com.android.library' android { compileSdkVersion 23 - buildToolsVersion "23.0.2" + buildToolsVersion "23.0.3" defaultConfig { minSdkVersion 18 @@ -42,5 +42,5 @@ android { dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) - compile 'com.android.support:support-v4:23.1.1' + compile 'com.android.support:support-v4:23.4.0' } diff --git a/common/common.iml b/common/common.iml deleted file mode 100644 index f58a14bb..00000000 --- a/common/common.iml +++ /dev/null @@ -1,89 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/common/src/main/java/no/nordicsemi/android/nrftoolbox/wearable/common/Constants.java b/common/src/main/java/no/nordicsemi/android/nrftoolbox/wearable/common/Constants.java index 8c2e0d0d..5d652d78 100644 --- a/common/src/main/java/no/nordicsemi/android/nrftoolbox/wearable/common/Constants.java +++ b/common/src/main/java/no/nordicsemi/android/nrftoolbox/wearable/common/Constants.java @@ -60,6 +60,7 @@ public final class Constants { public static final class Command { public static final String ICON_ID = "icon_id"; public static final String MESSAGE = "message"; + public static final String EOL = "eol"; } } } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index f64777bd..99bbfde0 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Mon Nov 02 11:30:44 CET 2015 +#Tue Jun 14 13:22:53 CEST 2016 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.7-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip diff --git a/nRFToolbox.iml b/nRFToolbox.iml deleted file mode 100644 index e37ba875..00000000 --- a/nRFToolbox.iml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/wear/build.gradle b/wear/build.gradle index ae358b8a..37d9b55f 100644 --- a/wear/build.gradle +++ b/wear/build.gradle @@ -3,7 +3,7 @@ apply plugin: 'com.android.application' android { compileSdkVersion 23 - buildToolsVersion "23.0.2" + buildToolsVersion "23.0.3" defaultConfig { applicationId "no.nordicsemi.android.nrftoolbox" @@ -23,7 +23,7 @@ android { dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.google.android.support:wearable:1.3.0' - compile 'com.google.android.gms:play-services-wearable:8.3.0' + compile 'com.google.android.gms:play-services-wearable:9.0.2' compile 'no.nordicsemi.android.support.v18:scanner:0.1.1' compile project(':common') } diff --git a/wear/src/main/AndroidManifest.xml b/wear/src/main/AndroidManifest.xml index d655f750..f08e4a88 100644 --- a/wear/src/main/AndroidManifest.xml +++ b/wear/src/main/AndroidManifest.xml @@ -28,6 +28,7 @@ + - + + + diff --git a/wear/src/main/java/no/nordicsemi/android/nrftoolbox/ScannerActivity.java b/wear/src/main/java/no/nordicsemi/android/nrftoolbox/ScannerActivity.java index b7aaf32a..c6e5e9b3 100644 --- a/wear/src/main/java/no/nordicsemi/android/nrftoolbox/ScannerActivity.java +++ b/wear/src/main/java/no/nordicsemi/android/nrftoolbox/ScannerActivity.java @@ -22,6 +22,7 @@ package no.nordicsemi.android.nrftoolbox; +import android.Manifest; import android.app.Activity; import android.bluetooth.BluetoothDevice; import android.content.BroadcastReceiver; @@ -29,9 +30,14 @@ import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.ServiceConnection; +import android.content.pm.PackageManager; +import android.os.Build; import android.os.Bundle; import android.os.IBinder; +import android.support.annotation.NonNull; +import android.support.v4.content.ContextCompat; import android.support.v4.content.LocalBroadcastManager; +import android.support.v4.content.PermissionChecker; import android.support.wearable.view.WearableListView; import android.util.Log; import android.view.View; @@ -43,6 +49,8 @@ import no.nordicsemi.android.nrftoolbox.uart.UARTConfigurationsActivity; public class ScannerActivity extends Activity { private static final String TAG = "ScannerActivity"; + private static final int PERMISSION_REQUEST_LOCATION = 1; + private DevicesAdapter mDeviceAdapter; private View mHeader; @@ -108,9 +116,30 @@ public class ScannerActivity extends Activity { LocalBroadcastManager.getInstance(this).unregisterReceiver(mServiceBroadcastReceiver); } + @Override + public void onRequestPermissionsResult(final int requestCode, @NonNull final String[] permissions, @NonNull final int[] grantResults) { + switch (requestCode) { + case PERMISSION_REQUEST_LOCATION: + if (grantResults[0] == PackageManager.PERMISSION_GRANTED) { + mDeviceAdapter.startLeScan(); + } else { + Toast.makeText(ScannerActivity.this, "Location permission required", Toast.LENGTH_SHORT).show(); + finish(); + } + break; + } + } + @Override protected void onResume() { super.onResume(); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { + requestPermissions(new String[] { Manifest.permission.ACCESS_COARSE_LOCATION}, PERMISSION_REQUEST_LOCATION); + return; + } + } mDeviceAdapter.startLeScan(); } diff --git a/wear/src/main/java/no/nordicsemi/android/nrftoolbox/uart/UARTCommandsActivity.java b/wear/src/main/java/no/nordicsemi/android/nrftoolbox/uart/UARTCommandsActivity.java index e74ae0df..7fa891a4 100644 --- a/wear/src/main/java/no/nordicsemi/android/nrftoolbox/uart/UARTCommandsActivity.java +++ b/wear/src/main/java/no/nordicsemi/android/nrftoolbox/uart/UARTCommandsActivity.java @@ -190,7 +190,7 @@ public class UARTCommandsActivity extends Activity implements UARTCommandsAdapte } @Override - public void onConnectionFailed(final ConnectionResult connectionResult) { + public void onConnectionFailed(@NonNull final ConnectionResult connectionResult) { finish(); } @@ -248,10 +248,21 @@ public class UARTCommandsActivity extends Activity implements UARTCommandsAdapte @Override public void onCommandSelected(final Command command) { // Send command to handheld if the watch is not connected directly to the UART device. + final Command.Eol eol = command.getEol(); + String text = command.getCommand(); + switch (eol) { + case CR_LF: + text = text.replaceAll("\n", "\r\n"); + break; + case CR: + text = text.replaceAll("\n", "\r"); + break; + } + if (mProfile != null) - mProfile.send(command.getCommand()); + mProfile.send(text); else - sendMessageToHandheld(this, command.getCommand()); + sendMessageToHandheld(this, text); } /** diff --git a/wear/src/main/java/no/nordicsemi/android/nrftoolbox/uart/domain/Command.java b/wear/src/main/java/no/nordicsemi/android/nrftoolbox/uart/domain/Command.java index 90f1def8..fe0fca63 100644 --- a/wear/src/main/java/no/nordicsemi/android/nrftoolbox/uart/domain/Command.java +++ b/wear/src/main/java/no/nordicsemi/android/nrftoolbox/uart/domain/Command.java @@ -54,22 +54,37 @@ public class Command implements Parcelable { public int index; - private Icon(final int index) { + Icon(final int index) { this.index = index; } } + public enum Eol { + LF(0), + CR(1), + CR_LF(2); + + public final int index; + + Eol(final int index) { + this.index = index; + } + } + + private Eol eol = Eol.LF; private Icon icon = Icon.LEFT; private String command; /* package */ Command(final DataMap dataMap) { icon = Icon.values()[dataMap.getInt(Constants.UART.Configuration.Command.ICON_ID)]; command = dataMap.getString(Constants.UART.Configuration.Command.MESSAGE); + eol = Eol.values()[dataMap.getInt(Constants.UART.Configuration.Command.EOL)]; } private Command(final Parcel in) { icon = (Icon) in.readSerializable(); command = in.readString(); + eol = (Eol) in.readSerializable(); } /** @@ -80,6 +95,14 @@ public class Command implements Parcelable { this.command = command; } + /** + * Sets the new line type. + * @param eol end of line terminator + */ + /* package */ void setEol(final int eol) { + this.eol = Eol.values()[eol]; + } + /** * Sets the icon index. * @param index index of the icon. @@ -96,6 +119,14 @@ public class Command implements Parcelable { return command; } + /** + * Returns the new line type. + * @return end of line terminator + */ + public Eol getEol() { + return eol; + } + /** * Returns the icon index. * @return the icon index @@ -125,5 +156,6 @@ public class Command implements Parcelable { public void writeToParcel(final Parcel dest, int flags) { dest.writeSerializable(icon); dest.writeString(command); + dest.writeSerializable(eol); } } diff --git a/wear/wear.iml b/wear/wear.iml deleted file mode 100644 index fa175bef..00000000 --- a/wear/wear.iml +++ /dev/null @@ -1,96 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file