1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2025-01-10 20:15:54 +00:00

Toggle drawer when menu button is pressed (fixes #329).

This commit is contained in:
Felix Ableitner 2015-04-22 23:45:45 +02:00
parent f5e1a17965
commit 7ddee2f953

View file

@ -21,6 +21,7 @@ import android.support.v7.app.ActionBar.Tab;
import android.support.v7.app.ActionBar.TabListener;
import android.support.v7.app.ActionBarDrawerToggle;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
@ -293,4 +294,20 @@ public class MainActivity extends SyncthingActivity
mDrawerLayout.closeDrawer(Gravity.START);
}
/**
* Toggles the drawer on menu button press.
*/
@Override
public boolean onKeyDown(int keyCode, KeyEvent e) {
if (keyCode == KeyEvent.KEYCODE_MENU) {
if (!mDrawerLayout.isDrawerOpen(Gravity.START))
mDrawerLayout.openDrawer(Gravity.START);
else
closeDrawer();
return true;
}
return super.onKeyDown(keyCode, e);
}
}