Commit 28d63853 authored by Yusuke Iwaki's avatar Yusuke Iwaki

modify humberger icon to use DrawerArrowDrawable (refer to ActionBarDrawerToggle)

parent a32869da
...@@ -3,9 +3,8 @@ package chat.rocket.android.activity; ...@@ -3,9 +3,8 @@ package chat.rocket.android.activity;
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.graphics.drawable.VectorDrawableCompat;
import android.support.v4.widget.SlidingPaneLayout; import android.support.v4.widget.SlidingPaneLayout;
import android.support.v7.app.ActionBar; import android.support.v7.graphics.drawable.DrawerArrowDrawable;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
import android.view.View; import android.view.View;
...@@ -45,7 +44,6 @@ public class MainActivity extends AbstractAuthedActivity { ...@@ -45,7 +44,6 @@ public class MainActivity extends AbstractAuthedActivity {
setContentView(R.layout.activity_main); setContentView(R.layout.activity_main);
statusTicker = new StatusTicker(); statusTicker = new StatusTicker();
setupToolbar();
setupSidebar(); setupSidebar();
if (roomId == null) { if (roomId == null) {
showFragment(new HomeFragment()); showFragment(new HomeFragment());
...@@ -109,33 +107,32 @@ public class MainActivity extends AbstractAuthedActivity { ...@@ -109,33 +107,32 @@ public class MainActivity extends AbstractAuthedActivity {
} }
}); });
final DrawerArrowDrawable drawerArrowDrawable = new DrawerArrowDrawable(this);
Toolbar toolbar = (Toolbar) findViewById(R.id.activity_main_toolbar); Toolbar toolbar = (Toolbar) findViewById(R.id.activity_main_toolbar);
toolbar.setNavigationIcon(drawerArrowDrawable);
toolbar.setNavigationOnClickListener(view -> { toolbar.setNavigationOnClickListener(view -> {
if (pane.isSlideable() && !pane.isOpen()) { if (pane.isSlideable() && !pane.isOpen()) {
pane.openPane(); pane.openPane();
} }
}); });
}
private void setupToolbar() {
Toolbar toolbar = (Toolbar) findViewById(R.id.activity_main_toolbar);
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar(); //ref: ActionBarDrawerToggle#setProgress
if (actionBar == null) { pane.setPanelSlideListener(new SlidingPaneLayout.PanelSlideListener() {
return; @Override
public void onPanelSlide(View panel, float slideOffset) {
drawerArrowDrawable.setProgress(slideOffset);
} }
actionBar.setDisplayShowTitleEnabled(false); @Override
public void onPanelOpened(View panel) {
if (findViewById(R.id.sliding_pane) == null) { drawerArrowDrawable.setVerticalMirror(true);
return;
} }
actionBar.setDisplayShowHomeEnabled(true); @Override
actionBar.setDisplayHomeAsUpEnabled(true); public void onPanelClosed(View panel) {
actionBar.setHomeAsUpIndicator( drawerArrowDrawable.setVerticalMirror(false);
VectorDrawableCompat.create(getResources(), R.drawable.ic_menu_black_24dp, null)); }
});
} }
private boolean closeSidebarIfNeeded() { private boolean closeSidebarIfNeeded() {
......
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:pathData="M3,18h18v-2L3,16v2zM3,13h18v-2L3,11v2zM3,6v2h18L21,6L3,6z"
android:fillColor="#000000"/>
</vector>
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