mirror of
https://github.com/syncthing/syncthing-android.git
synced 2025-01-26 20:06:02 +00:00
Toggle drawer when menu button is pressed (fixes #329).
This commit is contained in:
parent
f5e1a17965
commit
7ddee2f953
1 changed files with 17 additions and 0 deletions
|
@ -21,6 +21,7 @@ import android.support.v7.app.ActionBar.Tab;
|
||||||
import android.support.v7.app.ActionBar.TabListener;
|
import android.support.v7.app.ActionBar.TabListener;
|
||||||
import android.support.v7.app.ActionBarDrawerToggle;
|
import android.support.v7.app.ActionBarDrawerToggle;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
|
import android.view.KeyEvent;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -293,4 +294,20 @@ public class MainActivity extends SyncthingActivity
|
||||||
mDrawerLayout.closeDrawer(Gravity.START);
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue