Use correct file names for each type of backup

This commit is contained in:
RichyHBM 2018-01-15 21:08:42 +00:00
parent 00d6e9b936
commit 155c1481ff
2 changed files with 5 additions and 15 deletions

View file

@ -14,7 +14,6 @@ import org.shadowice.flocke.andotp.Utilities.KeyStoreHelper;
import org.shadowice.flocke.andotp.Utilities.Settings; import org.shadowice.flocke.andotp.Utilities.Settings;
import org.shadowice.flocke.andotp.Utilities.Tools; import org.shadowice.flocke.andotp.Utilities.Tools;
import java.io.File;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.ArrayList; import java.util.ArrayList;
@ -27,12 +26,7 @@ public class EncryptedBackupBroadcastReceiver extends BackupBroadcastReceiver {
return; return;
Settings settings = new Settings(context); Settings settings = new Settings(context);
Uri savePath = Tools.buildUri(settings.getBackupDir(), Constants.BACKUP_FILENAME_PLAIN); Uri savePath = Tools.buildUri(settings.getBackupDir(), Constants.BACKUP_FILENAME_CRYPT);
File dir = new File(savePath.getPath());
if(!dir.exists()) {
dir.mkdirs();
}
String password = settings.getBackupPasswordEnc(); String password = settings.getBackupPasswordEnc();

View file

@ -19,7 +19,6 @@ import org.shadowice.flocke.andotp.Utilities.Tools;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.InputStream; import java.io.InputStream;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.ArrayList; import java.util.ArrayList;
@ -34,11 +33,7 @@ public class OpenPGPBackupBroadcasrReceiver extends BackupBroadcastReceiver {
Settings settings = new Settings(context); Settings settings = new Settings(context);
Uri savePath = Tools.buildUri(settings.getBackupDir(), Constants.BACKUP_FILENAME_PLAIN); Uri savePath = Tools.buildUri(settings.getBackupDir(), Constants.BACKUP_FILENAME_PGP);
File dir = new File(savePath.getPath());
if(!dir.exists()) {
dir.mkdirs();
}
SecretKey encryptionKey; SecretKey encryptionKey;
@ -61,7 +56,7 @@ public class OpenPGPBackupBroadcasrReceiver extends BackupBroadcastReceiver {
return; return;
} }
OpenPgpServiceConnection pgpServiceConnection = new OpenPgpServiceConnection(context.getApplicationContext(), PGPProvider); OpenPgpServiceConnection pgpServiceConnection = new OpenPgpServiceConnection(context, PGPProvider);
pgpServiceConnection.bindToService(); pgpServiceConnection.bindToService();
ArrayList<Entry> entries = DatabaseHelper.loadDatabase(context, encryptionKey); ArrayList<Entry> entries = DatabaseHelper.loadDatabase(context, encryptionKey);
@ -86,6 +81,7 @@ public class OpenPGPBackupBroadcasrReceiver extends BackupBroadcastReceiver {
Intent result = api.executeApi(encryptIntent, is, os); Intent result = api.executeApi(encryptIntent, is, os);
handleOpenPGPResult(context, result, os, savePath, Constants.INTENT_BACKUP_ENCRYPT_PGP); handleOpenPGPResult(context, result, os, savePath, Constants.INTENT_BACKUP_ENCRYPT_PGP);
pgpServiceConnection.unbindFromService();
} }
@ -108,7 +104,7 @@ public class OpenPGPBackupBroadcasrReceiver extends BackupBroadcastReceiver {
} }
} else { } else {
OpenPgpError error = result.getParcelableExtra(OpenPgpApi.RESULT_ERROR); OpenPgpError error = result.getParcelableExtra(OpenPgpApi.RESULT_ERROR);
notify(context, R.string.app_name, R.string.backup_toast_export_failed /* error with openpgp */); notify(context, R.string.app_name, context.getText(R.string.backup_toast_export_failed) + " " + error.getMessage() );
} }
} }
} }