diff options
| author | Mohamed Zenadi <zeapo@users.noreply.github.com> | 2016-12-11 16:57:17 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-12-11 16:57:17 +0100 |
| commit | 737d2819273e7ba07d3a993422b138b93b852415 (patch) | |
| tree | d3f03de3764a39560b24e1b550bc0eed2feedd38 /app/src/main/java/com/zeapo/pwdstore/git/SyncOperation.java | |
| parent | fd9e958d40a56a2a3b8dfbef86944d3d5f53fec2 (diff) | |
| download | HardenedPass-737d2819273e7ba07d3a993422b138b93b852415.tar.gz HardenedPass-737d2819273e7ba07d3a993422b138b93b852415.zip | |
Handle jgit errors (#243)
* initial work on the git error handling
* remove throws exception and handle the jsch one correctly
* move the commit task into its own operation
* get rid of the interface and rely on the abstract class GitOperation
* add error message to the pull command
* add error message to the push command
* add error message to the sync operationˆ
Diffstat (limited to 'app/src/main/java/com/zeapo/pwdstore/git/SyncOperation.java')
| -rw-r--r-- | app/src/main/java/com/zeapo/pwdstore/git/SyncOperation.java | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/git/SyncOperation.java b/app/src/main/java/com/zeapo/pwdstore/git/SyncOperation.java index 9351cc1b..4b698075 100644 --- a/app/src/main/java/com/zeapo/pwdstore/git/SyncOperation.java +++ b/app/src/main/java/com/zeapo/pwdstore/git/SyncOperation.java @@ -1,6 +1,10 @@ package com.zeapo.pwdstore.git; import android.app.Activity; +import android.app.AlertDialog; +import android.content.DialogInterface; + +import com.zeapo.pwdstore.R; import org.eclipse.jgit.api.Git; import org.eclipse.jgit.api.PullCommand; @@ -39,12 +43,27 @@ public class SyncOperation extends GitOperation { } @Override - public void execute() throws Exception { - + public void execute() { if (this.provider != null) { this.pullCommand.setCredentialsProvider(this.provider); this.pushCommand.setCredentialsProvider(this.provider); } - new GitAsyncTask(callingActivity, true, false, PullCommand.class).execute(this.pullCommand, this.pushCommand); + new GitAsyncTask(callingActivity, true, false, this).execute(this.pullCommand, this.pushCommand); + } + + @Override + public void onTaskEnded(String result) { + new AlertDialog.Builder(callingActivity). + setTitle(callingActivity.getResources().getString(R.string.jgit_error_dialog_title)). + setMessage("Error occured during the sync operation, " + + callingActivity.getResources().getString(R.string.jgit_error_dialog_text) + + result + + "\nPlease check the FAQ for possible reasons why this error might occur."). + setPositiveButton(callingActivity.getResources().getString(R.string.dialog_ok), new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + callingActivity.finish(); + } + }).show(); } } |
