Skip to content
This repository was archived by the owner on Apr 12, 2022. It is now read-only.

Commit 3960ced

Browse files
committed
Merge branch 'release/0.9.31'
2 parents 7c10698 + dc67570 commit 3960ced

File tree

34 files changed

+657
-761
lines changed

34 files changed

+657
-761
lines changed

CHANGES.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
Changes to Matrix Android SDK in 0.9.31 (2019-11-22)
2+
=======================================================
3+
4+
Features:
5+
- Integrations / Manage Widget Permissions in Account Data
6+
7+
Improvements:
8+
- Integration Manager preferences are now managed by SDK
9+
- Integrations / Manage Jitsi Domain Permissions in Account Data
10+
11+
Bugfix:
12+
- Crash on Realm crypto DB (vector-im/riot-android#3373)
13+
- Match identity server registration to the IS r0.3.0 spec (#3382)
14+
15+
API Change:
16+
- /account/3pid/add requires user interactive Auth
17+
18+
119
Changes to Matrix Android SDK in 0.9.30 (2019-10-09)
220
=======================================================
321

matrix-sdk-core/src/main/java/org/matrix/androidsdk/rest/model/WellKnown.kt

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,17 @@ import com.google.gson.annotations.SerializedName
2727
* "m.identity_server": {
2828
* "base_url": "https://vector.im"
2929
* }
30+
* "m.integrations": {
31+
* "managers": [
32+
* {
33+
* "api_url": "https://integrations.example.org",
34+
* "ui_url": "https://integrations.example.org/ui"
35+
* },
36+
* {
37+
* "api_url": "https://bots.example.org"
38+
* }
39+
* ]
40+
* }
3041
* }
3142
* </pre>
3243
*/
@@ -39,4 +50,35 @@ class WellKnown {
3950
@JvmField
4051
@SerializedName("m.identity_server")
4152
var identityServer: WellKnownBaseConfig? = null
53+
54+
55+
@JvmField
56+
@SerializedName("m.integrations")
57+
var integrations: Map<String, *>? = null
58+
59+
/**
60+
* Returns the list of integration managers proposed
61+
*/
62+
fun getIntegrationManagers(): List<WellKnownManagerConfig> {
63+
val managers = ArrayList<WellKnownManagerConfig>()
64+
integrations?.get("managers")?.let {
65+
(it as? ArrayList<*>)?.let { configs ->
66+
configs.forEach { config ->
67+
(config as? Map<*, *>)?.let { map ->
68+
val apiUrl = map["api_url"] as? String
69+
val uiUrl = map["ui_url"] as? String ?: apiUrl
70+
if (apiUrl != null
71+
&& apiUrl.startsWith("https://")
72+
&& uiUrl!!.startsWith("https://")) {
73+
managers.add(WellKnownManagerConfig(
74+
apiUrl = apiUrl,
75+
uiUrl = uiUrl
76+
))
77+
}
78+
}
79+
}
80+
}
81+
}
82+
return managers
83+
}
4284
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Copyright 2019 New Vector Ltd
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.matrix.androidsdk.rest.model
17+
18+
19+
data class WellKnownManagerConfig(
20+
val apiUrl : String,
21+
val uiUrl: String
22+
)

matrix-sdk-crypto/src/main/java/org/matrix/androidsdk/crypto/cryptostore/db/Helper.kt

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -50,41 +50,36 @@ fun String.hash() = try {
5050
* Get realm, invoke the action, close realm, and return the result of the action
5151
*/
5252
fun <T> doWithRealm(realmConfiguration: RealmConfiguration, action: (Realm) -> T): T {
53-
val realm = Realm.getInstance(realmConfiguration)
54-
val result = action.invoke(realm)
55-
realm.close()
56-
return result
53+
return Realm.getInstance(realmConfiguration).use {
54+
action.invoke(it)
55+
}
5756
}
5857

5958
/**
6059
* Get realm, do the query, copy from realm, close realm, and return the copied result
6160
*/
6261
fun <T : RealmObject> doRealmQueryAndCopy(realmConfiguration: RealmConfiguration, action: (Realm) -> T?): T? {
63-
val realm = Realm.getInstance(realmConfiguration)
64-
val result = action.invoke(realm)
65-
val copiedResult = result?.let { realm.copyFromRealm(result) }
66-
realm.close()
67-
return copiedResult
62+
return Realm.getInstance(realmConfiguration).use { realm ->
63+
action.invoke(realm)?.let { realm.copyFromRealm(it) }
64+
}
6865
}
6966

7067
/**
7168
* Get realm, do the list query, copy from realm, close realm, and return the copied result
7269
*/
7370
fun <T : RealmObject> doRealmQueryAndCopyList(realmConfiguration: RealmConfiguration, action: (Realm) -> Iterable<T>): Iterable<T> {
74-
val realm = Realm.getInstance(realmConfiguration)
75-
val result = action.invoke(realm)
76-
val copiedResult = realm.copyFromRealm(result)
77-
realm.close()
78-
return copiedResult
71+
return Realm.getInstance(realmConfiguration).use { realm ->
72+
action.invoke(realm).let { realm.copyFromRealm(it) }
73+
}
7974
}
8075

8176
/**
8277
* Get realm instance, invoke the action in a transaction and close realm
8378
*/
8479
fun doRealmTransaction(realmConfiguration: RealmConfiguration, action: (Realm) -> Unit) {
85-
val realm = Realm.getInstance(realmConfiguration)
86-
realm.executeTransaction { action.invoke(it) }
87-
realm.close()
80+
Realm.getInstance(realmConfiguration).use { realm ->
81+
realm.executeTransaction { action.invoke(it) }
82+
}
8883
}
8984

9085
/**

matrix-sdk-crypto/src/main/java/org/matrix/androidsdk/crypto/cryptostore/db/RealmCryptoStore.kt

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ class RealmCryptoStore(private val enableFileEncryption: Boolean = false) : IMXC
100100

101101
override fun open() {
102102
// Ensure CryptoMetadataEntity is inserted in DB
103-
doWithRealm(realmConfiguration) { realm ->
103+
doRealmTransaction(realmConfiguration) { realm ->
104104
var currentMetadata = realm.where<CryptoMetadataEntity>().findFirst()
105105

106106
var deleteAll = false
@@ -118,15 +118,13 @@ class RealmCryptoStore(private val enableFileEncryption: Boolean = false) : IMXC
118118
}
119119

120120
if (currentMetadata == null) {
121-
realm.executeTransaction {
122-
if (deleteAll) {
123-
it.deleteAll()
124-
}
121+
if (deleteAll) {
122+
realm.deleteAll()
123+
}
125124

126-
// Metadata not found, or database cleaned, create it
127-
it.createObject(CryptoMetadataEntity::class.java, credentials.getUserId()).apply {
128-
deviceId = credentials.getDeviceId()
129-
}
125+
// Metadata not found, or database cleaned, create it
126+
realm.createObject(CryptoMetadataEntity::class.java, credentials.getUserId()).apply {
127+
deviceId = credentials.getDeviceId()
130128
}
131129
}
132130
}

matrix-sdk-crypto/src/main/res/values/strings.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
<string name="verification_emoji_robot">Robot</string>
3737
<string name="verification_emoji_hat">Hat</string>
3838
<string name="verification_emoji_glasses">Glasses</string>
39-
<string name="verification_emoji_wrench">Spanner</string>
39+
<string name="verification_emoji_wrench">Wrench</string>
4040
<string name="verification_emoji_santa">Santa</string>
4141
<string name="verification_emoji_thumbsup">Thumbs Up</string>
4242
<string name="verification_emoji_umbrella">Umbrella</string>
@@ -55,7 +55,7 @@
5555
<string name="verification_emoji_flag">Flag</string>
5656
<string name="verification_emoji_train">Train</string>
5757
<string name="verification_emoji_bicycle">Bicycle</string>
58-
<string name="verification_emoji_airplane">Aeroplane</string>
58+
<string name="verification_emoji_airplane">Airplane</string>
5959
<string name="verification_emoji_rocket">Rocket</string>
6060
<string name="verification_emoji_trophy">Trophy</string>
6161
<string name="verification_emoji_ball">Ball</string>

matrix-sdk/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ android {
2727
defaultConfig {
2828
minSdkVersion 16
2929
targetSdkVersion 28
30-
versionCode 930
31-
versionName "0.9.30"
30+
versionCode 931
31+
versionName "0.9.31"
3232
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
3333

3434
// Enable multi dex for test

matrix-sdk/src/main/java/org/matrix/androidsdk/MXSession.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
import org.matrix.androidsdk.db.MXMediaCache;
7171
import org.matrix.androidsdk.features.identityserver.IdentityServerManager;
7272
import org.matrix.androidsdk.features.identityserver.IdentityServerNotConfiguredException;
73+
import org.matrix.androidsdk.features.integrationmanager.IntegrationManager;
7374
import org.matrix.androidsdk.features.terms.TermsManager;
7475
import org.matrix.androidsdk.groups.GroupsManager;
7576
import org.matrix.androidsdk.network.NetworkConnectivityReceiver;
@@ -179,6 +180,8 @@ public class MXSession implements CryptoSession {
179180

180181
private IdentityServerManager mIdentityServerManager;
181182

183+
private IntegrationManager mIntegrationManager;
184+
182185
private boolean mIsAliveSession = true;
183186

184187
// online status
@@ -384,6 +387,8 @@ public void onReadReceiptsLoaded(final String roomId) {
384387
termsManager = new TermsManager(this);
385388

386389
mIdentityServerManager = new IdentityServerManager(this, appContext);
390+
391+
mIntegrationManager = new IntegrationManager(this, appContext);
387392
}
388393

389394
private void checkIfAlive() {
@@ -569,6 +574,11 @@ public IdentityServerManager getIdentityServerManager() {
569574
return mIdentityServerManager;
570575
}
571576

577+
public IntegrationManager getIntegrationManager() {
578+
checkIfAlive();
579+
return mIntegrationManager;
580+
}
581+
572582
public CallRestClient getCallRestClient() {
573583
checkIfAlive();
574584
return mCallRestClient;
@@ -2124,6 +2134,13 @@ public void unIgnoreUsers(List<String> userIds, ApiCallback<Void> callback) {
21242134
}
21252135
}
21262136

2137+
public void enableIntegrationManagerUsage(Boolean enable, ApiCallback<Void> callback) {
2138+
Map<String, Object> enableImAccountDataEl = new HashMap<>();
2139+
enableImAccountDataEl.put("enabled", enable);
2140+
2141+
mAccountDataRestClient.setAccountData(getMyUserId(), AccountDataElement.ACCOUNT_DATA_TYPE_INTEGRATION_PROVISIONING, enableImAccountDataEl, callback);
2142+
}
2143+
21272144
/**
21282145
* @return the network receiver.
21292146
*/

0 commit comments

Comments
 (0)