From d403693dcdc1d2f7bcb97162fdc65cacbe7414b9 Mon Sep 17 00:00:00 2001 From: Isai Damier Date: Wed, 19 May 2021 13:31:59 -0400 Subject: [PATCH] Refactor sample. Change obsolete APIs, make jetpack friendly, update files --- BluetoothLeChat/app/build.gradle | 4 ++-- .../bluetoothlechat/bluetooth/ChatServer.kt | 4 +++- .../main/res/layout/fragment_bluetooth_chat.xml | 11 +++++++---- .../src/main/res/layout/fragment_device_scan.xml | 4 ++-- .../main/res/layout/fragment_location_required.xml | 6 +++--- .../app/src/main/res/layout/item_device.xml | 14 +++++++------- .../app/src/main/res/layout/item_local_message.xml | 8 ++++---- .../src/main/res/layout/item_remote_message.xml | 8 ++++---- BluetoothLeChat/app/src/main/res/values/dimens.xml | 6 ++++++ .../app/src/main/res/values/strings.xml | 1 + BluetoothLeChat/build.gradle | 8 ++++---- .../gradle/wrapper/gradle-wrapper.properties | 6 +++--- 12 files changed, 46 insertions(+), 34 deletions(-) create mode 100644 BluetoothLeChat/app/src/main/res/values/dimens.xml diff --git a/BluetoothLeChat/app/build.gradle b/BluetoothLeChat/app/build.gradle index 2bd6c82f..22bc74af 100644 --- a/BluetoothLeChat/app/build.gradle +++ b/BluetoothLeChat/app/build.gradle @@ -55,8 +55,8 @@ dependencies { implementation fileTree(dir: "libs", include: ["*.jar"]) implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" implementation 'androidx.core:core-ktx:1.3.2' - implementation 'androidx.fragment:fragment-ktx:1.3.3' - implementation 'androidx.activity:activity-ktx:1.3.0-alpha07' + implementation 'androidx.fragment:fragment-ktx:1.3.4' + implementation 'androidx.activity:activity-ktx:1.3.0-alpha08' implementation 'androidx.appcompat:appcompat:1.2.0' implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1' implementation 'androidx.constraintlayout:constraintlayout:2.0.4' diff --git a/BluetoothLeChat/app/src/main/java/com/example/bluetoothlechat/bluetooth/ChatServer.kt b/BluetoothLeChat/app/src/main/java/com/example/bluetoothlechat/bluetooth/ChatServer.kt index 54da248c..75aba420 100644 --- a/BluetoothLeChat/app/src/main/java/com/example/bluetoothlechat/bluetooth/ChatServer.kt +++ b/BluetoothLeChat/app/src/main/java/com/example/bluetoothlechat/bluetooth/ChatServer.kt @@ -13,6 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +@file:Suppress("ObjectPropertyName") + package com.example.bluetoothlechat.bluetooth import android.app.Application @@ -305,7 +307,7 @@ object ChatServer { super.onStartFailure(errorCode) // Send error state to display val errorMessage = "Advertise failed with error: $errorCode" - Log.d(TAG, "Advertising failed") + Log.d(TAG, errorMessage) //_viewState.value = DeviceScanViewState.Error(errorMessage) } diff --git a/BluetoothLeChat/app/src/main/res/layout/fragment_bluetooth_chat.xml b/BluetoothLeChat/app/src/main/res/layout/fragment_bluetooth_chat.xml index 1714b3dc..070a52d3 100644 --- a/BluetoothLeChat/app/src/main/res/layout/fragment_bluetooth_chat.xml +++ b/BluetoothLeChat/app/src/main/res/layout/fragment_bluetooth_chat.xml @@ -35,7 +35,7 @@ android:id="@+id/connect_devices" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginTop="16dp" + android:layout_marginTop="@dimen/std_margin" android:text="@string/connect_device_prompt" /> @@ -50,8 +50,8 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" - android:padding="16dp" - android:textSize="18sp" /> + android:padding="@dimen/std_margin" + android:textSize="@dimen/txt_size_18" /> + android:layout_height="wrap_content" + android:importantForAutofill="no" />