Commit c43c00f8 authored by Yusuke Iwaki's avatar Yusuke Iwaki

implement sidemenu in the room

parent f6b9138a
......@@ -92,6 +92,7 @@ dependencies {
compile rootProject.ext.timber
compile 'com.jakewharton.rxbinding:rxbinding:0.4.0'
compile 'com.jakewharton.rxbinding:rxbinding-support-v4:0.4.0'
compile 'com.trello:rxlifecycle:1.0'
compile 'com.trello:rxlifecycle-android:1.0'
......
......@@ -2,8 +2,13 @@ package chat.rocket.android.fragment.chatroom;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v4.widget.SlidingPaneLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.Toast;
import chat.rocket.android.R;
import chat.rocket.android.helper.LoadMoreScrollListener;
import chat.rocket.android.helper.LogcatIfError;
......@@ -17,7 +22,9 @@ import chat.rocket.android.realm_helper.RealmHelper;
import chat.rocket.android.realm_helper.RealmObjectObserver;
import chat.rocket.android.realm_helper.RealmStore;
import chat.rocket.android.service.RocketChatService;
import com.jakewharton.rxbinding.support.v4.widget.RxDrawerLayout;
import io.realm.Sort;
import java.lang.reflect.Field;
import org.json.JSONObject;
import timber.log.Timber;
......@@ -96,6 +103,39 @@ public class RoomFragment extends AbstractChatRoomFragment {
}
};
listView.addOnScrollListener(scrollListener);
setupSideMenu();
}
private void setupSideMenu() {
View sidemenu = rootView.findViewById(R.id.room_side_menu);
sidemenu.findViewById(R.id.btn_users).setOnClickListener(view -> {
Toast.makeText(view.getContext(), "not implemented yet.", Toast.LENGTH_SHORT).show();
closeSideMenuIfNeeded();
});
DrawerLayout drawerLayout = (DrawerLayout) rootView.findViewById(R.id.drawer_layout);
SlidingPaneLayout pane = (SlidingPaneLayout) getActivity().findViewById(R.id.sliding_pane);
if (drawerLayout != null && pane != null) {
RxDrawerLayout.drawerOpen(drawerLayout, GravityCompat.END)
.compose(bindToLifecycle())
.subscribe(opened -> {
try {
Field fieldSlidable = pane.getClass().getDeclaredField("mCanSlide");
fieldSlidable.setAccessible(true);
fieldSlidable.setBoolean(pane, !opened);
} catch (Exception exception) {
Timber.w(exception);
}
});
}
}
private void closeSideMenuIfNeeded() {
DrawerLayout drawerLayout = (DrawerLayout) rootView.findViewById(R.id.drawer_layout);
if (drawerLayout != null && drawerLayout.isDrawerOpen(GravityCompat.END)) {
drawerLayout.closeDrawer(GravityCompat.END);
}
}
private void onRenderRoom(RoomSubscription roomSubscription) {
......@@ -160,6 +200,7 @@ public class RoomFragment extends AbstractChatRoomFragment {
super.onResume();
roomObserver.sub();
procedureObserver.sub();
closeSideMenuIfNeeded();
}
@Override public void onPause() {
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<include layout="@layout/fragment_room_main"/>
<include layout="@layout/room_side_menu"/>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
>
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerview"
<include layout="@layout/fragment_room_main"/>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab_compose"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_margin="@dimen/margin_16"
/>
</FrameLayout>
\ No newline at end of file
android:layout_gravity="end"
android:clickable="true"
android:theme="@style/AppTheme.Dark"
>
<include layout="@layout/room_side_menu"/>
</FrameLayout>
</android.support.v4.widget.DrawerLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab_compose"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_margin="@dimen/margin_16"
/>
</FrameLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/room_side_menu"
android:layout_width="48dp"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_gravity="end"
>
<chat.rocket.android.widget.FontAwesomeButton
android:layout_width="48dp"
android:layout_height="48dp"
android:textSize="24dp"
android:text="@string/fa_search"
android:enabled="false"
/>
<chat.rocket.android.widget.FontAwesomeButton
android:id="@+id/btn_users"
android:layout_width="48dp"
android:layout_height="48dp"
android:textSize="24dp"
android:text="@string/fa_users"
/>
<chat.rocket.android.widget.FontAwesomeButton
android:layout_width="48dp"
android:layout_height="48dp"
android:textSize="24dp"
android:text="@string/fa_at"
android:enabled="false"
/>
</LinearLayout>
\ No newline at end of file
......@@ -5,4 +5,8 @@
<string name="fa_github" translatable="false">&#xf09b;</string>
<string name="fa_plus" translatable="false">&#xf067;</string>
<string name="fa_sign_out" translatable="false">&#xf08b;</string>
<string name="fa_search" translatable="false">&#xf002;</string>
<string name="fa_users" translatable="false">&#xf0c0;</string>
<string name="fa_at" translatable="false">&#xf1fa;</string>
</resources>
\ 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