mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-05-04 20:30:36 +00:00
Merge pull request #392 from alexbakker/export-filename
Append a timestamp to the filename of exported vaults
This commit is contained in:
commit
984010dc7a
2 changed files with 11 additions and 3 deletions
|
@ -37,6 +37,7 @@ import com.beemdevelopment.aegis.services.NotificationService;
|
|||
import com.beemdevelopment.aegis.ui.models.ImportEntry;
|
||||
import com.beemdevelopment.aegis.ui.preferences.SwitchPreference;
|
||||
import com.beemdevelopment.aegis.util.UUIDMap;
|
||||
import com.beemdevelopment.aegis.vault.VaultBackupManager;
|
||||
import com.beemdevelopment.aegis.vault.VaultEntry;
|
||||
import com.beemdevelopment.aegis.vault.VaultFileCredentials;
|
||||
import com.beemdevelopment.aegis.vault.VaultFileException;
|
||||
|
@ -633,10 +634,13 @@ public class PreferencesFragment extends PreferenceFragmentCompat {
|
|||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity())
|
||||
.setTitle(R.string.pref_export_summary)
|
||||
.setPositiveButton(android.R.string.ok, (dialog, which) -> {
|
||||
String filename = checked.get() ? VaultManager.FILENAME_EXPORT : VaultManager.FILENAME_EXPORT_PLAIN;
|
||||
filename = new VaultBackupManager.FileInfo(filename).toString();
|
||||
|
||||
Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT)
|
||||
.addCategory(Intent.CATEGORY_OPENABLE)
|
||||
.setType("application/json")
|
||||
.putExtra(Intent.EXTRA_TITLE, checked.get() ? VaultManager.FILENAME_EXPORT : VaultManager.FILENAME_EXPORT_PLAIN);
|
||||
.putExtra(Intent.EXTRA_TITLE, filename);
|
||||
|
||||
startActivityForResult(intent, checked.get() ? CODE_EXPORT_ENCRYPT : CODE_EXPORT);
|
||||
})
|
||||
|
|
|
@ -41,7 +41,7 @@ public class VaultBackupManager {
|
|||
}
|
||||
|
||||
public void create(Uri dirUri, int versionsToKeep) throws VaultManagerException {
|
||||
FileInfo fileInfo = new FileInfo(FILENAME_PREFIX, Calendar.getInstance().getTime());
|
||||
FileInfo fileInfo = new FileInfo(FILENAME_PREFIX);
|
||||
DocumentFile dir = DocumentFile.fromTreeUri(_context, dirUri);
|
||||
|
||||
Log.i(TAG, String.format("Creating backup at %s: %s", Uri.decode(dir.getUri().toString()), fileInfo.toString()));
|
||||
|
@ -112,7 +112,7 @@ public class VaultBackupManager {
|
|||
}
|
||||
}
|
||||
|
||||
private static class FileInfo {
|
||||
public static class FileInfo {
|
||||
private String _filename;
|
||||
private Date _date;
|
||||
|
||||
|
@ -121,6 +121,10 @@ public class VaultBackupManager {
|
|||
_date = date;
|
||||
}
|
||||
|
||||
public FileInfo(String filename) {
|
||||
this(filename, Calendar.getInstance().getTime());
|
||||
}
|
||||
|
||||
public static FileInfo parseFilename(String filename) throws ParseException {
|
||||
if (filename == null) {
|
||||
throw new ParseException("The filename must not be null", 0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue