diff --git a/Android/BlunoBasicDemo/.idea/caches/build_file_checksums.ser b/Android/BlunoBasicDemo/.idea/caches/build_file_checksums.ser new file mode 100644 index 0000000..ce2fd99 Binary files /dev/null and b/Android/BlunoBasicDemo/.idea/caches/build_file_checksums.ser differ diff --git a/Android/BlunoBasicDemo/.idea/caches/gradle_models.ser b/Android/BlunoBasicDemo/.idea/caches/gradle_models.ser new file mode 100644 index 0000000..774a26f Binary files /dev/null and b/Android/BlunoBasicDemo/.idea/caches/gradle_models.ser differ diff --git a/Android/BlunoBasicDemo/.idea/codeStyles/Project.xml b/Android/BlunoBasicDemo/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..30aa626 --- /dev/null +++ b/Android/BlunoBasicDemo/.idea/codeStyles/Project.xml @@ -0,0 +1,29 @@ +<component name="ProjectCodeStyleConfiguration"> + <code_scheme name="Project" version="173"> + <Objective-C-extensions> + <file> + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Import" /> + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Macro" /> + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Typedef" /> + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Enum" /> + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Constant" /> + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Global" /> + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Struct" /> + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="FunctionPredecl" /> + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Function" /> + </file> + <class> + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Property" /> + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Synthesize" /> + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InitMethod" /> + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="StaticMethod" /> + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InstanceMethod" /> + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="DeallocMethod" /> + </class> + <extensions> + <pair source="cpp" header="h" fileNamingConvention="NONE" /> + <pair source="c" header="h" fileNamingConvention="NONE" /> + </extensions> + </Objective-C-extensions> + </code_scheme> +</component> \ No newline at end of file diff --git a/Android/BlunoBasicDemo/.idea/gradle.xml b/Android/BlunoBasicDemo/.idea/gradle.xml index 39139a6..9d9baf8 100644 --- a/Android/BlunoBasicDemo/.idea/gradle.xml +++ b/Android/BlunoBasicDemo/.idea/gradle.xml @@ -3,6 +3,9 @@ <component name="GradleSettings"> <option name="linkedExternalProjectsSettings"> <GradleProjectSettings> + <compositeConfiguration> + <compositeBuild compositeDefinitionSource="SCRIPT" /> + </compositeConfiguration> <option name="distributionType" value="LOCAL" /> <option name="externalProjectPath" value="$PROJECT_DIR$" /> <option name="gradleHome" value="$APPLICATION_HOME_DIR$/gradle/gradle-2.8" /> @@ -13,6 +16,7 @@ <option value="$PROJECT_DIR$/app" /> </set> </option> + <option name="resolveModulePerSourceSet" value="false" /> </GradleProjectSettings> </option> </component> diff --git a/Android/BlunoBasicDemo/.idea/misc.xml b/Android/BlunoBasicDemo/.idea/misc.xml index 8e2533e..a98dac1 100644 --- a/Android/BlunoBasicDemo/.idea/misc.xml +++ b/Android/BlunoBasicDemo/.idea/misc.xml @@ -1,43 +1,41 @@ <?xml version="1.0" encoding="UTF-8"?> <project version="4"> - <component name="EntryPointsManager"> - <entry_points version="2.0" /> - </component> <component name="NullableNotNullManager"> <option name="myDefaultNullable" value="android.support.annotation.Nullable" /> <option name="myDefaultNotNull" value="android.support.annotation.NonNull" /> <option name="myNullables"> <value> - <list size="4"> + <list size="10"> <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" /> <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" /> <item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" /> <item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" /> + <item index="4" class="java.lang.String" itemvalue="javax.annotation.CheckForNull" /> + <item index="5" class="java.lang.String" itemvalue="androidx.annotation.Nullable" /> + <item index="6" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNullable" /> + <item index="7" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.qual.Nullable" /> + <item index="8" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NullableDecl" /> + <item index="9" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NullableType" /> </list> </value> </option> <option name="myNotNulls"> <value> - <list size="4"> + <list size="9"> <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" /> <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" /> <item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" /> <item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" /> + <item index="4" class="java.lang.String" itemvalue="androidx.annotation.NonNull" /> + <item index="5" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNonNull" /> + <item index="6" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.qual.NonNull" /> + <item index="7" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NonNullDecl" /> + <item index="8" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NonNullType" /> </list> </value> </option> </component> - <component name="ProjectLevelVcsManager" settingsEditedManually="false"> - <OptionsSetting value="true" id="Add" /> - <OptionsSetting value="true" id="Remove" /> - <OptionsSetting value="true" id="Checkout" /> - <OptionsSetting value="true" id="Update" /> - <OptionsSetting value="true" id="Status" /> - <OptionsSetting value="true" id="Edit" /> - <ConfirmationsSetting value="0" id="Add" /> - <ConfirmationsSetting value="0" id="Remove" /> - </component> - <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK"> + <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="JDK" project-jdk-type="JavaSDK"> <output url="file://$PROJECT_DIR$/build/classes" /> </component> <component name="ProjectType"> diff --git a/Android/BlunoBasicDemo/.idea/modules.xml b/Android/BlunoBasicDemo/.idea/modules.xml index 130956c..dc8a49d 100644 --- a/Android/BlunoBasicDemo/.idea/modules.xml +++ b/Android/BlunoBasicDemo/.idea/modules.xml @@ -3,6 +3,8 @@ <component name="ProjectModuleManager"> <modules> <module fileurl="file://$PROJECT_DIR$/BlunoBasicDemo.iml" filepath="$PROJECT_DIR$/BlunoBasicDemo.iml" /> + <module fileurl="file://$PROJECT_DIR$/BlunoBasicDemo.iml" filepath="$PROJECT_DIR$/BlunoBasicDemo.iml" /> + <module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" /> <module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" /> </modules> </component> diff --git a/Android/BlunoBasicDemo/.idea/vcs.xml b/Android/BlunoBasicDemo/.idea/vcs.xml index 6564d52..b2bdec2 100644 --- a/Android/BlunoBasicDemo/.idea/vcs.xml +++ b/Android/BlunoBasicDemo/.idea/vcs.xml @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <project version="4"> <component name="VcsDirectoryMappings"> - <mapping directory="" vcs="" /> + <mapping directory="$PROJECT_DIR$/../.." vcs="Git" /> </component> </project> \ No newline at end of file diff --git a/Android/BlunoBasicDemo/app/build.gradle b/Android/BlunoBasicDemo/app/build.gradle index 3c0c393..660aa2b 100644 --- a/Android/BlunoBasicDemo/app/build.gradle +++ b/Android/BlunoBasicDemo/app/build.gradle @@ -1,13 +1,13 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 21 - buildToolsVersion "21.1.2" + compileSdkVersion 26 + buildToolsVersion "28.0.3" defaultConfig { applicationId "com.dfrobot.angelo.blunobasicdemo" - minSdkVersion 18 - targetSdkVersion 21 + minSdkVersion 26 + targetSdkVersion 26 versionCode 1 versionName "1.0" } @@ -22,5 +22,5 @@ android { dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' - compile 'com.android.support:appcompat-v7:21.0.3' + compile 'com.android.support:appcompat-v7:26.1.0' } diff --git a/Android/BlunoBasicDemo/app/src/main/AndroidManifest.xml b/Android/BlunoBasicDemo/app/src/main/AndroidManifest.xml index 8732f8c..e3f4d91 100644 --- a/Android/BlunoBasicDemo/app/src/main/AndroidManifest.xml +++ b/Android/BlunoBasicDemo/app/src/main/AndroidManifest.xml @@ -8,7 +8,8 @@ devices only. If you want to make your app available to devices that don't supp you should omit this in the manifest. Instead, determine BLE capability by using PackageManager.hasSystemFeature(FEATURE_BLUETOOTH_LE) --> <uses-feature android:name="android.hardware.bluetooth_le" android:required="true"/> - + <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> + <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> <uses-permission android:name="android.permission.BLUETOOTH"/> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/> diff --git a/Android/BlunoBasicDemo/app/src/main/java/com/dfrobot/angelo/blunobasicdemo/MainActivity.java b/Android/BlunoBasicDemo/app/src/main/java/com/dfrobot/angelo/blunobasicdemo/MainActivity.java index 1ed3858..f47b2b4 100644 --- a/Android/BlunoBasicDemo/app/src/main/java/com/dfrobot/angelo/blunobasicdemo/MainActivity.java +++ b/Android/BlunoBasicDemo/app/src/main/java/com/dfrobot/angelo/blunobasicdemo/MainActivity.java @@ -1,14 +1,20 @@ package com.dfrobot.angelo.blunobasicdemo; +import android.Manifest; +import android.app.AlertDialog; import android.content.Context; +import android.content.pm.PackageManager; import android.os.Bundle; import android.content.Intent; +import android.support.v4.app.ActivityCompat; +import android.support.v4.content.ContextCompat; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText; import android.widget.ScrollView; import android.widget.TextView; +import android.widget.Toast; public class MainActivity extends BlunoLibrary { private Button buttonScan; @@ -21,9 +27,8 @@ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); onCreateProcess(); //onCreate Process by BlunoLibrary - - - serialBegin(115200); //set the Uart Baudrate on BLE chip to 115200 + requestPermissions(new String[]{Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION}, 1); + serialBegin(115200); //set the Uart Baudrate on BLE chip to 115200 serialReceivedText=(TextView) findViewById(R.id.serialReveicedText); //initial the EditText of the received data serialSendText=(EditText) findViewById(R.id.serialSendText); //initial the EditText of the sending data @@ -45,8 +50,21 @@ public void onClick(View v) { @Override public void onClick(View v) { // TODO Auto-generated method stub - - buttonScanOnClickProcess(); //Alert Dialog for selecting the BLE device + int permissionCheck = ContextCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.ACCESS_FINE_LOCATION); + if (permissionCheck != PackageManager.PERMISSION_GRANTED){ + boolean requestCheck = ActivityCompat.shouldShowRequestPermissionRationale(MainActivity.this, Manifest.permission.ACCESS_FINE_LOCATION); + if (requestCheck){ + requestPermissions(new String[]{Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION}, 1); + }else { + new AlertDialog.Builder(MainActivity.this) + .setTitle("Permission Required") + .setMessage("Please enable location permission to use this application.") + .setNeutralButton("I Understand", null) + .show(); + } + }else { + buttonScanOnClickProcess(); //Alert Dialog for selecting the BLE device + } } }); } diff --git a/Android/BlunoBasicDemo/app/src/main/res/layout/activity_main.xml b/Android/BlunoBasicDemo/app/src/main/res/layout/activity_main.xml index 9576a17..3bcc135 100644 --- a/Android/BlunoBasicDemo/app/src/main/res/layout/activity_main.xml +++ b/Android/BlunoBasicDemo/app/src/main/res/layout/activity_main.xml @@ -21,7 +21,7 @@ <TextView android:id="@+id/serialReveicedText" - android:layout_width="wrap_content" + android:layout_width="match_parent" android:layout_height="wrap_content" android:ems="10" android:textSize="10sp" @@ -53,16 +53,14 @@ <EditText android:id="@+id/serialSendText" android:layout_width="310dp" - android:layout_height="40dp" + android:layout_height="50dp" android:layout_below="@+id/buttonScan" android:layout_centerHorizontal="true" android:layout_marginTop="22dp" - android:background="#555555" android:bufferType="editable" android:ems="10" android:inputType="text" - android:text="Data sending Area" - android:textColor="#999999" + android:hint="Data sending area" android:textSize="20dip" /> <Button diff --git a/Android/BlunoBasicDemo/app/src/main/res/layout/listitem_device.xml b/Android/BlunoBasicDemo/app/src/main/res/layout/listitem_device.xml index eff44fc..70924d0 100644 --- a/Android/BlunoBasicDemo/app/src/main/res/layout/listitem_device.xml +++ b/Android/BlunoBasicDemo/app/src/main/res/layout/listitem_device.xml @@ -16,7 +16,8 @@ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" - android:layout_height="wrap_content"> + android:layout_height="wrap_content" + android:paddingHorizontal="20dp"> <TextView android:id="@+id/device_name" android:layout_width="match_parent" android:layout_height="wrap_content" diff --git a/Android/BlunoBasicDemo/app/src/main/res/values/styles.xml b/Android/BlunoBasicDemo/app/src/main/res/values/styles.xml index e84bc5e..e2a328b 100644 --- a/Android/BlunoBasicDemo/app/src/main/res/values/styles.xml +++ b/Android/BlunoBasicDemo/app/src/main/res/values/styles.xml @@ -1,7 +1,7 @@ <resources> <!-- Base application theme. --> - <style name="AppTheme" parent="android:Theme.Light"> + <style name="AppTheme" parent="android:Theme.Material"> <!-- Customize your theme here. --> </style> diff --git a/Android/BlunoBasicDemo/build.gradle b/Android/BlunoBasicDemo/build.gradle index e0b366a..b76d033 100644 --- a/Android/BlunoBasicDemo/build.gradle +++ b/Android/BlunoBasicDemo/build.gradle @@ -3,6 +3,10 @@ buildscript { repositories { jcenter() + maven { + url 'https://maven.google.com/' + name 'Google' + } } dependencies { classpath 'com.android.tools.build:gradle:1.5.0' @@ -15,6 +19,10 @@ buildscript { allprojects { repositories { jcenter() + maven { + url 'https://maven.google.com/' + name 'Google' + } } }