Add a module for the Matrix SDK with the aar of the Rust SDK
This commit is contained in:
parent
b223a39d34
commit
4219281691
5 changed files with 79 additions and 1 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1,6 +1,5 @@
|
||||||
# Built application files
|
# Built application files
|
||||||
*.apk
|
*.apk
|
||||||
*.aar
|
|
||||||
*.ap_
|
*.ap_
|
||||||
*.aab
|
*.aab
|
||||||
|
|
||||||
|
|
|
||||||
33
libraries/sdk/matrix/build.gradle
Normal file
33
libraries/sdk/matrix/build.gradle
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
plugins {
|
||||||
|
id 'com.android.library'
|
||||||
|
id 'org.jetbrains.kotlin.android'
|
||||||
|
}
|
||||||
|
|
||||||
|
android {
|
||||||
|
namespace 'io.element.android.x.sdk.matrix'
|
||||||
|
compileSdk 33
|
||||||
|
|
||||||
|
defaultConfig {
|
||||||
|
minSdk 29
|
||||||
|
targetSdk 33
|
||||||
|
}
|
||||||
|
|
||||||
|
buildTypes {
|
||||||
|
release {
|
||||||
|
minifyEnabled false
|
||||||
|
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
compileOptions {
|
||||||
|
sourceCompatibility JavaVersion.VERSION_1_8
|
||||||
|
targetCompatibility JavaVersion.VERSION_1_8
|
||||||
|
}
|
||||||
|
kotlinOptions {
|
||||||
|
jvmTarget = '1.8'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation(name: 'sdk-android-release', ext: 'aar')
|
||||||
|
implementation "net.java.dev.jna:jna:5.10.0@aar"
|
||||||
|
}
|
||||||
2
libraries/sdk/matrix/src/main/AndroidManifest.xml
Normal file
2
libraries/sdk/matrix/src/main/AndroidManifest.xml
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest />
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
package io.element.android.x.sdk.matrix
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.util.Log
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
|
private const val LOG_TAG = "Matrix"
|
||||||
|
|
||||||
|
class Matrix(
|
||||||
|
private val context: Context,
|
||||||
|
) {
|
||||||
|
fun login(username: String, password: String) {
|
||||||
|
val authFolder = File(context.filesDir, "auth")
|
||||||
|
val authService = AuthenticationService(authFolder.absolutePath)
|
||||||
|
authService.configureHomeserver("matrix.org")
|
||||||
|
val client = authService.login(username, password, "MatrixRustSDKSample", null)
|
||||||
|
val clientDelegate = object : ClientDelegate {
|
||||||
|
override fun didReceiveAuthError(isSoftLogout: Boolean) {
|
||||||
|
Log.v(LOG_TAG, "didReceiveAuthError()")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun didReceiveSyncUpdate() {
|
||||||
|
Log.v(LOG_TAG, "didReceiveSyncUpdate()")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun didUpdateRestoreToken() {
|
||||||
|
Log.v(LOG_TAG, "didUpdateRestoreToken()")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
client.setDelegate(clientDelegate)
|
||||||
|
Log.v(LOG_TAG, "DisplayName = ${client.displayName()}")
|
||||||
|
try {
|
||||||
|
client.fullSlidingSync()
|
||||||
|
} catch (failure: Throwable) {
|
||||||
|
Log.e(LOG_TAG, "fullSlidingSync() fail", failure)
|
||||||
|
}
|
||||||
|
client.logout()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -10,9 +10,13 @@ dependencyResolutionManagement {
|
||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
flatDir {
|
||||||
|
dirs 'libs'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rootProject.name = "ElementX"
|
rootProject.name = "ElementX"
|
||||||
include ':app'
|
include ':app'
|
||||||
include ':libraries:ui:theme'
|
include ':libraries:ui:theme'
|
||||||
include ':libraries:ui:screens:login'
|
include ':libraries:ui:screens:login'
|
||||||
|
include ':libraries:sdk:matrix'
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue