summaryrefslogtreecommitdiff
path: root/Source/Android/app/src/main/java
diff options
context:
space:
mode:
authorsigmabeta <sigmabeta@users.noreply.github.com>2015-06-07 23:11:34 -0400
committersigmabeta <sigmabeta@users.noreply.github.com>2015-06-07 23:11:34 -0400
commita97e9addf0f3a465c6a8b1db1aab38829b902a42 (patch)
treefa6e947efa43d5021818ec726e16462fe09e2aa3 /Source/Android/app/src/main/java
parent5c7caf1f22685430f98f39b86b07cadee3171f68 (diff)
Android: Show the in-game menu when back button is pushed.
Diffstat (limited to 'Source/Android/app/src/main/java')
-rw-r--r--Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java29
1 files changed, 27 insertions, 2 deletions
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java
index de7ebb17d3..7b0d4057f6 100644
--- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java
+++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java
@@ -25,6 +25,9 @@ public final class EmulationActivity extends Activity
{
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
* on the UI thread. This Handler responds to any message, even blank ones, by
@@ -44,6 +47,8 @@ public final class EmulationActivity extends Activity
{
super.onCreate(savedInstanceState);
+ mDeviceHasTouchScreen = getPackageManager().hasSystemFeature("android.hardware.touchscreen");
+
// Get a handle to the Window containing the UI.
mDecorView = getWindow().getDecorView();
@@ -59,9 +64,9 @@ public final class EmulationActivity extends Activity
@Override
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();
hideSystemUiAfterDelay();
@@ -118,6 +123,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
public boolean onCreateOptionsMenu(Menu menu)
{
// Inflate the menu; this adds items to the action bar if it is present.
@@ -275,6 +294,8 @@ public final class EmulationActivity extends Activity
private void hideSystemUI()
{
+ mSystemUiVisible = false;
+
mDecorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
@@ -285,8 +306,12 @@ public final class EmulationActivity extends Activity
private void showSystemUI()
{
+ mSystemUiVisible = true;
+
mDecorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
+
+ hideSystemUiAfterDelay();
}
}