diff --git a/CHANGELOG b/CHANGELOG
index e6d9874b9..cbee6e3a3 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,7 @@
* Restore the timeout service, we need it to keep the app in memory long
enough to clear the clipboard and to remove the notifications.
* Autolink comment and advanced fields
+ * i18n more database error strings
KeePassDroid (1.9.18.2)
* Updated Dutch translations from Erik Jan Meijer
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 4faf4892c..23922180d 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -106,7 +106,10 @@
Install from Play Store
Install from Web
Invalid password or key file.
+ Invalid algorithm.
Database format not recognized.
+ Key file does not exist.
+ Key file is empty.
Length
Group list size
Text size in the group list
diff --git a/src/com/keepassdroid/database/PwDatabase.java b/src/com/keepassdroid/database/PwDatabase.java
index e9fdc7972..cb1db89ca 100644
--- a/src/com/keepassdroid/database/PwDatabase.java
+++ b/src/com/keepassdroid/database/PwDatabase.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2009-2011 Brian Pellin.
+ * Copyright 2009-2012 Brian Pellin.
*
* This file is part of KeePassDroid.
*
@@ -33,6 +33,7 @@ import java.util.List;
import com.keepassdroid.crypto.finalkey.FinalKey;
import com.keepassdroid.crypto.finalkey.FinalKeyFactory;
import com.keepassdroid.database.exception.InvalidKeyFileException;
+import com.keepassdroid.database.exception.KeyFileEmptyException;
import com.keepassdroid.stream.NullOutputStream;
public abstract class PwDatabase {
@@ -111,7 +112,7 @@ public abstract class PwDatabase {
File keyfile = new File(fileName);
if ( ! keyfile.exists() ) {
- throw new InvalidKeyFileException("Key file does not exist.");
+ throw new InvalidKeyFileException();
}
byte[] key = loadXmlKeyFile(fileName);
@@ -123,14 +124,14 @@ public abstract class PwDatabase {
try {
fis = new FileInputStream(keyfile);
} catch (FileNotFoundException e) {
- throw new InvalidKeyFileException("Key file does not exist.");
+ throw new InvalidKeyFileException();
}
BufferedInputStream bis = new BufferedInputStream(fis, 64);
long fileSize = keyfile.length();
if ( fileSize == 0 ) {
- throw new InvalidKeyFileException("Key file is empty.");
+ throw new KeyFileEmptyException();
} else if ( fileSize == 32 ) {
byte[] outputKey = new byte[32];
if ( bis.read(outputKey, 0, 32) != 32 ) {
diff --git a/src/com/keepassdroid/database/edit/LoadDB.java b/src/com/keepassdroid/database/edit/LoadDB.java
index 0e5bba956..3eb009d02 100644
--- a/src/com/keepassdroid/database/edit/LoadDB.java
+++ b/src/com/keepassdroid/database/edit/LoadDB.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2009 Brian Pellin.
+ * Copyright 2009-2012 Brian Pellin.
*
* This file is part of KeePassDroid.
*
@@ -30,11 +30,13 @@ import com.android.keepass.R;
import com.keepassdroid.Database;
import com.keepassdroid.app.App;
import com.keepassdroid.database.exception.ArcFourException;
+import com.keepassdroid.database.exception.InvalidAlgorithmException;
import com.keepassdroid.database.exception.InvalidDBException;
import com.keepassdroid.database.exception.InvalidDBSignatureException;
import com.keepassdroid.database.exception.InvalidDBVersionException;
import com.keepassdroid.database.exception.InvalidKeyFileException;
import com.keepassdroid.database.exception.InvalidPasswordException;
+import com.keepassdroid.database.exception.KeyFileEmptyException;
import com.keepassdroid.fileselect.FileDbHelper;
public class LoadDB extends RunnableOnFinish {
@@ -77,8 +79,14 @@ public class LoadDB extends RunnableOnFinish {
} catch (IOException e) {
finish(false, e.getMessage());
return;
+ } catch (KeyFileEmptyException e) {
+ finish(false, mCtx.getString(R.string.keyfile_is_empty));
+ return;
+ } catch (InvalidAlgorithmException e) {
+ finish(false, mCtx.getString(R.string.invalid_algorithm));
+ return;
} catch (InvalidKeyFileException e) {
- finish(false, e.getMessage());
+ finish(false, mCtx.getString(R.string.keyfile_does_not_exist));
return;
} catch (InvalidDBSignatureException e) {
finish(false, mCtx.getString(R.string.invalid_db_sig));
diff --git a/src/com/keepassdroid/database/exception/InvalidAlgorithmException.java b/src/com/keepassdroid/database/exception/InvalidAlgorithmException.java
new file mode 100644
index 000000000..97b783ecd
--- /dev/null
+++ b/src/com/keepassdroid/database/exception/InvalidAlgorithmException.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2012 Brian Pellin.
+ *
+ * This file is part of KeePassDroid.
+ *
+ * KeePassDroid is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * KeePassDroid is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with KeePassDroid. If not, see .
+ *
+ */
+package com.keepassdroid.database.exception;
+
+public class InvalidAlgorithmException extends InvalidDBException {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 3062682891863487208L;
+
+ public InvalidAlgorithmException() {
+ super();
+ }
+
+}
\ No newline at end of file
diff --git a/src/com/keepassdroid/database/exception/InvalidKeyFileException.java b/src/com/keepassdroid/database/exception/InvalidKeyFileException.java
index 7f6e5315e..11cd1d8b8 100644
--- a/src/com/keepassdroid/database/exception/InvalidKeyFileException.java
+++ b/src/com/keepassdroid/database/exception/InvalidKeyFileException.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2009 Brian Pellin.
+ * Copyright 2009-2012 Brian Pellin.
*
* This file is part of KeePassDroid.
*
@@ -24,7 +24,7 @@ public class InvalidKeyFileException extends InvalidDBException {
*/
private static final long serialVersionUID = 5540694419562294464L;
- public InvalidKeyFileException(String str) {
- super(str);
+ public InvalidKeyFileException() {
+ super();
}
}
diff --git a/src/com/keepassdroid/database/exception/KeyFileEmptyException.java b/src/com/keepassdroid/database/exception/KeyFileEmptyException.java
new file mode 100644
index 000000000..21a7a1010
--- /dev/null
+++ b/src/com/keepassdroid/database/exception/KeyFileEmptyException.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2012 Brian Pellin.
+ *
+ * This file is part of KeePassDroid.
+ *
+ * KeePassDroid is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * KeePassDroid is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with KeePassDroid. If not, see .
+ *
+ */package com.keepassdroid.database.exception;
+
+public class KeyFileEmptyException extends InvalidKeyFileException {
+ /**
+ *
+ */
+ private static final long serialVersionUID = -1630780661204212325L;
+
+ public KeyFileEmptyException() {
+ super();
+ }
+}
diff --git a/src/com/keepassdroid/database/load/ImporterV3.java b/src/com/keepassdroid/database/load/ImporterV3.java
index 8065bf1c8..d2436b279 100644
--- a/src/com/keepassdroid/database/load/ImporterV3.java
+++ b/src/com/keepassdroid/database/load/ImporterV3.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2009-2011 Brian Pellin.
+ * Copyright 2009-2012 Brian Pellin.
*
* This file is part of KeePassDroid.
*
@@ -75,6 +75,7 @@ import com.keepassdroid.database.PwDbHeaderV3;
import com.keepassdroid.database.PwEncryptionAlgorithm;
import com.keepassdroid.database.PwEntryV3;
import com.keepassdroid.database.PwGroupV3;
+import com.keepassdroid.database.exception.InvalidAlgorithmException;
import com.keepassdroid.database.exception.InvalidDBException;
import com.keepassdroid.database.exception.InvalidDBSignatureException;
import com.keepassdroid.database.exception.InvalidDBVersionException;
@@ -164,7 +165,7 @@ public class ImporterV3 extends Importer {
} else if( (hdr.flags & PwDbHeaderV3.FLAG_TWOFISH) != 0 ) {
newManager.algorithm = PwEncryptionAlgorithm.Twofish;
} else {
- throw new IOException( "Unknown algorithm." );
+ throw new InvalidAlgorithmException();
}