Adds side drawer opening/closing by pressing the physical menu button, if present. Closes #178

main
Vavassor 8 years ago
parent 805fbe2690
commit d96ff61876
  1. 20
      app/src/main/java/com/keylesspalace/tusky/MainActivity.java

@ -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…
Cancel
Save