Commit 35eb28ca authored by Rafael Kellermann Streit's avatar Rafael Kellermann Streit Committed by GitHub

Merge branch 'develop' into local-spotlight

parents 6c48f18d ef6cf99d
......@@ -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();
......
......@@ -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)) {
......@@ -606,4 +651,4 @@ public class RoomFragment extends AbstractChatRoomFragment implements
edittingMessage = message;
messageFormManager.setEditMessage(message.getMessage());
}
}
}
\ No newline at end of file
......@@ -296,6 +296,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
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