From 96deb2d8971fd5c9d0644bc0fae9155334c76153 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Mon, 27 Feb 2023 22:04:42 +0100 Subject: [PATCH] Android: Hide controller mappings button when controller type is None Also removed the make_sure_continuous_scan_enabled message. It doesn't make sense with the new UX. --- .../settings/ui/SettingsActivity.java | 6 +++ .../ui/SettingsActivityPresenter.java | 37 ++++++++++++++----- .../settings/ui/SettingsActivityView.java | 13 ++++++- .../features/settings/ui/SettingsAdapter.java | 5 +++ .../settings/ui/SettingsFragment.java | 5 +++ .../settings/ui/SettingsFragmentView.java | 13 ++++++- .../ui/viewholder/SingleChoiceViewHolder.java | 3 +- .../res/layout-ldrtl/list_item_setting.xml | 8 ++-- .../src/main/res/layout/list_item_setting.xml | 8 ++-- .../app/src/main/res/values/strings.xml | 1 - 10 files changed, 76 insertions(+), 23 deletions(-) diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsActivity.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsActivity.java index 99ec999f39..2af17e2d2f 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsActivity.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsActivity.java @@ -310,6 +310,12 @@ public final class SettingsActivity extends AppCompatActivity implements Setting mPresenter.onMenuTagAction(menuTag, value); } + @Override + public boolean hasMenuTagActionForValue(@NonNull MenuTag menuTag, int value) + { + return mPresenter.hasMenuTagActionForValue(menuTag, value); + } + @Override public boolean onSupportNavigateUp() { diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsActivityPresenter.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsActivityPresenter.java index 8bc2e2141f..cc235b9863 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsActivityPresenter.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsActivityPresenter.java @@ -153,21 +153,15 @@ public final class SettingsActivityPresenter if (menuTag.isWiimoteMenu()) { - switch (value) + if (value == 1) // Emulated Wii Remote { - case 1: - mView.showSettingsFragment(menuTag, null, true, mGameId); - break; - - case 2: - mView.showToastMessage(mActivity.getString(R.string.make_sure_continuous_scan_enabled)); - break; + mView.showSettingsFragment(menuTag, null, true, mGameId); } } if (menuTag.isWiimoteExtensionMenu()) { - if (value != 0) // None + if (value != 0) // Not disabled { Bundle bundle = new Bundle(); bundle.putInt(SettingsFragmentPresenter.ARG_CONTROLLER_TYPE, value); @@ -175,4 +169,29 @@ public final class SettingsActivityPresenter } } } + + public boolean hasMenuTagActionForValue(@NonNull MenuTag menuTag, int value) + { + if (menuTag.isSerialPort1Menu()) + { + return (value != 0 && value != 255); // Not disabled or dummy + } + + if (menuTag.isGCPadMenu()) + { + return (value != 0); // Not disabled + } + + if (menuTag.isWiimoteMenu()) + { + return (value == 1); // Emulated Wii Remote + } + + if (menuTag.isWiimoteExtensionMenu()) + { + return (value != 0); // Not disabled + } + + return false; + } } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsActivityView.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsActivityView.java index cb0c23f7be..c835aa4399 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsActivityView.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsActivityView.java @@ -64,11 +64,20 @@ public interface SettingsActivityView * Called by a containing Fragment to tell the containing Activity that the user wants to open the * MenuTag associated with a setting. * - * @param menuTag The MenuTag to open. - * @param value The current value of the associated setting. + * @param menuTag The MenuTag of the setting. + * @param value The current value of the setting. */ void onMenuTagAction(@NonNull MenuTag menuTag, int value); + /** + * Returns whether anything will happen when the user wants to open the MenuTag associated with a + * setting, given the current value of the setting. + * + * @param menuTag The MenuTag of the setting. + * @param value The current value of the setting. + */ + boolean hasMenuTagActionForValue(@NonNull MenuTag menuTag, int value); + /** * Show loading dialog while loading the settings */ diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsAdapter.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsAdapter.java index cc9bf8f85e..a7f028afe3 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsAdapter.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsAdapter.java @@ -472,6 +472,11 @@ public final class SettingsAdapter extends RecyclerView.Adapter diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentView.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentView.java index 7deeead9d2..295ff95abd 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentView.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentView.java @@ -76,8 +76,17 @@ public interface SettingsFragmentView * Have the fragment tell the containing Activity that the user wants to open the MenuTag * associated with a setting. * - * @param menuTag The MenuTag to open. - * @param value The current value of the associated setting. + * @param menuTag The MenuTag of the setting. + * @param value The current value of the setting. */ void onMenuTagAction(@NonNull MenuTag menuTag, int value); + + /** + * Returns whether anything will happen when the user wants to open the MenuTag associated with a + * setting, given the current value of the setting. + * + * @param menuTag The MenuTag of the setting. + * @param value The current value of the setting. + */ + boolean hasMenuTagActionForValue(@NonNull MenuTag menuTag, int value); } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/SingleChoiceViewHolder.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/SingleChoiceViewHolder.java index 462ed4bb53..db56ebea40 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/SingleChoiceViewHolder.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/SingleChoiceViewHolder.java @@ -101,7 +101,8 @@ public final class SingleChoiceViewHolder extends SettingViewHolder getSelectedValue = setting::getSelectedValueIndex; } - if (menuTag != null) + if (menuTag != null && + adapter.hasMenuTagActionForValue(menuTag, getSelectedValue.apply(settings))) { mBinding.buttonMoreSettings.setVisibility(View.VISIBLE); diff --git a/Source/Android/app/src/main/res/layout-ldrtl/list_item_setting.xml b/Source/Android/app/src/main/res/layout-ldrtl/list_item_setting.xml index 8e923c4bd8..eb2ac6c617 100644 --- a/Source/Android/app/src/main/res/layout-ldrtl/list_item_setting.xml +++ b/Source/Android/app/src/main/res/layout-ldrtl/list_item_setting.xml @@ -8,15 +8,13 @@ android:background="?android:attr/selectableItemBackground" android:clickable="true" android:focusable="true" - android:minHeight="72dp" android:nextFocusLeft="@id/button_more_settings"> diff --git a/Source/Android/app/src/main/res/layout/list_item_setting.xml b/Source/Android/app/src/main/res/layout/list_item_setting.xml index 93c4f2d6d3..e0bae52bef 100644 --- a/Source/Android/app/src/main/res/layout/list_item_setting.xml +++ b/Source/Android/app/src/main/res/layout/list_item_setting.xml @@ -8,15 +8,13 @@ android:background="?android:attr/selectableItemBackground" android:clickable="true" android:focusable="true" - android:minHeight="72dp" android:nextFocusRight="@id/button_more_settings"> diff --git a/Source/Android/app/src/main/res/values/strings.xml b/Source/Android/app/src/main/res/values/strings.xml index a89032e7e6..e81092cbb9 100644 --- a/Source/Android/app/src/main/res/values/strings.xml +++ b/Source/Android/app/src/main/res/values/strings.xml @@ -683,7 +683,6 @@ It can efficiently compress both junk data and encrypted Wii data. GameCube Adapter couldn\'t be opened. Please re-plug the device. GameCube Controller 1 is set to \"None\" Ignore for this session - Please make sure Continuous Scanning is enabled in Core Settings. JIT Recompiler for x86–64 (recommended)