local backup/restore: archive restore fix

This commit is contained in:
Yuriy Liskov
2025-12-08 06:31:44 +02:00
parent 8f88dcf70e
commit 37683ce531
3 changed files with 10 additions and 4 deletions
@@ -54,8 +54,8 @@ public class BackupSettingsPresenter extends BasePresenter<Void> {
createAndShowDialog();
}
public void showLocalRestoreDialog() {
BackupAndRestoreManager backupManager = new BackupAndRestoreManager(getContext());
public void showLocalRestoreDialogApi30() {
BackupAndRestoreManager backupManager = new BackupAndRestoreManager(getContext(), true);
backupManager.getBackupNames(names -> showLocalRestoreDialog(backupManager, names));
}
@@ -139,7 +139,7 @@ public class BackupAndRestoreHelper implements OnResult {
// Delete the temporary ZIP
tempZip.delete();
BackupSettingsPresenter.instance(mContext).showLocalRestoreDialog();
BackupSettingsPresenter.instance(mContext).showLocalRestoreDialogApi30();
//Toast.makeText(mContext, "Backup restored successfully", Toast.LENGTH_SHORT).show();
@@ -26,6 +26,7 @@ public class BackupAndRestoreManager implements MotherActivity.OnPermissions {
private final File mDataDir;
private final List<File> mBackupDirs;
private final BackupAndRestoreHelper mHelper;
private final boolean mForceApi30;
private final String[] mBackupPatterns = new String[] {
"yt_service_prefs.xml",
"com.liskovsoft.appupdatechecker2.preferences.xml",
@@ -39,7 +40,12 @@ public class BackupAndRestoreManager implements MotherActivity.OnPermissions {
}
public BackupAndRestoreManager(Context context) {
this(context, false);
}
public BackupAndRestoreManager(Context context, boolean forceApi30) {
mContext = context;
mForceApi30 = forceApi30;
mHelper = new BackupAndRestoreHelper(context);
@@ -334,7 +340,7 @@ public class BackupAndRestoreManager implements MotherActivity.OnPermissions {
// Android 11+: only backup through the file manager (no shared dir)
private boolean hasAccessOnlyToAppFolders() {
return getTargetSdkVersion() > 29;
return getTargetSdkVersion() > 29 || mForceApi30;
}
private int getTargetSdkVersion() {