Commit 4a29236c authored by Yusuke Iwaki's avatar Yusuke Iwaki

fix back-key behavior

parent 39fbcb80
......@@ -54,7 +54,7 @@ public class MainActivity extends AbstractAuthedActivity {
private boolean closeSidebarIfNeeded() {
// REMARK: Tablet UI doesn't have SlidingPane!
SlidingPaneLayout pane = (SlidingPaneLayout) findViewById(R.id.sliding_pane);
if (pane != null && pane.isOpen()) {
if (pane != null && pane.isSlideable() && pane.isOpen()) {
pane.closePane();
return true;
}
......
......@@ -12,6 +12,7 @@ import android.widget.Toast;
import chat.rocket.android.R;
import chat.rocket.android.helper.LoadMoreScrollListener;
import chat.rocket.android.helper.LogcatIfError;
import chat.rocket.android.helper.OnBackPressListener;
import chat.rocket.android.layouthelper.chatroom.MessageListAdapter;
import chat.rocket.android.model.ServerConfig;
import chat.rocket.android.model.SyncState;
......@@ -31,7 +32,7 @@ import timber.log.Timber;
/**
* Chat room screen.
*/
public class RoomFragment extends AbstractChatRoomFragment {
public class RoomFragment extends AbstractChatRoomFragment implements OnBackPressListener {
private RealmHelper realmHelper;
private String roomId;
......@@ -131,11 +132,13 @@ public class RoomFragment extends AbstractChatRoomFragment {
}
}
private void closeSideMenuIfNeeded() {
private boolean closeSideMenuIfNeeded() {
DrawerLayout drawerLayout = (DrawerLayout) rootView.findViewById(R.id.drawer_layout);
if (drawerLayout != null && drawerLayout.isDrawerOpen(GravityCompat.END)) {
drawerLayout.closeDrawer(GravityCompat.END);
return true;
}
return false;
}
private void onRenderRoom(RoomSubscription roomSubscription) {
......@@ -208,4 +211,8 @@ public class RoomFragment extends AbstractChatRoomFragment {
roomObserver.unsub();
super.onPause();
}
@Override public boolean onBackPressed() {
return closeSideMenuIfNeeded();
}
}
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