Skip to content
Permalink
Browse files

Android: Don't let onSettingChanged clobber ConfirmRunnable changes

  • Loading branch information
Ebola16 committed Mar 24, 2020
1 parent de5430b commit d15d6e70d7fa1cca77f51c3f22d5eb04fafadde1
@@ -27,8 +27,7 @@
WIIMOTE_EXTENSION_1("wiimote_extension", 4),
WIIMOTE_EXTENSION_2("wiimote_extension", 5),
WIIMOTE_EXTENSION_3("wiimote_extension", 6),
WIIMOTE_EXTENSION_4("wiimote_extension", 7),
BLANK("Blank");
WIIMOTE_EXTENSION_4("wiimote_extension", 7);

private String tag;
private int subType = -1;
@@ -105,13 +105,13 @@ public void onBackPressed()

@Override
public void showSettingsFragment(MenuTag menuTag, Bundle extras, boolean addToStack,
boolean customAnimations, String gameID)
String gameID)
{
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();

if (addToStack)
{
if (areSystemAnimationsEnabled() && customAnimations)
if (areSystemAnimationsEnabled())
{
transaction.setCustomAnimations(
R.animator.settings_enter,
@@ -70,7 +70,7 @@ private void loadSettingsUI()
}
}

mView.showSettingsFragment(menuTag, null, false, true, gameId);
mView.showSettingsFragment(menuTag, null, false, gameId);
mView.onSettingsFileLoaded(mSettings);
}

@@ -195,7 +195,7 @@ public void onGcPadSettingChanged(MenuTag key, int value)
{
Bundle bundle = new Bundle();
bundle.putInt(SettingsFragmentPresenter.ARG_CONTROLLER_TYPE, value / 6);
mView.showSettingsFragment(key, bundle, true, true, gameId);
mView.showSettingsFragment(key, bundle, true, gameId);
}
}

@@ -204,7 +204,7 @@ public void onWiimoteSettingChanged(MenuTag menuTag, int value)
switch (value)
{
case 1:
mView.showSettingsFragment(menuTag, null, true, true, gameId);
mView.showSettingsFragment(menuTag, null, true, gameId);
break;

case 2:
@@ -219,7 +219,7 @@ public void onExtensionSettingChanged(MenuTag menuTag, int value)
{
Bundle bundle = new Bundle();
bundle.putInt(SettingsFragmentPresenter.ARG_CONTROLLER_TYPE, value);
mView.showSettingsFragment(menuTag, bundle, true, true, gameId);
mView.showSettingsFragment(menuTag, bundle, true, gameId);
}
}

@@ -14,12 +14,10 @@
/**
* Show a new SettingsFragment.
*
* @param menuTag Identifier for the settings group that should be displayed.
* @param addToStack Whether or not this fragment should replace a previous one.
* @param customAnimations Custom animations are used if true while system animations are enabled.
* @param menuTag Identifier for the settings group that should be displayed.
* @param addToStack Whether or not this fragment should replace a previous one.
*/
void showSettingsFragment(MenuTag menuTag, Bundle extras, boolean addToStack,
boolean customAnimations, String gameId);
void showSettingsFragment(MenuTag menuTag, Bundle extras, boolean addToStack, String gameId);

