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) diff --git a/Source/Android/app/src/main/res/layout/fragment_ingame_menu.xml b/Source/Android/app/src/main/res/layout/fragment_ingame_menu.xml index 16276d8313..54295f0eac 100644 --- a/Source/Android/app/src/main/res/layout/fragment_ingame_menu.xml +++ b/Source/Android/app/src/main/res/layout/fragment_ingame_menu.xml @@ -4,6 +4,7 @@ android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" + android:paddingBottom="16dp" android:background="@color/dolphin_blue_dark" tools:layout_width="250dp"> @@ -89,13 +90,21 @@ android:text="@string/emulation_change_disc" style="@style/InGameMenuOption"/> -