Adds side drawer opening/closing by pressing the physical menu button, if present. Closes #178
This commit is contained in:
parent
ef60701627
commit
b9d6f489d1
1 changed files with 20 additions and 0 deletions
|
@ -31,6 +31,7 @@ import android.support.v4.content.LocalBroadcastManager;
|
|||
import android.support.v4.view.ViewPager;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
|
@ -478,6 +479,25 @@ public class MainActivity extends BaseActivity {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
switch (keyCode) {
|
||||
case KeyEvent.KEYCODE_MENU: {
|
||||
if (drawer.isDrawerOpen()) {
|
||||
drawer.closeDrawer();
|
||||
} else {
|
||||
drawer.openDrawer();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case KeyEvent.KEYCODE_SEARCH: {
|
||||
startActivity(new Intent(this, SearchActivity.class));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
|
||||
// Fix for GitHub issues #190, #259 (MainActivity won't restart on screen rotation.)
|
||||
@Override
|
||||
public void onConfigurationChanged(Configuration newConfig) {
|
||||
|
|
Loading…
Reference in a new issue