/**
* Called by a contained Fragment to get access to the Setting HashMap
@@ -55,6 +55,7 @@
implements DialogInterface.OnClickListener, SeekBar.OnSeekBarChangeListener
{
private SettingsFragmentView mView;
private static SettingsFragmentView sView;
private Context mContext;
private ArrayList<SettingsItem> mSettings;

@@ -72,6 +73,7 @@
public SettingsAdapter(SettingsFragmentView view, Context context)
{
mView = view;
sView = view;
mContext = context;
mClickedPosition = -1;
}
@@ -332,20 +334,32 @@ public static void onFilePickerConfirmation(String file)

public static void resetPaths()
{
NativeLibrary.SetConfig(SettingsFile.FILE_NAME_DOLPHIN + ".ini", Settings.SECTION_INI_CORE,
SettingsFile.KEY_DEFAULT_ISO, "");
NativeLibrary.SetConfig(SettingsFile.FILE_NAME_DOLPHIN + ".ini", Settings.SECTION_INI_GENERAL,
SettingsFile.KEY_NAND_ROOT_PATH, SettingsFragmentPresenter.getDefaultNANDRootPath());
NativeLibrary.SetConfig(SettingsFile.FILE_NAME_DOLPHIN + ".ini", Settings.SECTION_INI_GENERAL,
SettingsFile.KEY_DUMP_PATH, SettingsFragmentPresenter.getDefaultDumpPath());
NativeLibrary.SetConfig(SettingsFile.FILE_NAME_DOLPHIN + ".ini", Settings.SECTION_INI_GENERAL,
SettingsFile.KEY_LOAD_PATH, SettingsFragmentPresenter.getDefaultLoadPath());
NativeLibrary.SetConfig(SettingsFile.FILE_NAME_DOLPHIN + ".ini", Settings.SECTION_INI_GENERAL,
SettingsFile.KEY_RESOURCE_PACK_PATH,
SettingsFragmentPresenter.getDefaultResourcePackPath());
NativeLibrary.SetConfig(SettingsFile.FILE_NAME_DOLPHIN + ".ini", Settings.SECTION_INI_GENERAL,
SettingsFile.KEY_WII_SD_CARD_PATH, SettingsFragmentPresenter.getDefaultSDPath());
NativeLibrary.ReloadConfig();
StringSetting defaultISO =
new StringSetting(SettingsFile.KEY_DEFAULT_ISO, Settings.SECTION_INI_CORE, "");
StringSetting NANDRootPath =
new StringSetting(SettingsFile.KEY_NAND_ROOT_PATH, Settings.SECTION_INI_GENERAL,
SettingsFragmentPresenter.getDefaultNANDRootPath());
StringSetting dumpPath =
new StringSetting(SettingsFile.KEY_DUMP_PATH, Settings.SECTION_INI_GENERAL,
SettingsFragmentPresenter.getDefaultDumpPath());
StringSetting loadPath =
new StringSetting(SettingsFile.KEY_LOAD_PATH, Settings.SECTION_INI_GENERAL,
SettingsFragmentPresenter.getDefaultLoadPath());
StringSetting resourcePackPath =
new StringSetting(SettingsFile.KEY_RESOURCE_PACK_PATH, Settings.SECTION_INI_GENERAL,
SettingsFragmentPresenter.getDefaultResourcePackPath());
StringSetting sdPath =
new StringSetting(SettingsFile.KEY_WII_SD_CARD_PATH, Settings.SECTION_INI_GENERAL,
SettingsFragmentPresenter.getDefaultSDPath());

sView.putSetting(defaultISO);
sView.putSetting(NANDRootPath);
sView.putSetting(dumpPath);
sView.putSetting(loadPath);
sView.putSetting(resourcePackPath);
sView.putSetting(sdPath);

sView.onSettingChanged();
}

@Override
@@ -20,7 +20,6 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

public final class SettingsFragment extends Fragment implements SettingsFragmentView
{
@@ -180,18 +179,7 @@ public void loadDefaultSettings()
@Override
public void loadSubMenu(MenuTag menuKey)
{
mActivity
.showSettingsFragment(menuKey, null, true, true,
getArguments().getString(ARGUMENT_GAME_ID));
}

@Override
public void reloadSubMenu()
{
mActivity
.showSettingsFragment(MenuTag.BLANK, null, true, false,
getArguments().getString(ARGUMENT_GAME_ID));
Objects.requireNonNull(getActivity()).onBackPressed();
mActivity.showSettingsFragment(menuKey, null, true, getArguments().getString(ARGUMENT_GAME_ID));
}

@Override
@@ -197,9 +197,6 @@ private void loadSettingsList()
addStereoSettings(sl);
break;

case BLANK:
break;

default:
mView.showToastMessage("Unimplemented menu");
return;
@@ -353,8 +350,8 @@ private void addPathsSettings(ArrayList<SettingsItem> sl)
sl.add(new FilePicker(SettingsFile.FILE_NAME_DOLPHIN, SettingsFile.KEY_WII_SD_CARD_PATH,
Settings.SECTION_INI_GENERAL, R.string.SD_card_path, 0, getDefaultSDPath(),
MainPresenter.REQUEST_SD_FILE, wiiSDCardPath));
sl.add(new ConfirmRunnable(R.string.reset_paths, 0, R.string.reset_paths_confirmation,
R.string.reset_paths_complete, () -> SettingsAdapter.resetPaths()));
sl.add(new ConfirmRunnable(R.string.reset_paths, 0, R.string.reset_paths_confirmation, 0,
SettingsAdapter::resetPaths));
}

private void addGameCubeSettings(ArrayList<SettingsItem> sl)
@@ -57,12 +57,6 @@
*/
void loadSubMenu(MenuTag menuKey);

/**
* Show a new blank submenu and then immediately back out of it.
* Useful for updating dynamic setting descriptions.
*/
void reloadSubMenu();

/**
* Tell the Fragment to tell the containing activity to display a toast message.
*
@@ -57,7 +57,6 @@ public void onClick(View clicked)
{
String alertTitle = mContext.getString(mItem.getNameId());
String alertText = mContext.getString(mItem.getAlertText());
String confirmationText = mContext.getString(mItem.getConfirmationText());

AlertDialog.Builder builder = new AlertDialog.Builder(mContext)
.setTitle(alertTitle)
@@ -70,10 +69,13 @@ public void onClick(View clicked)

if (mItem.getConfirmationText() > 0)
{
String confirmationText = mContext.getString(mItem.getConfirmationText());
Toast.makeText(mContext, confirmationText, Toast.LENGTH_SHORT).show();
}
dialog.dismiss();
mView.reloadSubMenu();

// TODO: Remove finish and properly update dynamic settings descriptions.
mView.getActivity().finish();
})
.setNegativeButton("No", (dialog, whichButton) ->
{
@@ -172,7 +172,6 @@
<string name="SD_card_path">SD Card Path</string>
<string name="reset_paths">Reset Paths to Default Settings</string>
<string name="reset_paths_confirmation">Are you sure you want to reset Paths to default settings?</string>
<string name="reset_paths_complete">Paths reset</string>

<!-- Graphics Settings -->
<string name="graphics_general">General</string>

0 comments on commit d15d6e7

Please sign in to comment.
You can’t perform that action at this time.