Android: Don't let onSettingChanged clobber ConfirmRunnable changes

This commit is contained in:
Ryan Meredith 2020-03-24 17:08:35 -04:00
parent de5430b222
commit d15d6e70d7
10 changed files with 45 additions and 54 deletions

View File

@ -27,8 +27,7 @@ public enum MenuTag
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;

View File

@ -105,13 +105,13 @@ public final class SettingsActivity extends AppCompatActivity implements Setting
@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,

View File

@ -70,7 +70,7 @@ public final class SettingsActivityPresenter
}
}
mView.showSettingsFragment(menuTag, null, false, true, gameId);
mView.showSettingsFragment(menuTag, null, false, gameId);
mView.onSettingsFileLoaded(mSettings);
}
@ -195,7 +195,7 @@ public final class SettingsActivityPresenter
{
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 final class SettingsActivityPresenter
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 final class SettingsActivityPresenter
{
Bundle bundle = new Bundle();
bundle.putInt(SettingsFragmentPresenter.ARG_CONTROLLER_TYPE, value);
mView.showSettingsFragment(menuTag, bundle, true, true, gameId);
mView.showSettingsFragment(menuTag, bundle, true, gameId);
}
}

View File

@ -14,12 +14,10 @@ public interface SettingsActivityView
/**
* 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

View File

@ -55,6 +55,7 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
implements DialogInterface.OnClickListener, SeekBar.OnSeekBarChangeListener
{
private SettingsFragmentView mView;
private static SettingsFragmentView sView;
private Context mContext;
private ArrayList<SettingsItem> mSettings;
@ -72,6 +73,7 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
public SettingsAdapter(SettingsFragmentView view, Context context)
{
mView = view;
sView = view;
mContext = context;
mClickedPosition = -1;
}
@ -332,20 +334,32 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
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

View File

@ -20,7 +20,6 @@ import org.dolphinemu.dolphinemu.ui.DividerItemDecoration;
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 final class SettingsFragment extends Fragment implements SettingsFragment
@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

View File

@ -197,9 +197,6 @@ public final class SettingsFragmentPresenter
addStereoSettings(sl);
break;
case BLANK:
break;
default:
mView.showToastMessage("Unimplemented menu");
return;
@ -353,8 +350,8 @@ public final class SettingsFragmentPresenter
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)

View File

@ -57,12 +57,6 @@ public interface SettingsFragmentView
*/
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.
*

View File

@ -57,7 +57,6 @@ public final class ConfirmRunnableViewHolder extends SettingViewHolder
{
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 final class ConfirmRunnableViewHolder extends SettingViewHolder
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) ->
{

View File

@ -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>