mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-21 05:09:34 -06:00
Android: Implement save overwrite confirmation
This commit is contained in:
@ -18,11 +18,14 @@ import org.dolphinemu.dolphinemu.features.settings.ui.MenuTag;
|
||||
import org.dolphinemu.dolphinemu.model.GameFileCache;
|
||||
import org.dolphinemu.dolphinemu.services.GameFileCacheService;
|
||||
import org.dolphinemu.dolphinemu.utils.AfterDirectoryInitializationRunner;
|
||||
import org.dolphinemu.dolphinemu.utils.BooleanSupplier;
|
||||
import org.dolphinemu.dolphinemu.utils.ContentHandler;
|
||||
import org.dolphinemu.dolphinemu.utils.FileBrowserHelper;
|
||||
import org.dolphinemu.dolphinemu.utils.WiiUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public final class MainPresenter
|
||||
@ -168,9 +171,41 @@ public final class MainPresenter
|
||||
|
||||
public void importWiiSave(String path)
|
||||
{
|
||||
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.N)
|
||||
return; // TODO
|
||||
|
||||
final Activity mainPresenterActivity = (Activity) mContext;
|
||||
|
||||
CompletableFuture<Boolean> canOverwriteFuture = new CompletableFuture<>();
|
||||
|
||||
runOnThreadAndShowResult(R.string.import_in_progress, () ->
|
||||
{
|
||||
int result = WiiUtils.importWiiSave(path);
|
||||
BooleanSupplier canOverwrite = () ->
|
||||
{
|
||||
mainPresenterActivity.runOnUiThread(() ->
|
||||
{
|
||||
AlertDialog.Builder builder =
|
||||
new AlertDialog.Builder(mContext, R.style.DolphinDialogBase);
|
||||
builder.setMessage(R.string.wii_save_exists);
|
||||
builder.setCancelable(false);
|
||||
builder.setPositiveButton(R.string.yes, (dialog, i) -> canOverwriteFuture.complete(true));
|
||||
builder.setNegativeButton(R.string.no, (dialog, i) -> canOverwriteFuture.complete(false));
|
||||
builder.show();
|
||||
});
|
||||
|
||||
try
|
||||
{
|
||||
return canOverwriteFuture.get();
|
||||
}
|
||||
catch (ExecutionException | InterruptedException e)
|
||||
{
|
||||
// Shouldn't happen
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
};
|
||||
|
||||
int result = WiiUtils.importWiiSave(path, canOverwrite);
|
||||
|
||||
int message;
|
||||
switch (result)
|
||||
{
|
||||
|
@ -0,0 +1,6 @@
|
||||
package org.dolphinemu.dolphinemu.utils;
|
||||
|
||||
public interface BooleanSupplier
|
||||
{
|
||||
boolean get();
|
||||
}
|
@ -10,5 +10,5 @@ public final class WiiUtils
|
||||
|
||||
public static native boolean installWAD(String file);
|
||||
|
||||
public static native int importWiiSave(String file);
|
||||
public static native int importWiiSave(String file, BooleanSupplier canOverwrite);
|
||||
}
|
||||
|
@ -333,6 +333,7 @@
|
||||
<string name="import_in_progress">Importing...</string>
|
||||
<string name="wad_install_success">Successfully installed this title to the NAND.</string>
|
||||
<string name="wad_install_failure">Failed to install this title to the NAND.</string>
|
||||
<string name="wii_save_exists">Save data for this title already exists in the NAND. Consider backing up the current data before overwriting.\nOverwrite now?</string>
|
||||
<string name="wii_save_import_success">Successfully imported save file.</string>
|
||||
<string name="wii_save_import_error">Failed to import save file. Your NAND may be corrupt, or something is preventing access to files within it.</string>
|
||||
<string name="wii_save_import_corruped_source">Failed to import save file. The given file appears to be corrupted or is not a valid Wii save.</string>
|
||||
|
Reference in New Issue
Block a user