From 8cb7260375a85ce6d426ccf2fb72a27c1edcbda4 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 9 Sep 2020 12:10:46 +0200 Subject: [PATCH] Small changes (PR review) --- .../sdk/internal/database/RealmInstanceWrapper.kt | 2 +- .../sdk/internal/database/RealmSessionProvider.kt | 2 +- .../android/sdk/internal/session/SessionModule.kt | 12 ++++++------ tools/check/forbidden_strings_in_code.txt | 3 +++ 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/RealmInstanceWrapper.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/RealmInstanceWrapper.kt index 851605437f..4d02d696d8 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/RealmInstanceWrapper.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/RealmInstanceWrapper.kt @@ -19,7 +19,7 @@ package org.matrix.android.sdk.internal.database import io.realm.Realm import java.io.Closeable -class RealmInstanceWrapper(private val realm: Realm, private val closeRealmOnClose: Boolean) : Closeable { +internal class RealmInstanceWrapper (private val realm: Realm, private val closeRealmOnClose: Boolean) : Closeable { override fun close() { if (closeRealmOnClose) { diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/RealmSessionProvider.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/RealmSessionProvider.kt index a232d83b6d..a7f934ffc0 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/RealmSessionProvider.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/RealmSessionProvider.kt @@ -31,7 +31,7 @@ import kotlin.concurrent.getOrSet * instance. This does check each time if you are on the main thread or not and returns the appropriate realm instance. */ @SessionScope -class RealmSessionProvider @Inject constructor(@SessionDatabase private val monarchy: Monarchy) +internal class RealmSessionProvider @Inject constructor(@SessionDatabase private val monarchy: Monarchy) : SessionLifecycleObserver { private val realmThreadLocal = ThreadLocal() diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/SessionModule.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/SessionModule.kt index e2042bfeac..5397b8d9bd 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/SessionModule.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/SessionModule.kt @@ -326,27 +326,27 @@ internal abstract class SessionModule { @Binds @IntoSet - abstract fun bindIntegrationManager(observer: IntegrationManager): SessionLifecycleObserver + abstract fun bindIntegrationManager(manager: IntegrationManager): SessionLifecycleObserver @Binds @IntoSet - abstract fun bindWidgetUrlFormatter(observer: DefaultWidgetURLFormatter): SessionLifecycleObserver + abstract fun bindWidgetUrlFormatter(formatter: DefaultWidgetURLFormatter): SessionLifecycleObserver @Binds @IntoSet - abstract fun bindShieldTrustUpdated(observer: ShieldTrustUpdater): SessionLifecycleObserver + abstract fun bindShieldTrustUpdated(updater: ShieldTrustUpdater): SessionLifecycleObserver @Binds @IntoSet - abstract fun bindIdentityService(observer: DefaultIdentityService): SessionLifecycleObserver + abstract fun bindIdentityService(service: DefaultIdentityService): SessionLifecycleObserver @Binds @IntoSet - abstract fun bindDatabaseCleaner(observer: DatabaseCleaner): SessionLifecycleObserver + abstract fun bindDatabaseCleaner(cleaner: DatabaseCleaner): SessionLifecycleObserver @Binds @IntoSet - abstract fun bindRealmSessionProvider(observer: RealmSessionProvider): SessionLifecycleObserver + abstract fun bindRealmSessionProvider(provider: RealmSessionProvider): SessionLifecycleObserver @Binds abstract fun bindInitialSyncProgressService(service: DefaultInitialSyncProgressService): InitialSyncProgressService diff --git a/tools/check/forbidden_strings_in_code.txt b/tools/check/forbidden_strings_in_code.txt index b5438a0c5b..425fc5a6d6 100644 --- a/tools/check/forbidden_strings_in_code.txt +++ b/tools/check/forbidden_strings_in_code.txt @@ -172,3 +172,6 @@ import org.matrix.androidsdk.crypto.data===2 ### Use `Context#getSystemService` extension function provided by `core-ktx` getSystemService\(Context + +### Use DefaultSharedPreferences.getInstance() instead for better performance +PreferenceManager\.getDefaultSharedPreferences==2