Browse Source

Add Timber

feature/bma/flipper
ganfra 2 years ago
parent
commit
485b38efad
  1. 1
      app/build.gradle
  2. 2
      app/src/main/java/io/element/android/x/ElementXApplication.kt
  3. 4
      features/login/build.gradle.kts
  4. 4
      features/roomlist/build.gradle.kts
  5. 6
      gradle/libs.versions.toml
  6. 36
      libraries/matrix/build.gradle
  7. 16
      libraries/matrix/build.gradle.kts
  8. 9
      libraries/matrix/src/main/java/io/element/android/x/matrix/MatrixClient.kt
  9. 7
      libraries/matrix/src/main/java/io/element/android/x/matrix/util/Error.kt

1
app/build.gradle

@ -83,6 +83,7 @@ dependencies { @@ -83,6 +83,7 @@ dependencies {
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.1'
implementation 'androidx.activity:activity-compose:1.6.1'
implementation 'androidx.lifecycle:lifecycle-viewmodel-compose:2.5.1'
implementation 'com.jakewharton.timber:timber:5.0.1'
debugImplementation "androidx.compose.ui:ui-tooling"
debugImplementation "androidx.compose.ui:ui-test-manifest"
implementation 'com.airbnb.android:mavericks-compose:3.0.1'

2
app/src/main/java/io/element/android/x/ElementXApplication.kt

@ -3,11 +3,13 @@ package io.element.android.x @@ -3,11 +3,13 @@ package io.element.android.x
import android.app.Application
import com.airbnb.mvrx.Mavericks
import io.element.android.x.matrix.MatrixInstance
import timber.log.Timber
class ElementXApplication : Application() {
override fun onCreate() {
super.onCreate()
Timber.plant(Timber.DebugTree())
MatrixInstance.init(this)
Mavericks.initialize(this)
}

4
features/login/build.gradle.kts

@ -10,8 +10,8 @@ dependencies { @@ -10,8 +10,8 @@ dependencies {
implementation(project(":libraries:core"))
implementation(project(":libraries:matrix"))
implementation(project(":libraries:designsystem"))
implementation("com.airbnb.android:mavericks-compose:3.0.1")
implementation(libs.mavericks.compose)
implementation(libs.timber)
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.3")
androidTestImplementation("androidx.test.espresso:espresso-core:3.4.0")

4
features/roomlist/build.gradle.kts

@ -10,8 +10,8 @@ dependencies { @@ -10,8 +10,8 @@ dependencies {
implementation(project(":libraries:core"))
implementation(project(":libraries:matrix"))
implementation(project(":libraries:designsystem"))
implementation("com.airbnb.android:mavericks-compose:3.0.1")
implementation(libs.mavericks.compose)
implementation(libs.timber)
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.3")
androidTestImplementation("androidx.test.espresso:espresso-core:3.4.0")

6
gradle/libs.versions.toml

@ -29,6 +29,10 @@ test_barista = "4.2.0" @@ -29,6 +29,10 @@ test_barista = "4.2.0"
test_hamcrest = "2.2"
test_orchestrator = "1.4.1"
#other
mavericks = "3.0.1"
timber = "5.0.1"
[libraries]
# Project
android_gradle_plugin = { module = "com.android.tools.build:gradle", version.ref = "android_gradle_plugin" }
@ -63,5 +67,7 @@ test_barista = { module = "com.adevinta.android:barista", version.ref = "test_ba @@ -63,5 +67,7 @@ test_barista = { module = "com.adevinta.android:barista", version.ref = "test_ba
test_hamcrest = { module = "org.hamcrest:hamcrest", version.ref = "test_hamcrest" }
test_orchestrator = { module = "androidx.test:orchestrator", version.ref = "test_orchestrator" }
mavericks_compose = { module = "com.airbnb.android:mavericks-compose", version.ref = "mavericks" }
timber = { module = "com.jakewharton.timber:timber", version.ref = "timber" }
[bundles]

36
libraries/matrix/build.gradle

@ -1,36 +0,0 @@ @@ -1,36 +0,0 @@
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 {
api(name: 'matrix-rust-sdk', ext: 'aar')
implementation project(":libraries:core")
implementation "net.java.dev.jna:jna:5.10.0@aar"
implementation 'androidx.datastore:datastore-core:1.0.0'
implementation 'androidx.datastore:datastore-preferences:1.0.0'
}

16
libraries/matrix/build.gradle.kts

@ -0,0 +1,16 @@ @@ -0,0 +1,16 @@
plugins {
id("io.element.android-library")
}
android {
namespace = "io.element.android.x.sdk.matrix"
}
dependencies {
api(files("./libs/matrix-rust-sdk.aar"))
implementation(project(":libraries:core"))
implementation(libs.timber)
implementation("net.java.dev.jna:jna:5.10.0@aar")
implementation("androidx.datastore:datastore-core:1.0.0")
implementation("androidx.datastore:datastore-preferences:1.0.0")
}

9
libraries/matrix/src/main/java/io/element/android/x/matrix/MatrixClient.kt

@ -8,6 +8,7 @@ import io.element.android.x.matrix.room.RustRoomSummaryDataSource @@ -8,6 +8,7 @@ import io.element.android.x.matrix.room.RustRoomSummaryDataSource
import io.element.android.x.matrix.session.SessionStore
import kotlinx.coroutines.withContext
import org.matrix.rustcomponents.sdk.*
import timber.log.Timber
import java.io.Closeable
class MatrixClient internal constructor(
@ -18,21 +19,21 @@ class MatrixClient internal constructor( @@ -18,21 +19,21 @@ class MatrixClient internal constructor(
private val clientDelegate = object : ClientDelegate {
override fun didReceiveAuthError(isSoftLogout: Boolean) {
Log.v(LOG_TAG, "didReceiveAuthError()")
Timber.v("didReceiveAuthError()")
}
override fun didReceiveSyncUpdate() {
Log.v(LOG_TAG, "didReceiveSyncUpdate()")
Timber.v("didReceiveSyncUpdate()")
}
override fun didUpdateRestoreToken() {
Log.v(LOG_TAG, "didUpdateRestoreToken()")
Timber.v("didUpdateRestoreToken()")
}
}
private val slidingSyncObserver = object : SlidingSyncObserver {
override fun didReceiveSyncUpdate(summary: UpdateSummary) {
Log.v(LOG_TAG, "didReceiveSyncUpdate=$summary")
Timber.v("didReceiveSyncUpdate=$summary")
roomSummaryDataSource.updateRoomsWithIdentifiers(summary.rooms)
}
}

7
libraries/matrix/src/main/java/io/element/android/x/matrix/util/Error.kt

@ -1,16 +1,15 @@ @@ -1,16 +1,15 @@
package io.element.android.x.matrix.util
import android.util.Log
import io.element.android.x.matrix.LOG_TAG
import org.matrix.rustcomponents.sdk.ClientException
import timber.log.Timber
fun logError(throwable: Throwable) {
when (throwable) {
is ClientException.Generic -> {
Log.e(LOG_TAG, "Error ${throwable.msg}", throwable)
Timber.e("Error ${throwable.msg}", throwable)
}
else -> {
Log.e(LOG_TAG, "Error", throwable)
Timber.e("Error", throwable)
}
}
}
Loading…
Cancel
Save