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

Commit

Permalink
Merge pull request #319 from matrix-org/riot_sdk_310
Browse files Browse the repository at this point in the history
Remove Room.getLiveState() and keep only Room.getState()
  • Loading branch information
bmarty authored Jul 16, 2018
2 parents 84c7ca9 + 59ab720 commit 6bbe7ea
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 38 deletions.
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ Improvements:

Bugfix:
- Send Access Token as a header instead of a url parameter to upload content (#311)
- Add API CallSoundsManager.startRingingSilently() to fix issue when incoming call sound is disable (vector-im/riot-android32417)
- Add API CallSoundsManager.startRingingSilently() to fix issue when incoming call sound is disable (vector-im/riot-android#2417)

API Change:
- Parameter historyVisibility removed from MxSession.createRoom(). It had no effect.
- New API: CreateRoomParams.setHistoryVisibility(String historyVisibility) to force the history visibility during Room creation.
- Room.getLiveState() has been removed, please use Room.getState() (#310)

Translations:
-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1049,7 +1049,7 @@ public void onCryptoSyncComplete() {
Room roomFromAlicePOV2 = aliceSession2.getDataHandler().getRoom(mRoomId);

Assert.assertNotNull(roomFromAlicePOV2);
Assert.assertTrue(roomFromAlicePOV2.getLiveState().isEncrypted());
Assert.assertTrue(roomFromAlicePOV2.getState().isEncrypted());

Event event = roomFromAlicePOV2.getDataHandler().getStore().getLatestEvent(mRoomId);
Assert.assertNotNull(event);
Expand Down Expand Up @@ -2332,7 +2332,7 @@ public void onCryptoSyncComplete() {
Room roomFromAlicePOV2 = aliceSession2.getDataHandler().getRoom(mRoomId);

Assert.assertNotNull(roomFromAlicePOV2);
Assert.assertTrue(roomFromAlicePOV2.getLiveState().isEncrypted());
Assert.assertTrue(roomFromAlicePOV2.getState().isEncrypted());

Event event = roomFromAlicePOV2.getDataHandler().getStore().getLatestEvent(mRoomId);
Assert.assertNotNull(event);
Expand Down Expand Up @@ -2430,8 +2430,9 @@ public void test25_testLeftAndJoinedBob() throws Exception {
mBobSession.getCrypto().setWarnOnUnknownDevices(false);

CountDownLatch lock0 = new CountDownLatch(1);
mAliceSession.createRoom(null, null, RoomState.DIRECTORY_VISIBILITY_PUBLIC, null, RoomState.GUEST_ACCESS_CAN_JOIN,
RoomState.HISTORY_VISIBILITY_SHARED, null, new TestApiCallback<String>(lock0) {
mAliceSession.createRoom(null, null, RoomState.DIRECTORY_VISIBILITY_PUBLIC,
null, RoomState.GUEST_ACCESS_CAN_JOIN,
null, new TestApiCallback<String>(lock0) {
@Override
public void onSuccess(String roomId) {
results.put("roomId", roomId);
Expand Down Expand Up @@ -2902,8 +2903,9 @@ public void onSuccess(Void info) {
mBobSession.getCrypto().setWarnOnUnknownDevices(false);

CountDownLatch lock0 = new CountDownLatch(1);
mAliceSession.createRoom(null, null, RoomState.DIRECTORY_VISIBILITY_PUBLIC, null, RoomState.GUEST_ACCESS_CAN_JOIN,
RoomState.HISTORY_VISIBILITY_SHARED, null, new TestApiCallback<String>(lock0) {
mAliceSession.createRoom(null, null, RoomState.DIRECTORY_VISIBILITY_PUBLIC,
null, RoomState.GUEST_ACCESS_CAN_JOIN,
null, new TestApiCallback<String>(lock0) {
@Override
public void onSuccess(String roomId) {
results.put("roomId", roomId);
Expand Down Expand Up @@ -3022,8 +3024,9 @@ public void onSuccess(Void info) {

// - Alice and Bob start sharing a room again
CountDownLatch lock3 = new CountDownLatch(1);
aliceSession2.createRoom(null, null, RoomState.DIRECTORY_VISIBILITY_PUBLIC, null, RoomState.GUEST_ACCESS_CAN_JOIN,
RoomState.HISTORY_VISIBILITY_SHARED, null, new TestApiCallback<String>(lock3) {
aliceSession2.createRoom(null, null, RoomState.DIRECTORY_VISIBILITY_PUBLIC,
null, RoomState.GUEST_ACCESS_CAN_JOIN,
null, new TestApiCallback<String>(lock3) {
@Override
public void onSuccess(String info) {
mRoomId = info;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,7 @@ public boolean isRoomEncrypted(String roomId) {
Room room = mSession.getDataHandler().getRoom(roomId);

if (null != room) {
res = room.getLiveState().isEncrypted();
res = room.getState().isEncrypted();
}
}
}
Expand Down Expand Up @@ -1296,7 +1296,7 @@ public void run() {
}

if (null == alg) {
String algorithm = room.getLiveState().encryptionAlgorithm();
String algorithm = room.getState().encryptionAlgorithm();

if (null != algorithm) {
if (setEncryptionInRoom(room.getRoomId(), algorithm, false)) {
Expand Down Expand Up @@ -1349,7 +1349,7 @@ public void onUnexpectedError(final Exception e) {
}
});
} else {
final String algorithm = room.getLiveState().encryptionAlgorithm();
final String algorithm = room.getState().encryptionAlgorithm();
final String reason = String.format(MXCryptoError.UNABLE_TO_ENCRYPT_REASON,
(null == algorithm) ? MXCryptoError.NO_MORE_ALGORITHM_REASON : algorithm);
Log.e(LOG_TAG, "## encryptEventContent() : " + reason);
Expand Down Expand Up @@ -1768,7 +1768,7 @@ private void onRoomMembership(final Event event) {
final String userId = event.stateKey;
final Room room = mSession.getDataHandler().getRoom(event.roomId);

RoomMember roomMember = room.getLiveState().getMember(userId);
RoomMember roomMember = room.getState().getMember(userId);

if (null != roomMember) {
final String membership = roomMember.membership;
Expand Down
30 changes: 13 additions & 17 deletions matrix-sdk/src/main/java/org/matrix/androidsdk/data/Room.java
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public boolean shouldEncryptForInvitedMembers() {
* @return true if it is a call conference room.
*/
public boolean isConferenceUserRoom() {
return getLiveState().isConferenceUserRoom();
return getState().isConferenceUserRoom();
}

/**
Expand All @@ -212,7 +212,7 @@ public boolean isConferenceUserRoom() {
* @param isConferenceUserRoom true when it is an user conference room.
*/
public void setIsConferenceUserRoom(boolean isConferenceUserRoom) {
getLiveState().setIsConferenceUserRoom(isConferenceUserRoom);
getState().setIsConferenceUserRoom(isConferenceUserRoom);
}

/**
Expand All @@ -221,7 +221,7 @@ public void setIsConferenceUserRoom(boolean isConferenceUserRoom) {
* @return true if there is one.
*/
public boolean isOngoingConferenceCall() {
RoomMember conferenceUser = getLiveState().getMember(MXCallsManager.getConferenceUserId(getRoomId()));
RoomMember conferenceUser = getState().getMember(MXCallsManager.getConferenceUserId(getRoomId()));
return (null != conferenceUser) && TextUtils.equals(conferenceUser.membership, RoomMember.MEMBERSHIP_JOIN);
}

Expand Down Expand Up @@ -426,10 +426,6 @@ public RoomState getState() {
return mLiveTimeline.getState();
}

public RoomState getLiveState() {
return getState();
}

public boolean isLeaving() {
return mIsLeaving;
}
Expand Down Expand Up @@ -881,7 +877,7 @@ public void onSuccess(Void info) {
* @return the room aliases list.
*/
public List<String> getAliases() {
return getLiveState().getAliases();
return getState().getAliases();
}

/**
Expand Down Expand Up @@ -943,7 +939,7 @@ public void onSuccess(Void info) {
* @param callback the asynchronous callback
*/
public void addRelatedGroup(final String groupId, final ApiCallback<Void> callback) {
List<String> nextGroupIdsList = new ArrayList<>(getLiveState().getRelatedGroups());
List<String> nextGroupIdsList = new ArrayList<>(getState().getRelatedGroups());

if (!nextGroupIdsList.contains(groupId)) {
nextGroupIdsList.add(groupId);
Expand All @@ -959,7 +955,7 @@ public void addRelatedGroup(final String groupId, final ApiCallback<Void> callba
* @param callback the asynchronous callback
*/
public void removeRelatedGroup(final String groupId, final ApiCallback<Void> callback) {
List<String> nextGroupIdsList = new ArrayList<>(getLiveState().getRelatedGroups());
List<String> nextGroupIdsList = new ArrayList<>(getState().getRelatedGroups());
nextGroupIdsList.remove(groupId);

updateRelatedGroups(nextGroupIdsList, callback);
Expand All @@ -979,7 +975,7 @@ public void updateRelatedGroups(final List<String> groupIds, final ApiCallback<V
.sendStateEvent(getRoomId(), Event.EVENT_TYPE_STATE_RELATED_GROUPS, null, params, new SimpleApiCallback<Void>(callback) {
@Override
public void onSuccess(Void info) {
getLiveState().groups = groupIds;
getState().groups = groupIds;
getDataHandler().getStore().storeLiveStateForRoom(getRoomId());

if (null != callback) {
Expand Down Expand Up @@ -1254,8 +1250,8 @@ private void clearUnreadCounters(RoomSummary summary) {
Log.d(LOG_TAG, "## clearUnreadCounters " + getRoomId());

// reset the notification count
getLiveState().setHighlightCount(0);
getLiveState().setNotificationCount(0);
getState().setHighlightCount(0);
getState().setNotificationCount(0);

if (null != getStore()) {
getStore().storeLiveStateForRoom(getRoomId());
Expand Down Expand Up @@ -1339,11 +1335,11 @@ private boolean markAllAsRead(boolean updateReadMarker, final ApiCallback<Void>
Log.e(LOG_TAG, "## sendReadReceipt() : no summary for " + getRoomId());
}

if ((0 != getLiveState().getNotificationCount()) || (0 != getLiveState().getHighlightCount())) {
if ((0 != getState().getNotificationCount()) || (0 != getState().getHighlightCount())) {
Log.e(LOG_TAG, "## markAllAsRead() : the notification messages count for " + getRoomId() + " should have been cleared");

getLiveState().setNotificationCount(0);
getLiveState().setHighlightCount(0);
getState().setNotificationCount(0);
getState().setHighlightCount(0);

if (null != getStore()) {
getStore().storeLiveStateForRoom(getRoomId());
Expand Down Expand Up @@ -2761,7 +2757,7 @@ public void onLiveEvent(Event event, RoomState roomState) {
* @return if the room content is encrypted
*/
public boolean isEncrypted() {
return getLiveState().isEncrypted();
return getState().isEncrypted();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ public void run() {
Collection<Room> rooms = getRooms();

for (Room room : rooms) {
Collection<RoomMember> members = room.getLiveState().getMembers();
Collection<RoomMember> members = room.getState().getMembers();
for (RoomMember member : members) {
updateUserWithRoomMemberEvent(member);
}
Expand Down Expand Up @@ -494,8 +494,8 @@ public void run() {
for (String roomId : roomIds) {
Room room = getRoom(roomId);

if ((null != room) && (null != room.getLiveState())) {
int membersCount = room.getLiveState().getMembers().size();
if ((null != room) && (null != room.getState())) {
int membersCount = room.getState().getMembers().size();
int eventsCount = mRoomEvents.get(roomId).size();

Log.d(LOG_TAG, " room " + roomId + " : membersCount " + membersCount + " - eventsCount " + eventsCount);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,7 @@ public void run() {
redacterEvent.redacts = redactedEvent.eventId;
redacterEvent.setType(Event.EVENT_TYPE_REDACTION);

onEvent(redacterEvent, EventTimeline.Direction.FORWARDS, mRoom.getLiveState());
onEvent(redacterEvent, EventTimeline.Direction.FORWARDS, mRoom.getState());

if (null != mEventSendingListener) {
try {
Expand Down Expand Up @@ -1827,7 +1827,7 @@ public void onEventSent(final Event event, final String prevEventId) {
mAdapter.updateEventById(event, prevEventId);
} else {
// refresh the listView only when it is a live timeline or a search
mAdapter.add(new MessageRow(event, mRoom.getLiveState()), true);
mAdapter.add(new MessageRow(event, mRoom.getState()), true);
}

if (mFutureReadMarkerEventId != null && prevEventId.equals(mFutureReadMarkerEventId)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,8 @@ private BingRule fulfilledBingRule(Event event, boolean highlightRuleOnly) {
if ((null != mSession.getDataHandler()) && (null != mSession.getDataHandler().getStore())) {
Room room = mSession.getDataHandler().getStore().getRoom(event.roomId);

if ((null != room) && (null != room.getLiveState())) {
String disambiguousedName = room.getLiveState().getMemberName(mMyUserId);
if ((null != room) && (null != room.getState())) {
String disambiguousedName = room.getState().getMemberName(mMyUserId);

if (!TextUtils.equals(disambiguousedName, mMyUserId)) {
pattern = Pattern.quote(disambiguousedName);
Expand Down Expand Up @@ -470,7 +470,7 @@ private boolean eventMatchesConditions(Event event, List<Condition> conditions)
if (event.roomId != null) {
Room room = mDataHandler.getRoom(event.roomId, false);

if (!((SenderNotificationPermissionCondition) condition).isSatisfied(room.getLiveState().getPowerLevels(), event.sender)) {
if (!((SenderNotificationPermissionCondition) condition).isSatisfied(room.getState().getPowerLevels(), event.sender)) {
return false;
}
}
Expand Down

0 comments on commit 6bbe7ea

Please sign in to comment.