Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
elm
Element Android
Commits
9cd69d1e
Commit
9cd69d1e
authored
5 years ago
by
Benoit Marty
Browse files
Options
Download
Plain Diff
Merge branch 'release/0.3.0'
parents
df6080b1
e216cd15
Changes
368
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
235 additions
and
150 deletions
+235
-150
CHANGES.md
CHANGES.md
+32
-1
matrix-sdk-android-rx/build.gradle
matrix-sdk-android-rx/build.gradle
+2
-1
matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/LiveDataObservable.kt
...x/src/main/java/im/vector/matrix/rx/LiveDataObservable.kt
+3
-1
matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/MatrixCallbackCompletable.kt
...ain/java/im/vector/matrix/rx/MatrixCallbackCompletable.kt
+39
-0
matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/MatrixCallbackSingle.kt
...src/main/java/im/vector/matrix/rx/MatrixCallbackSingle.kt
+38
-0
matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/RxRoom.kt
...dk-android-rx/src/main/java/im/vector/matrix/rx/RxRoom.kt
+13
-5
matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/RxSession.kt
...android-rx/src/main/java/im/vector/matrix/rx/RxSession.kt
+30
-5
matrix-sdk-android/build.gradle
matrix-sdk-android/build.gradle
+1
-5
matrix-sdk-android/libs/react-native-webrtc.aar
matrix-sdk-android/libs/react-native-webrtc.aar
+0
-0
matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/LiveDataTestObserver.java
...t/java/im/vector/matrix/android/LiveDataTestObserver.java
+1
-1
matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/session/room/timeline/ChunkEntityTest.kt
...r/matrix/android/session/room/timeline/ChunkEntityTest.kt
+1
-5
matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/session/room/timeline/FakeGetContextOfEventTask.kt
...ndroid/session/room/timeline/FakeGetContextOfEventTask.kt
+1
-2
matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/session/room/timeline/FakePaginationTask.kt
...atrix/android/session/room/timeline/FakePaginationTask.kt
+1
-2
matrix-sdk-android/src/main/java/im/vector/matrix/android/api/MatrixPatterns.kt
.../main/java/im/vector/matrix/android/api/MatrixPatterns.kt
+23
-4
matrix-sdk-android/src/main/java/im/vector/matrix/android/api/auth/data/HomeServerConnectionConfig.kt
...atrix/android/api/auth/data/HomeServerConnectionConfig.kt
+2
-2
matrix-sdk-android/src/main/java/im/vector/matrix/android/api/failure/MatrixError.kt
.../java/im/vector/matrix/android/api/failure/MatrixError.kt
+10
-2
matrix-sdk-android/src/main/java/im/vector/matrix/android/api/permalinks/MatrixPermalinkSpan.kt
...ctor/matrix/android/api/permalinks/MatrixPermalinkSpan.kt
+1
-0
matrix-sdk-android/src/main/java/im/vector/matrix/android/api/pushrules/PushRuleService.kt
...im/vector/matrix/android/api/pushrules/PushRuleService.kt
+3
-1
matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/crypto/CryptoService.kt
...vector/matrix/android/api/session/crypto/CryptoService.kt
+0
-2
matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/events/model/Event.kt
...m/vector/matrix/android/api/session/events/model/Event.kt
+34
-111
No files found.
CHANGES.md
View file @
9cd69d1e
Changes in RiotX 0.3.0 (2019-08-08)
===================================================
Features:
-
Create Direct Room flow
-
Handle
`/markdown`
command
Improvements:
-
UI for pending edits (#193)
-
UX image preview screen transition (#393)
-
Basic support for resending failed messages (retry/remove)
-
Enable proper cancellation of suspending functions (including db transaction)
-
Enhances network connectivity checks in SDK
-
Add "View Edit History" item in the message bottom sheet (#401)
-
Cancel sync request on pause and timeout to 0 after pause (#404)
Other changes:
-
Show sync progress also in room detail screen (#403)
Bugfix:
-
Edited message: link confusion when (edited) appears in body (#398)
-
Close detail room screen when the room is left with another client (#256)
-
Clear notification for a room left on another client
-
Fix messages with empty
`in_reply_to`
not rendering (#447)
-
Fix clear cache (#408) and Logout (#205)
-
Fix
`(edited)`
link can be copied to clipboard (#402)
Build:
-
Split APK: generate one APK per arch, to reduce APK size of about 30%
Changes in RiotX 0.2.0 (2019-07-18)
===================================================
...
...
@@ -36,7 +67,7 @@ Mode details here: https://medium.com/@RiotChat/introducing-the-riotx-beta-for-a
=======================================================
Changes in RiotX 0.
XX
(2019-XX-XX)
Changes in RiotX 0.
0.0
(2019-XX-XX)
===================================================
Features:
...
...
This diff is collapsed.
Click to expand it.
matrix-sdk-android-rx/build.gradle
View file @
9cd69d1e
...
...
@@ -33,11 +33,12 @@ android {
}
dependencies
{
implementation
fileTree
(
dir:
'libs'
,
include:
[
'*.jar'
])
implementation
project
(
":matrix-sdk-android"
)
implementation
'androidx.appcompat:appcompat:1.1.0-beta01'
implementation
'io.reactivex.rxjava2:rxkotlin:2.3.0'
implementation
'io.reactivex.rxjava2:rxandroid:2.1.1'
// Paging
implementation
"androidx.paging:paging-runtime-ktx:2.1.0"
testImplementation
'junit:junit:4.12'
androidTestImplementation
'androidx.test:runner:1.2.0'
...
...
This diff is collapsed.
Click to expand it.
matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/LiveDataObservable.kt
View file @
9cd69d1e
...
...
@@ -20,6 +20,8 @@ import androidx.lifecycle.LiveData
import
androidx.lifecycle.Observer
import
io.reactivex.Observable
import
io.reactivex.android.MainThreadDisposable
import
io.reactivex.android.schedulers.AndroidSchedulers
import
io.reactivex.schedulers.Schedulers
private
class
LiveDataObservable
<
T
>(
private
val
liveData
:
LiveData
<
T
>,
...
...
@@ -57,5 +59,5 @@ private class LiveDataObservable<T>(
}
fun
<
T
>
LiveData
<
T
>.
asObservable
():
Observable
<
T
>
{
return
LiveDataObservable
(
this
)
return
LiveDataObservable
(
this
)
.
observeOn
(
Schedulers
.
computation
())
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/MatrixCallbackCompletable.kt
0 → 100644
View file @
9cd69d1e
/*
* Copyright 2019 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
im.vector.matrix.rx
import
im.vector.matrix.android.api.MatrixCallback
import
im.vector.matrix.android.api.util.Cancelable
import
io.reactivex.CompletableEmitter
import
io.reactivex.SingleEmitter
internal
class
MatrixCallbackCompletable
<
T
>(
private
val
completableEmitter
:
CompletableEmitter
)
:
MatrixCallback
<
T
>
{
override
fun
onSuccess
(
data
:
T
)
{
completableEmitter
.
onComplete
()
}
override
fun
onFailure
(
failure
:
Throwable
)
{
completableEmitter
.
tryOnError
(
failure
)
}
}
fun
Cancelable
.
toCompletable
(
completableEmitter
:
CompletableEmitter
)
{
completableEmitter
.
setCancellable
{
this
.
cancel
()
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/MatrixCallbackSingle.kt
0 → 100644
View file @
9cd69d1e
/*
* Copyright 2019 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
im.vector.matrix.rx
import
im.vector.matrix.android.api.MatrixCallback
import
im.vector.matrix.android.api.util.Cancelable
import
io.reactivex.SingleEmitter
internal
class
MatrixCallbackSingle
<
T
>(
private
val
singleEmitter
:
SingleEmitter
<
T
>)
:
MatrixCallback
<
T
>
{
override
fun
onSuccess
(
data
:
T
)
{
singleEmitter
.
onSuccess
(
data
)
}
override
fun
onFailure
(
failure
:
Throwable
)
{
singleEmitter
.
tryOnError
(
failure
)
}
}
fun
<
T
>
Cancelable
.
toSingle
(
singleEmitter
:
SingleEmitter
<
T
>)
{
singleEmitter
.
setCancellable
{
this
.
cancel
()
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/RxRoom.kt
View file @
9cd69d1e
...
...
@@ -21,24 +21,32 @@ import im.vector.matrix.android.api.session.room.model.EventAnnotationsSummary
import
im.vector.matrix.android.api.session.room.model.RoomSummary
import
im.vector.matrix.android.api.session.room.timeline.TimelineEvent
import
io.reactivex.Observable
import
io.reactivex.
schedulers.Schedulers
import
io.reactivex.
Single
class
RxRoom
(
private
val
room
:
Room
)
{
fun
liveRoomSummary
():
Observable
<
RoomSummary
>
{
return
room
.
liveRoomSummary
().
asObservable
()
.
observeOn
(
Schedulers
.
computation
())
return
room
.
liveRoomSummary
().
asObservable
()
}
fun
liveRoomMemberIds
():
Observable
<
List
<
String
>>
{
return
room
.
getRoomMemberIdsLive
().
asObservable
()
.
observeOn
(
Schedulers
.
computation
())
return
room
.
getRoomMemberIdsLive
().
asObservable
()
}
fun
liveAnnotationSummary
(
eventId
:
String
):
Observable
<
EventAnnotationsSummary
>
{
return
room
.
getEventSummaryLive
(
eventId
).
asObservable
()
.
observeOn
(
Schedulers
.
computation
())
return
room
.
getEventSummaryLive
(
eventId
).
asObservable
()
}
fun
liveTimelineEvent
(
eventId
:
String
):
Observable
<
TimelineEvent
>
{
return
room
.
liveTimeLineEvent
(
eventId
).
asObservable
().
observeOn
(
Schedulers
.
computation
())
return
room
.
liveTimeLineEvent
(
eventId
).
asObservable
()
}
fun
loadRoomMembersIfNeeded
():
Single
<
Unit
>
=
Single
.
create
{
room
.
loadRoomMembersIfNeeded
(
MatrixCallbackSingle
(
it
)).
toSingle
(
it
)
}
fun
joinRoom
(
viaServers
:
List
<
String
>
=
emptyList
()):
Single
<
Unit
>
=
Single
.
create
{
room
.
join
(
viaServers
,
MatrixCallbackSingle
(
it
)).
toSingle
(
it
)
}
}
...
...
This diff is collapsed.
Click to expand it.
matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/RxSession.kt
View file @
9cd69d1e
...
...
@@ -16,30 +16,55 @@
package
im.vector.matrix.rx
import
androidx.paging.PagedList
import
im.vector.matrix.android.api.session.Session
import
im.vector.matrix.android.api.session.group.model.GroupSummary
import
im.vector.matrix.android.api.session.pushers.Pusher
import
im.vector.matrix.android.api.session.room.model.RoomSummary
import
im.vector.matrix.android.api.session.room.model.create.CreateRoomParams
import
im.vector.matrix.android.api.session.sync.SyncState
import
im.vector.matrix.android.api.session.user.model.User
import
io.reactivex.Observable
import
io.reactivex.
schedulers.Schedulers
import
io.reactivex.
Single
class
RxSession
(
private
val
session
:
Session
)
{
fun
liveRoomSummaries
():
Observable
<
List
<
RoomSummary
>>
{
return
session
.
liveRoomSummaries
().
asObservable
()
.
observeOn
(
Schedulers
.
computation
())
return
session
.
liveRoomSummaries
().
asObservable
()
}
fun
liveGroupSummaries
():
Observable
<
List
<
GroupSummary
>>
{
return
session
.
liveGroupSummaries
().
asObservable
()
.
observeOn
(
Schedulers
.
computation
())
return
session
.
liveGroupSummaries
().
asObservable
()
}
fun
liveSyncState
():
Observable
<
SyncState
>
{
return
session
.
syncState
().
asObservable
()
.
observeOn
(
Schedulers
.
computation
())
return
session
.
syncState
().
asObservable
()
}
fun
livePushers
():
Observable
<
List
<
Pusher
>>
{
return
session
.
livePushers
().
asObservable
().
observeOn
(
Schedulers
.
computation
())
return
session
.
livePushers
().
asObservable
()
}
fun
liveUsers
():
Observable
<
List
<
User
>>
{
return
session
.
liveUsers
().
asObservable
()
}
fun
livePagedUsers
(
filter
:
String
?
=
null
):
Observable
<
PagedList
<
User
>>
{
return
session
.
livePagedUsers
(
filter
).
asObservable
()
}
fun
createRoom
(
roomParams
:
CreateRoomParams
):
Single
<
String
>
=
Single
.
create
{
session
.
createRoom
(
roomParams
,
MatrixCallbackSingle
(
it
)).
toSingle
(
it
)
}
fun
searchUsersDirectory
(
search
:
String
,
limit
:
Int
,
excludedUserIds
:
Set
<
String
>):
Single
<
List
<
User
>>
=
Single
.
create
{
session
.
searchUsersDirectory
(
search
,
limit
,
excludedUserIds
,
MatrixCallbackSingle
(
it
)).
toSingle
(
it
)
}
fun
joinRoom
(
roomId
:
String
,
viaServers
:
List
<
String
>
=
emptyList
()):
Single
<
Unit
>
=
Single
.
create
{
session
.
joinRoom
(
roomId
,
viaServers
,
MatrixCallbackSingle
(
it
)).
toSingle
(
it
)
}
}
...
...
This diff is collapsed.
Click to expand it.
matrix-sdk-android/build.gradle
View file @
9cd69d1e
...
...
@@ -94,7 +94,6 @@ dependencies {
def
markwon_version
=
'3.0.0'
def
daggerVersion
=
'2.23.1'
implementation
fileTree
(
dir:
'libs'
,
include:
[
'*.aar'
])
implementation
"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation
"org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
implementation
"org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"
...
...
@@ -110,7 +109,7 @@ dependencies {
implementation
'com.squareup.retrofit2:converter-moshi:2.4.0'
implementation
'com.squareup.okhttp3:okhttp:3.14.1'
implementation
'com.squareup.okhttp3:logging-interceptor:3.10.0'
implementation
'com.novoda:merlin:1.
1.6
'
implementation
'com.novoda:merlin:1.
2.0
'
implementation
"com.squareup.moshi:moshi-adapters:$moshi_version"
kapt
"com.squareup.moshi:moshi-kotlin-codegen:$moshi_version"
...
...
@@ -126,9 +125,6 @@ dependencies {
// FP
implementation
"io.arrow-kt:arrow-core:$arrow_version"
implementation
"io.arrow-kt:arrow-instances-core:$arrow_version"
implementation
"io.arrow-kt:arrow-effects:$arrow_version"
implementation
"io.arrow-kt:arrow-effects-instances:$arrow_version"
implementation
"io.arrow-kt:arrow-integration-retrofit-adapter:$arrow_version"
// olm lib is now hosted by jitpack: https://jitpack.io/#org.matrix.gitlab.matrix-org/olm
implementation
'org.matrix.gitlab.matrix-org:olm:3.1.2'
...
...
This diff is collapsed.
Click to expand it.
matrix-sdk-android/libs/react-native-webrtc.aar
deleted
100644 → 0
View file @
df6080b1
File deleted
This diff is collapsed.
Click to expand it.
matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/LiveDataTestObserver.java
View file @
9cd69d1e
...
...
@@ -16,10 +16,10 @@
package
im.vector.matrix.android
;
import
androidx.annotation.Nullable
;
import
androidx.lifecycle.LiveData
;
import
androidx.lifecycle.MutableLiveData
;
import
androidx.lifecycle.Observer
;
import
androidx.annotation.Nullable
;
import
java.util.ArrayList
;
import
java.util.Collections
;
...
...
This diff is collapsed.
Click to expand it.
matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/session/room/timeline/ChunkEntityTest.kt
View file @
9cd69d1e
...
...
@@ -19,11 +19,7 @@ package im.vector.matrix.android.session.room.timeline
import
androidx.test.ext.junit.runners.AndroidJUnit4
import
com.zhuinden.monarchy.Monarchy
import
im.vector.matrix.android.InstrumentedTest
import
im.vector.matrix.android.internal.database.helper.add
import
im.vector.matrix.android.internal.database.helper.addAll
import
im.vector.matrix.android.internal.database.helper.isUnlinked
import
im.vector.matrix.android.internal.database.helper.lastStateIndex
import
im.vector.matrix.android.internal.database.helper.merge
import
im.vector.matrix.android.internal.database.helper.*
import
im.vector.matrix.android.internal.database.model.ChunkEntity
import
im.vector.matrix.android.internal.session.room.timeline.PaginationDirection
import
im.vector.matrix.android.session.room.timeline.RoomDataHelper.createFakeListOfEvents
...
...
This diff is collapsed.
Click to expand it.
matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/session/room/timeline/FakeGetContextOfEventTask.kt
View file @
9cd69d1e
...
...
@@ -16,7 +16,6 @@
package
im.vector.matrix.android.session.room.timeline
import
arrow.core.Try
import
im.vector.matrix.android.internal.session.room.timeline.GetContextOfEventTask
import
im.vector.matrix.android.internal.session.room.timeline.PaginationDirection
import
im.vector.matrix.android.internal.session.room.timeline.TokenChunkEventPersistor
...
...
@@ -24,7 +23,7 @@ import kotlin.random.Random
internal
class
FakeGetContextOfEventTask
constructor
(
private
val
tokenChunkEventPersistor
:
TokenChunkEventPersistor
)
:
GetContextOfEventTask
{
override
suspend
fun
execute
(
params
:
GetContextOfEventTask
.
Params
):
Try
<
TokenChunkEventPersistor
.
Result
>
{
override
suspend
fun
execute
(
params
:
GetContextOfEventTask
.
Params
):
TokenChunkEventPersistor
.
Result
{
val
fakeEvents
=
RoomDataHelper
.
createFakeListOfEvents
(
30
)
val
tokenChunkEvent
=
FakeTokenChunkEvent
(
Random
.
nextLong
(
System
.
currentTimeMillis
()).
toString
(),
...
...
This diff is collapsed.
Click to expand it.
matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/session/room/timeline/FakePaginationTask.kt
View file @
9cd69d1e
...
...
@@ -16,7 +16,6 @@
package
im.vector.matrix.android.session.room.timeline
import
arrow.core.Try
import
im.vector.matrix.android.internal.session.room.timeline.PaginationTask
import
im.vector.matrix.android.internal.session.room.timeline.TokenChunkEventPersistor
import
javax.inject.Inject
...
...
@@ -24,7 +23,7 @@ import kotlin.random.Random
internal
class
FakePaginationTask
@Inject
constructor
(
private
val
tokenChunkEventPersistor
:
TokenChunkEventPersistor
)
:
PaginationTask
{
override
suspend
fun
execute
(
params
:
PaginationTask
.
Params
):
Try
<
TokenChunkEventPersistor
.
Result
>
{
override
suspend
fun
execute
(
params
:
PaginationTask
.
Params
):
TokenChunkEventPersistor
.
Result
{
val
fakeEvents
=
RoomDataHelper
.
createFakeListOfEvents
(
30
)
val
tokenChunkEvent
=
FakeTokenChunkEvent
(
params
.
from
,
Random
.
nextLong
(
System
.
currentTimeMillis
()).
toString
(),
fakeEvents
)
return
tokenChunkEventPersistor
.
insertInDb
(
tokenChunkEvent
,
params
.
roomId
,
params
.
direction
)
...
...
This diff is collapsed.
Click to expand it.
matrix-sdk-android/src/main/java/im/vector/matrix/android/api/MatrixPatterns.kt
View file @
9cd69d1e
...
...
@@ -28,7 +28,7 @@ object MatrixPatterns {
// regex pattern to find matrix user ids in a string.
// See https://matrix.org/speculator/spec/HEAD/appendices.html#historical-user-ids
private
const
val
MATRIX_USER_IDENTIFIER_REGEX
=
"@[A-Z0-9\\x21-\\x39\\x3B-\\x7F]+$DOMAIN_REGEX"
private
val
PATTERN_CONTAIN_MATRIX_USER_IDENTIFIER
=
MATRIX_USER_IDENTIFIER_REGEX
.
toRegex
(
RegexOption
.
IGNORE_CASE
)
val
PATTERN_CONTAIN_MATRIX_USER_IDENTIFIER
=
MATRIX_USER_IDENTIFIER_REGEX
.
toRegex
(
RegexOption
.
IGNORE_CASE
)
// regex pattern to find room ids in a string.
private
const
val
MATRIX_ROOM_IDENTIFIER_REGEX
=
"![A-Z0-9]+$DOMAIN_REGEX"
...
...
@@ -123,9 +123,9 @@ object MatrixPatterns {
*/
fun
isEventId
(
str
:
String
?):
Boolean
{
return
str
!=
null
&&
(
str
matches
PATTERN_CONTAIN_MATRIX_EVENT_IDENTIFIER
||
str
matches
PATTERN_CONTAIN_MATRIX_EVENT_IDENTIFIER_V3
||
str
matches
PATTERN_CONTAIN_MATRIX_EVENT_IDENTIFIER_V4
)
&&
(
str
matches
PATTERN_CONTAIN_MATRIX_EVENT_IDENTIFIER
||
str
matches
PATTERN_CONTAIN_MATRIX_EVENT_IDENTIFIER_V3
||
str
matches
PATTERN_CONTAIN_MATRIX_EVENT_IDENTIFIER_V4
)
}
/**
...
...
@@ -137,4 +137,23 @@ object MatrixPatterns {
fun
isGroupId
(
str
:
String
?):
Boolean
{
return
str
!=
null
&&
str
matches
PATTERN_CONTAIN_MATRIX_GROUP_IDENTIFIER
}
/**
* Extract server name from a matrix id
*
* @param matrixId
* @return null if not found or if matrixId is null
*/
fun
extractServerNameFromId
(
matrixId
:
String
?):
String
?
{
if
(
matrixId
==
null
)
{
return
null
}
val
index
=
matrixId
.
indexOf
(
":"
)
return
if
(
index
==
-
1
)
{
null
}
else
matrixId
.
substring
(
index
+
1
)
}
}
This diff is collapsed.
Click to expand it.
matrix-sdk-android/src/main/java/im/vector/matrix/android/api/auth/data/HomeServerConnectionConfig.kt
View file @
9cd69d1e
...
...
@@ -31,7 +31,7 @@ import okhttp3.TlsVersion
@JsonClass
(
generateAdapter
=
true
)
data class
HomeServerConnectionConfig
(
val
homeServerUri
:
Uri
,
val
identityServerUri
:
Uri
,
val
identityServerUri
:
Uri
?
=
null
,
val
antiVirusServerUri
:
Uri
?
=
null
,
val
allowedFingerprints
:
MutableList
<
Fingerprint
>
=
ArrayList
(),
val
shouldPin
:
Boolean
=
false
,
...
...
@@ -48,7 +48,7 @@ data class HomeServerConnectionConfig(
class
Builder
{
private
lateinit
var
homeServerUri
:
Uri
private
lateinit
var
identityServerUri
:
Uri
private
var
identityServerUri
:
Uri
?
=
null
private
var
antiVirusServerUri
:
Uri
?
=
null
private
val
allowedFingerprints
:
MutableList
<
Fingerprint
>
=
ArrayList
()
private
var
shouldPin
:
Boolean
=
false
...
...
This diff is collapsed.
Click to expand it.
matrix-sdk-android/src/main/java/im/vector/matrix/android/api/failure/MatrixError.kt
View file @
9cd69d1e
...
...
@@ -26,8 +26,13 @@ import com.squareup.moshi.JsonClass
@JsonClass
(
generateAdapter
=
true
)
data class
MatrixError
(
@Json
(
name
=
"errcode"
)
val
code
:
String
,
@Json
(
name
=
"error"
)
val
message
:
String
)
{
@Json
(
name
=
"error"
)
val
message
:
String
,
@Json
(
name
=
"consent_uri"
)
val
consentUri
:
String
?
=
null
,
// RESOURCE_LIMIT_EXCEEDED data
@Json
(
name
=
"limit_type"
)
val
limitType
:
String
?
=
null
,
@Json
(
name
=
"admin_contact"
)
val
adminUri
:
String
?
=
null
)
{
companion
object
{
const
val
FORBIDDEN
=
"M_FORBIDDEN"
...
...
@@ -55,5 +60,8 @@ data class MatrixError(
const
val
M_CONSENT_NOT_GIVEN
=
"M_CONSENT_NOT_GIVEN"
const
val
RESOURCE_LIMIT_EXCEEDED
=
"M_RESOURCE_LIMIT_EXCEEDED"
const
val
WRONG_ROOM_KEYS_VERSION
=
"M_WRONG_ROOM_KEYS_VERSION"
// Possible value for "limit_type"
const
val
LIMIT_TYPE_MAU
=
"monthly_active_user"
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
matrix-sdk-android/src/main/java/im/vector/matrix/android/api/permalinks/MatrixPermalinkSpan.kt
View file @
9cd69d1e
...
...
@@ -18,6 +18,7 @@ package im.vector.matrix.android.api.permalinks
import
android.text.style.ClickableSpan
import
android.view.View
import
im.vector.matrix.android.api.permalinks.MatrixPermalinkSpan.Callback
/**
* This MatrixPermalinkSpan is a clickable span which use a [Callback] to communicate back.
...
...
This diff is collapsed.
Click to expand it.
matrix-sdk-android/src/main/java/im/vector/matrix/android/api/pushrules/PushRuleService.kt
View file @
9cd69d1e
...
...
@@ -18,6 +18,7 @@ package im.vector.matrix.android.api.pushrules
import
im.vector.matrix.android.api.MatrixCallback
import
im.vector.matrix.android.api.pushrules.rest.PushRule
import
im.vector.matrix.android.api.session.events.model.Event
import
im.vector.matrix.android.api.util.Cancelable
interface
PushRuleService
{
...
...
@@ -31,7 +32,7 @@ interface PushRuleService {
//TODO update rule
fun
updatePushRuleEnableStatus
(
kind
:
String
,
pushRule
:
PushRule
,
enabled
:
Boolean
,
callback
:
MatrixCallback
<
Unit
>)
fun
updatePushRuleEnableStatus
(
kind
:
String
,
pushRule
:
PushRule
,
enabled
:
Boolean
,
callback
:
MatrixCallback
<
Unit
>)
:
Cancelable
fun
addPushRuleListener
(
listener
:
PushRuleListener
)
...
...
@@ -41,6 +42,7 @@ interface PushRuleService {
interface
PushRuleListener
{
fun
onMatchRule
(
event
:
Event
,
actions
:
List
<
Action
>)
fun
onRoomLeft
(
roomId
:
String
)
fun
batchFinish
()
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/crypto/CryptoService.kt
View file @
9cd69d1e
...
...
@@ -26,14 +26,12 @@ import im.vector.matrix.android.api.session.events.model.Content
import
im.vector.matrix.android.api.session.events.model.Event
import
im.vector.matrix.android.internal.crypto.MXEventDecryptionResult
import
im.vector.matrix.android.internal.crypto.NewSessionListener
import
im.vector.matrix.android.internal.crypto.attachments.ElementToDecrypt
import
im.vector.matrix.android.internal.crypto.model.ImportRoomKeysResult
import
im.vector.matrix.android.internal.crypto.model.MXDeviceInfo
import
im.vector.matrix.android.internal.crypto.model.MXEncryptEventContentResult
import
im.vector.matrix.android.internal.crypto.model.MXUsersDevicesMap
import
im.vector.matrix.android.internal.crypto.model.rest.DevicesListResponse
import
im.vector.matrix.android.internal.crypto.model.rest.RoomKeyRequestBody
import
java.io.File
interface
CryptoService
{
...
...
This diff is collapsed.
Click to expand it.
matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/events/model/Event.kt
View file @
9cd69d1e
...
...
@@ -20,6 +20,9 @@ import android.text.TextUtils
import
com.squareup.moshi.Json
import
com.squareup.moshi.JsonClass
import
im.vector.matrix.android.api.session.crypto.MXCryptoError
import
im.vector.matrix.android.api.session.room.model.message.MessageContent
import
im.vector.matrix.android.api.session.room.model.message.MessageType
import
im.vector.matrix.android.api.session.room.send.SendState
import
im.vector.matrix.android.api.util.JsonDict
import
im.vector.matrix.android.internal.crypto.algorithms.olm.OlmDecryptionResult
import
im.vector.matrix.android.internal.di.MoshiProvider
...
...
@@ -79,9 +82,15 @@ data class Event(
)
{
@Transient
var
mxDecryptionResult
:
OlmDecryptionResult
?
=
null
@Transient
var
mCryptoError
:
MXCryptoError
.
ErrorType
?
=
null
@Transient
var
sendState
:
SendState
=
SendState
.
UNKNOWN
/**
* Check if event is a state event.
...
...
@@ -95,42 +104,6 @@ data class Event(
// Crypto
//==============================================================================================================
// /**
// * For encrypted events, the plaintext payload for the event.
// * This is a small MXEvent instance with typically value for `type` and 'content' fields.
// */
// @Transient
// var mClearEvent: Event? = null
// private set
//
// /**
// * Curve25519 key which we believe belongs to the sender of the event.
// * See `senderKey` property.
// */
// @Transient
// private var mSenderCurve25519Key: String? = null
//
// /**
// * Ed25519 key which the sender of this event (for olm) or the creator of the megolm session (for megolm) claims to own.
// * See `claimedEd25519Key` property.
// */
// @Transient
// private var mClaimedEd25519Key: String? = null
//
// /**
// * Curve25519 keys of devices involved in telling us about the senderCurve25519Key and claimedEd25519Key.
// * See `forwardingCurve25519KeyChain` property.
// */
// @Transient
// private var mForwardingCurve25519KeyChain: List<String> = ArrayList()
//
// /**
// * Decryption error
// */
// @Transient
// var mCryptoError: MXCryptoError? = null
// private set
/**
* @return true if this event is encrypted.
*/
...
...
@@ -138,51 +111,11 @@ data class Event(
return
TextUtils
.
equals
(
type
,
EventType
.
ENCRYPTED
)
}
/**
* Update the clear data on this event.
* This is used after decrypting an event; it should not be used by applications.
*
* @param decryptionResult the decryption result, including the plaintext and some key info.
*/
// internal fun setClearData(decryptionResult: MXEventDecryptionResult?) {
// mClearEvent = null
// if (decryptionResult != null) {
// if (decryptionResult.clearEvent != null) {
// val adapter = MoshiProvider.providesMoshi().adapter(Event::class.java)
// mClearEvent = adapter.fromJsonValue(decryptionResult.clearEvent)
//
// if (mClearEvent != null) {
// mSenderCurve25519Key = decryptionResult.senderCurve25519Key
// mClaimedEd25519Key = decryptionResult.claimedEd25519Key
// mForwardingCurve25519KeyChain = decryptionResult.forwardingCurve25519KeyChain
//
// // For encrypted events with relation, the m.relates_to is kept in clear, so we need to put it back
// // in the clear event
// try {
// content?.get("m.relates_to")?.let { clearRelates ->
// mClearEvent = mClearEvent?.copy(
// content = HashMap(mClearEvent!!.content).apply {
// this["m.relates_to"] = clearRelates
// }
// )
// }
// } catch (e: Exception) {
// Timber.e(e, "Unable to restore 'm.relates_to' the clear event")
// }
// }
//
//
// }
// }
// mCryptoError = null
// }
/**
* @return The curve25519 key that sent this event.
*/
fun
getSenderKey
():
String
?
{
return
mxDecryptionResult
?.
senderKey
// return mClearEvent?.mSenderCurve25519Key ?: mSenderCurve25519Key
}
/**
...
...
@@ -190,23 +123,13 @@ data class Event(
*/
fun
getKeysClaimed
():
Map
<
String
,
String
>
{
return
mxDecryptionResult
?.
keysClaimed
?:
HashMap
()
// val res = HashMap<String, String>()
//
// val claimedEd25519Key = if (null != mClearEvent) mClearEvent!!.mClaimedEd25519Key else mClaimedEd25519Key
//
// if (null != claimedEd25519Key) {
// res["ed25519"] = claimedEd25519Key
// }
//
// return res
}
//
/**
* @return the event type
*/
fun
getClearType
():
String
{
return
mxDecryptionResult
?.
payload
?.
get
(
"type"
)
?.
toString
()
?:
type
//get("type")?.toString() ?: type
return
mxDecryptionResult
?.
payload
?.
get
(
"type"
)
?.
toString
()
?:
type
}
/**
...
...
@@ -216,30 +139,8 @@ data class Event(
return
mxDecryptionResult
?.
payload
?.
get
(
"content"
)
as
?
Content
?:
content
}
// /**
// * @return the linked crypto error
// */
// fun getCryptoError(): MXCryptoError? {
// return mCryptoError
// }
//
// /**
// * Update the linked crypto error
// *
// * @param error the new crypto error.
// */
// fun setCryptoError(error: MXCryptoError?) {
// mCryptoError = error
// if (null != error) {
// mClearEvent = null
// }
// }
fun
toContentStringWithIndent
():
String
{
val
contentMap
=
this
.
toContent
()
?.
toMutableMap
()
?:
HashMap
()
contentMap
.
remove
(
"mxDecryptionResult"
)
contentMap
.
remove
(
"mCryptoError"
)
val
contentMap
=
toContent
()
?.
toMutableMap
()
?:
HashMap
()
return
JSONObject
(
contentMap
).
toString
(
4
)
}
...
...
@@ -272,6 +173,7 @@ data class Event(
if
(
redacts
!=
other
.
redacts
)
return
false
if
(
mxDecryptionResult
!=
other
.
mxDecryptionResult
)
return
false
if
(
mCryptoError
!=
other
.
mCryptoError
)
return
false
if
(
sendState
!=
other
.
sendState
)
return
false
return
true
}
...
...
@@ -289,6 +191,27 @@ data class Event(
result
=
31
*
result
+
(
redacts
?.
hashCode
()
?:
0
)
result
=
31
*
result
+
(
mxDecryptionResult
?.
hashCode
()
?:
0
)
result
=
31
*
result
+
(
mCryptoError
?.
hashCode
()
?:
0
)
result
=
31
*
result
+
sendState
.
hashCode
()
return
result
}
}
fun
Event
.
isTextMessage
():
Boolean
{
return
getClearType
()
==
EventType
.
MESSAGE
&&
when
(
getClearContent
()
?.
toModel
<
MessageContent
>()
?.
type
)
{
MessageType
.
MSGTYPE_TEXT
,
MessageType
.
MSGTYPE_EMOTE
,
MessageType
.
MSGTYPE_NOTICE
->
true
else
->
false
}
}
fun
Event
.
isImageMessage
():
Boolean
{
return
getClearType
()
==
EventType
.
MESSAGE
&&
when
(
getClearContent
()
?.
toModel
<
MessageContent
>()
?.
type
)
{
MessageType
.
MSGTYPE_IMAGE
->
true
else
->
false
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Prev
1
2
3
4
5
…
19
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment