alert user when password is being overridden
This commit is contained in:
parent
9496ed31fd
commit
054056fa22
1 changed files with 22 additions and 9 deletions
|
@ -716,11 +716,8 @@ public class PasswordStore extends AppCompatActivity {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
File destinationFile = new File(target.getAbsolutePath() + "/" + source.getName());
|
||||||
|
|
||||||
if (!source.renameTo(new File(target.getAbsolutePath() + "/" + source.getName()))) {
|
|
||||||
// TODO this should show a warning to the user
|
|
||||||
Log.e("Moving", "Something went wrong while moving.");
|
|
||||||
} else {
|
|
||||||
String basename = FilenameUtils.getBaseName(source.getAbsolutePath());
|
String basename = FilenameUtils.getBaseName(source.getAbsolutePath());
|
||||||
|
|
||||||
String sourceLongName = PgpActivity.getLongName(source.getParent(),
|
String sourceLongName = PgpActivity.getLongName(source.getParent(),
|
||||||
|
@ -729,6 +726,22 @@ public class PasswordStore extends AppCompatActivity {
|
||||||
String destinationLongName = PgpActivity.getLongName(target.getAbsolutePath(),
|
String destinationLongName = PgpActivity.getLongName(target.getAbsolutePath(),
|
||||||
repositoryPath, basename);
|
repositoryPath, basename);
|
||||||
|
|
||||||
|
if (destinationFile.exists()) {
|
||||||
|
Log.e("Moving", "Trying to move a file that already exists.");
|
||||||
|
// TODO: Add option to cancel overwrite. Will be easier once this is an async task.
|
||||||
|
// TODO: Replace with resource strings
|
||||||
|
new AlertDialog.Builder(this)
|
||||||
|
.setTitle("Password already exists!")
|
||||||
|
.setMessage(String.format("This will overwrite %1$s with %2$s.",
|
||||||
|
destinationLongName, sourceLongName))
|
||||||
|
.setPositiveButton("Okay", null)
|
||||||
|
.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!source.renameTo(destinationFile)) {
|
||||||
|
// TODO this should show a warning to the user
|
||||||
|
Log.e("Moving", "Something went wrong while moving.");
|
||||||
|
} else {
|
||||||
commitChange(this.getResources()
|
commitChange(this.getResources()
|
||||||
.getString(R.string.git_commit_move_text,
|
.getString(R.string.git_commit_move_text,
|
||||||
sourceLongName,
|
sourceLongName,
|
||||||
|
|
Loading…
Reference in a new issue