Commit 06fa294b authored by Leonardo Aramaki's avatar Leonardo Aramaki

Add support to custom room types fallbacking to group if not any of the defaults: p, c, d or l

parent 906cabca
...@@ -179,7 +179,7 @@ object RestApiHelper { ...@@ -179,7 +179,7 @@ object RestApiHelper {
var restApiUrl: String? = null var restApiUrl: String? = null
when (roomType) { when (roomType) {
Room.TYPE_CHANNEL -> restApiUrl = "/api/v1/channels.messages" Room.TYPE_CHANNEL -> restApiUrl = "/api/v1/channels.messages"
Room.TYPE_PRIVATE -> restApiUrl = "/api/v1/groups.messages" Room.TYPE_GROUP -> restApiUrl = "/api/v1/groups.messages"
Room.TYPE_DIRECT_MESSAGE -> restApiUrl = "/api/v1/dm.messages" Room.TYPE_DIRECT_MESSAGE -> restApiUrl = "/api/v1/dm.messages"
} }
return restApiUrl return restApiUrl
...@@ -195,7 +195,7 @@ object RestApiHelper { ...@@ -195,7 +195,7 @@ object RestApiHelper {
var restApiUrl: String? = null var restApiUrl: String? = null
when (roomType) { when (roomType) {
Room.TYPE_CHANNEL -> restApiUrl = "/api/v1/channels.files" Room.TYPE_CHANNEL -> restApiUrl = "/api/v1/channels.files"
Room.TYPE_PRIVATE -> restApiUrl = "/api/v1/groups.files" Room.TYPE_GROUP -> restApiUrl = "/api/v1/groups.files"
Room.TYPE_DIRECT_MESSAGE -> restApiUrl = "/api/v1/dm.files" Room.TYPE_DIRECT_MESSAGE -> restApiUrl = "/api/v1/dm.files"
} }
return restApiUrl return restApiUrl
...@@ -211,7 +211,7 @@ object RestApiHelper { ...@@ -211,7 +211,7 @@ object RestApiHelper {
var restApiUrl: String? = null var restApiUrl: String? = null
when (roomType) { when (roomType) {
Room.TYPE_CHANNEL -> restApiUrl = "/api/v1/channels.members" Room.TYPE_CHANNEL -> restApiUrl = "/api/v1/channels.members"
Room.TYPE_PRIVATE -> restApiUrl = "/api/v1/groups.members" Room.TYPE_GROUP -> restApiUrl = "/api/v1/groups.members"
Room.TYPE_DIRECT_MESSAGE -> restApiUrl = "/api/v1/dm.members" Room.TYPE_DIRECT_MESSAGE -> restApiUrl = "/api/v1/dm.members"
} }
return restApiUrl return restApiUrl
......
...@@ -23,14 +23,14 @@ public class ChannelRoomListHeader implements RoomListHeader { ...@@ -23,14 +23,14 @@ public class ChannelRoomListHeader implements RoomListHeader {
@Override @Override
public boolean owns(RoomSidebar roomSidebar) { public boolean owns(RoomSidebar roomSidebar) {
return roomSidebar.getType().equals(Room.TYPE_CHANNEL) || roomSidebar.getType().equals(Room.TYPE_PRIVATE); return roomSidebar.getType().equals(Room.TYPE_CHANNEL) || roomSidebar.getType().equals(Room.TYPE_GROUP);
} }
@Override @Override
public boolean shouldShow(@NonNull List<RoomSidebar> roomSidebarList) { public boolean shouldShow(@NonNull List<RoomSidebar> roomSidebarList) {
for (RoomSidebar roomSidebar: roomSidebarList) { for (RoomSidebar roomSidebar: roomSidebarList) {
if ((roomSidebar.getType().equals(Room.TYPE_CHANNEL) if ((roomSidebar.getType().equals(Room.TYPE_CHANNEL)
|| roomSidebar.getType().equals(Room.TYPE_PRIVATE)) || roomSidebar.getType().equals(Room.TYPE_GROUP))
&& !roomSidebar.isAlert() && !roomSidebar.isAlert()
&& !roomSidebar.isFavorite()) { && !roomSidebar.isFavorite()) {
return true; return true;
......
...@@ -93,7 +93,7 @@ public class RoomListItemViewHolder extends RecyclerView.ViewHolder { ...@@ -93,7 +93,7 @@ public class RoomListItemViewHolder extends RecyclerView.ViewHolder {
case Room.TYPE_CHANNEL: case Room.TYPE_CHANNEL:
itemView.showPublicChannelIcon(); itemView.showPublicChannelIcon();
break; break;
case Room.TYPE_PRIVATE: case Room.TYPE_GROUP:
itemView.showPrivateChannelIcon(); itemView.showPrivateChannelIcon();
break; break;
case Room.TYPE_LIVECHAT: case Room.TYPE_LIVECHAT:
......
...@@ -6,7 +6,7 @@ import com.google.auto.value.AutoValue; ...@@ -6,7 +6,7 @@ import com.google.auto.value.AutoValue;
public abstract class Room { public abstract class Room {
public static final String TYPE_CHANNEL = "c"; public static final String TYPE_CHANNEL = "c";
public static final String TYPE_PRIVATE = "p"; public static final String TYPE_GROUP = "p";
public static final String TYPE_DIRECT_MESSAGE = "d"; public static final String TYPE_DIRECT_MESSAGE = "d";
public static final String TYPE_LIVECHAT = "l"; public static final String TYPE_LIVECHAT = "l";
...@@ -35,7 +35,7 @@ public abstract class Room { ...@@ -35,7 +35,7 @@ public abstract class Room {
} }
public boolean isPrivate() { public boolean isPrivate() {
return TYPE_PRIVATE.equals(getType()); return TYPE_GROUP.equals(getType());
} }
public boolean isDirectMessage() { public boolean isDirectMessage() {
......
...@@ -2,9 +2,10 @@ package chat.rocket.core.models ...@@ -2,9 +2,10 @@ package chat.rocket.core.models
class RoomSidebar { class RoomSidebar {
lateinit var id: String lateinit var id: String
lateinit var roomId: String
lateinit var roomName: String lateinit var roomName: String
lateinit var type: String lateinit var roomId: String
var type: String? = null
get() = RoomType.get(field) ?: Room.TYPE_GROUP
var userStatus: String? = null var userStatus: String? = null
var isAlert: Boolean = false var isAlert: Boolean = false
var isFavorite: Boolean = false var isFavorite: Boolean = false
......
package chat.rocket.core.models;
import org.jetbrains.annotations.Nullable;
public enum RoomType {
CHANNEL("c"),
GROUP("p"),
DIRECT_MESSAGE("d"),
LIVECHAT("l")
;
private final String type;
RoomType(String type) {
this.type = type;
}
@Nullable
public static String get(@Nullable String type) {
for (RoomType roomType : RoomType.values()) {
if (roomType.type.equals(type)) {
return roomType.type;
}
}
return null;
}
}
...@@ -16,7 +16,7 @@ public abstract class SpotlightRoom { ...@@ -16,7 +16,7 @@ public abstract class SpotlightRoom {
} }
public boolean isPrivate() { public boolean isPrivate() {
return Room.TYPE_PRIVATE.equals(getType()); return Room.TYPE_GROUP.equals(getType());
} }
public boolean isDirectMessage() { public boolean isDirectMessage() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment