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

Commit e1b5004

Browse files
committed
Fix / Keysbackup not working
Regression after ParentRestClient refactoring, the retrofit converter has changed and is not able to serialize kotlin class (if no @JVMField is set)
1 parent ad135fa commit e1b5004

File tree

4 files changed

+13
-16
lines changed

4 files changed

+13
-16
lines changed

CHANGES.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Improvements:
88
-
99

1010
Bugfix:
11-
-
11+
- Fix / Keysbackup not working (failed to get version)
1212

1313
API Change:
1414
-

matrix-sdk-core/src/main/java/org/matrix/androidsdk/RestClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public enum EndPointServer {
100100
private OkHttpClient mOkHttpClient;
101101

102102
public RestClient(HomeServerConnectionConfig hsConfig, Class<T> type, String uriPrefix) {
103-
this(hsConfig, type, uriPrefix, GsonProvider.provideGson(), EndPointServer.HOME_SERVER);
103+
this(hsConfig, type, uriPrefix, GsonProvider.provideKotlinGson(), EndPointServer.HOME_SERVER);
104104
}
105105

106106
public RestClient(HomeServerConnectionConfig hsConfig, Class<T> type, String uriPrefix, Gson gson) {

matrix-sdk-core/src/main/java/org/matrix/androidsdk/core/json/GsonProvider.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,15 @@ public static Gson provideGson() {
3535
return gson;
3636
}
3737

38+
// Can serialize/deserialise kt objects without the need to add @JVMField
39+
private static final Gson kotlinGson = new GsonBuilder()
40+
.registerTypeAdapter(boolean.class, new BooleanDeserializer(false))
41+
.registerTypeAdapter(Boolean.class, new BooleanDeserializer(true))
42+
.create();
43+
44+
public static Gson provideKotlinGson() {
45+
return kotlinGson;
46+
}
47+
48+
3849
}

matrix-sdk/src/main/java/org/matrix/androidsdk/core/JsonUtils.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,6 @@ public class JsonUtils {
7070

7171
private static final Gson basicGson = new Gson();
7272

73-
private static final Gson kotlinGson = new GsonBuilder()
74-
.registerTypeAdapter(boolean.class, new BooleanDeserializer(false))
75-
.registerTypeAdapter(Boolean.class, new BooleanDeserializer(true))
76-
.create();
77-
7873
private static final Gson gson = new GsonBuilder()
7974
.setFieldNamingStrategy(new MatrixFieldNamingStrategy())
8075
.excludeFieldsWithModifiers(Modifier.PRIVATE, Modifier.STATIC)
@@ -104,15 +99,6 @@ public static Gson getBasicGson() {
10499
return basicGson;
105100
}
106101

107-
/**
108-
* Provides the JSON parser for Kotlin.
109-
*
110-
* @return the kotlin JSON parser
111-
*/
112-
public static Gson getKotlinGson() {
113-
return kotlinGson;
114-
}
115-
116102
/**
117103
* Provides the JSON parser.
118104
*

0 commit comments

Comments
 (0)