summaryrefslogtreecommitdiff
path: root/Source/Android
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
parent6b68b76aed90f0a2a275774375dd899c0f5874ab (diff)
Android: Always show Exit Emulation at bottom of menu
To make it easier to access on touchscreens.
Diffstat (limited to 'Source/Android')
-rw-r--r--Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/MenuFragment.java26
-rw-r--r--Source/Android/app/src/main/res/layout/fragment_ingame_menu.xml19
2 files changed, 40 insertions, 5 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)
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"/>
- <Button
- android:id="@+id/menu_exit"
- android:text="@string/emulation_exit"
- style="@style/InGameMenuOption"/>
-
</LinearLayout>
</ScrollView>
+ <View
+ android:id="@+id/divider"
+ android:layout_width="match_parent"
+ android:layout_height="1dp"
+ android:background="#FFFFFF"
+ android:layout_marginTop="24dp"
+ android:layout_marginBottom="16dp"/>
+
+ <Button
+ android:id="@+id/menu_exit"
+ android:text="@string/emulation_exit"
+ style="@style/InGameMenuOption"/>
+
</LinearLayout>