From 7050323fa65ed32a301c3cd4fc25dbee60636c00 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 18 Oct 2018 15:43:15 +0200 Subject: [PATCH 01/14] Version ++ --- CHANGES.rst | 27 +++++++++++++++++++++++++++ matrix-sdk/build.gradle | 4 ++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index c0d78adcf..13c82e665 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,3 +1,30 @@ +Changes to Matrix Android SDK in 0.9.13 (2018-XX-XX) +======================================================= + +Features: + - + +Improvements: + - + +Bugfix: + - + +API Change: + - + +Translations: + - + +Others: + - + +Build: + - + +Test: + - + Changes to Matrix Android SDK in 0.9.12 (2018-10-18) ======================================================= diff --git a/matrix-sdk/build.gradle b/matrix-sdk/build.gradle index ce7936a1c..2be25ad76 100644 --- a/matrix-sdk/build.gradle +++ b/matrix-sdk/build.gradle @@ -14,8 +14,8 @@ android { defaultConfig { minSdkVersion 16 targetSdkVersion 26 - versionCode 912 - versionName "0.9.12" + versionCode 913 + versionName "0.9.13-dev" resValue "string", "flavor_description", "SDKApp" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } From e7fb4c729fd9ea1f585c1cd374bbbc197e37ff93 Mon Sep 17 00:00:00 2001 From: Karol Kosek Date: Sat, 20 Oct 2018 15:16:54 +0000 Subject: [PATCH 02/14] Translated using Weblate (Polish) Currently translated at 66.6% (42 of 63 strings) Translation: Riot Android/matrix-android-sdk Translate-URL: https://translate.riot.im/projects/riot-android/matrix-android-sdk/pl/ --- matrix-sdk/src/main/res/values-pl/strings.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/matrix-sdk/src/main/res/values-pl/strings.xml b/matrix-sdk/src/main/res/values-pl/strings.xml index 3e4fdee0a..f752dfb6d 100644 --- a/matrix-sdk/src/main/res/values-pl/strings.xml +++ b/matrix-sdk/src/main/res/values-pl/strings.xml @@ -57,4 +57,5 @@ - +** Nie można odszyfrować: %s ** + From dc080b24960225f3e121e47d1eb91af1959a59ef Mon Sep 17 00:00:00 2001 From: hamster Date: Sat, 20 Oct 2018 16:05:38 +0000 Subject: [PATCH 03/14] Translated using Weblate (Polish) Currently translated at 100.0% (63 of 63 strings) Translation: Riot Android/matrix-android-sdk Translate-URL: https://translate.riot.im/projects/riot-android/matrix-android-sdk/pl/ --- matrix-sdk/src/main/res/values-pl/strings.xml | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/matrix-sdk/src/main/res/values-pl/strings.xml b/matrix-sdk/src/main/res/values-pl/strings.xml index f752dfb6d..97ce1bc8c 100644 --- a/matrix-sdk/src/main/res/values-pl/strings.xml +++ b/matrix-sdk/src/main/res/values-pl/strings.xml @@ -58,4 +58,30 @@ ** Nie można odszyfrować: %s ** + %s umieścił wideo rozmowe. + %s umieścił połączenie głosowe. + %1$s uczynił historię pokoju widoczną do %2$s + wszyscy członkowie pokoju, od momentu w którym zostali zaproszeni. + wszyscy członkowie pokoju, od momentu w którym dołączyli. + nieznane (%s). + %1$s zażądał grupowego połączenia VoIP + Rozpoczęto grupowe połączenie głosowe VoIP + Zakończono grupowe połączenie głosowe VoIP + + "zredagowane %1$s… " + " przez %1$s" + %1$s zaktualizował swój profil %2$s + %1$s wysłał(a) zaproszenie do %2$s aby dołączył(a) do tego pokoju + %1$s zaakceptował(a) zaproszenie dla %2$s + + Urządzenie nadawcy nie wysłało nam kluczy do tej wiadomości. + + Nie można zredagować + Obecnie nie jest możliwe ponowne dołączenie do pustego pokoju. + + wyślij zdjęcie. + wyślij wideo. + wyślij plik audio. + wyślij plik. + From a7aeb7200cf865e38b464dfbe88bdaf918195b11 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Mon, 29 Oct 2018 15:01:00 +0100 Subject: [PATCH 04/14] Add RTL support and treat some Lint warnings as errors --- CHANGES.rst | 4 ++-- matrix-sdk/build.gradle | 9 +++++++++ matrix-sdk/src/main/AndroidManifest.xml | 4 ++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 13c82e665..6f6654ca5 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -5,7 +5,7 @@ Features: - Improvements: - - + - Add RTL support Bugfix: - @@ -20,7 +20,7 @@ Others: - Build: - - + - Treat some Lint warnings as errors Test: - diff --git a/matrix-sdk/build.gradle b/matrix-sdk/build.gradle index 2be25ad76..51e8b5ed6 100644 --- a/matrix-sdk/build.gradle +++ b/matrix-sdk/build.gradle @@ -84,6 +84,15 @@ android { disable 'InvalidPackage' disable 'MissingTranslation' disable 'RestrictedApi' + + // Treat some warnings as errors + error 'StringFormatCount' + error 'HardcodedText' + error 'SpUsage' + + // RTL + error 'RtlEnabled' + error 'RtlHardcoded' } repositories { diff --git a/matrix-sdk/src/main/AndroidManifest.xml b/matrix-sdk/src/main/AndroidManifest.xml index 4bfd8ee9d..801fef75d 100644 --- a/matrix-sdk/src/main/AndroidManifest.xml +++ b/matrix-sdk/src/main/AndroidManifest.xml @@ -20,7 +20,7 @@ - - + + From 9d71c3ac7d7283737c8e9c87803be89e5709a26d Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Mon, 29 Oct 2018 16:25:19 +0100 Subject: [PATCH 05/14] Fix crash when change visibility room (vector-im/riot-android#2679) --- CHANGES.rst | 2 +- .../src/main/java/org/matrix/androidsdk/rest/api/RoomsApi.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 13c82e665..5f976a759 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -8,7 +8,7 @@ Improvements: - Bugfix: - - + - Fix crash when change visibility room (vector-im/riot-android#2679) API Change: - diff --git a/matrix-sdk/src/main/java/org/matrix/androidsdk/rest/api/RoomsApi.java b/matrix-sdk/src/main/java/org/matrix/androidsdk/rest/api/RoomsApi.java index 8240480e6..c9af6c458 100644 --- a/matrix-sdk/src/main/java/org/matrix/androidsdk/rest/api/RoomsApi.java +++ b/matrix-sdk/src/main/java/org/matrix/androidsdk/rest/api/RoomsApi.java @@ -384,7 +384,7 @@ Call updateAccountData(@Path("userId") String userId, * @param roomDirectoryVisibility the put params containing the new "visibility" field */ @PUT("directory/list/room/{roomId}") - Call setRoomDirectoryVisibility(@Path("roomId") String roomId, RoomDirectoryVisibility roomDirectoryVisibility); + Call setRoomDirectoryVisibility(@Path("roomId") String roomId, @Body RoomDirectoryVisibility roomDirectoryVisibility); /** * Get the visibility of the given room in the list directory. From 89c1d2b10d0420c76c11719b9c1bb67c03c954f2 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Tue, 30 Oct 2018 11:29:56 +0100 Subject: [PATCH 06/14] Move Permalink parsing to the Matrix SDK --- .../androidsdk/util/PermalinkUtils.java | 136 +++++++++++++++++- 1 file changed, 135 insertions(+), 1 deletion(-) diff --git a/matrix-sdk/src/main/java/org/matrix/androidsdk/util/PermalinkUtils.java b/matrix-sdk/src/main/java/org/matrix/androidsdk/util/PermalinkUtils.java index 87ca9d4b1..90394dcb6 100644 --- a/matrix-sdk/src/main/java/org/matrix/androidsdk/util/PermalinkUtils.java +++ b/matrix-sdk/src/main/java/org/matrix/androidsdk/util/PermalinkUtils.java @@ -16,19 +16,36 @@ package org.matrix.androidsdk.util; +import android.net.Uri; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.text.TextUtils; +import org.matrix.androidsdk.MXPatterns; import org.matrix.androidsdk.rest.model.Event; +import java.net.URLDecoder; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + /** * Useful methods to deals with Matrix permalink */ public class PermalinkUtils { + private static final String LOG_TAG = PermalinkUtils.class.getSimpleName(); private static final String MATRIX_TO_URL_BASE = "https://matrix.to/#/"; + // index of each items in the map when parsing a universal link + public static final String ULINK_ROOM_ID_OR_ALIAS_KEY = "ULINK_ROOM_ID_OR_ALIAS_KEY"; + public static final String ULINK_MATRIX_USER_ID_KEY = "ULINK_MATRIX_USER_ID_KEY"; + public static final String ULINK_GROUP_ID_KEY = "ULINK_GROUP_ID_KEY"; + public static final String ULINK_EVENT_ID_KEY = "ULINK_EVENT_ID_KEY"; + /** * Creates a permalink for an event. * Ex: "https://matrix.to/#/!nbzmcXAqpxBXjAdgoX:matrix.org/$1531497316352799BevdV:matrix.org" @@ -90,7 +107,6 @@ public static String getLinkedId(@Nullable String url) { return null; } - /** * Escape '/' in id, because it is used as a separator * @@ -100,4 +116,122 @@ public static String getLinkedId(@Nullable String url) { private static String escape(String id) { return id.replaceAll("/", "%2F"); } + + /*** + * Tries to parse an universal link. + * + * @param uri the uri to parse + * @param supportedHosts + * @param supportedPaths + * @return the universal link items, null if the universal link is invalid + */ + @Nullable + public static Map parseUniversalLink(@Nullable Uri uri, + @NonNull List supportedHosts, + @NonNull List supportedPaths) { + Map map = null; + + try { + // sanity check + if (uri == null || TextUtils.isEmpty(uri.getPath())) { + Log.e(LOG_TAG, "## parseUniversalLink : null"); + return null; + } + + if (!supportedHosts.contains(uri.getHost()) && !TextUtils.equals(uri.getHost(), "matrix.to")) { + Log.e(LOG_TAG, "## parseUniversalLink : unsupported host " + uri.getHost()); + return null; + } + + boolean isSupportedHost = TextUtils.equals(uri.getHost(), "vector.im") || TextUtils.equals(uri.getHost(), "riot.im"); + + // when the uri host is vector.im, it is followed by a dedicated path + if (isSupportedHost && !supportedPaths.contains(uri.getPath())) { + Log.e(LOG_TAG, "## parseUniversalLink : not supported"); + return null; + } + + // remove the server part + String uriFragment; + if ((uriFragment = uri.getFragment()) != null) { + uriFragment = uriFragment.substring(1); // get rid of first "/" + } else { + Log.e(LOG_TAG, "## parseUniversalLink : cannot extract path"); + return null; + } + + String temp[] = uriFragment.split("/", 3); // limit to 3 for security concerns (stack overflow injection) + + if (!isSupportedHost) { + List compliantList = new ArrayList<>(Arrays.asList(temp)); + compliantList.add(0, "room"); + temp = compliantList.toArray(new String[compliantList.size()]); + } + + if (temp.length < 2) { + Log.e(LOG_TAG, "## parseUniversalLink : too short"); + return null; + } + + if (!TextUtils.equals(temp[0], "room") && !TextUtils.equals(temp[0], "user")) { + Log.e(LOG_TAG, "## parseUniversalLink : not supported " + temp[0]); + return null; + } + + map = new HashMap<>(); + + String firstParam = temp[1]; + + if (MXPatterns.isUserId(firstParam)) { + if (temp.length > 2) { + Log.e(LOG_TAG, "## parseUniversalLink : universal link to member id is too long"); + return null; + } + + map.put(ULINK_MATRIX_USER_ID_KEY, firstParam); + } else if (MXPatterns.isRoomAlias(firstParam) || MXPatterns.isRoomId(firstParam)) { + map.put(ULINK_ROOM_ID_OR_ALIAS_KEY, firstParam); + } else if (MXPatterns.isGroupId(firstParam)) { + map.put(ULINK_GROUP_ID_KEY, firstParam); + } + + // room id only ? + if (temp.length > 2) { + String eventId = temp[2]; + + if (MXPatterns.isEventId(eventId)) { + map.put(ULINK_EVENT_ID_KEY, temp[2]); + } else { + uri = Uri.parse(uri.toString().replace("#/room/", "room/")); + + map.put(ULINK_ROOM_ID_OR_ALIAS_KEY, uri.getLastPathSegment()); + + Set names = uri.getQueryParameterNames(); + + for (String name : names) { + String value = uri.getQueryParameter(name); + + try { + value = URLDecoder.decode(value, "UTF-8"); + } catch (Exception e) { + Log.e(LOG_TAG, "## parseUniversalLink : URLDecoder.decode " + e.getMessage(), e); + return null; + } + + map.put(name, value); + } + } + } + } catch (Exception e) { + Log.e(LOG_TAG, "## parseUniversalLink : crashes " + e.getLocalizedMessage(), e); + } + + // check if the parsing succeeds + if (map != null && map.isEmpty()) { + Log.e(LOG_TAG, "## parseUniversalLink : empty dictionary"); + return null; + } + + return map; + } } From 0c82fdf01d581c41eb4b0c8bf844bdf0d746c38d Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Tue, 30 Oct 2018 11:41:19 +0100 Subject: [PATCH 07/14] Add unit test --- .../androidsdk/util/PermalinkUtilsTest.java | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 matrix-sdk/src/test/java/org/matrix/androidsdk/util/PermalinkUtilsTest.java diff --git a/matrix-sdk/src/test/java/org/matrix/androidsdk/util/PermalinkUtilsTest.java b/matrix-sdk/src/test/java/org/matrix/androidsdk/util/PermalinkUtilsTest.java new file mode 100644 index 000000000..008df5c70 --- /dev/null +++ b/matrix-sdk/src/test/java/org/matrix/androidsdk/util/PermalinkUtilsTest.java @@ -0,0 +1,61 @@ +/* + * Copyright 2018 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.androidsdk.util; + +import android.net.Uri; + +import org.junit.Assert; +import org.junit.FixMethodOrder; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; +import org.robolectric.RobolectricTestRunner; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +@RunWith(RobolectricTestRunner.class) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class PermalinkUtilsTest { + + // supported host list + private static final List sSupportedVectorHosts = Arrays.asList("vector.im", "riot.im"); + + // supported paths list + private static final List sSupportedVectorLinkPaths = Arrays.asList("/beta/", "/develop/", "/app/", "/staging/"); + + + @Test + public void parseUniversalLink_standardCase() { + Map result = testUri("https://matrix.to/#/!GnEEPYXUhoaHbkFBNX:matrix.org/$154089010924835FMJsT:sorunome.de?via=jki.re&via=matrix.org&via=disroot.org&via=tchncs.de"); + + Assert.assertEquals("!GnEEPYXUhoaHbkFBNX:matrix.org", result.get(PermalinkUtils.ULINK_ROOM_ID_OR_ALIAS_KEY)); + Assert.assertEquals("$154089010924835FMJsT:sorunome.de", result.get(PermalinkUtils.ULINK_EVENT_ID_KEY)); + Assert.assertNull(result.get(PermalinkUtils.ULINK_GROUP_ID_KEY)); + Assert.assertNull(result.get(PermalinkUtils.ULINK_MATRIX_USER_ID_KEY)); + } + + + private Map testUri(String uri) { + Map result = PermalinkUtils.parseUniversalLink(Uri.parse(uri), sSupportedVectorHosts, sSupportedVectorLinkPaths); + + Assert.assertNotNull(result); + + return result; + } +} From 987dbb52976ed0b6456e14c03ced1a109c488af2 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Tue, 30 Oct 2018 11:48:47 +0100 Subject: [PATCH 08/14] Make the test pass. --- .../org/matrix/androidsdk/util/PermalinkUtils.java | 10 +++++----- .../org/matrix/androidsdk/util/PermalinkUtilsTest.java | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/matrix-sdk/src/main/java/org/matrix/androidsdk/util/PermalinkUtils.java b/matrix-sdk/src/main/java/org/matrix/androidsdk/util/PermalinkUtils.java index 90394dcb6..8b167bac9 100644 --- a/matrix-sdk/src/main/java/org/matrix/androidsdk/util/PermalinkUtils.java +++ b/matrix-sdk/src/main/java/org/matrix/androidsdk/util/PermalinkUtils.java @@ -121,9 +121,9 @@ private static String escape(String id) { * Tries to parse an universal link. * * @param uri the uri to parse - * @param supportedHosts - * @param supportedPaths - * @return the universal link items, null if the universal link is invalid + * @param supportedHosts list of supported hosts, not including "matrix.to" + * @param supportedPaths list of supported paths, when the host is in supportedHosts + * @return the universal link items, or null if the universal link is invalid */ @Nullable public static Map parseUniversalLink(@Nullable Uri uri, @@ -143,9 +143,9 @@ public static Map parseUniversalLink(@Nullable Uri uri, return null; } - boolean isSupportedHost = TextUtils.equals(uri.getHost(), "vector.im") || TextUtils.equals(uri.getHost(), "riot.im"); + boolean isSupportedHost = supportedHosts.contains(uri.getHost()); - // when the uri host is vector.im, it is followed by a dedicated path + // when the uri host is in supportedHosts (and is not "matrix.to"), it is followed by a dedicated path if (isSupportedHost && !supportedPaths.contains(uri.getPath())) { Log.e(LOG_TAG, "## parseUniversalLink : not supported"); return null; diff --git a/matrix-sdk/src/test/java/org/matrix/androidsdk/util/PermalinkUtilsTest.java b/matrix-sdk/src/test/java/org/matrix/androidsdk/util/PermalinkUtilsTest.java index 008df5c70..b57f50a67 100644 --- a/matrix-sdk/src/test/java/org/matrix/androidsdk/util/PermalinkUtilsTest.java +++ b/matrix-sdk/src/test/java/org/matrix/androidsdk/util/PermalinkUtilsTest.java @@ -42,7 +42,7 @@ public class PermalinkUtilsTest { @Test public void parseUniversalLink_standardCase() { - Map result = testUri("https://matrix.to/#/!GnEEPYXUhoaHbkFBNX:matrix.org/$154089010924835FMJsT:sorunome.de?via=jki.re&via=matrix.org&via=disroot.org&via=tchncs.de"); + Map result = testUri("https://matrix.to/#/!GnEEPYXUhoaHbkFBNX:matrix.org/$154089010924835FMJsT:sorunome.de"); Assert.assertEquals("!GnEEPYXUhoaHbkFBNX:matrix.org", result.get(PermalinkUtils.ULINK_ROOM_ID_OR_ALIAS_KEY)); Assert.assertEquals("$154089010924835FMJsT:sorunome.de", result.get(PermalinkUtils.ULINK_EVENT_ID_KEY)); From b167d2f0606f16de633711a6d551d020eeefdb7b Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Tue, 30 Oct 2018 11:51:09 +0100 Subject: [PATCH 09/14] Upate CHANGES.rst --- CHANGES.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index 5f976a759..e88ac2c23 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -5,7 +5,7 @@ Features: - Improvements: - - + - PermalinkUtils is now able to parse a permalink Bugfix: - Fix crash when change visibility room (vector-im/riot-android#2679) From 85863822e63c916eabf0f85efbac9ec752e7597b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A0?= Date: Thu, 1 Nov 2018 21:32:17 +0000 Subject: [PATCH 10/14] Translated using Weblate (Catalan) Currently translated at 100.0% (63 of 63 strings) Translation: Riot Android/matrix-android-sdk Translate-URL: https://translate.riot.im/projects/riot-android/matrix-android-sdk/ca/ --- matrix-sdk/src/main/res/values-ca/strings.xml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/matrix-sdk/src/main/res/values-ca/strings.xml b/matrix-sdk/src/main/res/values-ca/strings.xml index 0ab98c0ab..321b40036 100644 --- a/matrix-sdk/src/main/res/values-ca/strings.xml +++ b/matrix-sdk/src/main/res/values-ca/strings.xml @@ -76,4 +76,13 @@ - +%1$s ha enviat una enganxina. + + En resposta a + + ha enviat una imatge. + ha enviat un vídeo. + ha enviat un fitxer d\'àudio. + ha enviat un fitxer. + + From 286ab7f61ce0ad16c97d3fde5835c58e38b8bebc Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Fri, 2 Nov 2018 20:47:22 +0100 Subject: [PATCH 11/14] MXSession.initUserAgent() takes a second parameter for flavor description. --- CHANGES.rst | 2 +- matrix-sdk/build.gradle | 1 - .../androidsdk/lazyloading/RoomMembersTest.java | 3 ++- .../matrix/androidsdk/lazyloading/RoomNameTest.java | 2 +- .../androidsdk/lazyloading/RoomStateTest.java | 3 ++- .../androidsdk/lazyloading/RoomSummaryTest.java | 3 ++- .../matrix/androidsdk/lazyloading/SearchTest.java | 3 ++- .../main/java/org/matrix/androidsdk/MXSession.java | 9 +++++---- .../main/java/org/matrix/androidsdk/RestClient.java | 13 +++++++------ 9 files changed, 22 insertions(+), 17 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 8fa15a0db..f4f1cc234 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -12,7 +12,7 @@ Bugfix: - Fix crash when change visibility room (vector-im/riot-android#2679) API Change: - - + - MXSession.initUserAgent() takes a second parameter for flavor description. Translations: - diff --git a/matrix-sdk/build.gradle b/matrix-sdk/build.gradle index 51e8b5ed6..7635ef7d5 100644 --- a/matrix-sdk/build.gradle +++ b/matrix-sdk/build.gradle @@ -16,7 +16,6 @@ android { targetSdkVersion 26 versionCode 913 versionName "0.9.13-dev" - resValue "string", "flavor_description", "SDKApp" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } diff --git a/matrix-sdk/src/androidTest/java/org/matrix/androidsdk/lazyloading/RoomMembersTest.java b/matrix-sdk/src/androidTest/java/org/matrix/androidsdk/lazyloading/RoomMembersTest.java index dd0d9c4af..247e501ed 100644 --- a/matrix-sdk/src/androidTest/java/org/matrix/androidsdk/lazyloading/RoomMembersTest.java +++ b/matrix-sdk/src/androidTest/java/org/matrix/androidsdk/lazyloading/RoomMembersTest.java @@ -22,6 +22,7 @@ import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runners.MethodSorters; +import org.matrix.androidsdk.MXSession; import org.matrix.androidsdk.RestClient; import org.matrix.androidsdk.common.CommonTestHelper; import org.matrix.androidsdk.common.TestApiCallback; @@ -39,7 +40,7 @@ public class RoomMembersTest { @BeforeClass public static void init() { - RestClient.initUserAgent(InstrumentationRegistry.getContext()); + MXSession.initUserAgent(InstrumentationRegistry.getContext(), null); } @Test diff --git a/matrix-sdk/src/androidTest/java/org/matrix/androidsdk/lazyloading/RoomNameTest.java b/matrix-sdk/src/androidTest/java/org/matrix/androidsdk/lazyloading/RoomNameTest.java index 2b4be86da..4ad38cb17 100644 --- a/matrix-sdk/src/androidTest/java/org/matrix/androidsdk/lazyloading/RoomNameTest.java +++ b/matrix-sdk/src/androidTest/java/org/matrix/androidsdk/lazyloading/RoomNameTest.java @@ -41,7 +41,7 @@ public class RoomNameTest { @BeforeClass public static void init() { - RestClient.initUserAgent(InstrumentationRegistry.getContext()); + MXSession.initUserAgent(InstrumentationRegistry.getContext(), null); } @Test diff --git a/matrix-sdk/src/androidTest/java/org/matrix/androidsdk/lazyloading/RoomStateTest.java b/matrix-sdk/src/androidTest/java/org/matrix/androidsdk/lazyloading/RoomStateTest.java index 7f4cbcce8..cc5e96e98 100644 --- a/matrix-sdk/src/androidTest/java/org/matrix/androidsdk/lazyloading/RoomStateTest.java +++ b/matrix-sdk/src/androidTest/java/org/matrix/androidsdk/lazyloading/RoomStateTest.java @@ -23,6 +23,7 @@ import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runners.MethodSorters; +import org.matrix.androidsdk.MXSession; import org.matrix.androidsdk.RestClient; import org.matrix.androidsdk.common.CommonTestHelper; import org.matrix.androidsdk.data.Room; @@ -44,7 +45,7 @@ public class RoomStateTest { @BeforeClass public static void init() { - RestClient.initUserAgent(InstrumentationRegistry.getContext()); + MXSession.initUserAgent(InstrumentationRegistry.getContext(), null); } @Test diff --git a/matrix-sdk/src/androidTest/java/org/matrix/androidsdk/lazyloading/RoomSummaryTest.java b/matrix-sdk/src/androidTest/java/org/matrix/androidsdk/lazyloading/RoomSummaryTest.java index 5d7742a68..c42727e77 100644 --- a/matrix-sdk/src/androidTest/java/org/matrix/androidsdk/lazyloading/RoomSummaryTest.java +++ b/matrix-sdk/src/androidTest/java/org/matrix/androidsdk/lazyloading/RoomSummaryTest.java @@ -23,6 +23,7 @@ import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runners.MethodSorters; +import org.matrix.androidsdk.MXSession; import org.matrix.androidsdk.RestClient; import org.matrix.androidsdk.common.CommonTestHelper; import org.matrix.androidsdk.common.TestApiCallback; @@ -40,7 +41,7 @@ public class RoomSummaryTest { @BeforeClass public static void init() { - RestClient.initUserAgent(InstrumentationRegistry.getContext()); + MXSession.initUserAgent(InstrumentationRegistry.getContext(), null); } @Test diff --git a/matrix-sdk/src/androidTest/java/org/matrix/androidsdk/lazyloading/SearchTest.java b/matrix-sdk/src/androidTest/java/org/matrix/androidsdk/lazyloading/SearchTest.java index 7d19e8b8c..b18a75f26 100644 --- a/matrix-sdk/src/androidTest/java/org/matrix/androidsdk/lazyloading/SearchTest.java +++ b/matrix-sdk/src/androidTest/java/org/matrix/androidsdk/lazyloading/SearchTest.java @@ -8,6 +8,7 @@ import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runners.MethodSorters; +import org.matrix.androidsdk.MXSession; import org.matrix.androidsdk.RestClient; import org.matrix.androidsdk.common.CommonTestHelper; import org.matrix.androidsdk.common.TestApiCallback; @@ -24,7 +25,7 @@ public class SearchTest { @BeforeClass public static void init() { - RestClient.initUserAgent(InstrumentationRegistry.getContext()); + MXSession.initUserAgent(InstrumentationRegistry.getContext(), null); } @Test diff --git a/matrix-sdk/src/main/java/org/matrix/androidsdk/MXSession.java b/matrix-sdk/src/main/java/org/matrix/androidsdk/MXSession.java index 531b1a4c2..5e41e5ca8 100644 --- a/matrix-sdk/src/main/java/org/matrix/androidsdk/MXSession.java +++ b/matrix-sdk/src/main/java/org/matrix/androidsdk/MXSession.java @@ -113,7 +113,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.regex.Pattern; /** * Class that represents one user's session with a particular home server. @@ -344,10 +343,12 @@ private void checkIfAlive() { /** * Init the user-agent used by the REST requests. * - * @param context the application context + * @param appContext the application context + * @param flavorDescription the flavor description, or null if not defined */ - public static void initUserAgent(Context context) { - RestClient.initUserAgent(context); + public static void initUserAgent(@Nullable Context appContext, + @Nullable String flavorDescription) { + RestClient.initUserAgent(appContext, flavorDescription == null ? "SDKApp" : flavorDescription); } /** diff --git a/matrix-sdk/src/main/java/org/matrix/androidsdk/RestClient.java b/matrix-sdk/src/main/java/org/matrix/androidsdk/RestClient.java index 6c959e347..2528c94ac 100644 --- a/matrix-sdk/src/main/java/org/matrix/androidsdk/RestClient.java +++ b/matrix-sdk/src/main/java/org/matrix/androidsdk/RestClient.java @@ -23,7 +23,6 @@ import android.content.pm.PackageManager; import android.support.annotation.NonNull; import android.support.annotation.Nullable; -import android.support.annotation.VisibleForTesting; import android.text.TextUtils; import android.util.Pair; @@ -262,9 +261,11 @@ private String sanitizeDynamicPath(String dynamicPath) { * Create an user agent with the application version. * Ex: Riot/0.8.12 (Linux; U; Android 6.0.1; SM-A510F Build/MMB29; Flavour FDroid; MatrixAndroidSDK 0.9.6) * - * @param appContext the application context + * @param appContext the application context + * @param flavorDescription the flavor description */ - public static void initUserAgent(Context appContext) { + public static void initUserAgent(@Nullable Context appContext, + @NonNull String flavorDescription) { String appName = ""; String appVersion = ""; @@ -292,14 +293,14 @@ public static void initUserAgent(Context appContext) { } // if there is no user agent or cannot parse it - if ((null == sUserAgent) || (sUserAgent.lastIndexOf(")") == -1) || (sUserAgent.indexOf("(") == -1)) { - sUserAgent = appName + "/" + appVersion + " ( Flavour " + appContext.getString(R.string.flavor_description) + if ((null == sUserAgent) || (sUserAgent.lastIndexOf(")") == -1) || !sUserAgent.contains("(")) { + sUserAgent = appName + "/" + appVersion + " ( Flavour " + flavorDescription + "; MatrixAndroidSDK " + BuildConfig.VERSION_NAME + ")"; } else { // update sUserAgent = appName + "/" + appVersion + " " + sUserAgent.substring(sUserAgent.indexOf("("), sUserAgent.lastIndexOf(")") - 1) + - "; Flavour " + appContext.getString(R.string.flavor_description) + + "; Flavour " + flavorDescription + "; MatrixAndroidSDK " + BuildConfig.VERSION_NAME + ")"; } } From 1b4411fdbbe310feca1b5bf5b7896b2a9c35e2db Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Tue, 9 Oct 2018 16:58:16 +0200 Subject: [PATCH 12/14] Move `invite_room_state` to the UnsignedData object (vector-im/riot-android#2555) --- CHANGES.rst | 1 + .../org/matrix/androidsdk/rest/model/Event.java | 13 ------------- .../matrix/androidsdk/rest/model/UnsignedData.java | 8 ++++++++ 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 8fa15a0db..d1d184a4b 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -10,6 +10,7 @@ Improvements: Bugfix: - Fix crash when change visibility room (vector-im/riot-android#2679) + - Move `invite_room_state` to the UnsignedData object (vector-im/riot-android#2555) API Change: - diff --git a/matrix-sdk/src/main/java/org/matrix/androidsdk/rest/model/Event.java b/matrix-sdk/src/main/java/org/matrix/androidsdk/rest/model/Event.java index e17954260..88a423a22 100644 --- a/matrix-sdk/src/main/java/org/matrix/androidsdk/rest/model/Event.java +++ b/matrix-sdk/src/main/java/org/matrix/androidsdk/rest/model/Event.java @@ -158,9 +158,6 @@ public enum SentState { // Specific to redaction public String redacts; - // A subset of the state of the room at the time of the invite, if membership is invite - public List invite_room_state; - // store the exception triggered when unsent public Exception unsentException = null; public MatrixError unsentMatrixError = null; @@ -583,7 +580,6 @@ public Event deepCopy() { copy.prev_content_as_string = prev_content_as_string; copy.unsigned = unsigned; - copy.invite_room_state = invite_room_state; copy.redacts = redacts; copy.mSentState = mSentState; @@ -914,10 +910,6 @@ public void readExternal(ObjectInput input) throws IOException, ClassNotFoundExc redacts = input.readUTF(); } - if (input.readBoolean()) { - invite_room_state = (List) input.readObject(); - } - if (input.readBoolean()) { unsentException = (Exception) input.readObject(); } @@ -1002,11 +994,6 @@ public void writeExternal(ObjectOutput output) throws IOException { output.writeUTF(redacts); } - output.writeBoolean(null != invite_room_state); - if (null != invite_room_state) { - output.writeObject(invite_room_state); - } - output.writeBoolean(null != unsentException); if (null != unsentException) { output.writeObject(unsentException); diff --git a/matrix-sdk/src/main/java/org/matrix/androidsdk/rest/model/UnsignedData.java b/matrix-sdk/src/main/java/org/matrix/androidsdk/rest/model/UnsignedData.java index aedcf2147..ca0beae8a 100644 --- a/matrix-sdk/src/main/java/org/matrix/androidsdk/rest/model/UnsignedData.java +++ b/matrix-sdk/src/main/java/org/matrix/androidsdk/rest/model/UnsignedData.java @@ -1,5 +1,6 @@ /* * Copyright 2014 OpenMarket Ltd + * Copyright 2018 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. @@ -16,6 +17,9 @@ package org.matrix.androidsdk.rest.model; import com.google.gson.JsonElement; +import com.google.gson.annotations.SerializedName; + +import java.util.List; /** * Contains optional extra information about the event. @@ -37,6 +41,10 @@ public class UnsignedData implements java.io.Serializable { */ public String transaction_id; + // A subset of the state of the room at the time of the invite, if membership is invite + @SerializedName("invite_room_state") + public List inviteRoomState; + /** * The previous event content (room member information only) */ From 148ef1f765ad297c966e1a74ce0f40d57a0035a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vasyl=CC=81=20V=2E=20Vercyns=CC=81kyj?= Date: Sat, 3 Nov 2018 12:15:41 +0000 Subject: [PATCH 13/14] Translated using Weblate (Ukrainian) Currently translated at 14.2% (9 of 63 strings) Translation: Riot Android/matrix-android-sdk Translate-URL: https://translate.riot.im/projects/riot-android/matrix-android-sdk/uk/ --- matrix-sdk/src/main/res/values-uk/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/matrix-sdk/src/main/res/values-uk/strings.xml b/matrix-sdk/src/main/res/values-uk/strings.xml index 18d89e4f3..1ab049871 100644 --- a/matrix-sdk/src/main/res/values-uk/strings.xml +++ b/matrix-sdk/src/main/res/values-uk/strings.xml @@ -5,7 +5,7 @@ %s запрошення %1$s запросив(ла) %2$s - Закодоване повідомлення + Зашифроване повідомлення Запрошення від %s From a6b71ec9e83e9df16d8d2716c6aefb41e10e7c6f Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Tue, 6 Nov 2018 14:00:36 +0100 Subject: [PATCH 14/14] Prepare release 0.9.13 --- CHANGES.rst | 14 +------------- matrix-sdk/build.gradle | 2 +- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 1cdf112aa..5720b6ed9 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,9 +1,6 @@ -Changes to Matrix Android SDK in 0.9.13 (2018-XX-XX) +Changes to Matrix Android SDK in 0.9.13 (2018-11-06) ======================================================= -Features: - - - Improvements: - Add RTL support - PermalinkUtils is now able to parse a permalink @@ -15,18 +12,9 @@ Bugfix: API Change: - MXSession.initUserAgent() takes a second parameter for flavor description. -Translations: - - - -Others: - - - Build: - Treat some Lint warnings as errors -Test: - - - Changes to Matrix Android SDK in 0.9.12 (2018-10-18) ======================================================= diff --git a/matrix-sdk/build.gradle b/matrix-sdk/build.gradle index 7635ef7d5..a7359c6ce 100644 --- a/matrix-sdk/build.gradle +++ b/matrix-sdk/build.gradle @@ -15,7 +15,7 @@ android { minSdkVersion 16 targetSdkVersion 26 versionCode 913 - versionName "0.9.13-dev" + versionName "0.9.13" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" }