summaryrefslogtreecommitdiff
path: root/Source/Android/app/src/main/java/org
diff options
context:
space:
mode:
authorJosJuice <josjuice@gmail.com>2020-08-16 16:22:41 +0200
committerJosJuice <josjuice@gmail.com>2020-09-08 16:39:34 +0200
commitcecec756ec50f49802b594c59a44efe2af2328d7 (patch)
tree70da87972d89079d560b863f50a7dea81f411817 /Source/Android/app/src/main/java/org
parent6b68b76aed90f0a2a275774375dd899c0f5874ab (diff)
Android: Always show Exit Emulation at bottom of menu
To make it easier to access on touchscreens.
Diffstat (limited to 'Source/Android/app/src/main/java/org')
-rw-r--r--Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/MenuFragment.java26
1 files changed, 26 insertions, 0 deletions
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/MenuFragment.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/MenuFragment.java
index 6b46937667..2d053a99d7 100644
--- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/MenuFragment.java
+++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/MenuFragment.java
@@ -1,6 +1,7 @@
package org.dolphinemu.dolphinemu.fragments;
import android.content.pm.PackageManager;
+import android.graphics.Rect;
import android.os.Bundle;
import android.util.SparseIntArray;
import android.view.LayoutInflater;
@@ -62,6 +63,14 @@ public final class MenuFragment extends Fragment implements View.OnClickListener
return fragment;
}
+ // This is primarily intended to account for any navigation bar at the bottom of the screen
+ private int getBottomPaddingRequired()
+ {
+ Rect visibleFrame = new Rect();
+ requireActivity().getWindow().getDecorView().getWindowVisibleDisplayFrame(visibleFrame);
+ return visibleFrame.bottom - visibleFrame.top - getResources().getDisplayMetrics().heightPixels;
+ }
+
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
@@ -106,6 +115,21 @@ public final class MenuFragment extends Fragment implements View.OnClickListener
options.findViewById(R.id.menu_screen_orientation).setVisibility(View.GONE);
}
+ int bottomPaddingRequired = getBottomPaddingRequired();
+
+ // Provide a safe zone between the navigation bar and Exit Emulation to avoid accidental touches
+ float density = getResources().getDisplayMetrics().density;
+ if (bottomPaddingRequired >= 32 * density)
+ {
+ bottomPaddingRequired += 32 * density;
+ }
+
+ if (bottomPaddingRequired > rootView.getPaddingBottom())
+ {
+ rootView.setPadding(rootView.getPaddingLeft(), rootView.getPaddingTop(),
+ rootView.getPaddingRight(), bottomPaddingRequired);
+ }
+
for (int childIndex = 0; childIndex < options.getChildCount(); childIndex++)
{
Button button = (Button) options.getChildAt(childIndex);
@@ -113,6 +137,8 @@ public final class MenuFragment extends Fragment implements View.OnClickListener
button.setOnClickListener(this);
}
+ rootView.findViewById(R.id.menu_exit).setOnClickListener(this);
+
mTitleText = rootView.findViewById(R.id.text_game_title);
String title = getArguments().getString(KEY_TITLE);
if (title != null)