Skip to content

Commit d8bbe8c

Browse files
authored
Merge pull request #98 from dsrees/update-deps
Update Dependencies
2 parents ac5b968 + 3d52007 commit d8bbe8c

File tree

11 files changed

+54
-57
lines changed

11 files changed

+54
-57
lines changed

ChatExample/app/build.gradle

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
apply plugin: 'com.android.application'
2-
32
apply plugin: 'kotlin-android'
43

5-
apply plugin: 'kotlin-android-extensions'
6-
74
android {
8-
compileSdkVersion 30
5+
compileSdkVersion 33
96
defaultConfig {
107
applicationId "com.github.dsrees.chatexample"
118
minSdkVersion 19
12-
targetSdkVersion 30
9+
targetSdkVersion 33
1310
versionCode 1
1411
versionName "1.0"
1512
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
@@ -21,6 +18,10 @@ android {
2118
}
2219
}
2320

21+
buildFeatures {
22+
viewBinding true
23+
}
24+
2425
compileOptions {
2526
targetCompatibility = "8"
2627
sourceCompatibility = "8"
@@ -40,14 +41,10 @@ dependencies {
4041
// implementation 'com.github.dsrees:JavaPhoenixClient:0.3.4'
4142

4243

43-
implementation "com.google.code.gson:gson:2.8.5"
44-
implementation "com.squareup.okhttp3:okhttp:3.12.2"
45-
46-
47-
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
48-
49-
implementation 'androidx.appcompat:appcompat:1.0.2'
50-
implementation 'androidx.recyclerview:recyclerview:1.0.0'
51-
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
44+
implementation "com.google.code.gson:gson:2.10.1"
45+
implementation "com.squareup.okhttp3:okhttp:4.11.0"
5246

47+
implementation 'androidx.appcompat:appcompat:1.6.1'
48+
implementation 'androidx.recyclerview:recyclerview:1.3.1'
49+
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
5350
}
-112 KB
Binary file not shown.
Binary file not shown.

ChatExample/app/src/main/AndroidManifest.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
android:theme="@style/AppTheme"
1515
android:usesCleartextTraffic="true"
1616
tools:ignore="GoogleAppIndexingWarning">
17-
<activity android:name=".MainActivity">
17+
<activity android:name=".MainActivity"
18+
android:exported="true"
19+
>
1820
<intent-filter>
1921
<action android:name="android.intent.action.MAIN" />
2022

ChatExample/app/src/main/java/com/github/dsrees/chatexample/MainActivity.kt

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,8 @@ package com.github.dsrees.chatexample
33
import androidx.appcompat.app.AppCompatActivity
44
import android.os.Bundle
55
import android.util.Log
6-
import android.widget.ArrayAdapter
7-
import android.widget.Button
8-
import android.widget.EditText
96
import androidx.recyclerview.widget.LinearLayoutManager
10-
import kotlinx.android.synthetic.main.activity_main.*
7+
import com.github.dsrees.chatexample.databinding.ActivityMainBinding
118
import org.phoenixframework.Channel
129
import org.phoenixframework.Socket
1310

@@ -17,44 +14,47 @@ class MainActivity : AppCompatActivity() {
1714
const val TAG = "MainActivity"
1815
}
1916

17+
private lateinit var binding: ActivityMainBinding
18+
2019
private val messagesAdapter = MessagesAdapter()
2120
private val layoutManager = LinearLayoutManager(this)
2221

2322

2423
// Use when connecting to https://github.com/dwyl/phoenix-chat-example
25-
// private val socket = Socket("https://phxchat.herokuapp.com/socket/websocket")
26-
// private val topic = "room:lobby"
24+
private val socket = Socket("https://phoenix-chat.fly.dev/socket/websocket")
25+
private val topic = "room:lobby"
2726

2827
// Use when connecting to local server
29-
private val socket = Socket("ws://10.0.2.2:4000/socket/websocket")
30-
private val topic = "rooms:lobby"
28+
// private val socket = Socket("ws://10.0.2.2:4000/socket/websocket")
29+
// private val topic = "rooms:lobby"
3130

3231
private var lobbyChannel: Channel? = null
3332

3433
private val username: String
35-
get() = username_input.text.toString()
34+
get() = binding.usernameInput.text.toString()
3635

3736
private val message: String
38-
get() = message_input.text.toString()
37+
get() = binding.messageInput.text.toString()
3938

4039
override fun onCreate(savedInstanceState: Bundle?) {
4140
super.onCreate(savedInstanceState)
42-
setContentView(R.layout.activity_main)
4341

42+
this.binding = ActivityMainBinding.inflate(layoutInflater)
43+
setContentView(binding.root)
4444

4545
layoutManager.stackFromEnd = true
4646

47-
messages_recycler_view.layoutManager = layoutManager
48-
messages_recycler_view.adapter = messagesAdapter
47+
binding.messagesRecyclerView.layoutManager = layoutManager
48+
binding.messagesRecyclerView.adapter = messagesAdapter
4949

5050
socket.onOpen {
5151
this.addText("Socket Opened")
52-
runOnUiThread { connect_button.text = "Disconnect" }
52+
runOnUiThread { binding.connectButton.text = "Disconnect" }
5353
}
5454

5555
socket.onClose {
5656
this.addText("Socket Closed")
57-
runOnUiThread { connect_button.text = "Connect" }
57+
runOnUiThread { binding.connectButton.text = "Connect" }
5858
}
5959

6060
socket.onError { throwable, response ->
@@ -67,7 +67,7 @@ class MainActivity : AppCompatActivity() {
6767
}
6868

6969

70-
connect_button.setOnClickListener {
70+
binding.connectButton.setOnClickListener {
7171
if (socket.isConnected) {
7272
this.disconnectAndLeave()
7373
} else {
@@ -76,7 +76,7 @@ class MainActivity : AppCompatActivity() {
7676
}
7777
}
7878

79-
send_button.setOnClickListener { sendMessage() }
79+
binding.sendButton.setOnClickListener { sendMessage() }
8080
}
8181

8282
private fun sendMessage() {
@@ -85,7 +85,7 @@ class MainActivity : AppCompatActivity() {
8585
?.receive("ok") { Log.d(TAG, "success $it") }
8686
?.receive("error") { Log.d(TAG, "error $it") }
8787

88-
message_input.text.clear()
88+
binding.messageInput.text.clear()
8989
}
9090

9191
private fun disconnectAndLeave() {
@@ -132,9 +132,7 @@ class MainActivity : AppCompatActivity() {
132132
private fun addText(message: String) {
133133
runOnUiThread {
134134
this.messagesAdapter.add(message)
135-
layoutManager.smoothScrollToPosition(messages_recycler_view, null, messagesAdapter.itemCount)
135+
layoutManager.smoothScrollToPosition(binding.messagesRecyclerView, null, messagesAdapter.itemCount)
136136
}
137-
138137
}
139-
140138
}

ChatExample/app/src/main/java/com/github/dsrees/chatexample/MessagesAdapter.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import android.view.View
55
import android.view.ViewGroup
66
import android.widget.TextView
77
import androidx.recyclerview.widget.RecyclerView
8+
import com.github.dsrees.chatexample.databinding.ItemMessageBinding
89

910
class MessagesAdapter : RecyclerView.Adapter<MessagesAdapter.ViewHolder>() {
1011

@@ -17,8 +18,8 @@ class MessagesAdapter : RecyclerView.Adapter<MessagesAdapter.ViewHolder>() {
1718

1819

1920
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
20-
val view = LayoutInflater.from(parent.context).inflate(R.layout.item_message, parent, false)
21-
return ViewHolder(view)
21+
val binding = ItemMessageBinding.inflate(LayoutInflater.from(parent.context), parent, false)
22+
return ViewHolder(binding)
2223
}
2324

2425
override fun getItemCount(): Int = messages.size
@@ -27,8 +28,8 @@ class MessagesAdapter : RecyclerView.Adapter<MessagesAdapter.ViewHolder>() {
2728
holder.label.text = messages[position]
2829
}
2930

30-
inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
31-
val label: TextView = itemView.findViewById(R.id.item_message_label)
31+
inner class ViewHolder(binding: ItemMessageBinding) : RecyclerView.ViewHolder(binding.root) {
32+
val label: TextView = binding.itemMessageLabel
3233
}
3334

3435
}

ChatExample/build.gradle

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22

33
buildscript {
4-
ext.kotlin_version = '1.3.31'
4+
ext.kotlin_version = '1.8.0'
55
repositories {
66
google()
77
mavenCentral()
88

99
}
1010
dependencies {
11-
classpath 'com.android.tools.build:gradle:3.4.1'
11+
classpath 'com.android.tools.build:gradle:7.4.2'
1212
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
13-
// NOTE: Do not place your application dependencies here; they belong
14-
// in the individual module build.gradle files
1513
}
1614
}
1715

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Tue May 14 11:28:07 EDT 2019
1+
#Wed Oct 04 12:35:15 EDT 2023
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.2-bin.zip
45
zipStoreBase=GRADLE_USER_HOME
56
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip

build.gradle

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ buildscript {
1313
plugins {
1414
id 'java'
1515
id 'jacoco'
16-
id 'org.jetbrains.kotlin.jvm' version '1.3.31'
16+
id 'org.jetbrains.kotlin.jvm' version '1.8.0'
1717
}
1818

1919
ext {
@@ -47,16 +47,16 @@ test {
4747
}
4848

4949
dependencies {
50-
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
51-
compile "com.google.code.gson:gson:2.8.5"
52-
compile "com.squareup.okhttp3:okhttp:3.12.2"
50+
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
51+
implementation "com.google.code.gson:gson:2.10.1"
52+
implementation "com.squareup.okhttp3:okhttp:4.11.0"
5353

5454
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.3.1'
5555
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.3.1'
5656

57-
testCompile group: 'com.google.truth', name: 'truth', version: '1.1.3'
58-
testCompile group: 'org.mockito', name: 'mockito-core', version: '4.0.0'
59-
testCompile group: 'org.mockito.kotlin', name: 'mockito-kotlin', version: '4.0.0'
57+
testImplementation group: 'com.google.truth', name: 'truth', version: '1.1.3'
58+
testImplementation group: 'org.mockito', name: 'mockito-core', version: '4.0.0'
59+
testImplementation group: 'org.mockito.kotlin', name: 'mockito-kotlin', version: '4.0.0'
6060
}
6161

6262
jacocoTestReport {
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Thu Mar 18 20:34:38 EDT 2021
1+
#Wed Oct 04 12:21:20 EDT 2023
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.2-bin.zip
45
zipStoreBase=GRADLE_USER_HOME
56
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.2-all.zip

0 commit comments

Comments
 (0)