From a2f8b76ac7832c3030e565b179b7578a7550f9bf Mon Sep 17 00:00:00 2001 From: Mathieu B Date: Sat, 25 Mar 2023 12:21:27 +0100 Subject: [PATCH] add empty message check and updates dependencies --- app/build.gradle | 16 ++++++++-------- .../jarvis/android/utils/SocketHandler.kt | 15 +++++++++++---- build.gradle | 8 ++++---- gradle/wrapper/gradle-wrapper.properties | 2 +- 4 files changed, 24 insertions(+), 17 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 70c82f4..eec9a83 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -37,7 +37,7 @@ android { compose true } composeOptions { - kotlinCompilerExtensionVersion '1.1.1' + kotlinCompilerExtensionVersion '1.4.0' } packagingOptions { resources { @@ -49,20 +49,20 @@ android { dependencies { implementation 'androidx.core:core-ktx:1.9.0' - implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.1' - implementation 'androidx.activity:activity-compose:1.6.1' + implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.1' + implementation 'androidx.activity:activity-compose:1.7.0' implementation "androidx.compose.ui:ui:$compose_version" implementation "androidx.compose.ui:ui-tooling-preview:$compose_version" - implementation 'androidx.compose.material3:material3:1.1.0-alpha02' - implementation 'com.google.android.material:material:1.7.0' + implementation 'androidx.compose.material3:material3:1.1.0-beta01' + implementation 'com.google.android.material:material:1.8.0' testImplementation 'junit:junit:4.13.2' - androidTestImplementation 'androidx.test.ext:junit:1.1.4' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.0' + androidTestImplementation 'androidx.test.ext:junit:1.1.5' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version" debugImplementation "androidx.compose.ui:ui-tooling:$compose_version" debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version" - implementation "androidx.navigation:navigation-compose:2.6.0-alpha04" + implementation "androidx.navigation:navigation-compose:2.6.0-alpha08" implementation 'com.google.accompanist:accompanist-permissions:0.23.1' implementation 'com.google.accompanist:accompanist-insets:0.23.1' diff --git a/app/src/main/java/ch/broillet/jarvis/android/utils/SocketHandler.kt b/app/src/main/java/ch/broillet/jarvis/android/utils/SocketHandler.kt index d3e03ab..5554367 100644 --- a/app/src/main/java/ch/broillet/jarvis/android/utils/SocketHandler.kt +++ b/app/src/main/java/ch/broillet/jarvis/android/utils/SocketHandler.kt @@ -4,6 +4,7 @@ import ch.broillet.jarvis.android.chat.ConversationUiState import ch.broillet.jarvis.android.chat.Message import io.socket.client.IO import io.socket.client.Socket +import io.socket.engineio.client.transports.WebSocket import org.json.JSONObject import java.net.URISyntaxException @@ -14,7 +15,10 @@ object SocketHandler { @Synchronized fun setSocket() { try { - mSocket = IO.socket("https://jarvis-server.broillet.ch") + val options = IO.Options() + options.transports = arrayOf(WebSocket.NAME) + + mSocket = IO.socket("https://jarvis-server.broillet.ch", options) } catch (_: URISyntaxException) { } } @@ -53,7 +57,9 @@ object SocketHandler { fun messageFromJarvis(data: Array, uiState: ConversationUiState) { if (data[0].toString().contains("data")) { val result: JSONObject = data[0] as JSONObject - uiState.addMessage(Message(true, result.getString("data"))) + if(result.getString("data") != "") { + uiState.addMessage(Message(true, result.getString("data"))) + } } } @@ -61,8 +67,9 @@ object SocketHandler { fun messageFromUser(data: Array, uiState: ConversationUiState) { if (data[0].toString().contains("data")) { val result: JSONObject = data[0] as JSONObject - uiState.addMessage(Message(false, result.getString("data"))) + if(result.getString("data") != "") { + uiState.addMessage(Message(false, result.getString("data"))) + } } - } } diff --git a/build.gradle b/build.gradle index e5843f1..e19ac34 100644 --- a/build.gradle +++ b/build.gradle @@ -1,11 +1,11 @@ buildscript { ext { - compose_version = '1.1.1' + compose_version = '1.4.0' } }// Top-level build file where you can add configuration options common to all sub-projects/modules. plugins { - id 'com.android.application' version '7.3.1' apply false - id 'com.android.library' version '7.3.1' apply false - id 'org.jetbrains.kotlin.android' version '1.6.10' apply false + id 'com.android.application' version '7.4.2' apply false + id 'com.android.library' version '7.4.2' apply false + id 'org.jetbrains.kotlin.android' version '1.8.0' apply false } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 4510afc..5ec5207 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Tue Nov 29 18:41:19 CET 2022 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME