mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
tabs to spaces
This commit is contained in:
@@ -39,79 +39,79 @@ import com.keepassdroid.database.exception.InvalidPasswordException;
|
|||||||
import com.keepassdroid.database.exception.KeyFileEmptyException;
|
import com.keepassdroid.database.exception.KeyFileEmptyException;
|
||||||
|
|
||||||
public class LoadDB extends RunnableOnFinish {
|
public class LoadDB extends RunnableOnFinish {
|
||||||
private String mFileName;
|
private String mFileName;
|
||||||
private String mPass;
|
private String mPass;
|
||||||
private String mKey;
|
private String mKey;
|
||||||
private Database mDb;
|
private Database mDb;
|
||||||
private Context mCtx;
|
private Context mCtx;
|
||||||
private boolean mRememberKeyfile;
|
private boolean mRememberKeyfile;
|
||||||
|
|
||||||
public LoadDB(Database db, Context ctx, String fileName, String pass, String key, OnFinish finish) {
|
public LoadDB(Database db, Context ctx, String fileName, String pass, String key, OnFinish finish) {
|
||||||
super(finish);
|
super(finish);
|
||||||
|
|
||||||
mDb = db;
|
mDb = db;
|
||||||
mCtx = ctx;
|
mCtx = ctx;
|
||||||
mFileName = fileName;
|
mFileName = fileName;
|
||||||
mPass = pass;
|
mPass = pass;
|
||||||
mKey = key;
|
mKey = key;
|
||||||
|
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctx);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctx);
|
||||||
mRememberKeyfile = prefs.getBoolean(ctx.getString(R.string.keyfile_key), ctx.getResources().getBoolean(R.bool.keyfile_default));
|
mRememberKeyfile = prefs.getBoolean(ctx.getString(R.string.keyfile_key), ctx.getResources().getBoolean(R.bool.keyfile_default));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
mDb.LoadData(mCtx, mFileName, mPass, mKey, mStatus);
|
||||||
|
|
||||||
|
saveFileData(mFileName, mKey);
|
||||||
|
|
||||||
|
} catch (ArcFourException e) {
|
||||||
|
finish(false, mCtx.getString(R.string.error_arc4));
|
||||||
|
return;
|
||||||
|
} catch (InvalidPasswordException e) {
|
||||||
|
finish(false, mCtx.getString(R.string.InvalidPassword));
|
||||||
|
return;
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
finish(false, mCtx.getString(R.string.FileNotFound));
|
||||||
|
return;
|
||||||
|
} 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, mCtx.getString(R.string.keyfile_does_not_exist));
|
||||||
|
return;
|
||||||
|
} catch (InvalidDBSignatureException e) {
|
||||||
|
finish(false, mCtx.getString(R.string.invalid_db_sig));
|
||||||
|
return;
|
||||||
|
} catch (InvalidDBVersionException e) {
|
||||||
|
finish(false, mCtx.getString(R.string.unsupported_db_version));
|
||||||
|
return;
|
||||||
|
} catch (InvalidDBException e) {
|
||||||
|
finish(false, mCtx.getString(R.string.error_invalid_db));
|
||||||
|
return;
|
||||||
|
} catch (OutOfMemoryError e) {
|
||||||
|
finish(false, mCtx.getString(R.string.error_out_of_memory));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
finish(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void saveFileData(String fileName, String key) {
|
||||||
|
if ( ! mRememberKeyfile ) {
|
||||||
|
key = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
App.getFileHistory().createFile(fileName, key);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
try {
|
|
||||||
mDb.LoadData(mCtx, mFileName, mPass, mKey, mStatus);
|
|
||||||
|
|
||||||
saveFileData(mFileName, mKey);
|
|
||||||
|
|
||||||
} catch (ArcFourException e) {
|
|
||||||
finish(false, mCtx.getString(R.string.error_arc4));
|
|
||||||
return;
|
|
||||||
} catch (InvalidPasswordException e) {
|
|
||||||
finish(false, mCtx.getString(R.string.InvalidPassword));
|
|
||||||
return;
|
|
||||||
} catch (FileNotFoundException e) {
|
|
||||||
finish(false, mCtx.getString(R.string.FileNotFound));
|
|
||||||
return;
|
|
||||||
} 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, mCtx.getString(R.string.keyfile_does_not_exist));
|
|
||||||
return;
|
|
||||||
} catch (InvalidDBSignatureException e) {
|
|
||||||
finish(false, mCtx.getString(R.string.invalid_db_sig));
|
|
||||||
return;
|
|
||||||
} catch (InvalidDBVersionException e) {
|
|
||||||
finish(false, mCtx.getString(R.string.unsupported_db_version));
|
|
||||||
return;
|
|
||||||
} catch (InvalidDBException e) {
|
|
||||||
finish(false, mCtx.getString(R.string.error_invalid_db));
|
|
||||||
return;
|
|
||||||
} catch (OutOfMemoryError e) {
|
|
||||||
finish(false, mCtx.getString(R.string.error_out_of_memory));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
finish(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void saveFileData(String fileName, String key) {
|
|
||||||
if ( ! mRememberKeyfile ) {
|
|
||||||
key = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
App.getFileHistory().createFile(fileName, key);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user