Commit 5766fa21 authored by Filipe de Lima Brito's avatar Filipe de Lima Brito

Merge branch 'local-spotlight' of...

Merge branch 'local-spotlight' of github.com:filipedelimabrito/Rocket.Chat.Android into local-spotlight
parents 30fdb3bc a0e2abf6
......@@ -4,7 +4,6 @@ import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.Snackbar;
import android.support.v4.widget.SlidingPaneLayout;
import android.view.View;
import chat.rocket.android.LaunchUtil;
import chat.rocket.android.R;
......@@ -43,7 +42,6 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
setContentView(R.layout.activity_main);
toolbar = (RoomToolbar) findViewById(R.id.activity_main_toolbar);
statusTicker = new StatusTicker();
setupSidebar();
}
@Override
......@@ -63,48 +61,6 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
super.onPause();
}
private void setupSidebar() {
SlidingPaneLayout pane = (SlidingPaneLayout) findViewById(R.id.sliding_pane);
if (pane == null) {
return;
}
final SlidingPaneLayout subPane = (SlidingPaneLayout) findViewById(R.id.sub_sliding_pane);
pane.setPanelSlideListener(new SlidingPaneLayout.SimplePanelSlideListener() {
@Override
public void onPanelClosed(View panel) {
super.onPanelClosed(panel);
if (subPane != null) {
subPane.closePane();
}
}
});
toolbar.setNavigationOnClickListener(view -> {
if (pane.isSlideable() && !pane.isOpen()) {
pane.openPane();
}
});
//ref: ActionBarDrawerToggle#setProgress
pane.setPanelSlideListener(new SlidingPaneLayout.PanelSlideListener() {
@Override
public void onPanelSlide(View panel, float slideOffset) {
toolbar.setNavigationIconProgress(slideOffset);
}
@Override
public void onPanelOpened(View panel) {
toolbar.setNavigationIconVerticalMirror(true);
}
@Override
public void onPanelClosed(View panel) {
toolbar.setNavigationIconVerticalMirror(false);
closeUserActionContainer();
}
});
}
private boolean closeSidebarIfNeeded() {
// REMARK: Tablet UI doesn't have SlidingPane!
......@@ -156,14 +112,6 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
.commit();
}
private void closeUserActionContainer() {
SidebarMainFragment sidebarFragment = (SidebarMainFragment) getSupportFragmentManager()
.findFragmentById(R.id.sidebar_fragment_container);
if (sidebarFragment != null) {
sidebarFragment.closeUserActionContainer();
}
}
@Override
protected void onRoomIdUpdated() {
super.onRoomIdUpdated();
......
......@@ -33,6 +33,10 @@ abstract class AbstractChatRoomFragment extends AbstractFragment {
roomToolbar.showPublicChannelIcon();
}
protected void showToolbarLivechatChannelIcon() {
roomToolbar.showLivechatChannelIcon();
}
protected void showToolbarUserStatuslIcon(@Nullable String status) {
if (status == null) {
roomToolbar.showUserStatusIcon(RoomToolbar.STATUS_OFFLINE);
......
......@@ -21,6 +21,8 @@ import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import chat.rocket.android.fragment.sidebar.SidebarMainFragment;
import chat.rocket.android.widget.RoomToolbar;
import chat.rocket.core.models.User;
import java.lang.reflect.Field;
import java.util.ArrayList;
......@@ -125,6 +127,9 @@ public class RoomFragment extends AbstractChatRoomFragment implements
private Message edittingMessage = null;
private SlidingPaneLayout pane;
private SidebarMainFragment sidebarFragment;
public RoomFragment() {}
/**
......@@ -189,6 +194,7 @@ public class RoomFragment extends AbstractChatRoomFragment implements
@Override
protected void onSetupView() {
pane = getActivity().findViewById(R.id.sliding_pane);
messageRecyclerView = rootView.findViewById(R.id.messageRecyclerView);
messageListAdapter = new MessageListAdapter(getContext(), hostname);
......@@ -235,6 +241,7 @@ public class RoomFragment extends AbstractChatRoomFragment implements
}
};
setupSidebar();
setupSideMenu();
setupMessageComposer();
setupMessageActions();
......@@ -305,7 +312,6 @@ public class RoomFragment extends AbstractChatRoomFragment implements
});
DrawerLayout drawerLayout = rootView.findViewById(R.id.drawer_layout);
SlidingPaneLayout pane = getActivity().findViewById(R.id.sliding_pane);
if (drawerLayout != null && pane != null) {
compositeDisposable.add(RxDrawerLayout.drawerOpen(drawerLayout, GravityCompat.END)
.compose(bindToLifecycle())
......@@ -325,6 +331,45 @@ public class RoomFragment extends AbstractChatRoomFragment implements
}
}
private void setupSidebar() {
SlidingPaneLayout subPane = getActivity().findViewById(R.id.sub_sliding_pane);
RoomToolbar toolbar = getActivity().findViewById(R.id.activity_main_toolbar);
sidebarFragment = (SidebarMainFragment) getActivity().getSupportFragmentManager().findFragmentById(R.id.sidebar_fragment_container);
pane.setPanelSlideListener(new SlidingPaneLayout.PanelSlideListener() {
@Override
public void onPanelSlide(View view, float v) {
messageFormManager.enableComposingText(false);
sidebarFragment.clearSearchViewFocus();
//Ref: ActionBarDrawerToggle#setProgress
toolbar.setNavigationIconProgress(v);
}
@Override
public void onPanelOpened(View view) {
toolbar.setNavigationIconVerticalMirror(true);
}
@Override
public void onPanelClosed(View view) {
messageFormManager.enableComposingText(true);
toolbar.setNavigationIconVerticalMirror(false);
subPane.closePane();
closeUserActionContainer();
}
});
toolbar.setNavigationOnClickListener(view -> {
if (pane.isSlideable() && !pane.isOpen()) {
pane.openPane();
}
});
}
public void closeUserActionContainer() {
sidebarFragment.closeUserActionContainer();
}
private boolean closeSideMenuIfNeeded() {
DrawerLayout drawerLayout = rootView.findViewById(R.id.drawer_layout);
if (drawerLayout != null && drawerLayout.isDrawerOpen(GravityCompat.END)) {
......@@ -541,6 +586,10 @@ public class RoomFragment extends AbstractChatRoomFragment implements
if (room.isPrivate()) {
showToolbarPrivateChannelIcon();
}
if (room.isLivechat()) {
showToolbarLivechatChannelIcon();
}
}
@Override
......@@ -606,4 +655,4 @@ public class RoomFragment extends AbstractChatRoomFragment implements
edittingMessage = message;
messageFormManager.setEditMessage(message.getMessage());
}
}
}
\ No newline at end of file
......@@ -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.DirectMessageRoomListHeader;
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.RoomListHeader;
import chat.rocket.android.layouthelper.chatroom.roomlist.UnreadRoomListHeader;
......@@ -278,6 +279,10 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain
getString(R.string.fragment_sidebar_main_favorite_title)
));
roomListHeaders.add(new LivechatRoomListHeader(
getString(R.string.fragment_sidebar_main_livechat_title)
));
roomListHeaders.add(new ChannelRoomListHeader(
getString(R.string.fragment_sidebar_main_channels_title),
() -> showAddRoomDialog(AddChannelDialogFragment.create(hostname))
......@@ -299,6 +304,10 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain
});
}
public void clearSearchViewFocus() {
searchView.clearFocus();
}
public void closeUserActionContainer() {
final CompoundButton toggleUserAction = rootView.findViewById(R.id.toggle_user_action);
if (toggleUserAction != null && toggleUserAction.isChecked()) {
......
package chat.rocket.android.layouthelper.chatroom;
import chat.rocket.android.widget.message.MessageFormLayout;
/**
* Handles MessageForm.
*/
public class MessageFormManager {
private final MessageFormLayout messageFormLayout;
private SendMessageCallback sendMessageCallback;
public MessageFormManager(MessageFormLayout messageFormLayout, MessageFormLayout.ExtraActionSelectionClickListener callback) {
this.messageFormLayout = messageFormLayout;
init(callback);
}
private void init(MessageFormLayout.ExtraActionSelectionClickListener listener) {
messageFormLayout.setExtraActionSelectionClickListener(listener);
messageFormLayout.setSubmitTextListener(this::sendMessage);
}
public void setSendMessageCallback(SendMessageCallback sendMessageCallback) {
this.sendMessageCallback = sendMessageCallback;
}
public void onMessageSend() {
clearComposingText();
}
public void setEditMessage(String message) {
clearComposingText();
messageFormLayout.setText(message);
}
public void clearComposingText() {
messageFormLayout.setText("");
}
private void sendMessage(String message) {
if (sendMessageCallback == null) {
return;
}
sendMessageCallback.onSubmitText(message);
}
public interface SendMessageCallback {
void onSubmitText(String messageText);
}
}
\ No newline at end of file
package chat.rocket.android.layouthelper.chatroom
import chat.rocket.android.widget.message.MessageFormLayout
class MessageFormManager(private val messageFormLayout: MessageFormLayout, val callback: MessageFormLayout.ExtraActionSelectionClickListener) {
private var sendMessageCallback: SendMessageCallback? = null
init {
messageFormLayout.setExtraActionSelectionClickListener(callback)
messageFormLayout.setSubmitTextListener(this::sendMessage)
}
fun setSendMessageCallback(sendMessageCallback: SendMessageCallback) {
this.sendMessageCallback = sendMessageCallback
}
fun onMessageSend() {
clearComposingText()
}
fun setEditMessage(message: String) {
clearComposingText()
messageFormLayout.setText(message)
}
fun clearComposingText() {
messageFormLayout.setText("")
}
fun enableComposingText(enable: Boolean) {
messageFormLayout.isEnabled = enable
}
private fun sendMessage(message: String) {
sendMessageCallback?.onSubmitText(message)
}
interface SendMessageCallback {
fun onSubmitText(messageText: String)
}
}
\ No newline at end of file
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 {
case Room.TYPE_PRIVATE:
itemView.showPrivateChannelIcon();
break;
case Room.TYPE_LIVECHAT:
itemView.showLivechatChannelIcon();
break;
default:
throw new AssertionError("Room type doesn't satisfies the method documentation. Room type is:" + roomType);
}
......
......@@ -3,6 +3,7 @@
<string name="fragment_sidebar_main_favorite_title">FAVORITES</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_livechat_title">LIVECHAT</string>
<string name="user_status_online">Online</string>
<string name="user_status_away">Away</string>
<string name="user_status_busy">Busy</string>
......
......@@ -29,6 +29,7 @@ public class RoomToolbar extends Toolbar {
private Drawable privateChannelDrawable;
private Drawable publicChannelDrawable;
private Drawable livechatChannelDrawable;
private Drawable userStatusDrawable;
private DrawerArrowDrawable drawerArrowDrawable;
......@@ -63,6 +64,7 @@ public class RoomToolbar extends Toolbar {
privateChannelDrawable = VectorDrawableCompat.create(getResources(), R.drawable.ic_lock_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);
}
......@@ -102,6 +104,12 @@ public class RoomToolbar extends Toolbar {
roomTypeImage.setVisibility(VISIBLE);
}
public void showLivechatChannelIcon() {
roomTypeImage.setImageDrawable(livechatChannelDrawable);
userStatusImage.setVisibility(GONE);
roomTypeImage.setVisibility(VISIBLE);
}
public void showUserStatusIcon(int status) {
DrawableHelper.INSTANCE.wrapDrawable(userStatusDrawable);
......
......@@ -29,6 +29,7 @@ class RoomListItemView : FrameLayout {
lateinit private var alertCountText: TextView
lateinit private var privateChannelDrawable: Drawable
lateinit private var publicChannelDrawable: Drawable
lateinit private var livechatChannelDrawable: Drawable
lateinit private var userStatusDrawable: Drawable
constructor(context: Context) : super(context) {
......@@ -67,6 +68,7 @@ class RoomListItemView : FrameLayout {
privateChannelDrawable = VectorDrawableCompat.create(resources, R.drawable.ic_lock_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)!!
}
......@@ -103,6 +105,12 @@ class RoomListItemView : FrameLayout {
roomTypeImage.visibility = View.VISIBLE
}
fun showLivechatChannelIcon() {
roomTypeImage.setImageDrawable(livechatChannelDrawable)
userStatusImage.visibility = View.GONE
roomTypeImage.visibility = View.VISIBLE
}
fun showOnlineUserStatusIcon() {
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 {
public static final String TYPE_CHANNEL = "c";
public static final String TYPE_PRIVATE = "p";
public static final String TYPE_DIRECT_MESSAGE = "d";
public static final String TYPE_LIVECHAT = "l";
public abstract String getId();
......@@ -41,6 +42,10 @@ public abstract class Room {
return TYPE_DIRECT_MESSAGE.equals(getType());
}
public boolean isLivechat() {
return TYPE_LIVECHAT.equals(getType());
}
public static Builder 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