Android: Always show Exit Emulation at bottom of menu
To make it easier to access on touchscreens.
This commit is contained in:
parent
6b68b76aed
commit
cecec756ec
|
@ -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)
|
||||
|
|
|
@ -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"/>
|
||||
|
||||
</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>
|
||||
|
||||
</ScrollView>
|
||||
|
||||
</LinearLayout>
|
||||
|
|
Loading…
Reference in New Issue