Commit 0b087b61 authored by Leonardo Aramaki's avatar Leonardo Aramaki

Set the add button at the sidebar clickable and responding to a call to AddServerActivity

parent 6341fe2d
package chat.rocket.android.activity;
import android.content.Intent;
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 android.widget.Button;
import chat.rocket.android.LaunchUtil;
import chat.rocket.android.R;
......@@ -70,15 +72,18 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
}
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) {
if (subPane != null) {
Button addServerButton = subPane.findViewById(R.id.btn_add_server);
pane.setPanelSlideListener(new SlidingPaneLayout.SimplePanelSlideListener() {
@Override
public void onPanelClosed(View panel) {
super.onPanelClosed(panel);
subPane.closePane();
}
}
});
});
addServerButton.setOnClickListener(view -> showAddServerActivity());
}
toolbar.setNavigationOnClickListener(view -> {
if (pane.isSlideable() && !pane.isOpen()) {
......@@ -106,6 +111,12 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
});
}
private void showAddServerActivity() {
Intent intent = new Intent(this, AddServerActivity.class);
intent.putExtra(AddServerActivity.EXTRA_FINISH_ON_BACK_PRESS, true);
startActivity(intent);
}
private boolean closeSidebarIfNeeded() {
// REMARK: Tablet UI doesn't have SlidingPane!
SlidingPaneLayout pane = (SlidingPaneLayout) findViewById(R.id.sliding_pane);
......
......@@ -17,6 +17,7 @@
android:layout_height="wrap_content"
android:orientation="vertical">
<!-- FIXME replace this mock with real server -->
<ImageButton
style="@style/Base.Widget.AppCompat.Button.Borderless"
android:layout_width="80dp"
......@@ -26,6 +27,7 @@
<io.github.yusukeiwaki.android.widget.FontAwesomeButton
style="@style/Base.Widget.AppCompat.Button.Borderless"
android:id="@+id/btn_add_server"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_margin="@dimen/margin_8"
......
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