add a warning before overwriting games

This commit is contained in:
Eric House 2022-06-14 13:36:33 -07:00
parent c311eac65e
commit ca1b12d194
4 changed files with 23 additions and 7 deletions

View file

@ -148,9 +148,9 @@ public class BackupConfigView extends LinearLayout
? R.string.archive_button_store : R.string.archive_button_load;
}
public List<SaveWhat> getSaveWhat()
public ArrayList<SaveWhat> getSaveWhat()
{
List<SaveWhat> result = new ArrayList<>();
ArrayList<SaveWhat> result = new ArrayList<>();
for ( SaveWhat what : mCheckBoxes.keySet() ) {
CheckBox box = mCheckBoxes.get( what );
if ( box.isChecked() ) {

View file

@ -58,6 +58,7 @@ public class DlgDelegate {
SEND_LOGS,
OPEN_BYOD_DICT,
CLEAR_INT_STATS, // debug only
BACKUP_OVERWRITE,
// BoardDelegate
UNDO_LAST_ACTION,

View file

@ -1474,6 +1474,14 @@ public class GamesListDelegate extends ListDelegateBase
openWithChecks( rowid, summary );
break;
case BACKUP_OVERWRITE:
ArrayList<SaveWhat> whats = (ArrayList<SaveWhat>)params[0];
Uri uri = Uri.parse((String)params[1]);
if ( ZipUtils.load( m_activity, uri, whats ) ) {
ProcessPhoenix.triggerRebirth( m_activity );
}
break;
case QUARANTINE_DELETE:
deleteIfConfirmed( new long[] {(long)params[0]}, true );
break;
@ -1567,10 +1575,11 @@ public class GamesListDelegate extends ListDelegateBase
if ( null == uri ) { // store case
startFileChooser( view.getSaveWhat() );
} else {
List<ZipUtils.SaveWhat> what = view.getSaveWhat();
if ( ZipUtils.load( m_activity, uri, what ) ) {
ProcessPhoenix.triggerRebirth( m_activity );
}
ArrayList<SaveWhat> what = view.getSaveWhat();
makeConfirmThenBuilder( R.string.backup_overwrite_confirm,
Action.BACKUP_OVERWRITE )
.setParams(what, uri.toString())
.show();
}
}
} )
@ -1581,7 +1590,7 @@ public class GamesListDelegate extends ListDelegateBase
// This is in liu of passing through the startActivityForResult call,
// which apparently isn't supported.
private List<ZipUtils.SaveWhat> mSaveWhat;
private List<SaveWhat> mSaveWhat;
private void startFileChooser( List<SaveWhat> what )
{

View file

@ -24,5 +24,11 @@
identify your device. Use this to migrate CrossWords to a new
device.</string>
<string name="backup_overwrite_confirm">Are you sure you want to
overwrite CrossWords\'s current games or settings with those from
the file you selected?\n\nPlease note that if you are bringing
networked games over from another device (migrating, that is), you
should not continue to use CrossWords on the old device.</string>
<string name="archive_filename_fmt">CrossWords-backup-%1$s.zip</string>
</resources>