Commit 3f81ab38 authored by Lucio Maciel's avatar Lucio Maciel

(Initial) support for livechat channels. Fix crash on 1.0.18

parent ef6cf99d
...@@ -33,6 +33,10 @@ abstract class AbstractChatRoomFragment extends AbstractFragment { ...@@ -33,6 +33,10 @@ abstract class AbstractChatRoomFragment extends AbstractFragment {
roomToolbar.showPublicChannelIcon(); roomToolbar.showPublicChannelIcon();
} }
protected void showToolbarLivechatChannelIcon() {
roomToolbar.showLivechatChannelIcon();
}
protected void showToolbarUserStatuslIcon(@Nullable String status) { protected void showToolbarUserStatuslIcon(@Nullable String status) {
if (status == null) { if (status == null) {
roomToolbar.showUserStatusIcon(RoomToolbar.STATUS_OFFLINE); roomToolbar.showUserStatusIcon(RoomToolbar.STATUS_OFFLINE);
......
...@@ -586,6 +586,10 @@ public class RoomFragment extends AbstractChatRoomFragment implements ...@@ -586,6 +586,10 @@ public class RoomFragment extends AbstractChatRoomFragment implements
if (room.isPrivate()) { if (room.isPrivate()) {
showToolbarPrivateChannelIcon(); showToolbarPrivateChannelIcon();
} }
if (room.isLivechat()) {
showToolbarLivechatChannelIcon();
}
} }
@Override @Override
......
...@@ -24,6 +24,7 @@ import chat.rocket.android.helper.Logger; ...@@ -24,6 +24,7 @@ import chat.rocket.android.helper.Logger;
import chat.rocket.android.layouthelper.chatroom.roomlist.ChannelRoomListHeader; import chat.rocket.android.layouthelper.chatroom.roomlist.ChannelRoomListHeader;
import chat.rocket.android.layouthelper.chatroom.roomlist.DirectMessageRoomListHeader; import chat.rocket.android.layouthelper.chatroom.roomlist.DirectMessageRoomListHeader;
import chat.rocket.android.layouthelper.chatroom.roomlist.FavoriteRoomListHeader; import chat.rocket.android.layouthelper.chatroom.roomlist.FavoriteRoomListHeader;
import chat.rocket.android.layouthelper.chatroom.roomlist.LivechatRoomListHeader;
import chat.rocket.android.layouthelper.chatroom.roomlist.RoomListAdapter; import chat.rocket.android.layouthelper.chatroom.roomlist.RoomListAdapter;
import chat.rocket.android.layouthelper.chatroom.roomlist.RoomListHeader; import chat.rocket.android.layouthelper.chatroom.roomlist.RoomListHeader;
import chat.rocket.android.layouthelper.chatroom.roomlist.UnreadRoomListHeader; import chat.rocket.android.layouthelper.chatroom.roomlist.UnreadRoomListHeader;
...@@ -237,6 +238,10 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain ...@@ -237,6 +238,10 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain
getString(R.string.fragment_sidebar_main_favorite_title) getString(R.string.fragment_sidebar_main_favorite_title)
)); ));
roomListHeaders.add(new LivechatRoomListHeader(
getString(R.string.fragment_sidebar_main_livechat_title)
));
roomListHeaders.add(new ChannelRoomListHeader( roomListHeaders.add(new ChannelRoomListHeader(
getString(R.string.fragment_sidebar_main_channels_title), getString(R.string.fragment_sidebar_main_channels_title),
() -> showAddRoomDialog(AddChannelDialogFragment.create(hostname)) () -> showAddRoomDialog(AddChannelDialogFragment.create(hostname))
......
package chat.rocket.android.layouthelper.chatroom.roomlist;
import android.support.annotation.NonNull;
import java.util.List;
import chat.rocket.core.models.Room;
import chat.rocket.core.models.RoomSidebar;
public class LivechatRoomListHeader implements RoomListHeader {
private final String title;
public LivechatRoomListHeader(String title) {
this.title = title;
}
@Override
public String getTitle() {
return title;
}
@Override
public boolean owns(RoomSidebar roomSidebar) {
return Room.TYPE_LIVECHAT.equals(roomSidebar.getType());
}
@Override
public boolean shouldShow(@NonNull List<RoomSidebar> roomSidebarList) {
for (RoomSidebar roomSidebar: roomSidebarList) {
if (owns(roomSidebar)) {
return true;
}
}
return false;
}
@Override
public ClickListener getClickListener() {
return null;
}
}
\ No newline at end of file
...@@ -95,6 +95,9 @@ public class RoomListItemViewHolder extends RecyclerView.ViewHolder { ...@@ -95,6 +95,9 @@ public class RoomListItemViewHolder extends RecyclerView.ViewHolder {
case Room.TYPE_PRIVATE: case Room.TYPE_PRIVATE:
itemView.showPrivateChannelIcon(); itemView.showPrivateChannelIcon();
break; break;
case Room.TYPE_LIVECHAT:
itemView.showLivechatChannelIcon();
break;
default: default:
throw new AssertionError("Room type doesn't satisfies the method documentation. Room type is:" + roomType); throw new AssertionError("Room type doesn't satisfies the method documentation. Room type is:" + roomType);
} }
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
<string name="fragment_sidebar_main_favorite_title">FAVORITES</string> <string name="fragment_sidebar_main_favorite_title">FAVORITES</string>
<string name="fragment_sidebar_main_channels_title">CHANNELS</string> <string name="fragment_sidebar_main_channels_title">CHANNELS</string>
<string name="fragment_sidebar_main_direct_messages_title">DIRECT MESSAGES</string> <string name="fragment_sidebar_main_direct_messages_title">DIRECT MESSAGES</string>
<string name="fragment_sidebar_main_livechat_title">LIVECHAT</string>
<string name="user_status_online">Online</string> <string name="user_status_online">Online</string>
<string name="user_status_away">Away</string> <string name="user_status_away">Away</string>
<string name="user_status_busy">Busy</string> <string name="user_status_busy">Busy</string>
......
...@@ -29,6 +29,7 @@ public class RoomToolbar extends Toolbar { ...@@ -29,6 +29,7 @@ public class RoomToolbar extends Toolbar {
private Drawable privateChannelDrawable; private Drawable privateChannelDrawable;
private Drawable publicChannelDrawable; private Drawable publicChannelDrawable;
private Drawable livechatChannelDrawable;
private Drawable userStatusDrawable; private Drawable userStatusDrawable;
private DrawerArrowDrawable drawerArrowDrawable; private DrawerArrowDrawable drawerArrowDrawable;
...@@ -63,6 +64,7 @@ public class RoomToolbar extends Toolbar { ...@@ -63,6 +64,7 @@ public class RoomToolbar extends Toolbar {
privateChannelDrawable = VectorDrawableCompat.create(getResources(), R.drawable.ic_lock_white_24dp, null); privateChannelDrawable = VectorDrawableCompat.create(getResources(), R.drawable.ic_lock_white_24dp, null);
publicChannelDrawable = VectorDrawableCompat.create(getResources(), R.drawable.ic_hashtag_white_24dp, null); publicChannelDrawable = VectorDrawableCompat.create(getResources(), R.drawable.ic_hashtag_white_24dp, null);
livechatChannelDrawable = VectorDrawableCompat.create(getResources(), R.drawable.ic_livechat_white_24dp, null);
userStatusDrawable = VectorDrawableCompat.create(getResources(), R.drawable.ic_user_status_black_24dp, null); userStatusDrawable = VectorDrawableCompat.create(getResources(), R.drawable.ic_user_status_black_24dp, null);
} }
...@@ -102,6 +104,12 @@ public class RoomToolbar extends Toolbar { ...@@ -102,6 +104,12 @@ public class RoomToolbar extends Toolbar {
roomTypeImage.setVisibility(VISIBLE); roomTypeImage.setVisibility(VISIBLE);
} }
public void showLivechatChannelIcon() {
roomTypeImage.setImageDrawable(livechatChannelDrawable);
userStatusImage.setVisibility(GONE);
roomTypeImage.setVisibility(VISIBLE);
}
public void showUserStatusIcon(int status) { public void showUserStatusIcon(int status) {
DrawableHelper.INSTANCE.wrapDrawable(userStatusDrawable); DrawableHelper.INSTANCE.wrapDrawable(userStatusDrawable);
......
...@@ -29,6 +29,7 @@ class RoomListItemView : FrameLayout { ...@@ -29,6 +29,7 @@ class RoomListItemView : FrameLayout {
lateinit private var alertCountText: TextView lateinit private var alertCountText: TextView
lateinit private var privateChannelDrawable: Drawable lateinit private var privateChannelDrawable: Drawable
lateinit private var publicChannelDrawable: Drawable lateinit private var publicChannelDrawable: Drawable
lateinit private var livechatChannelDrawable: Drawable
lateinit private var userStatusDrawable: Drawable lateinit private var userStatusDrawable: Drawable
constructor(context: Context) : super(context) { constructor(context: Context) : super(context) {
...@@ -67,6 +68,7 @@ class RoomListItemView : FrameLayout { ...@@ -67,6 +68,7 @@ class RoomListItemView : FrameLayout {
privateChannelDrawable = VectorDrawableCompat.create(resources, R.drawable.ic_lock_white_24dp, null)!! privateChannelDrawable = VectorDrawableCompat.create(resources, R.drawable.ic_lock_white_24dp, null)!!
publicChannelDrawable = VectorDrawableCompat.create(resources, R.drawable.ic_hashtag_white_24dp, null)!! publicChannelDrawable = VectorDrawableCompat.create(resources, R.drawable.ic_hashtag_white_24dp, null)!!
livechatChannelDrawable = VectorDrawableCompat.create(resources, R.drawable.ic_livechat_white_24dp, null)!!
userStatusDrawable = VectorDrawableCompat.create(resources, R.drawable.ic_user_status_black_24dp, null)!! userStatusDrawable = VectorDrawableCompat.create(resources, R.drawable.ic_user_status_black_24dp, null)!!
} }
...@@ -103,6 +105,12 @@ class RoomListItemView : FrameLayout { ...@@ -103,6 +105,12 @@ class RoomListItemView : FrameLayout {
roomTypeImage.visibility = View.VISIBLE roomTypeImage.visibility = View.VISIBLE
} }
fun showLivechatChannelIcon() {
roomTypeImage.setImageDrawable(livechatChannelDrawable)
userStatusImage.visibility = View.GONE
roomTypeImage.visibility = View.VISIBLE
}
fun showOnlineUserStatusIcon() { fun showOnlineUserStatusIcon() {
prepareDrawableAndShow(R.color.color_user_status_online) prepareDrawableAndShow(R.color.color_user_status_online)
} }
......
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24"
android:viewportWidth="24">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M 15.274 6.595 C 14.884 4.095 12.724 2.234 10.029 2.234 C 7.049 2.234 4.715 4.506 4.715 7.407 L 4.715 7.669 C 4.714 7.685 4.71 7.701 4.71 7.719 L 4.71 12.84 C 3.363 12.746 2.317 11.627 2.313 10.277 C 2.313 9.344 2.819 8.484 3.634 8.03 C 3.898 7.871 3.988 7.531 3.838 7.262 C 3.688 6.993 3.352 6.891 3.078 7.031 C 1.9 7.687 1.17 8.929 1.17 10.277 C 1.172 12.327 2.834 13.989 4.884 13.991 C 5.011 13.991 5.14 13.981 5.269 13.968 L 5.281 13.968 C 5.3 13.968 5.317 13.965 5.335 13.964 L 5.339 13.964 C 5.631 13.935 5.853 13.69 5.853 13.397 L 5.853 8.344 C 5.855 8.327 5.858 8.311 5.858 8.294 L 5.858 7.407 C 5.858 5.109 7.651 3.377 10.029 3.377 C 12.407 3.377 14.2 5.108 14.2 7.406 L 14.2 7.643 C 14.197 7.667 14.193 7.692 14.193 7.718 L 14.193 13.237 C 14.192 13.252 14.189 13.267 14.189 13.281 L 14.189 14.567 C 14.189 15.445 13.575 16.058 12.697 16.058 L 11.927 16.058 L 11.911 16.06 C 11.692 15.484 11.14 15.102 10.523 15.1 L 9.543 15.1 C 8.72 15.102 8.054 15.768 8.053 16.591 C 8.053 17.414 8.721 18.081 9.543 18.082 L 10.523 18.082 C 11.129 18.082 11.649 17.717 11.883 17.196 C 11.898 17.198 11.912 17.202 11.928 17.202 L 12.698 17.202 C 14.224 17.202 15.331 16.093 15.331 14.567 L 15.331 14.008 C 17.312 13.916 18.872 12.285 18.875 10.302 C 18.872 8.297 17.278 6.656 15.274 6.594 Z M 10.523 16.94 L 9.543 16.94 C 9.352 16.937 9.199 16.783 9.196 16.592 C 9.196 16.403 9.356 16.244 9.544 16.244 L 10.523 16.244 C 10.711 16.244 10.871 16.404 10.871 16.592 C 10.871 16.781 10.711 16.94 10.523 16.94 Z M 15.336 12.866 L 15.336 8.369 C 15.339 8.344 15.343 8.319 15.343 8.294 L 15.343 7.741 C 16.688 7.836 17.731 8.955 17.733 10.303 C 17.733 11.663 16.673 12.776 15.336 12.866 Z" />
</vector>
\ No newline at end of file
...@@ -8,6 +8,7 @@ public abstract class Room { ...@@ -8,6 +8,7 @@ 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_PRIVATE = "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 abstract String getId(); public abstract String getId();
...@@ -41,6 +42,10 @@ public abstract class Room { ...@@ -41,6 +42,10 @@ public abstract class Room {
return TYPE_DIRECT_MESSAGE.equals(getType()); return TYPE_DIRECT_MESSAGE.equals(getType());
} }
public boolean isLivechat() {
return TYPE_LIVECHAT.equals(getType());
}
public static Builder builder() { public static Builder builder() {
return new AutoValue_Room.Builder(); return new AutoValue_Room.Builder();
} }
......
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