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

Keep only Room.getState() method and remove Room.getLiveState() ... #2435

Merged
merged 3 commits into from
Jul 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Improvements:

Other changes:
- Remove dependency to `android-gif-drawable` lib and use Glide to animate logo on Splashscreen (#2421)
- Keep only Room.getState() method and remove Room.getLiveState() because they are similar (matrix-org/matrix-android-sdk#310)

Bugfix:
- Fix issue on incoming call screen when "Do not disturb mode" is active (#2417)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1020,8 +1020,8 @@ public static Intent buildIntentPreviewRoom(String aMatrixId, String aRoomId, Co
Room room = session.getDataHandler().getRoom(aRoomId);

// get the room alias (if any) for the preview data
if ((null != room) && (null != room.getLiveState())) {
roomAlias = room.getLiveState().getAlias();
if ((null != room) && (null != room.getState())) {
roomAlias = room.getState().getAlias();
}

intentRetCode = new Intent(aContext, aTargetActivity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ class IntegrationManagerActivity : AbstractWidgetActivity() {

Log.d(LOG_TAG, "Received request canSendEvent in room " + mRoom!!.roomId)

val member = mRoom!!.liveState.getMember(mSession!!.myUserId)
val member = mRoom!!.state.getMember(mSession!!.myUserId)

if (null == member || !TextUtils.equals(RoomMember.MEMBERSHIP_JOIN, member.membership)) {
sendError(getString(R.string.widget_integration_must_be_in_room), eventData)
Expand All @@ -302,7 +302,7 @@ class IntegrationManagerActivity : AbstractWidgetActivity() {

Log.d(LOG_TAG, "## canSendEvent() : eventType $eventType isState $isState")

val powerLevels = mRoom!!.liveState.powerLevels
val powerLevels = mRoom!!.state.powerLevels

val userPowerLevel = powerLevels!!.getUserPowerLevel(mSession!!.myUserId)

Expand Down Expand Up @@ -374,7 +374,7 @@ class IntegrationManagerActivity : AbstractWidgetActivity() {
}

Log.d(LOG_TAG, "Received request join rules in room " + mRoom!!.roomId)
val joinedEvents = mRoom!!.liveState.getStateEvents(HashSet(Arrays.asList(Event.EVENT_TYPE_STATE_ROOM_JOIN_RULES)))
val joinedEvents = mRoom!!.state.getStateEvents(HashSet(Arrays.asList(Event.EVENT_TYPE_STATE_ROOM_JOIN_RULES)))

if (joinedEvents.size > 0) {
Log.d(LOG_TAG, "Received request join rules returns " + joinedEvents[joinedEvents.size - 1])
Expand Down Expand Up @@ -424,7 +424,7 @@ class IntegrationManagerActivity : AbstractWidgetActivity() {

Log.d(LOG_TAG, "Received request to get options for bot " + userId + " in room " + mRoom!!.roomId + " requested")

val stateEvents = mRoom!!.liveState.getStateEvents(HashSet(Arrays.asList(Event.EVENT_TYPE_ROOM_BOT_OPTIONS)))
val stateEvents = mRoom!!.state.getStateEvents(HashSet(Arrays.asList(Event.EVENT_TYPE_ROOM_BOT_OPTIONS)))

var botOptionsEvent: Event? = null
val stateKey = "_$userId"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1606,8 +1606,8 @@ public void onPreviewRoom(MXSession session, String roomId) {
String roomAlias = null;

Room room = session.getDataHandler().getRoom(roomId);
if ((null != room) && (null != room.getLiveState())) {
roomAlias = room.getLiveState().getAlias();
if ((null != room) && (null != room.getState())) {
roomAlias = room.getState().getAlias();
}

final RoomPreviewData roomPreviewData = new RoomPreviewData(mSession, roomId, null, roomAlias, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ public void onClick(DialogInterface dialog, int which) {
case ITEM_ACTION_SET_DEFAULT_POWER_LEVEL:
if (null != mRoom) {
int defaultPowerLevel = 0;
PowerLevels powerLevels = mRoom.getLiveState().getPowerLevels();
PowerLevels powerLevels = mRoom.getState().getPowerLevels();

if (null != powerLevels) {
defaultPowerLevel = powerLevels.users_default;
Expand Down Expand Up @@ -746,7 +746,7 @@ private boolean populateDevicesListAdapter(MXUsersDevicesMap<MXDeviceInfo> aDevi
* @param callback the callback with the created event
*/
private void updateUserPowerLevels(final String userId, final int newPowerLevel, final ApiCallback<Void> callback) {
PowerLevels powerLevels = mRoom.getLiveState().getPowerLevels();
PowerLevels powerLevels = mRoom.getState().getPowerLevels();
int currentSelfPowerLevel = 0;

if (null != powerLevels) {
Expand Down Expand Up @@ -826,7 +826,7 @@ private List<Integer> supportedActionsList() {
int adminCount = 0;

if (null != mRoom) {
powerLevels = mRoom.getLiveState().getPowerLevels();
powerLevels = mRoom.getState().getPowerLevels();
}

mMemberAvatarBadgeImageView.setVisibility(View.GONE);
Expand Down
26 changes: 13 additions & 13 deletions vector/src/main/java/im/vector/activity/VectorRoomActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -1711,7 +1711,7 @@ private boolean isUserAllowedToStartConfCall() {
Log.d(LOG_TAG, "## isUserAllowedToStartConfCall(): conference in progress");
isAllowed = true;
} else if ((null != mRoom) && (mRoom.getActiveMembers().size() > 2)) {
PowerLevels powerLevels = mRoom.getLiveState().getPowerLevels();
PowerLevels powerLevels = mRoom.getState().getPowerLevels();

if (null != powerLevels) {
// to start a conf call, the user MUST have the power to invite someone (CFU)
Expand Down Expand Up @@ -3099,9 +3099,9 @@ public void onClick(View view) {
private boolean canSendMessages() {
boolean canSendMessage = false;

if ((null != mRoom) && (null != mRoom.getLiveState())) {
if ((null != mRoom) && (null != mRoom.getState())) {
canSendMessage = true;
PowerLevels powerLevels = mRoom.getLiveState().getPowerLevels();
PowerLevels powerLevels = mRoom.getState().getPowerLevels();

if (null != powerLevels) {
canSendMessage = powerLevels.maySendMessage(mMyUserId);
Expand All @@ -3115,7 +3115,7 @@ private boolean canSendMessages() {
* Check if the user can send a message in this room
*/
private void checkSendEventStatus() {
if ((null != mRoom) && (null != mRoom.getLiveState())) {
if ((null != mRoom) && (null != mRoom.getState())) {
boolean canSendMessage = canSendMessages();
mSendingMessagesLayout.setVisibility(canSendMessage ? View.VISIBLE : View.GONE);
mCanNotPostTextView.setVisibility(!canSendMessage ? View.VISIBLE : View.GONE);
Expand Down Expand Up @@ -3265,10 +3265,10 @@ private void manageBannedHeader(RoomMember member) {

if (TextUtils.equals(member.membership, RoomMember.MEMBERSHIP_BAN)) {
invitationTextView.setText(getString(R.string.has_been_banned,
VectorUtils.getRoomDisplayName(this, mSession, mRoom), mRoom.getLiveState().getMemberName(member.mSender)));
VectorUtils.getRoomDisplayName(this, mSession, mRoom), mRoom.getState().getMemberName(member.mSender)));
} else {
invitationTextView.setText(getString(R.string.has_been_kicked,
VectorUtils.getRoomDisplayName(this, mSession, mRoom), mRoom.getLiveState().getMemberName(member.mSender)));
VectorUtils.getRoomDisplayName(this, mSession, mRoom), mRoom.getState().getMemberName(member.mSender)));
}

TextView subInvitationTextView = findViewById(R.id.room_preview_subinvitation_textview);
Expand Down Expand Up @@ -3764,7 +3764,7 @@ private void onRoomTitleClick() {
titleText.setText(R.string.room_info_room_name);

final EditText textInput = dialogView.findViewById(R.id.dialog_edit_text);
textInput.setText(mRoom.getLiveState().name);
textInput.setText(mRoom.getState().name);

// set dialog message
alertDialogBuilder
Expand Down Expand Up @@ -3831,7 +3831,7 @@ private void onRoomTopicClick() {
titleText.setText(R.string.room_info_room_topic);

final EditText textInput = dialogView.findViewById(R.id.dialog_edit_text);
textInput.setText(mRoom.getLiveState().topic);
textInput.setText(mRoom.getState().topic);

// set dialog message
alertDialogBuilder
Expand Down Expand Up @@ -3890,7 +3890,7 @@ private void addRoomHeaderClickListeners() {
@Override
public void onClick(View v) {
// sanity checks : reported by GA
if ((null != mRoom) && (null != mRoom.getLiveState())) {
if ((null != mRoom) && (null != mRoom.getState())) {
if (MatrixSdkExtensionsKt.isPowerLevelEnoughForAvatarUpdate(mRoom, mSession)) {
// need to check if the camera permission has been granted
if (CommonActivityUtils.checkPermissions(CommonActivityUtils.REQUEST_CODE_PERMISSION_ROOM_DETAILS, VectorRoomActivity.this)) {
Expand All @@ -3914,9 +3914,9 @@ public void onClick(View v) {
@Override
public void onClick(View v) {
// sanity checks : reported by GA
if ((null != mRoom) && (null != mRoom.getLiveState())) {
if ((null != mRoom) && (null != mRoom.getState())) {
boolean canUpdateTitle = false;
PowerLevels powerLevels = mRoom.getLiveState().getPowerLevels();
PowerLevels powerLevels = mRoom.getState().getPowerLevels();

if (null != powerLevels) {
int powerLevel = powerLevels.getUserPowerLevel(mSession.getMyUserId());
Expand All @@ -3941,9 +3941,9 @@ public void onClick(View v) {
@Override
public void onClick(View v) {
// sanity checks : reported by GA
if ((null != mRoom) && (null != mRoom.getLiveState())) {
if ((null != mRoom) && (null != mRoom.getState())) {
boolean canUpdateTopic = false;
PowerLevels powerLevels = mRoom.getLiveState().getPowerLevels();
PowerLevels powerLevels = mRoom.getState().getPowerLevels();

if (null != powerLevels) {
int powerLevel = powerLevels.getUserPowerLevel(mSession.getMyUserId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ private void finish(final List<ParticipantAdapterItem> participantAdapterItems)
// if a room is defined
if (null != mRoom) {
// the room members must not be added again
Collection<RoomMember> members = mRoom.getLiveState().getDisplayableMembers();
Collection<RoomMember> members = mRoom.getState().getDisplayableMembers();
for (RoomMember member : members) {
if (TextUtils.equals(member.membership, RoomMember.MEMBERSHIP_JOIN) || TextUtils.equals(member.membership, RoomMember.MEMBERSHIP_INVITE)) {
hiddenUserIds.add(member.getUserId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2569,8 +2569,8 @@ private void onMessageClick(final Event event, final String textMsg, final View
// need the minimum power level to redact an event
Room room = mSession.getDataHandler().getRoom(event.roomId);

if ((null != room) && (null != room.getLiveState().getPowerLevels())) {
PowerLevels powerLevels = room.getLiveState().getPowerLevels();
if ((null != room) && (null != room.getState().getPowerLevels())) {
PowerLevels powerLevels = room.getState().getPowerLevels();
canBeRedacted = powerLevels.getUserPowerLevel(mSession.getMyUserId()) >= powerLevels.redact;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,11 +225,11 @@ public void onClick(View v) {
*/
private void refreshGroupFlairView(final View groupFlairView, final Event event, final Set<String> groupIdsSet, final String tag) {
Log.d(LOG_TAG, "## refreshGroupFlairView () : " + event.sender + " allows flair to " + groupIdsSet);
Log.d(LOG_TAG, "## refreshGroupFlairView () : room related groups " + mRoom.getLiveState().getRelatedGroups());
Log.d(LOG_TAG, "## refreshGroupFlairView () : room related groups " + mRoom.getState().getRelatedGroups());

if (!groupIdsSet.isEmpty()) {
// keeps only the intersections
groupIdsSet.retainAll(mRoom.getLiveState().getRelatedGroups());
groupIdsSet.retainAll(mRoom.getState().getRelatedGroups());
}

Log.d(LOG_TAG, "## refreshGroupFlairView () : group ids to display " + groupIdsSet);
Expand Down Expand Up @@ -363,7 +363,7 @@ private void refreshGroupFlairView(final View groupFlairView, final Event event)
}

// Check whether there are some related groups to this room
if (mRoom.getLiveState().getRelatedGroups().isEmpty()) {
if (mRoom.getState().getRelatedGroups().isEmpty()) {
Log.d(LOG_TAG, "## refreshGroupFlairView () : no related group");
groupFlairView.setVisibility(View.GONE);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ private void fillUsedMembersList() {
Room fromRoom = store.getRoom(mRoomId);

if (null != fromRoom) {
Collection<RoomMember> members = fromRoom.getLiveState().getDisplayableMembers();
Collection<RoomMember> members = fromRoom.getState().getDisplayableMembers();
for (RoomMember member : members) {
if (TextUtils.equals(member.membership, RoomMember.MEMBERSHIP_JOIN) || TextUtils.equals(member.membership, RoomMember.MEMBERSHIP_INVITE)) {
mUsedMemberUserIds.add(member.getUserId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ public void run() {

Collection<RoomMember> activeMembers = mRoom.getActiveMembers();
String myUserId = mSession.getMyUserId();
final PowerLevels powerLevels = mRoom.getLiveState().getPowerLevels();
final PowerLevels powerLevels = mRoom.getState().getPowerLevels();

// search loop to extract the following members: current user, invited, administrator and others
for (RoomMember member : activeMembers) {
Expand Down Expand Up @@ -348,11 +348,11 @@ public void run() {
}

// add 3rd party invite
Collection<RoomThirdPartyInvite> thirdPartyInvites = mRoom.getLiveState().thirdPartyInvites();
Collection<RoomThirdPartyInvite> thirdPartyInvites = mRoom.getState().thirdPartyInvites();

for (RoomThirdPartyInvite invite : thirdPartyInvites) {
// If the home server has converted the 3pid invite into a room member, do not show it
if (null == mRoom.getLiveState().memberWithThirdPartyInviteToken(invite.token)) {
if (null == mRoom.getState().memberWithThirdPartyInviteToken(invite.token)) {
ParticipantAdapterItem participant = new ParticipantAdapterItem(invite.display_name, "", null, true);

if ((!isSearchEnabled) || participant.contains(mSearchPattern)) {
Expand Down Expand Up @@ -754,7 +754,7 @@ public View getChildView(final int aGroupPosition, final int aChildPosition, boo

PowerLevels powerLevels = null;
if (null != mRoom) {
if (null != (powerLevels = mRoom.getLiveState().getPowerLevels())) {
if (null != (powerLevels = mRoom.getState().getPowerLevels())) {
if (powerLevels.getUserPowerLevel(participant.mUserId) >= CommonActivityUtils.UTILS_POWER_LEVEL_ADMIN) {
viewHolder.mMemberAvatarBadgeImageView.setVisibility(View.VISIBLE);
viewHolder.mMemberAvatarBadgeImageView.setImageResource(R.drawable.admin_icon);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public View getView(int position, View convertView2, ViewGroup parent) {
RoomState roomState = row.getRoomState();

if (null == roomState) {
roomState = room.getLiveState();
roomState = room.getState();
}

// refresh the avatar
Expand All @@ -127,7 +127,7 @@ public View getView(int position, View convertView2, ViewGroup parent) {
// display the body
TextView bodyTextView = convertView.findViewById(R.id.messagesAdapter_body);
// set the message text
EventDisplay display = new RiotEventDisplay(mContext, event, (null != room) ? room.getLiveState() : null);
EventDisplay display = new RiotEventDisplay(mContext, event, (null != room) ? room.getState() : null);
CharSequence text = display.getTextualDisplay();

if (null == text) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1111,7 +1111,7 @@ public void onAvatarClick(String userId) {
public boolean onAvatarLongClick(String userId) {
if (getActivity() instanceof VectorRoomActivity) {
try {
RoomState state = mRoom.getLiveState();
RoomState state = mRoom.getState();

if (null != state) {
String displayName = state.getMemberName(userId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -684,8 +684,8 @@ public void onPreviewRoom(MXSession session, String roomId) {
String roomAlias = null;

Room room = session.getDataHandler().getRoom(roomId);
if ((null != room) && (null != room.getLiveState())) {
roomAlias = room.getLiveState().getAlias();
if ((null != room) && (null != room.getState())) {
roomAlias = room.getState().getAlias();
}

final RoomPreviewData roomPreviewData = new RoomPreviewData(mSession, roomId, null, roomAlias, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ private boolean isUserAdmin() {
if ((null != mRoom) && (null != mSession)) {
PowerLevels powerLevels;

if (null != (powerLevels = mRoom.getLiveState().getPowerLevels())) {
if (null != (powerLevels = mRoom.getState().getPowerLevels())) {
String userId = mSession.getMyUserId();
isAdmin = (null != userId) && (powerLevels.getUserPowerLevel(userId) >= CommonActivityUtils.UTILS_POWER_LEVEL_ADMIN);
}
Expand Down
Loading