mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-15 05:47:56 -07:00
Merge pull request #2566 from sigmabeta/android-tv-back
Android TV: Show the in-game menu when back button is pushed.
This commit is contained in:
commit
21b1d143bc
@ -26,6 +26,9 @@ public final class EmulationActivity extends Activity
|
|||||||
{
|
{
|
||||||
private View mDecorView;
|
private View mDecorView;
|
||||||
|
|
||||||
|
private boolean mDeviceHasTouchScreen;
|
||||||
|
private boolean mSystemUiVisible;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handlers are a way to pass a message to an Activity telling it to do something
|
* Handlers are a way to pass a message to an Activity telling it to do something
|
||||||
* on the UI thread. This Handler responds to any message, even blank ones, by
|
* on the UI thread. This Handler responds to any message, even blank ones, by
|
||||||
@ -45,6 +48,8 @@ public final class EmulationActivity extends Activity
|
|||||||
{
|
{
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
mDeviceHasTouchScreen = getPackageManager().hasSystemFeature("android.hardware.touchscreen");
|
||||||
|
|
||||||
// Get a handle to the Window containing the UI.
|
// Get a handle to the Window containing the UI.
|
||||||
mDecorView = getWindow().getDecorView();
|
mDecorView = getWindow().getDecorView();
|
||||||
|
|
||||||
@ -60,9 +65,9 @@ public final class EmulationActivity extends Activity
|
|||||||
@Override
|
@Override
|
||||||
public void onSystemUiVisibilityChange(int flags)
|
public void onSystemUiVisibilityChange(int flags)
|
||||||
{
|
{
|
||||||
boolean visible = (flags & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0;
|
mSystemUiVisible = (flags & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0;
|
||||||
|
|
||||||
if (visible)
|
if (mSystemUiVisible)
|
||||||
{
|
{
|
||||||
getActionBar().show();
|
getActionBar().show();
|
||||||
hideSystemUiAfterDelay();
|
hideSystemUiAfterDelay();
|
||||||
@ -135,6 +140,20 @@ public final class EmulationActivity extends Activity
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBackPressed()
|
||||||
|
{
|
||||||
|
if (!mDeviceHasTouchScreen && !mSystemUiVisible)
|
||||||
|
{
|
||||||
|
showSystemUI();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Let the system handle it; i.e. quit the activity TODO or show "are you sure?" dialog.
|
||||||
|
super.onBackPressed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu)
|
public boolean onCreateOptionsMenu(Menu menu)
|
||||||
{
|
{
|
||||||
@ -293,6 +312,8 @@ public final class EmulationActivity extends Activity
|
|||||||
|
|
||||||
private void hideSystemUI()
|
private void hideSystemUI()
|
||||||
{
|
{
|
||||||
|
mSystemUiVisible = false;
|
||||||
|
|
||||||
mDecorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
|
mDecorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
|
||||||
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
|
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
|
||||||
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
|
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
|
||||||
@ -303,8 +324,12 @@ public final class EmulationActivity extends Activity
|
|||||||
|
|
||||||
private void showSystemUI()
|
private void showSystemUI()
|
||||||
{
|
{
|
||||||
|
mSystemUiVisible = true;
|
||||||
|
|
||||||
mDecorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
|
mDecorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
|
||||||
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
|
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
|
||||||
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
|
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
|
||||||
|
|
||||||
|
hideSystemUiAfterDelay();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user