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