From ff475a2c027c6a946a15387ac7e146aab31fc724 Mon Sep 17 00:00:00 2001 From: Mahdi Hijazi Date: Sat, 29 Apr 2017 22:01:22 +0200 Subject: [PATCH] [Android] Fix edit controls layout Not checking the none existing key in the buttonsActionsMap leads to break the sub menu of the configure controls menu on Android phones. --- .../dolphinemu/dolphinemu/activities/EmulationActivity.java | 6 +++++- .../dolphinemu/dolphinemu/fragments/LoadStateFragment.java | 6 +++++- .../org/dolphinemu/dolphinemu/fragments/MenuFragment.java | 6 +++++- .../dolphinemu/dolphinemu/fragments/SaveStateFragment.java | 6 +++++- 4 files changed, 20 insertions(+), 4 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 c962fba4fd..10e803bc19 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 @@ -468,7 +468,11 @@ public final class EmulationActivity extends AppCompatActivity @Override public boolean onOptionsItemSelected(MenuItem item) { - handleMenuAction(buttonsActionsMap.get(item.getItemId())); + int action = buttonsActionsMap.get(item.getItemId(), -1); + if (action >= 0) + { + handleMenuAction(action); + } return true; } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/LoadStateFragment.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/LoadStateFragment.java index 2fbbc1838b..95d5df94f5 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/LoadStateFragment.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/LoadStateFragment.java @@ -62,6 +62,10 @@ public final class LoadStateFragment extends Fragment implements View.OnClickLis @Override public void onClick(View button) { - ((EmulationActivity) getActivity()).handleMenuAction(buttonsActionsMap.get(button.getId())); + int action = buttonsActionsMap.get(button.getId(), -1); + if (action >= 0) + { + ((EmulationActivity) getActivity()).handleMenuAction(action); + } } } 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 f83b0a4f98..236ed89228 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 @@ -54,7 +54,11 @@ public final class MenuFragment extends Fragment implements View.OnClickListener @Override public void onClick(View button) { - ((EmulationActivity) getActivity()).handleMenuAction(buttonsActionsMap.get(button.getId())); + int action = buttonsActionsMap.get(button.getId()); + if (action >= 0) + { + ((EmulationActivity) getActivity()).handleMenuAction(action); + } } public void setTitleText(String title) diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/SaveStateFragment.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/SaveStateFragment.java index 4ddebc37d9..f6d9482ebf 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/SaveStateFragment.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/SaveStateFragment.java @@ -62,6 +62,10 @@ public final class SaveStateFragment extends Fragment implements View.OnClickLis @Override public void onClick(View button) { - ((EmulationActivity) getActivity()).handleMenuAction(buttonsActionsMap.get(button.getId())); + int action = buttonsActionsMap.get(button.getId(), -1); + if (action >= 0) + { + ((EmulationActivity) getActivity()).handleMenuAction(action); + } } }