re-enable locking for clone operation
This commit is contained in:
parent
a8f7282677
commit
110b8c5abc
3 changed files with 36 additions and 12 deletions
|
@ -70,7 +70,7 @@ public class CloneOperation extends GitOperation {
|
|||
if (this.provider != null) {
|
||||
((CloneCommand) this.command).setCredentialsProvider(this.provider);
|
||||
}
|
||||
new GitAsyncTask(callingActivity, true, false, this).execute(this.command);
|
||||
new GitAsyncTask(callingActivity, finishOnEnd, false, this).execute(this.command);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -5,6 +5,7 @@ import android.app.ProgressDialog;
|
|||
import android.os.AsyncTask;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.text.Html;
|
||||
import android.text.Spanned;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
@ -18,29 +19,40 @@ import org.eclipse.jgit.api.StatusCommand;
|
|||
|
||||
public class GitAsyncTask extends AsyncTask<GitCommand, String, String> {
|
||||
private Activity activity;
|
||||
private boolean finishOnEnd;
|
||||
private boolean lockAndFinishActivity;
|
||||
private boolean refreshListOnEnd;
|
||||
private ProgressDialog dialog;
|
||||
private GitOperation operation;
|
||||
private Snackbar snack;
|
||||
|
||||
public GitAsyncTask(Activity activity, boolean finishOnEnd, boolean refreshListOnEnd, GitOperation operation) {
|
||||
public GitAsyncTask(Activity activity, boolean lockAndFinishActivity, boolean refreshListOnEnd, GitOperation operation) {
|
||||
this.activity = activity;
|
||||
this.finishOnEnd = finishOnEnd;
|
||||
this.lockAndFinishActivity = lockAndFinishActivity;
|
||||
this.refreshListOnEnd = refreshListOnEnd;
|
||||
this.operation = operation;
|
||||
|
||||
this.dialog = new ProgressDialog(this.activity);
|
||||
}
|
||||
|
||||
protected void onPreExecute() {
|
||||
Toast.makeText(activity.getApplicationContext(),
|
||||
Html.fromHtml(String.format("<font color=\"#ffffff\">Running %s</font>", operation.getClass().getSimpleName())),
|
||||
Toast.LENGTH_LONG).show();
|
||||
final Spanned message = Html.fromHtml(String.format("<font color=\"#ffffff\">Running %s</font>", operation.getClass().getSimpleName()));
|
||||
|
||||
if (lockAndFinishActivity) {
|
||||
this.dialog.setMessage(message);
|
||||
this.dialog.setCancelable(false);
|
||||
this.dialog.show();
|
||||
} else {
|
||||
Toast.makeText(activity.getApplicationContext(), message, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
|
||||
protected void onProgressUpdate(String... progress) {
|
||||
Toast.makeText(activity.getApplicationContext(),
|
||||
Html.fromHtml(String.format("<font color=\"#ffffff\">Running jgit command: <strong>%s</strong></font>", progress[0])),
|
||||
Toast.LENGTH_LONG).show();
|
||||
final Spanned message = Html.fromHtml(String.format("<font color=\"#ffffff\">Running jgit command: <strong>%s</strong></font>", progress[0]));
|
||||
if (lockAndFinishActivity) {
|
||||
this.dialog.setMessage(message);
|
||||
} else {
|
||||
Toast.makeText(activity.getApplicationContext(), message, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -70,13 +82,20 @@ public class GitAsyncTask extends AsyncTask<GitCommand, String, String> {
|
|||
}
|
||||
|
||||
protected void onPostExecute(String result) {
|
||||
if (this.dialog != null)
|
||||
try {
|
||||
this.dialog.dismiss();
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
if (result == null)
|
||||
result = "Unexpected error";
|
||||
|
||||
if (!result.isEmpty()) {
|
||||
this.operation.onTaskEnded(result);
|
||||
} else {
|
||||
if (finishOnEnd) {
|
||||
if (lockAndFinishActivity) {
|
||||
this.activity.setResult(Activity.RESULT_OK);
|
||||
this.activity.finish();
|
||||
}
|
||||
|
|
|
@ -99,7 +99,12 @@ public abstract class GitOperation {
|
|||
* @param showError show the passphrase edit text in red
|
||||
* @param finishOnEnd
|
||||
*/
|
||||
private void executeAfterAuthentication(final String connectionMode, final String username, @Nullable final File sshKey, final boolean showError, final boolean finishOnEnd) {
|
||||
private void executeAfterAuthentication(
|
||||
final String connectionMode,
|
||||
final String username,
|
||||
@Nullable final File sshKey,
|
||||
final boolean showError,
|
||||
final boolean finishOnEnd) {
|
||||
if (connectionMode.equalsIgnoreCase("ssh-key")) {
|
||||
if (sshKey == null || !sshKey.exists()) {
|
||||
new AlertDialog.Builder(callingActivity)
|
||||
|
|
Loading…
Reference in a new issue