-
Notifications
You must be signed in to change notification settings - Fork 748
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
197 changed files
with
5,300 additions
and
1,057 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/raw/RawCacheStrategy.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright (c) 2020 New Vector Ltd | ||
* Copyright 2020 The Matrix.org Foundation C.I.C. | ||
* | ||
* 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 org.matrix.android.sdk.api.raw | ||
|
||
sealed class RawCacheStrategy { | ||
// Data is always fetched from the server | ||
object NoCache: RawCacheStrategy() | ||
|
||
// Once data is retrieved, it is stored for the provided amount of time. | ||
// In case of error, and if strict is set to false, the cache can be returned if available | ||
data class TtlCache(val validityDurationInMillis: Long, val strict: Boolean): RawCacheStrategy() | ||
|
||
// Once retrieved, the data is stored in cache and will be always get from the cache | ||
object InfiniteCache: RawCacheStrategy() | ||
} |
43 changes: 43 additions & 0 deletions
43
matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/raw/RawService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright 2020 New Vector Ltd | ||
* Copyright 2020 The Matrix.org Foundation C.I.C. | ||
* | ||
* 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 org.matrix.android.sdk.api.raw | ||
|
||
import org.matrix.android.sdk.api.MatrixCallback | ||
import org.matrix.android.sdk.api.util.Cancelable | ||
|
||
/** | ||
* Useful methods to fetch raw data from the server. The access token will not be used to fetched the data | ||
*/ | ||
interface RawService { | ||
/** | ||
* Get a URL, either from cache or from the remote server, depending on the cache strategy | ||
*/ | ||
fun getUrl(url: String, | ||
rawCacheStrategy: RawCacheStrategy, | ||
matrixCallback: MatrixCallback<String>): Cancelable | ||
|
||
/** | ||
* Specific case for the well-known file. Cache validity is 8 hours | ||
*/ | ||
fun getWellknown(userId: String, matrixCallback: MatrixCallback<String>): Cancelable | ||
|
||
/** | ||
* Clear all the cache data | ||
*/ | ||
fun clearCache(matrixCallback: MatrixCallback<Unit>): Cancelable | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
...oid/src/main/java/org/matrix/android/sdk/api/session/room/summary/RoomSummaryConstants.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright (c) 2020 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 org.matrix.android.sdk.api.session.room.summary | ||
|
||
import org.matrix.android.sdk.api.session.events.model.EventType | ||
|
||
object RoomSummaryConstants { | ||
|
||
val PREVIEWABLE_TYPES = listOf( | ||
// TODO filter message type (KEY_VERIFICATION_READY, etc.) | ||
EventType.MESSAGE, | ||
EventType.CALL_INVITE, | ||
EventType.CALL_HANGUP, | ||
EventType.CALL_ANSWER, | ||
EventType.ENCRYPTED, | ||
EventType.STICKER, | ||
EventType.REACTION | ||
) | ||
} |
40 changes: 40 additions & 0 deletions
40
...id/src/main/java/org/matrix/android/sdk/api/session/room/timeline/TimelineEventFilters.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright (c) 2020 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 org.matrix.android.sdk.api.session.room.timeline | ||
|
||
data class TimelineEventFilters( | ||
/** | ||
* A flag to filter edit events | ||
*/ | ||
val filterEdits: Boolean = false, | ||
/** | ||
* A flag to filter redacted events | ||
*/ | ||
val filterRedacted: Boolean = false, | ||
/** | ||
* A flag to filter useless events, such as membership events without any change | ||
*/ | ||
val filterUseless: Boolean = false, | ||
/** | ||
* A flag to filter by types. It should be used with [allowedTypes] field | ||
*/ | ||
val filterTypes: Boolean = false, | ||
/** | ||
* If [filterTypes] is true, the list of types allowed by the list. | ||
*/ | ||
val allowedTypes: List<String> = emptyList() | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
...dk-android/src/main/java/org/matrix/android/sdk/internal/database/RealmInstanceWrapper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright (c) 2020 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 org.matrix.android.sdk.internal.database | ||
|
||
import io.realm.Realm | ||
import java.io.Closeable | ||
|
||
internal class RealmInstanceWrapper(private val realm: Realm, private val closeRealmOnClose: Boolean) : Closeable { | ||
|
||
override fun close() { | ||
if (closeRealmOnClose) { | ||
realm.close() | ||
} | ||
} | ||
|
||
fun <R> withRealm(block: (Realm) -> R): R { | ||
return use { | ||
block(it.realm) | ||
} | ||
} | ||
} |
Oops, something went wrong.