Skip to content

Commit

Permalink
Upgrade dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
iheron committed Jan 25, 2024
1 parent a101570 commit 507c432
Show file tree
Hide file tree
Showing 32 changed files with 637 additions and 575 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 0.5.0

* Upgrade dependencies
* Upgrade NKN SDK
* Upgrade Android Project

## 0.4.0

* Update dependencies
Expand Down
12 changes: 6 additions & 6 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ group 'org.nkn.nkn_sdk_flutter'
version '1.0-SNAPSHOT'

buildscript {
ext.kotlin_version = '1.5.10'
ext.kotlin_version = '1.8.22'
repositories {
google()
jcenter()
}

dependencies {
classpath 'com.android.tools.build:gradle:4.2.1'
classpath 'com.android.tools.build:gradle:4.2.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand All @@ -28,13 +28,13 @@ apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

android {
compileSdkVersion 29
compileSdkVersion 34

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
minSdkVersion 16
minSdkVersion 21
}
lintOptions {
disable 'InvalidPackage'
Expand All @@ -45,6 +45,6 @@ dependencies {
implementation (name: "nkn", ext: "aar")
implementation "org.bouncycastle:bcprov-jdk15to18:1.68"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.3"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.7.0"
}
Binary file modified android/libs/nkn-sources.jar
Binary file not shown.
Binary file modified android/libs/nkn.aar
Binary file not shown.
76 changes: 46 additions & 30 deletions android/src/main/kotlin/org/nkn/sdk/impl/Client.kt
Original file line number Diff line number Diff line change
Expand Up @@ -75,41 +75,43 @@ class Client : IChannelHandler, MethodChannel.MethodCallHandler, EventChannel.St
} catch (e: Throwable) {
eventSink?.error(id, e.localizedMessage, "")
return@withContext
} finally {
clientMap.remove(id)
}
clientMap.remove(id)
}

private suspend fun onConnect(client: MultiClient, numSubClients: Long) =
withContext(Dispatchers.IO) {
try {
val node = client.onConnect.next()
val rpcServers = ArrayList<String>()
for (i in 0..numSubClients) {
val c = client.getClient(i)
val rpcNode = c?.node
var rpcAddr = rpcNode?.rpcAddr ?: ""
if (rpcAddr.isNotEmpty()) {
rpcAddr = "http://$rpcAddr"
if (!rpcServers.contains(rpcAddr)) {
rpcServers.add(rpcAddr)
}
private suspend fun onConnect(client: MultiClient, numSubClients: Long) {
try {
val node = client.onConnect.next()
val rpcServers = ArrayList<String>()
for (i in 0..numSubClients) {
val c = client.getClient(i)
val rpcNode = c?.node
var rpcAddr = rpcNode?.rpcAddr ?: ""
if (rpcAddr.isNotEmpty()) {
rpcAddr = "http://$rpcAddr"
if (!rpcServers.contains(rpcAddr)) {
rpcServers.add(rpcAddr)
}
}

val resp = hashMapOf(
"_id" to client.address(),
"event" to "onConnect",
"node" to hashMapOf("address" to node.addr, "publicKey" to node.pubKey),
"client" to hashMapOf("address" to client.address()),
"rpcServers" to rpcServers
)
Log.d(NknSdkFlutterPlugin.TAG, resp.toString())
eventSinkSuccess(eventSink, resp)
} catch (e: Throwable) {
eventSinkError(eventSink, client.address(), e.localizedMessage)
}

val resp = hashMapOf(
"_id" to client.address(),
"event" to "onConnect",
"node" to hashMapOf("address" to node.addr, "publicKey" to node.pubKey),
"client" to hashMapOf("address" to client.address()),
"rpcServers" to rpcServers
)
Log.d(NknSdkFlutterPlugin.TAG, resp.toString())
eventSinkSuccess(eventSink, resp)
} catch (e: Throwable) {
eventSinkError(eventSink, client.address(), e.localizedMessage)
}

onConnect(client, numSubClients)
}

private suspend fun onMessage(client: MultiClient) {
try {
val msg = client.onMessage.next() ?: return
Expand Down Expand Up @@ -142,42 +144,55 @@ class Client : IChannelHandler, MethodChannel.MethodCallHandler, EventChannel.St
"create" -> {
create(call, result)
}

"reconnect" -> {
reconnect(call, result)
}

"close" -> {
close(call, result)
}

"replyText" -> {
replyText(call, result)
}

"sendText" -> {
sendText(call, result)
}

"publishText" -> {
publishText(call, result)
}

"subscribe" -> {
subscribe(call, result)
}

"unsubscribe" -> {
unsubscribe(call, result)
}

"getSubscribersCount" -> {
getSubscribersCount(call, result)
}

"getSubscribers" -> {
getSubscribers(call, result)
}

"getSubscription" -> {
getSubscription(call, result)
}

"getHeight" -> {
getHeight(call, result)
}

"getNonce" -> {
getNonce(call, result)
}

else -> {
result.notImplemented()
}
Expand Down Expand Up @@ -249,9 +264,10 @@ class Client : IChannelHandler, MethodChannel.MethodCallHandler, EventChannel.St
)
resultSuccess(result, data)

onConnect(client, numSubClients)

async(Dispatchers.IO) { onMessage(client) }
async(Dispatchers.IO) {
onConnect(client, numSubClients)
// onMessage(client)
}
} catch (e: Throwable) {
resultError(result, "", e.localizedMessage)
}
Expand Down
7 changes: 4 additions & 3 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 31
compileSdkVersion 34

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
Expand All @@ -39,8 +39,9 @@ android {
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "org.nkn.nkn_sdk_flutter_example"
minSdkVersion 16
targetSdkVersion 31
multiDexEnabled true
minSdkVersion 21
targetSdkVersion 34
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
Expand Down
6 changes: 3 additions & 3 deletions example/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
buildscript {
ext.kotlin_version = '1.4.10'
ext.kotlin_version = '1.8.22'
repositories {
google()
jcenter()
}

dependencies {
classpath 'com.android.tools.build:gradle:7.2.0'
classpath 'com.android.tools.build:gradle:7.2.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand All @@ -26,6 +26,6 @@ subprojects {
project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
2 changes: 1 addition & 1 deletion example/ios/Flutter/AppFrameworkInfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>11.0</string>
<string>12.0</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion example/ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Uncomment this line to define a global platform for your project
platform :ios, '11.0'
platform :ios, '12.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
Expand Down
6 changes: 3 additions & 3 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/nkn_sdk_flutter/ios"

SPEC CHECKSUMS:
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
nkn_sdk_flutter: cb83324eb3ef17419f715707b59bee20a9adfd34

PODFILE CHECKSUM: 7368163408c647b7eb699d0d788ba6718e18fb8d
PODFILE CHECKSUM: 4e8f8b2be68aeea4c0d5beb6ff1e79fface1d048

COCOAPODS: 1.12.1
COCOAPODS: 1.14.3
Loading

0 comments on commit 507c432

Please sign in to comment.