Skip to content

Commit

Permalink
Android: Hide controller mappings button when controller type is None
Browse files Browse the repository at this point in the history
Also removed the make_sure_continuous_scan_enabled message.
It doesn't make sense with the new UX.
  • Loading branch information
JosJuice committed Feb 27, 2023
1 parent b827b15 commit 77c30ad
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 15 deletions.
Expand Up @@ -310,6 +310,12 @@ public void onMenuTagAction(@NonNull MenuTag menuTag, int value)
mPresenter.onMenuTagAction(menuTag, value);
}

@Override
public boolean hasMenuTagActionForValue(@NonNull MenuTag menuTag, int value)
{
return mPresenter.hasMenuTagActionForValue(menuTag, value);
}

@Override
public boolean onSupportNavigateUp()
{
Expand Down
Expand Up @@ -153,26 +153,45 @@ public void onMenuTagAction(@NonNull MenuTag menuTag, int value)

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);
mView.showSettingsFragment(menuTag, bundle, true, mGameId);
}
}
}

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;
}
}
Expand Up @@ -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
*/
Expand Down
Expand Up @@ -472,6 +472,11 @@ public void onMenuTagAction(@NonNull MenuTag menuTag, int value)
mView.onMenuTagAction(menuTag, value);
}

public boolean hasMenuTagActionForValue(@NonNull MenuTag menuTag, int value)
{
return mView.hasMenuTagActionForValue(menuTag, value);
}

@Override
public void onClick(DialogInterface dialog, int which)
{
Expand Down
Expand Up @@ -231,6 +231,11 @@ public void onMenuTagAction(@NonNull MenuTag menuTag, int value)
mActivity.onMenuTagAction(menuTag, value);
}

public boolean hasMenuTagActionForValue(@NonNull MenuTag menuTag, int value)
{
return mActivity.hasMenuTagActionForValue(menuTag, value);
}

private void setInsets()
{
ViewCompat.setOnApplyWindowInsetsListener(mBinding.listSettings, (v, windowInsets) ->
Expand Down
Expand Up @@ -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);
}
Expand Up @@ -101,7 +101,8 @@ else if (item instanceof StringSingleChoiceSetting)
getSelectedValue = setting::getSelectedValueIndex;
}

if (menuTag != null)
if (menuTag != null &&
adapter.hasMenuTagActionForValue(menuTag, getSelectedValue.apply(settings)))
{
mBinding.buttonMoreSettings.setVisibility(View.VISIBLE);

Expand Down
1 change: 0 additions & 1 deletion Source/Android/app/src/main/res/values/strings.xml
Expand Up @@ -683,7 +683,6 @@ It can efficiently compress both junk data and encrypted Wii data.
<string name="replug_gc_adapter">GameCube Adapter couldn\'t be opened. Please re-plug the device.</string>
<string name="disabled_gc_overlay_notice">GameCube Controller 1 is set to \"None\"</string>
<string name="ignore_warning_alert_messages">Ignore for this session</string>
<string name="make_sure_continuous_scan_enabled">Please make sure Continuous Scanning is enabled in Core Settings.</string>

<!-- UI CPU Core selection -->
<string name="jit_recompiler_x86">JIT Recompiler for x86–64 (recommended)</string>
Expand Down

0 comments on commit 77c30ad

Please sign in to comment.