From 8869799ffb94391937bd3dfb5dcebb4fade8f155 Mon Sep 17 00:00:00 2001 From: RichyHBM Date: Thu, 1 Feb 2018 13:06:39 +0000 Subject: [PATCH] Add constants for dated filename --- .../shadowice/flocke/andotp/Utilities/Constants.java | 4 ++++ .../org/shadowice/flocke/andotp/Utilities/Tools.java | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/app/src/main/java/org/shadowice/flocke/andotp/Utilities/Constants.java b/app/src/main/java/org/shadowice/flocke/andotp/Utilities/Constants.java index 7e268dbb..588a1864 100644 --- a/app/src/main/java/org/shadowice/flocke/andotp/Utilities/Constants.java +++ b/app/src/main/java/org/shadowice/flocke/andotp/Utilities/Constants.java @@ -107,6 +107,10 @@ public class Constants { public final static String BACKUP_FILENAME_CRYPT = "otp_accounts.json.aes"; public final static String BACKUP_FILENAME_PGP = "otp_accounts.json.gpg"; + public final static String BACKUP_FILENAME_PLAIN_FORMAT = "otp_accounts_%s.json"; + public final static String BACKUP_FILENAME_CRYPT_FORMAT = "otp_accounts_%s.json.aes"; + public final static String BACKUP_FILENAME_PGP_FORMAT = "otp_accounts_%s.json.gpg"; + public final static String BACKUP_MIMETYPE_PLAIN = "application/json"; public final static String BACKUP_MIMETYPE_CRYPT = "binary/aes"; public final static String BACKUP_MIMETYPE_PGP = "application/pgp-encrypted"; diff --git a/app/src/main/java/org/shadowice/flocke/andotp/Utilities/Tools.java b/app/src/main/java/org/shadowice/flocke/andotp/Utilities/Tools.java index 198327fe..ec5a7ba9 100644 --- a/app/src/main/java/org/shadowice/flocke/andotp/Utilities/Tools.java +++ b/app/src/main/java/org/shadowice/flocke/andotp/Utilities/Tools.java @@ -33,6 +33,10 @@ import android.os.Build; import android.os.Environment; import java.io.File; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; import java.util.Locale; public class Tools { @@ -94,4 +98,10 @@ public class Tools { } return ret.toString().trim(); } + + public static String getDateTimeString() { + DateFormat df = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss", Locale.ENGLISH); + Date now = Calendar.getInstance().getTime(); + return df.format(now); + } }