From 49dcce96e963fdd8fa4371c51c1886d9e9531e1d Mon Sep 17 00:00:00 2001 From: zilmar Date: Sat, 17 Sep 2016 11:38:11 +1000 Subject: [PATCH] [Android] Menu key shows menu in rom list --- .../src/emu/project64/GalleryActivity.java | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/Android/src/emu/project64/GalleryActivity.java b/Android/src/emu/project64/GalleryActivity.java index a0c48c73a..8f26f9d4d 100644 --- a/Android/src/emu/project64/GalleryActivity.java +++ b/Android/src/emu/project64/GalleryActivity.java @@ -46,6 +46,7 @@ import android.os.Bundle; import android.os.Handler; import android.os.Looper; import android.support.v4.content.res.ResourcesCompat; +import android.support.v4.view.GravityCompat; import android.support.v4.widget.DrawerLayout; import android.support.v7.app.ActionBarDrawerToggle; import android.support.v7.app.AppCompatActivity; @@ -54,6 +55,7 @@ import android.support.v7.widget.RecyclerView; import android.support.v7.widget.Toolbar; import android.util.DisplayMetrics; import android.util.Log; +import android.view.KeyEvent; import android.view.Menu; import android.view.MenuItem; import android.view.View; @@ -669,10 +671,35 @@ public class GalleryActivity extends AppCompatActivity implements IabBroadcastLi refreshGrid(); } + @Override + public boolean onKeyDown( int keyCode, KeyEvent event ) + { + if( keyCode == KeyEvent.KEYCODE_MENU ) + { + if( mDrawerLayout.isDrawerOpen( GravityCompat.START ) ) + { + mDrawerLayout.closeDrawer( GravityCompat.START ); + } + else + { + mDrawerLayout.openDrawer( GravityCompat.START ); + } + return true; + } + return super.onKeyDown( keyCode, event ); + } + @Override public void onBackPressed() { - moveTaskToBack(true); + if( mDrawerLayout.isDrawerOpen( GravityCompat.START ) ) + { + mDrawerLayout.closeDrawer( GravityCompat.START ); + } + else + { + moveTaskToBack(true); + } } public void launchGameActivity()