Skip to content

Commit

Permalink
Showing 1 changed file with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -673,8 +673,7 @@ public void onSuccess(ArrayList<String> strings) {
.addPermissions(Permissions.READ_EXTERNAL_STORAGE, Permissions.WRITE_EXTERNAL_STORAGE)
.rationale(R.string.restore_permission)
.onGranted((requestCode) -> {
Restore.INSTANCE.restore(Backup.INSTANCE.getDefaultPath());
recreate();
restoreOld();
return Unit.INSTANCE;
}).request();
}
@@ -698,14 +697,28 @@ public void onSuccess(Boolean t) {
});
}

private void restoreOld() {
Single.create((SingleOnSubscribe<Boolean>) e -> {
Restore.INSTANCE.restore(Backup.INSTANCE.getDefaultPath());
e.onSuccess(true);
}).subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new MySingleObserver<Boolean>() {
@Override
public void onSuccess(Boolean t) {
recreate();
}
});
}

@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
private void selectRestoreFolder() {
try {
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivityForResult(intent, restoreSelectRequestCode);
} catch (Exception e) {
Restore.INSTANCE.restore(Backup.INSTANCE.getDefaultPath());
restoreOld();
}
}

0 comments on commit 5b1d4f0

Please sign in to comment.