From c4316d50552d972de88c226d113ba2adeeca02ab Mon Sep 17 00:00:00 2001 From: ganfra Date: Thu, 4 Oct 2018 15:19:03 +0200 Subject: [PATCH] Make the sdk targeting android to win time --- .idea/caches/build_file_checksums.ser | Bin 708 -> 651 bytes .idea/gradle.xml | 1 - app/build.gradle | 9 ++-- app/src/main/AndroidManifest.xml | 1 + .../main/java/im/vector/riotredesign/Riot.kt | 3 +- .../vector/riotredesign/core/di/AppModule.kt | 20 +++++++ .../features/login/LoginActivity.kt | 17 +++--- matrix-sdk-android/build.gradle | 41 +++++++++++++- .../objectbox-models/default.json | 50 ++++++++++++++++++ .../im/vector/matrix/android}/api/Matrix.kt | 10 ++-- .../matrix/android}/api/MatrixCallback.kt | 4 +- .../matrix/android/api/MatrixOptions.kt | 8 +++ .../im/vector/matrix/android/api/Session.kt | 11 ++++ .../matrix/android}/api/events/Event.kt | 2 +- .../matrix/android}/api/events/EventType.kt | 2 +- .../matrix/android}/api/failure/Failure.kt | 2 +- .../android}/api/failure/MatrixError.kt | 2 +- .../matrix/android/api/login/Authenticator.kt | 11 ++++ .../android/api/login/CredentialsStore.kt | 11 ++++ .../android}/api/login/data/Credentials.kt | 8 ++- .../login/data/HomeServerConnectionConfig.kt | 2 +- .../android/api/persitence/Persister.kt | 15 ++++++ .../matrix/android/api/persitence/Query.kt | 11 ++++ .../android/api/persitence/QueryBuilder.kt | 7 +++ .../api/persitence/QueryDataObserver.java | 5 ++ .../{ => api}/thread/MainThreadExecutor.java | 2 +- .../matrix/android}/api/util/Cancelable.kt | 2 +- .../vector/matrix/android}/api/util/Logger.kt | 2 +- .../android}/internal/DefaultSession.kt | 10 ++-- .../internal/MatrixCoroutineDispatchers.kt | 2 +- .../android/internal/di/MatrixModule.kt | 41 ++++++++++++++ .../android/internal/di}/NetworkModule.kt | 3 +- .../internal/login/DefaultAuthenticator.kt | 24 ++++----- .../android}/internal/login/LoginApi.kt | 8 +-- .../android}/internal/login/LoginModule.kt | 8 +-- .../android}/internal/login/data/LoginFlow.kt | 2 +- .../internal/login/data/LoginFlowResponse.kt | 2 +- .../internal/login/data/LoginFlowTypes.kt | 2 +- .../internal/login/data/LoginParams.kt | 5 ++ .../login/data/PasswordLoginParams.kt | 2 +- .../login/db/InMemoryCredentialsStore.kt | 18 +++++++ .../login/db/ObjectBoxCredentialsStore.kt | 17 ++++++ .../network/AccessTokenInterceptor.kt | 6 +-- .../internal/network/NetworkConstants.kt | 2 +- .../android}/internal/network/Request.kt | 8 +-- .../matrix/android}/internal/sync/SyncAPI.kt | 6 +-- .../android}/internal/sync/data/DeviceInfo.kt | 2 +- .../internal/sync/data/DeviceListResponse.kt | 2 +- .../DeviceOneTimeKeysCountSyncResponse.kt | 2 +- .../internal/sync/data/DevicesListResponse.kt | 2 +- .../internal/sync/data/InvitedRoomSync.kt | 2 +- .../sync/data/PresenceSyncResponse.kt | 4 +- .../internal/sync/data/RoomInviteState.kt | 4 +- .../internal/sync/data/RoomResponse.kt | 4 +- .../android}/internal/sync/data/RoomSync.kt | 2 +- .../internal/sync/data/RoomSyncAccountData.kt | 4 +- .../internal/sync/data/RoomSyncEphemeral.kt | 4 +- .../internal/sync/data/RoomSyncState.kt | 4 +- .../internal/sync/data/RoomSyncTimeline.kt | 4 +- .../sync/data/RoomSyncUnreadNotifications.kt | 4 +- .../internal/sync/data/RoomsSyncResponse.kt | 2 +- .../internal/sync/data/SyncResponse.kt | 2 +- .../sync/data/ToDeviceSyncResponse.kt | 4 +- .../internal/sync/data/TokensChunkResponse.kt | 2 +- .../internal/util/CancelableCoroutine.kt | 4 +- .../matrix/android}/internal/util/Either.kt | 2 +- matrix-sdk-core/.gitignore | 1 - matrix-sdk-core/build.gradle | 26 --------- .../vector/matrix/core/api/MatrixOptions.kt | 5 -- .../java/im/vector/matrix/core/api/Session.kt | 11 ---- .../matrix/core/api/login/Authenticator.kt | 11 ---- .../matrix/core/api/login/CredentialsStore.kt | 6 --- .../vector/matrix/core/api/storage/MxQuery.kt | 11 ---- .../matrix/core/api/storage/MxQueryBuilder.kt | 7 --- .../core/api/storage/MxQueryDataObserver.java | 5 -- .../vector/matrix/core/api/storage/MxStore.kt | 13 ----- .../matrix/core/internal/MatrixModule.kt | 27 ---------- .../core/internal/login/data/LoginParams.kt | 5 -- .../login/db/InMemoryCredentialsStore.kt | 26 --------- settings.gradle | 2 +- 80 files changed, 380 insertions(+), 261 deletions(-) create mode 100644 app/src/main/java/im/vector/riotredesign/core/di/AppModule.kt create mode 100644 matrix-sdk-android/objectbox-models/default.json rename {matrix-sdk-core/src/main/java/im/vector/matrix/core => matrix-sdk-android/src/main/java/im/vector/matrix/android}/api/Matrix.kt (61%) rename {matrix-sdk-core/src/main/java/im/vector/matrix/core => matrix-sdk-android/src/main/java/im/vector/matrix/android}/api/MatrixCallback.kt (53%) create mode 100644 matrix-sdk-android/src/main/java/im/vector/matrix/android/api/MatrixOptions.kt create mode 100644 matrix-sdk-android/src/main/java/im/vector/matrix/android/api/Session.kt rename {matrix-sdk-core/src/main/java/im/vector/matrix/core => matrix-sdk-android/src/main/java/im/vector/matrix/android}/api/events/Event.kt (64%) rename {matrix-sdk-core/src/main/java/im/vector/matrix/core => matrix-sdk-android/src/main/java/im/vector/matrix/android}/api/events/EventType.kt (97%) rename {matrix-sdk-core/src/main/java/im/vector/matrix/core => matrix-sdk-android/src/main/java/im/vector/matrix/android}/api/failure/Failure.kt (84%) rename {matrix-sdk-core/src/main/java/im/vector/matrix/core => matrix-sdk-android/src/main/java/im/vector/matrix/android}/api/failure/MatrixError.kt (96%) create mode 100644 matrix-sdk-android/src/main/java/im/vector/matrix/android/api/login/Authenticator.kt create mode 100644 matrix-sdk-android/src/main/java/im/vector/matrix/android/api/login/CredentialsStore.kt rename {matrix-sdk-core/src/main/java/im/vector/matrix/core => matrix-sdk-android/src/main/java/im/vector/matrix/android}/api/login/data/Credentials.kt (63%) rename {matrix-sdk-core/src/main/java/im/vector/matrix/core => matrix-sdk-android/src/main/java/im/vector/matrix/android}/api/login/data/HomeServerConnectionConfig.kt (77%) create mode 100644 matrix-sdk-android/src/main/java/im/vector/matrix/android/api/persitence/Persister.kt create mode 100644 matrix-sdk-android/src/main/java/im/vector/matrix/android/api/persitence/Query.kt create mode 100644 matrix-sdk-android/src/main/java/im/vector/matrix/android/api/persitence/QueryBuilder.kt create mode 100644 matrix-sdk-android/src/main/java/im/vector/matrix/android/api/persitence/QueryDataObserver.java rename matrix-sdk-android/src/main/java/im/vector/matrix/android/{ => api}/thread/MainThreadExecutor.java (87%) rename {matrix-sdk-core/src/main/java/im/vector/matrix/core => matrix-sdk-android/src/main/java/im/vector/matrix/android}/api/util/Cancelable.kt (50%) rename {matrix-sdk-core/src/main/java/im/vector/matrix/core => matrix-sdk-android/src/main/java/im/vector/matrix/android}/api/util/Logger.kt (97%) rename {matrix-sdk-core/src/main/java/im/vector/matrix/core => matrix-sdk-android/src/main/java/im/vector/matrix/android}/internal/DefaultSession.kt (74%) rename {matrix-sdk-core/src/main/java/im/vector/matrix/core => matrix-sdk-android/src/main/java/im/vector/matrix/android}/internal/MatrixCoroutineDispatchers.kt (83%) create mode 100644 matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/di/MatrixModule.kt rename {matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/network => matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/di}/NetworkModule.kt (91%) rename {matrix-sdk-core/src/main/java/im/vector/matrix/core => matrix-sdk-android/src/main/java/im/vector/matrix/android}/internal/login/DefaultAuthenticator.kt (60%) rename {matrix-sdk-core/src/main/java/im/vector/matrix/core => matrix-sdk-android/src/main/java/im/vector/matrix/android}/internal/login/LoginApi.kt (64%) rename {matrix-sdk-core/src/main/java/im/vector/matrix/core => matrix-sdk-android/src/main/java/im/vector/matrix/android}/internal/login/LoginModule.kt (78%) rename {matrix-sdk-core/src/main/java/im/vector/matrix/core => matrix-sdk-android/src/main/java/im/vector/matrix/android}/internal/login/data/LoginFlow.kt (74%) rename {matrix-sdk-core/src/main/java/im/vector/matrix/core => matrix-sdk-android/src/main/java/im/vector/matrix/android}/internal/login/data/LoginFlowResponse.kt (70%) rename {matrix-sdk-core/src/main/java/im/vector/matrix/core => matrix-sdk-android/src/main/java/im/vector/matrix/android}/internal/login/data/LoginFlowTypes.kt (87%) create mode 100644 matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/login/data/LoginParams.kt rename {matrix-sdk-core/src/main/java/im/vector/matrix/core => matrix-sdk-android/src/main/java/im/vector/matrix/android}/internal/login/data/PasswordLoginParams.kt (97%) create mode 100644 matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/login/db/InMemoryCredentialsStore.kt create mode 100644 matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/login/db/ObjectBoxCredentialsStore.kt rename {matrix-sdk-core/src/main/java/im/vector/matrix/core => matrix-sdk-android/src/main/java/im/vector/matrix/android}/internal/network/AccessTokenInterceptor.kt (77%) rename {matrix-sdk-core/src/main/java/im/vector/matrix/core => matrix-sdk-android/src/main/java/im/vector/matrix/android}/internal/network/NetworkConstants.kt (74%) rename {matrix-sdk-core/src/main/java/im/vector/matrix/core => matrix-sdk-android/src/main/java/im/vector/matrix/android}/internal/network/Request.kt (88%) rename {matrix-sdk-core/src/main/java/im/vector/matrix/core => matrix-sdk-android/src/main/java/im/vector/matrix/android}/internal/sync/SyncAPI.kt (61%) rename {matrix-sdk-core/src/main/java/im/vector/matrix/core => matrix-sdk-android/src/main/java/im/vector/matrix/android}/internal/sync/data/DeviceInfo.kt (96%) rename {matrix-sdk-core/src/main/java/im/vector/matrix/core => matrix-sdk-android/src/main/java/im/vector/matrix/android}/internal/sync/data/DeviceListResponse.kt (94%) rename {matrix-sdk-core/src/main/java/im/vector/matrix/core => matrix-sdk-android/src/main/java/im/vector/matrix/android}/internal/sync/data/DeviceOneTimeKeysCountSyncResponse.kt (76%) rename {matrix-sdk-core/src/main/java/im/vector/matrix/core => matrix-sdk-android/src/main/java/im/vector/matrix/android}/internal/sync/data/DevicesListResponse.kt (93%) rename {matrix-sdk-core/src/main/java/im/vector/matrix/core => matrix-sdk-android/src/main/java/im/vector/matrix/android}/internal/sync/data/InvitedRoomSync.kt (96%) rename {matrix-sdk-core/src/main/java/im/vector/matrix/core => matrix-sdk-android/src/main/java/im/vector/matrix/android}/internal/sync/data/PresenceSyncResponse.kt (77%) rename {matrix-sdk-core/src/main/java/im/vector/matrix/core => matrix-sdk-android/src/main/java/im/vector/matrix/android}/internal/sync/data/RoomInviteState.kt (89%) rename {matrix-sdk-core/src/main/java/im/vector/matrix/core => matrix-sdk-android/src/main/java/im/vector/matrix/android}/internal/sync/data/RoomResponse.kt (92%) rename {matrix-sdk-core/src/main/java/im/vector/matrix/core => matrix-sdk-android/src/main/java/im/vector/matrix/android}/internal/sync/data/RoomSync.kt (96%) rename {matrix-sdk-core/src/main/java/im/vector/matrix/core => matrix-sdk-android/src/main/java/im/vector/matrix/android}/internal/sync/data/RoomSyncAccountData.kt (69%) rename {matrix-sdk-core/src/main/java/im/vector/matrix/core => matrix-sdk-android/src/main/java/im/vector/matrix/android}/internal/sync/data/RoomSyncEphemeral.kt (78%) rename {matrix-sdk-core/src/main/java/im/vector/matrix/core => matrix-sdk-android/src/main/java/im/vector/matrix/android}/internal/sync/data/RoomSyncState.kt (90%) rename {matrix-sdk-core/src/main/java/im/vector/matrix/core => matrix-sdk-android/src/main/java/im/vector/matrix/android}/internal/sync/data/RoomSyncTimeline.kt (86%) rename {matrix-sdk-core/src/main/java/im/vector/matrix/core => matrix-sdk-android/src/main/java/im/vector/matrix/android}/internal/sync/data/RoomSyncUnreadNotifications.kt (85%) rename {matrix-sdk-core/src/main/java/im/vector/matrix/core => matrix-sdk-android/src/main/java/im/vector/matrix/android}/internal/sync/data/RoomsSyncResponse.kt (95%) rename {matrix-sdk-core/src/main/java/im/vector/matrix/core => matrix-sdk-android/src/main/java/im/vector/matrix/android}/internal/sync/data/SyncResponse.kt (95%) rename {matrix-sdk-core/src/main/java/im/vector/matrix/core => matrix-sdk-android/src/main/java/im/vector/matrix/android}/internal/sync/data/ToDeviceSyncResponse.kt (74%) rename {matrix-sdk-core/src/main/java/im/vector/matrix/core => matrix-sdk-android/src/main/java/im/vector/matrix/android}/internal/sync/data/TokensChunkResponse.kt (80%) rename {matrix-sdk-core/src/main/java/im/vector/matrix/core => matrix-sdk-android/src/main/java/im/vector/matrix/android}/internal/util/CancelableCoroutine.kt (60%) rename {matrix-sdk-core/src/main/java/im/vector/matrix/core => matrix-sdk-android/src/main/java/im/vector/matrix/android}/internal/util/Either.kt (96%) delete mode 100644 matrix-sdk-core/.gitignore delete mode 100644 matrix-sdk-core/build.gradle delete mode 100644 matrix-sdk-core/src/main/java/im/vector/matrix/core/api/MatrixOptions.kt delete mode 100644 matrix-sdk-core/src/main/java/im/vector/matrix/core/api/Session.kt delete mode 100644 matrix-sdk-core/src/main/java/im/vector/matrix/core/api/login/Authenticator.kt delete mode 100644 matrix-sdk-core/src/main/java/im/vector/matrix/core/api/login/CredentialsStore.kt delete mode 100644 matrix-sdk-core/src/main/java/im/vector/matrix/core/api/storage/MxQuery.kt delete mode 100644 matrix-sdk-core/src/main/java/im/vector/matrix/core/api/storage/MxQueryBuilder.kt delete mode 100644 matrix-sdk-core/src/main/java/im/vector/matrix/core/api/storage/MxQueryDataObserver.java delete mode 100644 matrix-sdk-core/src/main/java/im/vector/matrix/core/api/storage/MxStore.kt delete mode 100644 matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/MatrixModule.kt delete mode 100644 matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/login/data/LoginParams.kt delete mode 100644 matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/login/db/InMemoryCredentialsStore.kt diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser index 8636578c627edd805daeb39eb90902b38b1e7553..63418f70773bac9b1139369b3e070d073d5100e0 100644 GIT binary patch delta 79 zcmV-V0I>hW1&alcm;^sKp{$XdOaTay=_wGo%CwNX){6g%n(A7GPfyyDA_1om4U5<3 lB3Jh*IVU#!t6~Wnli2~G5p24@;*lZ;dIk4T$*y5(J$R^iBtHNE delta 136 zcmV;30C)e31;hoAm;^eR4DOMfOaTdz=_wEy3Doc;{Y=FMuJUMgo;==@A_1omkV*L1 z!jgh&dSFX|Oh73Qli2~GN&xs6)K>&7W6f>*u);VnK6C&aZDDkBX?QJjWNR&BZ*pZX qVs&Y3WG-iNVPtG&b#VZG00sa601#nuPAJF8k7o#zX#$ER2|#!zIW-di diff --git a/.idea/gradle.xml b/.idea/gradle.xml index 043ba65437..35d2fcd030 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -10,7 +10,6 @@ diff --git a/app/build.gradle b/app/build.gradle index 0e4eafaa06..bf121577e4 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -22,16 +22,17 @@ android { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation project(":matrix-sdk-core") + implementation project(":matrix-sdk-android") implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation 'com.android.support:appcompat-v7:28.0.0' implementation 'com.android.support.constraint:constraint-layout:1.1.3' - implementation "org.koin:koin-core:$koin_version" - implementation "org.koin:koin-core-ext:$koin_version" + + implementation "org.koin:koin-android:$koin_version" + implementation "org.koin:koin-android-scope:$koin_version" + implementation "org.koin:koin-android-viewmodel:$koin_version" testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' - compile project(path: ':matrix-sdk-android') } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 54863ea504..584955dc7d 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -6,6 +6,7 @@ () + private val homeServerConnectionConfig = HomeServerConnectionConfig("https://matrix.org/") private val session = matrix.createSession(homeServerConnectionConfig) private val authenticator = session.authenticator() diff --git a/matrix-sdk-android/build.gradle b/matrix-sdk-android/build.gradle index 21e9640a47..e0a9b48293 100644 --- a/matrix-sdk-android/build.gradle +++ b/matrix-sdk-android/build.gradle @@ -1,5 +1,24 @@ apply plugin: 'com.android.library' apply plugin: 'kotlin-android' +apply plugin: 'kotlin-kapt' +apply plugin: 'io.objectbox' + +ext.support_version = '28.0.0' + +buildscript { + + repositories { + jcenter() + } + dependencies { + classpath "io.objectbox:objectbox-gradle-plugin:2.2.0" + } +} + +repositories { + google() + jcenter() +} android { compileSdkVersion 28 @@ -24,10 +43,28 @@ android { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - - implementation 'com.android.support:appcompat-v7:28.0.0' implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation "com.android.support:appcompat-v7:$support_version" + implementation "com.android.support:recyclerview-v7:$support_version" + + // Network + implementation 'com.squareup.retrofit2:retrofit:2.4.0' + implementation 'com.squareup.retrofit2:converter-moshi:2.4.0' + implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' + implementation 'com.squareup.okhttp3:okhttp:3.10.0' + implementation 'com.squareup.okhttp3:logging-interceptor:3.10.0' + implementation 'com.squareup.okio:okio:1.15.0' + implementation 'com.squareup.moshi:moshi-kotlin:1.7.0' + kapt 'com.squareup.moshi:moshi-kotlin-codegen:1.7.0' + + // Paging + implementation "android.arch.paging:runtime:1.0.1" + + // DI + implementation "org.koin:koin-core:$koin_version" + implementation "org.koin:koin-core-ext:$koin_version" + testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' diff --git a/matrix-sdk-android/objectbox-models/default.json b/matrix-sdk-android/objectbox-models/default.json new file mode 100644 index 0000000000..3717f95e0e --- /dev/null +++ b/matrix-sdk-android/objectbox-models/default.json @@ -0,0 +1,50 @@ +{ + "_note1": "KEEP THIS FILE! Check it into a version control system (VCS) like git.", + "_note2": "ObjectBox manages crucial IDs for your object model. See docs for details.", + "_note3": "If you have VCS merge conflicts, you must resolve them according to ObjectBox docs.", + "entities": [ + { + "id": "1:637433444018824383", + "lastPropertyId": "6:2515822585258942903", + "name": "Credentials", + "properties": [ + { + "id": "1:6211403495341530846", + "name": "id" + }, + { + "id": "2:1774175862476960436", + "name": "userId" + }, + { + "id": "3:5757014528669120452", + "name": "homeServer" + }, + { + "id": "4:6085081322264805865", + "name": "accessToken" + }, + { + "id": "5:5476767963007280768", + "name": "refreshToken" + }, + { + "id": "6:2515822585258942903", + "name": "deviceId" + } + ], + "relations": [] + } + ], + "lastEntityId": "1:637433444018824383", + "lastIndexId": "0:0", + "lastRelationId": "0:0", + "lastSequenceId": "0:0", + "modelVersion": 4, + "modelVersionParserMinimum": 4, + "retiredEntityUids": [], + "retiredIndexUids": [], + "retiredPropertyUids": [], + "retiredRelationUids": [], + "version": 1 +} \ No newline at end of file diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/api/Matrix.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/Matrix.kt similarity index 61% rename from matrix-sdk-core/src/main/java/im/vector/matrix/core/api/Matrix.kt rename to matrix-sdk-android/src/main/java/im/vector/matrix/android/api/Matrix.kt index 9764addc7b..f8410be8ad 100644 --- a/matrix-sdk-core/src/main/java/im/vector/matrix/core/api/Matrix.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/Matrix.kt @@ -1,9 +1,9 @@ -package im.vector.matrix.core.api +package im.vector.matrix.android.api -import im.vector.matrix.core.api.login.data.HomeServerConnectionConfig -import im.vector.matrix.core.internal.DefaultSession -import im.vector.matrix.core.internal.MatrixModule -import im.vector.matrix.core.internal.network.NetworkModule +import im.vector.matrix.android.api.login.data.HomeServerConnectionConfig +import im.vector.matrix.android.internal.DefaultSession +import im.vector.matrix.android.internal.di.MatrixModule +import im.vector.matrix.android.internal.di.NetworkModule import org.koin.standalone.StandAloneContext.loadKoinModules class Matrix(matrixOptions: MatrixOptions) { diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/api/MatrixCallback.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/MatrixCallback.kt similarity index 53% rename from matrix-sdk-core/src/main/java/im/vector/matrix/core/api/MatrixCallback.kt rename to matrix-sdk-android/src/main/java/im/vector/matrix/android/api/MatrixCallback.kt index 1a9fffc179..a94446bc67 100644 --- a/matrix-sdk-core/src/main/java/im/vector/matrix/core/api/MatrixCallback.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/MatrixCallback.kt @@ -1,6 +1,6 @@ -package im.vector.matrix.core.api +package im.vector.matrix.android.api -import im.vector.matrix.core.api.failure.Failure +import im.vector.matrix.android.api.failure.Failure interface MatrixCallback { diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/MatrixOptions.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/MatrixOptions.kt new file mode 100644 index 0000000000..d6d7849392 --- /dev/null +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/MatrixOptions.kt @@ -0,0 +1,8 @@ +package im.vector.matrix.android.api + +import android.content.Context +import im.vector.matrix.android.api.thread.MainThreadExecutor +import java.util.concurrent.Executor + +data class MatrixOptions(val context: Context, + val mainExecutor: Executor = MainThreadExecutor()) \ No newline at end of file diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/Session.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/Session.kt new file mode 100644 index 0000000000..f47e37700b --- /dev/null +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/Session.kt @@ -0,0 +1,11 @@ +package im.vector.matrix.android.api + +import im.vector.matrix.android.api.login.Authenticator + +interface Session { + + fun authenticator(): Authenticator + + fun close() + +} \ No newline at end of file diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/api/events/Event.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/events/Event.kt similarity index 64% rename from matrix-sdk-core/src/main/java/im/vector/matrix/core/api/events/Event.kt rename to matrix-sdk-android/src/main/java/im/vector/matrix/android/api/events/Event.kt index 26316635e3..f26ae839b8 100644 --- a/matrix-sdk-core/src/main/java/im/vector/matrix/core/api/events/Event.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/events/Event.kt @@ -1,4 +1,4 @@ -package im.vector.matrix.core.api.events +package im.vector.matrix.android.api.events data class Event(val sender: String, val eventType: EventType) diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/api/events/EventType.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/events/EventType.kt similarity index 97% rename from matrix-sdk-core/src/main/java/im/vector/matrix/core/api/events/EventType.kt rename to matrix-sdk-android/src/main/java/im/vector/matrix/android/api/events/EventType.kt index 3e5532732e..55d8f44650 100644 --- a/matrix-sdk-core/src/main/java/im/vector/matrix/core/api/events/EventType.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/events/EventType.kt @@ -1,4 +1,4 @@ -package im.vector.matrix.core.api.events +package im.vector.matrix.android.api.events sealed class EventType(val str: String) { diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/api/failure/Failure.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/failure/Failure.kt similarity index 84% rename from matrix-sdk-core/src/main/java/im/vector/matrix/core/api/failure/Failure.kt rename to matrix-sdk-android/src/main/java/im/vector/matrix/android/api/failure/Failure.kt index dd44215495..4a6a39b883 100644 --- a/matrix-sdk-core/src/main/java/im/vector/matrix/core/api/failure/Failure.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/failure/Failure.kt @@ -1,4 +1,4 @@ -package im.vector.matrix.core.api.failure +package im.vector.matrix.android.api.failure sealed class Failure { diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/api/failure/MatrixError.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/failure/MatrixError.kt similarity index 96% rename from matrix-sdk-core/src/main/java/im/vector/matrix/core/api/failure/MatrixError.kt rename to matrix-sdk-android/src/main/java/im/vector/matrix/android/api/failure/MatrixError.kt index d8cfa15571..ab1024ca1e 100644 --- a/matrix-sdk-core/src/main/java/im/vector/matrix/core/api/failure/MatrixError.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/failure/MatrixError.kt @@ -1,4 +1,4 @@ -package im.vector.matrix.core.api.failure +package im.vector.matrix.android.api.failure import com.squareup.moshi.Json diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/login/Authenticator.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/login/Authenticator.kt new file mode 100644 index 0000000000..6d28f162c9 --- /dev/null +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/login/Authenticator.kt @@ -0,0 +1,11 @@ +package im.vector.matrix.android.api.login + +import im.vector.matrix.android.api.MatrixCallback +import im.vector.matrix.android.api.util.Cancelable +import im.vector.matrix.android.api.login.data.Credentials + +interface Authenticator { + + fun authenticate(login: String, password: String, callback: MatrixCallback): Cancelable + +} \ No newline at end of file diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/login/CredentialsStore.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/login/CredentialsStore.kt new file mode 100644 index 0000000000..cae096949b --- /dev/null +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/login/CredentialsStore.kt @@ -0,0 +1,11 @@ +package im.vector.matrix.android.api.login + +import im.vector.matrix.android.api.login.data.Credentials + +interface CredentialsStore { + + fun get(): Credentials? + + fun save(credentials: Credentials) + +} \ No newline at end of file diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/api/login/data/Credentials.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/login/data/Credentials.kt similarity index 63% rename from matrix-sdk-core/src/main/java/im/vector/matrix/core/api/login/data/Credentials.kt rename to matrix-sdk-android/src/main/java/im/vector/matrix/android/api/login/data/Credentials.kt index 1dbeaf986e..3b8e83c927 100644 --- a/matrix-sdk-core/src/main/java/im/vector/matrix/core/api/login/data/Credentials.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/login/data/Credentials.kt @@ -1,10 +1,14 @@ -package im.vector.matrix.core.api.login.data +package im.vector.matrix.android.api.login.data import com.squareup.moshi.Json import com.squareup.moshi.JsonClass +import io.objectbox.annotation.Entity +import io.objectbox.annotation.Id +@Entity @JsonClass(generateAdapter = true) -data class Credentials(@Json(name = "user_id") val userId: String, +data class Credentials(@Id var id: Long = 0, + @Json(name = "user_id") val userId: String, @Json(name = "home_server") val homeServer: String, @Json(name = "access_token") val accessToken: String, @Json(name = "refresh_token") val refreshToken: String?, diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/api/login/data/HomeServerConnectionConfig.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/login/data/HomeServerConnectionConfig.kt similarity index 77% rename from matrix-sdk-core/src/main/java/im/vector/matrix/core/api/login/data/HomeServerConnectionConfig.kt rename to matrix-sdk-android/src/main/java/im/vector/matrix/android/api/login/data/HomeServerConnectionConfig.kt index f5bb843a48..8d8955b628 100644 --- a/matrix-sdk-core/src/main/java/im/vector/matrix/core/api/login/data/HomeServerConnectionConfig.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/login/data/HomeServerConnectionConfig.kt @@ -1,4 +1,4 @@ -package im.vector.matrix.core.api.login.data +package im.vector.matrix.android.api.login.data import com.squareup.moshi.JsonClass diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/persitence/Persister.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/persitence/Persister.kt new file mode 100644 index 0000000000..87dc2a60c6 --- /dev/null +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/persitence/Persister.kt @@ -0,0 +1,15 @@ +package im.vector.matrix.android.api.persitence + +import android.arch.paging.PagedList + +interface Persister { + + fun put(data: DATA) + + fun remove(data: DATA) + + fun get(id: KEY): DATA? + + fun getAll(): PagedList + +} \ No newline at end of file diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/persitence/Query.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/persitence/Query.kt new file mode 100644 index 0000000000..5275c18573 --- /dev/null +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/persitence/Query.kt @@ -0,0 +1,11 @@ +package im.vector.matrix.android.api.persitence + +import im.vector.matrix.android.api.util.Cancelable + +interface Query { + + fun find(): DATA + + fun subscribe(observer: QueryDataObserver): Cancelable + +} \ No newline at end of file diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/persitence/QueryBuilder.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/persitence/QueryBuilder.kt new file mode 100644 index 0000000000..c26639783e --- /dev/null +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/persitence/QueryBuilder.kt @@ -0,0 +1,7 @@ +package im.vector.matrix.android.api.persitence + +interface QueryBuilder> { + + fun build(): QUERY + +} \ No newline at end of file diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/persitence/QueryDataObserver.java b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/persitence/QueryDataObserver.java new file mode 100644 index 0000000000..fda584e060 --- /dev/null +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/persitence/QueryDataObserver.java @@ -0,0 +1,5 @@ +package im.vector.matrix.android.api.persitence; + +public interface QueryDataObserver { + void onData(DATA data); +} \ No newline at end of file diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/thread/MainThreadExecutor.java b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/thread/MainThreadExecutor.java similarity index 87% rename from matrix-sdk-android/src/main/java/im/vector/matrix/android/thread/MainThreadExecutor.java rename to matrix-sdk-android/src/main/java/im/vector/matrix/android/api/thread/MainThreadExecutor.java index 6654a7453b..a624e3bb6e 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/thread/MainThreadExecutor.java +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/thread/MainThreadExecutor.java @@ -1,4 +1,4 @@ -package im.vector.matrix.android.thread; +package im.vector.matrix.android.api.thread; import android.os.Handler; import android.os.Looper; diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/api/util/Cancelable.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/util/Cancelable.kt similarity index 50% rename from matrix-sdk-core/src/main/java/im/vector/matrix/core/api/util/Cancelable.kt rename to matrix-sdk-android/src/main/java/im/vector/matrix/android/api/util/Cancelable.kt index 7d69ae0b1f..e8092d7271 100644 --- a/matrix-sdk-core/src/main/java/im/vector/matrix/core/api/util/Cancelable.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/util/Cancelable.kt @@ -1,4 +1,4 @@ -package im.vector.matrix.core.api.util +package im.vector.matrix.android.api.util interface Cancelable { fun cancel() diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/api/util/Logger.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/util/Logger.kt similarity index 97% rename from matrix-sdk-core/src/main/java/im/vector/matrix/core/api/util/Logger.kt rename to matrix-sdk-android/src/main/java/im/vector/matrix/android/api/util/Logger.kt index 4cb98955e4..2c78e9f502 100644 --- a/matrix-sdk-core/src/main/java/im/vector/matrix/core/api/util/Logger.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/util/Logger.kt @@ -1,4 +1,4 @@ -package im.vector.matrix.core.api.util +package im.vector.matrix.android.api.util interface Logger { /** Log a verbose message with optional format args. */ diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/DefaultSession.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/DefaultSession.kt similarity index 74% rename from matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/DefaultSession.kt rename to matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/DefaultSession.kt index 9531e0c731..c909bd610f 100644 --- a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/DefaultSession.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/DefaultSession.kt @@ -1,9 +1,9 @@ -package im.vector.matrix.core.internal +package im.vector.matrix.android.internal -import im.vector.matrix.core.api.Session -import im.vector.matrix.core.api.login.Authenticator -import im.vector.matrix.core.api.login.data.HomeServerConnectionConfig -import im.vector.matrix.core.internal.login.LoginModule +import im.vector.matrix.android.api.Session +import im.vector.matrix.android.api.login.Authenticator +import im.vector.matrix.android.api.login.data.HomeServerConnectionConfig +import im.vector.matrix.android.internal.login.LoginModule import org.koin.core.scope.Scope import org.koin.standalone.KoinComponent import org.koin.standalone.StandAloneContext diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/MatrixCoroutineDispatchers.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/MatrixCoroutineDispatchers.kt similarity index 83% rename from matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/MatrixCoroutineDispatchers.kt rename to matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/MatrixCoroutineDispatchers.kt index 0b213056d3..9663725025 100644 --- a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/MatrixCoroutineDispatchers.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/MatrixCoroutineDispatchers.kt @@ -1,4 +1,4 @@ -package im.vector.matrix.core.internal +package im.vector.matrix.android.internal import kotlinx.coroutines.CoroutineDispatcher diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/di/MatrixModule.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/di/MatrixModule.kt new file mode 100644 index 0000000000..a61253101a --- /dev/null +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/di/MatrixModule.kt @@ -0,0 +1,41 @@ +package im.vector.matrix.android.internal.di + +import im.vector.matrix.android.api.MatrixOptions +import im.vector.matrix.android.api.login.CredentialsStore +import im.vector.matrix.android.api.login.data.Credentials +import im.vector.matrix.android.api.login.data.MyObjectBox +import im.vector.matrix.android.internal.MatrixCoroutineDispatchers +import im.vector.matrix.android.internal.login.db.ObjectBoxCredentialsStore +import io.objectbox.Box +import io.objectbox.BoxStore +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.IO +import kotlinx.coroutines.asCoroutineDispatcher +import org.koin.dsl.context.ModuleDefinition +import org.koin.dsl.module.Module +import org.koin.dsl.module.module + + +class MatrixModule(private val options: MatrixOptions) : Module { + + override fun invoke(): ModuleDefinition = module { + + single { + MatrixCoroutineDispatchers(io = Dispatchers.IO, computation = Dispatchers.IO, main = options.mainExecutor.asCoroutineDispatcher()) + } + + single { + MyObjectBox.builder().androidContext(options.context).build() + } + + single { + val boxStore = get() as BoxStore + boxStore.boxFor(Credentials::class.java) as Box + } + + single { + ObjectBoxCredentialsStore(get()) as CredentialsStore + } + + }.invoke() +} \ No newline at end of file diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/network/NetworkModule.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/di/NetworkModule.kt similarity index 91% rename from matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/network/NetworkModule.kt rename to matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/di/NetworkModule.kt index c16eb794bd..5a7a6a2824 100644 --- a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/network/NetworkModule.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/di/NetworkModule.kt @@ -1,8 +1,9 @@ -package im.vector.matrix.core.internal.network +package im.vector.matrix.android.internal.di import com.jakewharton.retrofit2.adapter.kotlin.coroutines.CoroutineCallAdapterFactory import com.squareup.moshi.Moshi import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory +import im.vector.matrix.android.internal.network.AccessTokenInterceptor import okhttp3.OkHttpClient import okhttp3.logging.HttpLoggingInterceptor import org.koin.dsl.context.ModuleDefinition diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/login/DefaultAuthenticator.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/login/DefaultAuthenticator.kt similarity index 60% rename from matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/login/DefaultAuthenticator.kt rename to matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/login/DefaultAuthenticator.kt index 97d2d03e13..e429c3de50 100644 --- a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/login/DefaultAuthenticator.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/login/DefaultAuthenticator.kt @@ -1,16 +1,16 @@ -package im.vector.matrix.core.internal.login +package im.vector.matrix.android.internal.login import com.squareup.moshi.Moshi -import im.vector.matrix.core.api.MatrixCallback -import im.vector.matrix.core.api.login.Authenticator -import im.vector.matrix.core.api.login.CredentialsStore -import im.vector.matrix.core.api.login.data.Credentials -import im.vector.matrix.core.api.util.Cancelable -import im.vector.matrix.core.internal.MatrixCoroutineDispatchers -import im.vector.matrix.core.internal.util.map -import im.vector.matrix.core.internal.login.data.PasswordLoginParams -import im.vector.matrix.core.internal.network.executeRequest -import im.vector.matrix.core.internal.util.CancelableCoroutine +import im.vector.matrix.android.api.MatrixCallback +import im.vector.matrix.android.api.login.Authenticator +import im.vector.matrix.android.api.login.CredentialsStore +import im.vector.matrix.android.api.login.data.Credentials +import im.vector.matrix.android.api.util.Cancelable +import im.vector.matrix.android.internal.MatrixCoroutineDispatchers +import im.vector.matrix.android.internal.util.map +import im.vector.matrix.android.internal.login.data.PasswordLoginParams +import im.vector.matrix.android.internal.network.executeRequest +import im.vector.matrix.android.internal.util.CancelableCoroutine import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch @@ -27,7 +27,7 @@ class DefaultAuthenticator(private val loginApi: LoginApi, moshi = jsonMapper dispatcher = coroutineDispatchers.io }.map { - it?.apply { credentialsStore.put(it) } + it?.apply { credentialsStore.save(it) } } loginResult.either({ callback.onFailure(it) }, { callback.onSuccess(it) }) } diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/login/LoginApi.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/login/LoginApi.kt similarity index 64% rename from matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/login/LoginApi.kt rename to matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/login/LoginApi.kt index fe108837fc..f618be5584 100644 --- a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/login/LoginApi.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/login/LoginApi.kt @@ -1,8 +1,8 @@ -package im.vector.matrix.core.internal.login +package im.vector.matrix.android.internal.login -import im.vector.matrix.core.api.login.data.Credentials -import im.vector.matrix.core.internal.login.data.PasswordLoginParams -import im.vector.matrix.core.internal.network.NetworkConstants +import im.vector.matrix.android.api.login.data.Credentials +import im.vector.matrix.android.internal.login.data.PasswordLoginParams +import im.vector.matrix.android.internal.network.NetworkConstants import kotlinx.coroutines.Deferred import retrofit2.Response import retrofit2.http.Body diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/login/LoginModule.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/login/LoginModule.kt similarity index 78% rename from matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/login/LoginModule.kt rename to matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/login/LoginModule.kt index 2a6d287bed..3589b849b1 100644 --- a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/login/LoginModule.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/login/LoginModule.kt @@ -1,8 +1,8 @@ -package im.vector.matrix.core.internal.login +package im.vector.matrix.android.internal.login -import im.vector.matrix.core.api.login.Authenticator -import im.vector.matrix.core.api.login.data.HomeServerConnectionConfig -import im.vector.matrix.core.internal.DefaultSession +import im.vector.matrix.android.api.login.Authenticator +import im.vector.matrix.android.api.login.data.HomeServerConnectionConfig +import im.vector.matrix.android.internal.DefaultSession import org.koin.dsl.context.ModuleDefinition import org.koin.dsl.module.Module import org.koin.dsl.module.module diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/login/data/LoginFlow.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/login/data/LoginFlow.kt similarity index 74% rename from matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/login/data/LoginFlow.kt rename to matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/login/data/LoginFlow.kt index 2d18ccb97b..46915c435a 100644 --- a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/login/data/LoginFlow.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/login/data/LoginFlow.kt @@ -1,4 +1,4 @@ -package im.vector.matrix.core.internal.login.data +package im.vector.matrix.android.internal.login.data import com.squareup.moshi.JsonClass diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/login/data/LoginFlowResponse.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/login/data/LoginFlowResponse.kt similarity index 70% rename from matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/login/data/LoginFlowResponse.kt rename to matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/login/data/LoginFlowResponse.kt index 3297dc5db0..341c6a32e9 100644 --- a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/login/data/LoginFlowResponse.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/login/data/LoginFlowResponse.kt @@ -1,4 +1,4 @@ -package im.vector.matrix.core.internal.login.data +package im.vector.matrix.android.internal.login.data import com.squareup.moshi.JsonClass diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/login/data/LoginFlowTypes.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/login/data/LoginFlowTypes.kt similarity index 87% rename from matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/login/data/LoginFlowTypes.kt rename to matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/login/data/LoginFlowTypes.kt index 782aeebe58..b7c23dd650 100644 --- a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/login/data/LoginFlowTypes.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/login/data/LoginFlowTypes.kt @@ -1,4 +1,4 @@ -package im.vector.matrix.core.internal.login.data +package im.vector.matrix.android.internal.login.data object LoginFlowTypes { const val PASSWORD = "m.login.password" diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/login/data/LoginParams.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/login/data/LoginParams.kt new file mode 100644 index 0000000000..35a1e8a089 --- /dev/null +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/login/data/LoginParams.kt @@ -0,0 +1,5 @@ +package im.vector.matrix.android.internal.login.data + +interface LoginParams { + val type: String +} \ No newline at end of file diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/login/data/PasswordLoginParams.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/login/data/PasswordLoginParams.kt similarity index 97% rename from matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/login/data/PasswordLoginParams.kt rename to matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/login/data/PasswordLoginParams.kt index 74be74d054..be896976fc 100644 --- a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/login/data/PasswordLoginParams.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/login/data/PasswordLoginParams.kt @@ -1,4 +1,4 @@ -package im.vector.matrix.core.internal.login.data +package im.vector.matrix.android.internal.login.data import com.squareup.moshi.Json import com.squareup.moshi.JsonClass diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/login/db/InMemoryCredentialsStore.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/login/db/InMemoryCredentialsStore.kt new file mode 100644 index 0000000000..7610344014 --- /dev/null +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/login/db/InMemoryCredentialsStore.kt @@ -0,0 +1,18 @@ +package im.vector.matrix.android.internal.login.db + +import im.vector.matrix.android.api.login.CredentialsStore +import im.vector.matrix.android.api.login.data.Credentials + +class InMemoryCredentialsStore : CredentialsStore { + + var credentials: Credentials? = null + + override fun get(): Credentials? { + return credentials + } + + override fun save(credentials: Credentials) { + this.credentials = credentials.copy() + } + +} \ No newline at end of file diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/login/db/ObjectBoxCredentialsStore.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/login/db/ObjectBoxCredentialsStore.kt new file mode 100644 index 0000000000..d6468c2624 --- /dev/null +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/login/db/ObjectBoxCredentialsStore.kt @@ -0,0 +1,17 @@ +package im.vector.matrix.android.internal.login.db + +import im.vector.matrix.android.api.login.CredentialsStore +import im.vector.matrix.android.api.login.data.Credentials +import io.objectbox.Box + +class ObjectBoxCredentialsStore(private val box: Box) : CredentialsStore { + + override fun save(credentials: Credentials) { + box.put(credentials) + } + + override fun get(): Credentials? { + return box.all.firstOrNull() + } + +} \ No newline at end of file diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/network/AccessTokenInterceptor.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/network/AccessTokenInterceptor.kt similarity index 77% rename from matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/network/AccessTokenInterceptor.kt rename to matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/network/AccessTokenInterceptor.kt index c82aeaef6b..cb961644ea 100644 --- a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/network/AccessTokenInterceptor.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/network/AccessTokenInterceptor.kt @@ -1,6 +1,6 @@ -package im.vector.matrix.core.internal.network +package im.vector.matrix.android.internal.network -import im.vector.matrix.core.api.login.CredentialsStore +import im.vector.matrix.android.api.login.CredentialsStore import okhttp3.Interceptor import okhttp3.Response @@ -10,7 +10,7 @@ class AccessTokenInterceptor(private val credentialsStore: CredentialsStore) : I var request = chain.request() val newRequestBuilder = request.newBuilder() // Add the access token to all requests if it is set - val credentials = credentialsStore.getAll().firstOrNull() + val credentials = credentialsStore.get() credentials?.let { newRequestBuilder.addHeader("Authorization", "Bearer " + it.accessToken) } diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/network/NetworkConstants.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/network/NetworkConstants.kt similarity index 74% rename from matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/network/NetworkConstants.kt rename to matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/network/NetworkConstants.kt index c872c7af9c..fe08d55f43 100644 --- a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/network/NetworkConstants.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/network/NetworkConstants.kt @@ -1,4 +1,4 @@ -package im.vector.matrix.core.internal.network +package im.vector.matrix.android.internal.network object NetworkConstants { diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/network/Request.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/network/Request.kt similarity index 88% rename from matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/network/Request.kt rename to matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/network/Request.kt index f2aa9aa058..5db65d8b3e 100644 --- a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/network/Request.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/network/Request.kt @@ -1,9 +1,9 @@ -package im.vector.matrix.core.internal.network +package im.vector.matrix.android.internal.network import com.squareup.moshi.Moshi -import im.vector.matrix.core.api.failure.Failure -import im.vector.matrix.core.api.failure.MatrixError -import im.vector.matrix.core.internal.util.Either +import im.vector.matrix.android.api.failure.Failure +import im.vector.matrix.android.api.failure.MatrixError +import im.vector.matrix.android.internal.util.Either import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.Deferred import kotlinx.coroutines.withContext diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/SyncAPI.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/sync/SyncAPI.kt similarity index 61% rename from matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/SyncAPI.kt rename to matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/sync/SyncAPI.kt index d96de314d1..dcb1c4049e 100644 --- a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/SyncAPI.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/sync/SyncAPI.kt @@ -1,7 +1,7 @@ -package im.vector.matrix.core.internal.sync +package im.vector.matrix.android.internal.sync -import im.vector.matrix.core.internal.network.NetworkConstants -import im.vector.matrix.core.internal.sync.data.SyncResponse +import im.vector.matrix.android.internal.network.NetworkConstants +import im.vector.matrix.android.internal.sync.data.SyncResponse import kotlinx.coroutines.Deferred import retrofit2.Response import retrofit2.http.GET diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/DeviceInfo.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/sync/data/DeviceInfo.kt similarity index 96% rename from matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/DeviceInfo.kt rename to matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/sync/data/DeviceInfo.kt index 257fc4e2b7..2a3742df20 100644 --- a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/DeviceInfo.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/sync/data/DeviceInfo.kt @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package im.vector.matrix.core.internal.sync.data +package im.vector.matrix.android.internal.sync.data import com.squareup.moshi.JsonClass diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/DeviceListResponse.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/sync/data/DeviceListResponse.kt similarity index 94% rename from matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/DeviceListResponse.kt rename to matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/sync/data/DeviceListResponse.kt index 6e78932259..b5e65035f6 100644 --- a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/DeviceListResponse.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/sync/data/DeviceListResponse.kt @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package im.vector.matrix.core.internal.sync.data +package im.vector.matrix.android.internal.sync.data import com.squareup.moshi.JsonClass diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/DeviceOneTimeKeysCountSyncResponse.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/sync/data/DeviceOneTimeKeysCountSyncResponse.kt similarity index 76% rename from matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/DeviceOneTimeKeysCountSyncResponse.kt rename to matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/sync/data/DeviceOneTimeKeysCountSyncResponse.kt index 31a8183468..54e21736ca 100644 --- a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/DeviceOneTimeKeysCountSyncResponse.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/sync/data/DeviceOneTimeKeysCountSyncResponse.kt @@ -1,4 +1,4 @@ -package im.vector.matrix.core.internal.sync.data +package im.vector.matrix.android.internal.sync.data import com.squareup.moshi.JsonClass diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/DevicesListResponse.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/sync/data/DevicesListResponse.kt similarity index 93% rename from matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/DevicesListResponse.kt rename to matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/sync/data/DevicesListResponse.kt index a1276d7f85..fba71794d3 100644 --- a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/DevicesListResponse.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/sync/data/DevicesListResponse.kt @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package im.vector.matrix.core.internal.sync.data +package im.vector.matrix.android.internal.sync.data import com.squareup.moshi.JsonClass diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/InvitedRoomSync.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/sync/data/InvitedRoomSync.kt similarity index 96% rename from matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/InvitedRoomSync.kt rename to matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/sync/data/InvitedRoomSync.kt index 83d66fb394..ea126737f9 100644 --- a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/InvitedRoomSync.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/sync/data/InvitedRoomSync.kt @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package im.vector.matrix.core.internal.sync.data +package im.vector.matrix.android.internal.sync.data import com.squareup.moshi.JsonClass diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/PresenceSyncResponse.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/sync/data/PresenceSyncResponse.kt similarity index 77% rename from matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/PresenceSyncResponse.kt rename to matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/sync/data/PresenceSyncResponse.kt index 2785ca0bf9..a43e7241f9 100644 --- a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/PresenceSyncResponse.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/sync/data/PresenceSyncResponse.kt @@ -1,7 +1,7 @@ -package im.vector.matrix.core.internal.sync.data +package im.vector.matrix.android.internal.sync.data import com.squareup.moshi.JsonClass -import im.vector.matrix.core.api.events.Event +import im.vector.matrix.android.api.events.Event // PresenceSyncResponse represents the updates to the presence status of other users during server sync v2. @JsonClass(generateAdapter = true) diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/RoomInviteState.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/sync/data/RoomInviteState.kt similarity index 89% rename from matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/RoomInviteState.kt rename to matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/sync/data/RoomInviteState.kt index c3e8755415..f79daf4386 100644 --- a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/RoomInviteState.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/sync/data/RoomInviteState.kt @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package im.vector.matrix.core.internal.sync.data +package im.vector.matrix.android.internal.sync.data import com.squareup.moshi.JsonClass -import im.vector.matrix.core.api.events.Event +import im.vector.matrix.android.api.events.Event // RoomInviteState represents the state of a room that the user has been invited to. @JsonClass(generateAdapter = true) diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/RoomResponse.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/sync/data/RoomResponse.kt similarity index 92% rename from matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/RoomResponse.kt rename to matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/sync/data/RoomResponse.kt index d3844f5640..5bd6cffef5 100644 --- a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/RoomResponse.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/sync/data/RoomResponse.kt @@ -1,8 +1,8 @@ -package im.vector.matrix.core.internal.sync.data +package im.vector.matrix.android.internal.sync.data import com.squareup.moshi.JsonClass -import im.vector.matrix.core.api.events.Event +import im.vector.matrix.android.api.events.Event /** * Class representing a room from a JSON response from room or global initial sync. diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/RoomSync.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/sync/data/RoomSync.kt similarity index 96% rename from matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/RoomSync.kt rename to matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/sync/data/RoomSync.kt index e713b48b4b..694f1a7ea3 100644 --- a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/RoomSync.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/sync/data/RoomSync.kt @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package im.vector.matrix.core.internal.sync.data +package im.vector.matrix.android.internal.sync.data import com.squareup.moshi.JsonClass diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/RoomSyncAccountData.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/sync/data/RoomSyncAccountData.kt similarity index 69% rename from matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/RoomSyncAccountData.kt rename to matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/sync/data/RoomSyncAccountData.kt index de998ec47c..d520211e81 100644 --- a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/RoomSyncAccountData.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/sync/data/RoomSyncAccountData.kt @@ -1,7 +1,7 @@ -package im.vector.matrix.core.internal.sync.data +package im.vector.matrix.android.internal.sync.data import com.squareup.moshi.JsonClass -import im.vector.matrix.core.api.events.Event +import im.vector.matrix.android.api.events.Event @JsonClass(generateAdapter = true) data class RoomSyncAccountData( diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/RoomSyncEphemeral.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/sync/data/RoomSyncEphemeral.kt similarity index 78% rename from matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/RoomSyncEphemeral.kt rename to matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/sync/data/RoomSyncEphemeral.kt index 84218bd29e..0b7e6bf3d4 100644 --- a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/RoomSyncEphemeral.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/sync/data/RoomSyncEphemeral.kt @@ -1,8 +1,8 @@ -package im.vector.matrix.core.internal.sync.data +package im.vector.matrix.android.internal.sync.data import com.squareup.moshi.JsonClass -import im.vector.matrix.core.api.events.Event +import im.vector.matrix.android.api.events.Event // RoomSyncEphemeral represents the ephemeral events in the room that aren't recorded in the timeline or state of the room (e.g. typing). @JsonClass(generateAdapter = true) diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/RoomSyncState.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/sync/data/RoomSyncState.kt similarity index 90% rename from matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/RoomSyncState.kt rename to matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/sync/data/RoomSyncState.kt index db287b5386..da3f441781 100644 --- a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/RoomSyncState.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/sync/data/RoomSyncState.kt @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package im.vector.matrix.core.internal.sync.data +package im.vector.matrix.android.internal.sync.data import com.squareup.moshi.JsonClass -import im.vector.matrix.core.api.events.Event +import im.vector.matrix.android.api.events.Event // RoomSyncState represents the state updates for a room during server sync v2. @JsonClass(generateAdapter = true) diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/RoomSyncTimeline.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/sync/data/RoomSyncTimeline.kt similarity index 86% rename from matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/RoomSyncTimeline.kt rename to matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/sync/data/RoomSyncTimeline.kt index 993d571514..5354695172 100644 --- a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/RoomSyncTimeline.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/sync/data/RoomSyncTimeline.kt @@ -1,8 +1,8 @@ -package im.vector.matrix.core.internal.sync.data +package im.vector.matrix.android.internal.sync.data import com.squareup.moshi.JsonClass -import im.vector.matrix.core.api.events.Event +import im.vector.matrix.android.api.events.Event // RoomSyncTimeline represents the timeline of messages and state changes for a room during server sync v2. @JsonClass(generateAdapter = true) diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/RoomSyncUnreadNotifications.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/sync/data/RoomSyncUnreadNotifications.kt similarity index 85% rename from matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/RoomSyncUnreadNotifications.kt rename to matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/sync/data/RoomSyncUnreadNotifications.kt index 252ea11807..872a35b693 100644 --- a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/RoomSyncUnreadNotifications.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/sync/data/RoomSyncUnreadNotifications.kt @@ -1,8 +1,8 @@ -package im.vector.matrix.core.internal.sync.data +package im.vector.matrix.android.internal.sync.data import com.squareup.moshi.JsonClass -import im.vector.matrix.core.api.events.Event +import im.vector.matrix.android.api.events.Event /** * `MXRoomSyncUnreadNotifications` represents the unread counts for a room. diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/RoomsSyncResponse.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/sync/data/RoomsSyncResponse.kt similarity index 95% rename from matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/RoomsSyncResponse.kt rename to matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/sync/data/RoomsSyncResponse.kt index fc7d7ea088..a79ea4e2c2 100644 --- a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/RoomsSyncResponse.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/sync/data/RoomsSyncResponse.kt @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package im.vector.matrix.core.internal.sync.data +package im.vector.matrix.android.internal.sync.data import com.squareup.moshi.JsonClass diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/SyncResponse.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/sync/data/SyncResponse.kt similarity index 95% rename from matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/SyncResponse.kt rename to matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/sync/data/SyncResponse.kt index 1fc83b0e50..015e1c8bdb 100644 --- a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/SyncResponse.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/sync/data/SyncResponse.kt @@ -1,4 +1,4 @@ -package im.vector.matrix.core.internal.sync.data +package im.vector.matrix.android.internal.sync.data import com.squareup.moshi.JsonClass diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/ToDeviceSyncResponse.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/sync/data/ToDeviceSyncResponse.kt similarity index 74% rename from matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/ToDeviceSyncResponse.kt rename to matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/sync/data/ToDeviceSyncResponse.kt index c71b4e2ef6..83024b4d9d 100644 --- a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/ToDeviceSyncResponse.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/sync/data/ToDeviceSyncResponse.kt @@ -1,8 +1,8 @@ -package im.vector.matrix.core.internal.sync.data +package im.vector.matrix.android.internal.sync.data import com.squareup.moshi.JsonClass -import im.vector.matrix.core.api.events.Event +import im.vector.matrix.android.api.events.Event // ToDeviceSyncResponse represents the data directly sent to one of user's devices. @JsonClass(generateAdapter = true) diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/TokensChunkResponse.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/sync/data/TokensChunkResponse.kt similarity index 80% rename from matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/TokensChunkResponse.kt rename to matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/sync/data/TokensChunkResponse.kt index e6745de312..aab839da1d 100644 --- a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/TokensChunkResponse.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/sync/data/TokensChunkResponse.kt @@ -1,4 +1,4 @@ -package im.vector.matrix.core.internal.sync.data +package im.vector.matrix.android.internal.sync.data import com.squareup.moshi.JsonClass diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/util/CancelableCoroutine.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/util/CancelableCoroutine.kt similarity index 60% rename from matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/util/CancelableCoroutine.kt rename to matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/util/CancelableCoroutine.kt index c3accb6043..8aa1883375 100644 --- a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/util/CancelableCoroutine.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/util/CancelableCoroutine.kt @@ -1,6 +1,6 @@ -package im.vector.matrix.core.internal.util +package im.vector.matrix.android.internal.util -import im.vector.matrix.core.api.util.Cancelable +import im.vector.matrix.android.api.util.Cancelable import kotlinx.coroutines.Job class CancelableCoroutine(private val job: Job) : Cancelable { diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/util/Either.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/util/Either.kt similarity index 96% rename from matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/util/Either.kt rename to matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/util/Either.kt index b9a2447fd7..56016e4b7e 100644 --- a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/util/Either.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/util/Either.kt @@ -1,4 +1,4 @@ -package im.vector.matrix.core.internal.util +package im.vector.matrix.android.internal.util sealed class Either { /** * Represents the left side of [Either] class which by convention is a "Failure". */ diff --git a/matrix-sdk-core/.gitignore b/matrix-sdk-core/.gitignore deleted file mode 100644 index 796b96d1c4..0000000000 --- a/matrix-sdk-core/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/build diff --git a/matrix-sdk-core/build.gradle b/matrix-sdk-core/build.gradle deleted file mode 100644 index fb9001d141..0000000000 --- a/matrix-sdk-core/build.gradle +++ /dev/null @@ -1,26 +0,0 @@ -apply plugin: 'java-library' -apply plugin: "kotlin" -apply plugin: 'kotlin-kapt' - - -dependencies { - - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - implementation fileTree(dir: 'libs', include: ['*.jar']) - - // Network - implementation 'com.squareup.retrofit2:retrofit:2.4.0' - implementation 'com.squareup.retrofit2:converter-moshi:2.4.0' - implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' - implementation 'com.squareup.okhttp3:okhttp:3.10.0' - implementation 'com.squareup.okhttp3:logging-interceptor:3.10.0' - implementation 'com.squareup.okio:okio:1.15.0' - implementation 'com.squareup.moshi:moshi-kotlin:1.7.0' - kapt 'com.squareup.moshi:moshi-kotlin-codegen:1.7.0' - - // DI - implementation "org.koin:koin-core:$koin_version" - implementation "org.koin:koin-core-ext:$koin_version" - - testImplementation 'junit:junit:4.12' -} diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/api/MatrixOptions.kt b/matrix-sdk-core/src/main/java/im/vector/matrix/core/api/MatrixOptions.kt deleted file mode 100644 index b3fa3c8f78..0000000000 --- a/matrix-sdk-core/src/main/java/im/vector/matrix/core/api/MatrixOptions.kt +++ /dev/null @@ -1,5 +0,0 @@ -package im.vector.matrix.core.api - -import java.util.concurrent.Executor - -data class MatrixOptions(val mainExecutor: Executor) \ No newline at end of file diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/api/Session.kt b/matrix-sdk-core/src/main/java/im/vector/matrix/core/api/Session.kt deleted file mode 100644 index b9e8ffaed5..0000000000 --- a/matrix-sdk-core/src/main/java/im/vector/matrix/core/api/Session.kt +++ /dev/null @@ -1,11 +0,0 @@ -package im.vector.matrix.core.api - -import im.vector.matrix.core.api.login.Authenticator - -interface Session { - - fun authenticator(): Authenticator - - fun close() - -} \ No newline at end of file diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/api/login/Authenticator.kt b/matrix-sdk-core/src/main/java/im/vector/matrix/core/api/login/Authenticator.kt deleted file mode 100644 index 3a4d00984e..0000000000 --- a/matrix-sdk-core/src/main/java/im/vector/matrix/core/api/login/Authenticator.kt +++ /dev/null @@ -1,11 +0,0 @@ -package im.vector.matrix.core.api.login - -import im.vector.matrix.core.api.MatrixCallback -import im.vector.matrix.core.api.util.Cancelable -import im.vector.matrix.core.api.login.data.Credentials - -interface Authenticator { - - fun authenticate(login: String, password: String, callback: MatrixCallback): Cancelable - -} \ No newline at end of file diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/api/login/CredentialsStore.kt b/matrix-sdk-core/src/main/java/im/vector/matrix/core/api/login/CredentialsStore.kt deleted file mode 100644 index 3fc83e330a..0000000000 --- a/matrix-sdk-core/src/main/java/im/vector/matrix/core/api/login/CredentialsStore.kt +++ /dev/null @@ -1,6 +0,0 @@ -package im.vector.matrix.core.api.login - -import im.vector.matrix.core.api.login.data.Credentials -import im.vector.matrix.core.api.storage.MxStore - -interface CredentialsStore : MxStore \ No newline at end of file diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/api/storage/MxQuery.kt b/matrix-sdk-core/src/main/java/im/vector/matrix/core/api/storage/MxQuery.kt deleted file mode 100644 index 7e05b8edec..0000000000 --- a/matrix-sdk-core/src/main/java/im/vector/matrix/core/api/storage/MxQuery.kt +++ /dev/null @@ -1,11 +0,0 @@ -package im.vector.matrix.core.api.storage - -import im.vector.matrix.core.api.util.Cancelable - -interface MxQuery { - - fun find(): DATA? - - fun subscribe(observer: MxQueryDataObserver): Cancelable - -} \ No newline at end of file diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/api/storage/MxQueryBuilder.kt b/matrix-sdk-core/src/main/java/im/vector/matrix/core/api/storage/MxQueryBuilder.kt deleted file mode 100644 index 316bab4cf3..0000000000 --- a/matrix-sdk-core/src/main/java/im/vector/matrix/core/api/storage/MxQueryBuilder.kt +++ /dev/null @@ -1,7 +0,0 @@ -package im.vector.matrix.core.api.storage - -interface MxQueryBuilder> { - - fun build(): QUERY - -} \ No newline at end of file diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/api/storage/MxQueryDataObserver.java b/matrix-sdk-core/src/main/java/im/vector/matrix/core/api/storage/MxQueryDataObserver.java deleted file mode 100644 index ef2dd731ac..0000000000 --- a/matrix-sdk-core/src/main/java/im/vector/matrix/core/api/storage/MxQueryDataObserver.java +++ /dev/null @@ -1,5 +0,0 @@ -package im.vector.matrix.core.api.storage; - -public interface MxQueryDataObserver { - void onData(DATA data); -} \ No newline at end of file diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/api/storage/MxStore.kt b/matrix-sdk-core/src/main/java/im/vector/matrix/core/api/storage/MxStore.kt deleted file mode 100644 index f0463386d2..0000000000 --- a/matrix-sdk-core/src/main/java/im/vector/matrix/core/api/storage/MxStore.kt +++ /dev/null @@ -1,13 +0,0 @@ -package im.vector.matrix.core.api.storage - -interface MxStore { - - fun put(data: DATA) - - fun remove(data: DATA) - - fun get(id: KEY): DATA? - - fun getAll(): List - -} \ No newline at end of file diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/MatrixModule.kt b/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/MatrixModule.kt deleted file mode 100644 index eff9cd1eae..0000000000 --- a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/MatrixModule.kt +++ /dev/null @@ -1,27 +0,0 @@ -package im.vector.matrix.core.internal - -import im.vector.matrix.core.api.MatrixOptions -import im.vector.matrix.core.api.login.CredentialsStore -import im.vector.matrix.core.internal.login.db.InMemoryCredentialsStore -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.IO -import kotlinx.coroutines.asCoroutineDispatcher -import org.koin.dsl.context.ModuleDefinition -import org.koin.dsl.module.Module -import org.koin.dsl.module.module - - -class MatrixModule(private val options: MatrixOptions) : Module { - - override fun invoke(): ModuleDefinition = module { - - single { - MatrixCoroutineDispatchers(io = Dispatchers.IO, computation = Dispatchers.IO, main = options.mainExecutor.asCoroutineDispatcher()) - } - - single { - InMemoryCredentialsStore() as CredentialsStore - } - - }.invoke() -} \ No newline at end of file diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/login/data/LoginParams.kt b/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/login/data/LoginParams.kt deleted file mode 100644 index 87e6536e7c..0000000000 --- a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/login/data/LoginParams.kt +++ /dev/null @@ -1,5 +0,0 @@ -package im.vector.matrix.core.internal.login.data - -interface LoginParams { - val type: String -} \ No newline at end of file diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/login/db/InMemoryCredentialsStore.kt b/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/login/db/InMemoryCredentialsStore.kt deleted file mode 100644 index c49cdfa30e..0000000000 --- a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/login/db/InMemoryCredentialsStore.kt +++ /dev/null @@ -1,26 +0,0 @@ -package im.vector.matrix.core.internal.login.db - -import im.vector.matrix.core.api.login.CredentialsStore -import im.vector.matrix.core.api.login.data.Credentials - -class InMemoryCredentialsStore : CredentialsStore { - - var credentials: Credentials? = null - - override fun put(data: Credentials) = synchronized(this) { - credentials = data.copy() - } - - override fun remove(data: Credentials) = synchronized(this) { - credentials = null - } - - override fun get(id: String): Credentials? = synchronized(this) { - return credentials - } - - override fun getAll(): List = synchronized(this) { - return credentials?.let { listOf(it) } ?: emptyList() - } - -} \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index a9ba70df48..cb22bfd794 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1 @@ -include ':app', ':matrix-sdk-core', ':matrix-sdk-rx', ':matrix-sdk-android' +include ':app', ':matrix-sdk-rx', ':matrix-sdk-android'