Improve backup notifications a little bit
This commit is contained in:
parent
ae751d8962
commit
12aeb17e8a
4 changed files with 19 additions and 24 deletions
|
@ -23,12 +23,12 @@ public abstract class BackupBroadcastReceiver extends BroadcastReceiver {
|
|||
|
||||
protected boolean canSaveBackup(Context context) {
|
||||
if (ContextCompat.checkSelfPermission(context, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||
NotificationHelper.notify(context, R.string.app_name, R.string.backup_receiver_read_permission_failed);
|
||||
NotificationHelper.notify(context, R.string.backup_receiver_title_backup_failed, R.string.backup_receiver_read_permission_failed);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ContextCompat.checkSelfPermission(context, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||
NotificationHelper.notify(context, R.string.app_name, R.string.backup_receiver_write_permission_failed);
|
||||
NotificationHelper.notify(context, R.string.backup_receiver_title_backup_failed, R.string.backup_receiver_write_permission_failed);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ public class EncryptedBackupBroadcastReceiver extends BackupBroadcastReceiver {
|
|||
String password = settings.getBackupPasswordEnc();
|
||||
|
||||
if (password.isEmpty()) {
|
||||
NotificationHelper.notify(context, R.string.app_name, R.string.backup_toast_crypt_password_not_set);
|
||||
NotificationHelper.notify(context, R.string.backup_receiver_title_backup_failed, R.string.backup_toast_crypt_password_not_set);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ public class EncryptedBackupBroadcastReceiver extends BackupBroadcastReceiver {
|
|||
if (settings.getEncryption() == Constants.EncryptionType.KEYSTORE) {
|
||||
encryptionKey = KeyStoreHelper.loadEncryptionKeyFromKeyStore(context, false);
|
||||
} else {
|
||||
NotificationHelper.notify(context, R.string.app_name, R.string.backup_receiver_custom_encryption_failed );
|
||||
NotificationHelper.notify(context, R.string.backup_receiver_title_backup_failed, R.string.backup_receiver_custom_encryption_failed );
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -55,13 +55,13 @@ public class EncryptedBackupBroadcastReceiver extends BackupBroadcastReceiver {
|
|||
SecretKey key = EncryptionHelper.generateSymmetricKeyFromPassword(password);
|
||||
byte[] encrypted = EncryptionHelper.encrypt(key, plain.getBytes(StandardCharsets.UTF_8));
|
||||
FileHelper.writeBytesToFile(context, savePath, encrypted);
|
||||
NotificationHelper.notify(context, R.string.app_name, context.getText(R.string.backup_receiver_completed) + savePath.getPath());
|
||||
NotificationHelper.notify(context, R.string.backup_receiver_title_backup_success, savePath.getPath());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
NotificationHelper.notify(context, R.string.app_name, R.string.backup_toast_export_failed);
|
||||
NotificationHelper.notify(context, R.string.backup_receiver_title_backup_failed, R.string.backup_toast_export_failed);
|
||||
}
|
||||
} else {
|
||||
NotificationHelper.notify(context, R.string.app_name, R.string.backup_toast_storage_not_accessible);
|
||||
NotificationHelper.notify(context, R.string.backup_receiver_title_backup_failed, R.string.backup_toast_storage_not_accessible);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ public class PlainTextBackupBroadcastReceiver extends BackupBroadcastReceiver {
|
|||
if (settings.getEncryption() == Constants.EncryptionType.KEYSTORE) {
|
||||
encryptionKey = KeyStoreHelper.loadEncryptionKeyFromKeyStore(context, false);
|
||||
} else {
|
||||
NotificationHelper.notify(context, R.string.app_name, R.string.backup_receiver_custom_encryption_failed);
|
||||
NotificationHelper.notify(context, R.string.backup_receiver_title_backup_failed, R.string.backup_receiver_custom_encryption_failed);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -42,12 +42,12 @@ public class PlainTextBackupBroadcastReceiver extends BackupBroadcastReceiver {
|
|||
ArrayList<Entry> entries = DatabaseHelper.loadDatabase(context, encryptionKey);
|
||||
|
||||
if (FileHelper.writeStringToFile(context, savePath, DatabaseHelper.entriesToString(entries))) {
|
||||
NotificationHelper.notify(context, R.string.app_name, context.getText(R.string.backup_receiver_completed) + savePath.getPath());
|
||||
NotificationHelper.notify(context, R.string.backup_receiver_title_backup_success, savePath.getPath());
|
||||
} else {
|
||||
NotificationHelper.notify(context, R.string.app_name, R.string.backup_toast_export_failed);
|
||||
NotificationHelper.notify(context, R.string.backup_receiver_title_backup_failed, R.string.backup_toast_export_failed);
|
||||
}
|
||||
} else {
|
||||
NotificationHelper.notify(context, R.string.app_name, R.string.backup_toast_storage_not_accessible);
|
||||
NotificationHelper.notify(context, R.string.backup_receiver_title_backup_failed, R.string.backup_toast_storage_not_accessible);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,21 +45,16 @@
|
|||
</string>
|
||||
|
||||
|
||||
<string name="backup_receiver_read_permission_failed">
|
||||
Read permission not granted, please do this before attempting backup
|
||||
</string>
|
||||
<string name="backup_receiver_title_backup_failed">Backup failed</string>
|
||||
<string name="backup_receiver_title_backup_success">Backup successful</string>
|
||||
|
||||
<string name="backup_receiver_write_permission_failed">
|
||||
Write permission not granted, please do this before attempting backup
|
||||
</string>
|
||||
<string name="backup_receiver_read_permission_failed">Read permission not granted, please do
|
||||
this before attempting backup</string>
|
||||
<string name="backup_receiver_write_permission_failed">Write permission not granted, please do
|
||||
this before attempting backup</string>
|
||||
<string name="backup_receiver_custom_encryption_failed">Password/PIN based encryption not
|
||||
supported with broadcast backup</string>
|
||||
|
||||
<string name="backup_receiver_custom_encryption_failed">
|
||||
Password/Pin based encryption not supported with broadcast backup
|
||||
</string>
|
||||
|
||||
<string name="backup_receiver_completed">
|
||||
Successful backup to:
|
||||
</string>
|
||||
|
||||
<!-- Toast messages -->
|
||||
<string name="backup_toast_mkdir_failed">Failed to create backup directory</string>
|
||||
|
|
Loading…
Reference in a new issue