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

Commit

Permalink
Merge branch 'release/0.9.9'
Browse files Browse the repository at this point in the history
  • Loading branch information
bmarty committed Aug 30, 2018
2 parents 5a0cb5f + 8be9955 commit 5f070b9
Showing 17 changed files with 199 additions and 79 deletions.
14 changes: 14 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
Changes to Matrix Android SDK in 0.9.9 (2018-08-30)
=======================================================

Improvements:
- Clear unreachable Url when clearing media cache (vector-im/riot-android#2479)
- "In reply to" is not clickable on Riot Android yet. Make it a plain text (vector-im/riot-android#2469)

Bugfix:
- Removing room from 'low priority' or 'favorite' does not work (vector-im/riot-android#2526)
- MatrixError mResourceLimitExceededError is now managed in MxDataHandler (vector-im/riot-android#2547)

API Change:
- MxSession constructor is now private. Please use MxSession.Builder() to create a MxSession

Changes to Matrix Android SDK in 0.9.8 (2018-08-27)
=======================================================

4 changes: 2 additions & 2 deletions matrix-sdk/build.gradle
Original file line number Diff line number Diff line change
@@ -14,8 +14,8 @@ android {
defaultConfig {
minSdkVersion 16
targetSdkVersion 26
versionCode 908
versionName "0.9.8"
versionCode 909
versionName "0.9.9"
resValue "string", "flavor_description", "SDKApp"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
Original file line number Diff line number Diff line change
@@ -153,8 +153,8 @@ public void onSuccess(Void info) {

IMXStore store = new MXFileStore(hs, context);

MXSession bobSession2 = new MXSession(hs, new MXDataHandler(store, bobCredentials), context);

MXSession bobSession2 = new MXSession.Builder(hs, new MXDataHandler(store, bobCredentials), context)
.build();

final CountDownLatch lock1 = new CountDownLatch(1);
MXStoreListener listener = new MXStoreListener() {
@@ -321,7 +321,8 @@ public void onSuccess(Void info) {

IMXStore store = new MXFileStore(hs, context);

MXSession bobSession2 = new MXSession(hs, new MXDataHandler(store, bobCredentials), context);
MXSession bobSession2 = new MXSession.Builder(hs, new MXDataHandler(store, bobCredentials), context)
.build();

final CountDownLatch lock4 = new CountDownLatch(1);

@@ -489,7 +490,8 @@ public void onSuccess(MXUsersDevicesMap<MXOlmSessionResult> info) {

IMXStore store = new MXFileStore(hs, context);

MXSession bobSession2 = new MXSession(hs, new MXDataHandler(store, bobCredentials), context);
MXSession bobSession2 = new MXSession.Builder(hs, new MXDataHandler(store, bobCredentials), context)
.build();

final CountDownLatch lock5 = new CountDownLatch(1);

@@ -847,7 +849,8 @@ public void test09_testAliceInAEncryptedRoomAfterInitialSync() throws Exception

final CountDownLatch lock1 = new CountDownLatch(1);

final MXSession aliceSession2 = new MXSession(hs, new MXDataHandler(store, aliceCredentials), context);
final MXSession aliceSession2 = new MXSession.Builder(hs, new MXDataHandler(store, aliceCredentials), context)
.build();

MXStoreListener listener = new MXStoreListener() {
@Override
@@ -977,7 +980,8 @@ public void onSuccess(Void info) {

IMXStore store = new MXFileStore(hs, context);

MXSession aliceSession2 = new MXSession(hs, new MXDataHandler(store, aliceCredentials2), context);
MXSession aliceSession2 = new MXSession.Builder(hs, new MXDataHandler(store, aliceCredentials2), context)
.build();

aliceSession2.enableCryptoWhenStarting();

@@ -1064,7 +1068,8 @@ public void test11_testAliceAndBobInAEncryptedRoomBackPaginationFromMemoryStore(

final CountDownLatch lock1 = new CountDownLatch(2);

MXSession bobSession2 = new MXSession(hs, new MXDataHandler(store, bobCredentials), context);
MXSession bobSession2 = new MXSession.Builder(hs, new MXDataHandler(store, bobCredentials), context)
.build();

MXEventListener eventListener = new MXEventListener() {
@Override
@@ -2257,7 +2262,8 @@ public void onSuccess(byte[] info) {

IMXStore store = new MXFileStore(hs, context);

MXSession aliceSession2 = new MXSession(hs, new MXDataHandler(store, aliceCredentials2), context);
MXSession aliceSession2 = new MXSession.Builder(hs, new MXDataHandler(store, aliceCredentials2), context)
.build();

aliceSession2.enableCryptoWhenStarting();

Original file line number Diff line number Diff line change
@@ -132,8 +132,8 @@ public void onSuccess(Credentials credentials) {

IMXStore store = new MXFileStore(hs, context);

MXSession mxSession = new MXSession(hs, new MXDataHandler(store, credentials), context);

MXSession mxSession = new MXSession.Builder(hs, new MXDataHandler(store, credentials), context)
.build();

if (!startSession) {
return mxSession;
@@ -194,7 +194,8 @@ public void onSuccess(Credentials credentials) {

IMXStore store = new MXFileStore(hs, context);

MXSession mxSession = new MXSession(hs, new MXDataHandler(store, credentials), context);
MXSession mxSession = new MXSession.Builder(hs, new MXDataHandler(store, credentials), context)
.build();

mxSession.enableCryptoWhenStarting();

23 changes: 23 additions & 0 deletions matrix-sdk/src/main/java/org/matrix/androidsdk/MXDataHandler.java
Original file line number Diff line number Diff line change
@@ -20,6 +20,7 @@
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Looper;
import android.support.annotation.Nullable;
import android.text.TextUtils;

import com.google.gson.Gson;
@@ -170,6 +171,10 @@ public interface RequestNetworkErrorListener {
// groups manager
private GroupsManager mGroupsManager;

// Resource limit exceeded error
@Nullable
private MatrixError mResourceLimitExceededError;

/**
* Default constructor.
*
@@ -402,6 +407,16 @@ public void onSSLCertificateError(UnrecognizedCertificateException exception) {
}
}

/**
* Get the last resource limit exceeded error if any or null
*
* @return the last resource limit exceeded error if any or null
*/
@Nullable
public MatrixError getResourceLimitExceededError() {
return mResourceLimitExceededError;
}

/**
* Get the session's current user. The MyUser object provides methods for updating user properties which are not possible for other users.
*
@@ -1945,6 +1960,9 @@ public void run() {

@Override
public void onLiveEventsChunkProcessed(final String startToken, final String toToken) {
// reset the resource limit exceeded error
mResourceLimitExceededError = null;

refreshUnreadCounters();

if (null != mCryptoEventsListener) {
@@ -2167,6 +2185,11 @@ public void onInitialSyncComplete(String toToken) {

@Override
public void onSyncError(final MatrixError matrixError) {
// Store the resource limit exceeded error
if (MatrixError.RESOURCE_LIMIT_EXCEEDED.equals(matrixError.errcode)) {
mResourceLimitExceededError = matrixError;
}

final List<IMXEventListener> eventListeners = getListenersSnapshot();

mUiHandler.post(new Runnable() {
67 changes: 56 additions & 11 deletions matrix-sdk/src/main/java/org/matrix/androidsdk/MXSession.java
Original file line number Diff line number Diff line change
@@ -126,7 +126,7 @@ public class MXSession {
private PresenceRestClient mPresenceRestClient;
private RoomsRestClient mRoomsRestClient;
private final PushRulesRestClient mPushRulesRestClient;
private final PushersRestClient mPushersRestClient;
private PushersRestClient mPushersRestClient;
private final ThirdPidRestClient mThirdPidRestClient;
private final CallRestClient mCallRestClient;
private final AccountDataRestClient mAccountDataRestClient;
@@ -237,12 +237,13 @@ private MXSession(HomeServerConnectionConfig hsConfig) {

/**
* Create a user session with a data handler.
* Private, please use the MxSession.Builder now
*
* @param hsConfig the home server connection config
* @param dataHandler the data handler
* @param appContext the application context
*/
public MXSession(HomeServerConnectionConfig hsConfig, MXDataHandler dataHandler, Context appContext) {
private MXSession(HomeServerConnectionConfig hsConfig, MXDataHandler dataHandler, Context appContext) {
this(hsConfig);
mDataHandler = dataHandler;

@@ -423,15 +424,6 @@ public MXDataHandler getDataHandler() {
return mDataHandler;
}

/**
* Update the metrics listener
*
* @param metricsListener the metrics listener
*/
public void setMetricsListener(MetricsListener metricsListener) {
mMetricsListener = metricsListener;
}

/**
* Get the user credentials.
*
@@ -2472,4 +2464,57 @@ public void openIdToken(final ApiCallback<Map<Object, Object>> callback) {
public GroupsManager getGroupsManager() {
return mGroupsManager;
}

/* ==========================================================================================
* Builder
* ========================================================================================== */

public static class Builder {
private MXSession mxSession;

public Builder(HomeServerConnectionConfig hsConfig, MXDataHandler dataHandler, Context context) {
mxSession = new MXSession(hsConfig, dataHandler, context);
}

/**
* Create a pusher rest client, overriding the push server url if necessary
*
* @param pushServerUrl the push server url, or null or empty to use the default PushersRestClient
* @return
*/
public Builder withPushServerUrl(@Nullable String pushServerUrl) {
// If not empty, create a special PushersRestClient
PushersRestClient pushersRestClient = null;

if (!TextUtils.isEmpty(pushServerUrl)) {
// pusher uses a custom server
try {
HomeServerConnectionConfig alteredHsConfig = new HomeServerConnectionConfig(Uri.parse(pushServerUrl));
alteredHsConfig.setCredentials(mxSession.mHsConfig.getCredentials());
pushersRestClient = new PushersRestClient(alteredHsConfig);
} catch (Exception e) {
Log.e(LOG_TAG, "## withPushServerUrl() failed " + e.getMessage(), e);
}
}

if (null != pushersRestClient) {
// Replace the existing client
mxSession.mPushersRestClient = pushersRestClient;
}

return this;
}

public Builder withMetricsListener(@Nullable MetricsListener metricsListener) {
mxSession.mMetricsListener = metricsListener;

return this;
}

// TODO LazyLoading: add useLazyLoading() method to this builder

public MXSession build() {
return mxSession;
}
}
}
Original file line number Diff line number Diff line change
@@ -18,6 +18,8 @@

package org.matrix.androidsdk.data;

import android.support.annotation.Nullable;

import org.matrix.androidsdk.rest.model.Event;

import java.util.Map;
@@ -51,6 +53,7 @@ public void handleTagEvent(Event event) {
* @param key the key.
* @return the roomTag if it is found else null
*/
@Nullable
public RoomTag roomTag(String key) {
if ((null != tags) && tags.containsKey(key)) {
return tags.get(key);
@@ -67,8 +70,9 @@ public boolean hasTags() {
}

/**
* @return the list of keys
* @return the list of keys, or null if no tag
*/
@Nullable
public Set<String> getKeys() {
if (hasTags()) {
return tags.keySet();
Original file line number Diff line number Diff line change
@@ -31,7 +31,6 @@
import org.matrix.androidsdk.util.Log;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
@@ -515,7 +514,11 @@ public Set<String> getRoomTags() {
* @param roomTags the room tags
*/
public void setRoomTags(final Set<String> roomTags) {
// wraps the set into a serializable one
mRoomTags = new HashSet<>(roomTags);
if (roomTags != null) {
// wraps the set into a serializable one
mRoomTags = new HashSet<>(roomTags);
} else {
mRoomTags = new HashSet<>();
}
}
}
Original file line number Diff line number Diff line change
@@ -38,9 +38,9 @@ public int compare(final Room r1, final Room r2) {
final RoomTag tag1 = r1.getAccountData().roomTag(mTag);
final RoomTag tag2 = r2.getAccountData().roomTag(mTag);

if (tag1.mOrder != null && tag2.mOrder != null) {
if (tag1 != null && tag1.mOrder != null && tag2 != null && tag2.mOrder != null) {
res = Double.compare(tag1.mOrder, tag2.mOrder);
} else if (tag1.mOrder != null) {
} else if (tag1 != null && tag1.mOrder != null) {
res = 1;
} else {
res = -1;
Loading

0 comments on commit 5f070b9

Please sign in to comment.