Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to AndroidX #18

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Android-Simple-Bluetooth-Example.zip
Binary file not shown.
19 changes: 12 additions & 7 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
compileSdk 32

defaultConfig {
applicationId "com.mcuhq.simplebluetooth"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionCode 29
versionName "1.0"
}
buildTypes {
Expand All @@ -17,13 +16,19 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
dependenciesInfo {
includeInApk true
includeInBundle true
}
buildToolsVersion '31.0.0 rc3'
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:appcompat-v7:23.3.0'
testImplementation 'junit:junit:4.13.2'
implementation 'androidx.appcompat:appcompat:1.5.1'
}
8 changes: 7 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,27 @@

<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

<permission android:name="android.permission.BLUETOOTH" android:label="BLUETOOTH" />
<permission android:name="android.permission.BLUETOOTH_ADMIN" />
<permission android:name="android.permission.BLUETOOTH_CONNECT" />
<permission android:name="android.permission.BLUETOOTH_SCAN" />
<permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<permission android:name="android.permission.ACCESS_COARSE_LOCATION" />


<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<activity android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
193 changes: 116 additions & 77 deletions app/src/main/java/com/mcuhq/simplebluetooth/MainActivity.java

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
android:checked="false"
android:scaleX="1.7"
android:scaleY="1.7"
android:text="Toggle LED"
android:text="@string/toggle_led"
android:textStyle="bold" />

<LinearLayout
Expand All @@ -34,7 +34,7 @@
android:layout_weight="0.1"
android:ellipsize="end"
android:maxLines="1"
android:text="RX:"
android:text="@string/rx"
android:textStyle="bold" />

<TextView
Expand All @@ -44,7 +44,7 @@
android:layout_weight="0.9"
android:ellipsize="end"
android:maxLines="1"
android:text="&lt;Read Buffer>" />
android:text="@string/lt_read_buffer" />
</LinearLayout>

<LinearLayout
Expand All @@ -58,7 +58,7 @@
android:layout_weight="0.1"
android:ellipsize="end"
android:maxLines="1"
android:text="Status:"
android:text="@string/status"
android:textStyle="bold" />

<TextView
Expand All @@ -68,32 +68,32 @@
android:layout_weight="0.9"
android:ellipsize="end"
android:maxLines="1"
android:text="&lt;Bluetooth Status>" />
android:text="@string/lt_bluetooth_status" />
</LinearLayout>

<Button
android:id="@+id/scan"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Bluetooth ON" />
android:text="@string/bluetooth_on" />

<Button
android:id="@+id/off"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Bluetooth OFF" />
android:text="@string/bluetooth_off" />

<Button
android:id="@+id/paired_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Show paired Devices" />
android:text="@string/show_paired_devices" />

<Button
android:id="@+id/discover"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Discover New Devices" />
android:text="@string/discover_new_devices" />

<ListView
android:id="@+id/devices_list_view"
Expand Down
29 changes: 29 additions & 0 deletions app/src/main/res/values-it-rIT/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="BTEnable">Bluetooth abilitato</string>
<string name="sBTstaNF">Stato: Bluetooth non trovato</string>
<string name="sBTdevNF">Dispositivo Bluetooth non trovato!</string>
<string name="sBTturON">Richiesta Accensione Bluetooth</string>
<string name="BTisON">Il bluetooth è già acceso</string>
<string name="sEnabled">Abilitato</string>
<string name="sDisabled">Disabilitato</string>
<string name="BTConnected">"Connesso al dispositivo: "</string>
<string name="sBTdisabl">Il bluetooth è disabilitato</string>
<string name="BTturOff">Il bluetooth è stato spento</string>
<string name="DisStart">Ricerca in corso…</string>
<string name="BTnotOn">Il bluetooth non è acceso</string>
<string name="cConnet">Connessione in corso…</string>
<string name="ErrSockCrea">Creazione del Socket non riuscita</string>
<string name="toggle_led">Commuta LED</string>
<string name="lt_read_buffer">&lt;Buffer di lettura></string>
<string name="lt_bluetooth_status">&lt;Stato del Bluetooth</string>
<string name="status">"Stato: "</string>
<string name="bluetooth_on">Bluetooth ON</string>
<string name="bluetooth_off">Bluetooth OFF</string>
<string name="show_paired_devices">Dispositivi associati</string>
<string name="discover_new_devices">Ricerca dispositivi disponibili</string>
<string name="sConnFailF">Connessione %s non riuscita</string>
<string name="DisStop">Ricerca annullata</string>
<string name="BTisOff">Bluetooth è già spento</string>
<string name="BTconnFail">Connessione non riuscita</string>
</resources>
27 changes: 26 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
<resources>
<string name="app_name">Simple Bluetooth</string>
<string name="app_name" translatable="false">Simple Bluetooth</string>
<string name="BTconnFail">Connection Failed</string>
<string name="BTConnected">Connected to Device: </string>
<string name="sBTdevNF">"Bluetooth device not found!"</string>
<string name="sBTstaNF">Status: Bluetooth not found</string>
<string name="BTEnable">Bluetooth enabled</string>
<string name="sBTturON">Bluetooth turned on</string>
<string name="BTisON">Bluetooth is already on</string>
<string name="sEnabled">Enabled</string>
<string name="sDisabled">Disabled</string>
<string name="sBTdisabl">Bluetooth disabled</string>
<string name="BTnotOn">Bluetooth not on</string>
<string name="lt_bluetooth_status">Bluetooth status</string>
<string name="BTturOff">Bluetooth turned off</string>
<string name="cConnet">Connecting…</string>
<string name="ErrSockCrea">Socket creation failed</string>
<string name="DisStart">Discovery started</string>
<string name="show_paired_devices">Show Paired Devices</string>
<string name="DisStop">Discovery stopped</string>
<string name="status">"Status:"</string>
<string name="discover_new_devices">Discover new device</string>
<string name="toggle_led">Toggle LED</string>
<string name="rx" translatable="false">RX:</string>
<string name="lt_read_buffer">&lt;Read Buffer></string>
<string name="bluetooth_on">Bluetooth ON</string>
<string name="bluetooth_off">Bluetooth OFF</string>
</resources>
9 changes: 6 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

buildscript {
repositories {
jcenter()
mavenCentral()
maven {
url "https://maven.google.com"
name 'Google'
}
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.3'
classpath 'com.android.tools.build:gradle:7.2.2'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand All @@ -17,9 +19,10 @@ buildscript {

allprojects {
repositories {
jcenter()
mavenCentral()
maven {
url "https://maven.google.com"
name 'Google'
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# org.gradle.parallel=true
android.enableJetifier=true
android.useAndroidX=true
6 changes: 3 additions & 3 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed May 20 11:09:54 BST 2020
#Mon Sep 26 15:21:11 CEST 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-milestone-1-bin.zip
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
zipStoreBase=GRADLE_USER_HOME