fix authentication dialog not showing

This commit is contained in:
Mohamed 2017-06-15 13:51:19 +02:00
parent d9ca609089
commit 496d058819
4 changed files with 11 additions and 7 deletions

View file

@ -634,8 +634,7 @@ public class GitActivity extends AppCompatActivity {
try { try {
op.executeAfterAuthentication(connectionMode, op.executeAfterAuthentication(connectionMode,
settings.getString("git_remote_username", "git"), settings.getString("git_remote_username", "git"),
new File(getFilesDir() + "/.ssh_key"), true); new File(getFilesDir() + "/.ssh_key"), false);
activity.finish();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }

View file

@ -76,13 +76,15 @@ public abstract class GitOperation {
/** /**
* Executes the GitCommand in an async task * Executes the GitCommand in an async task
*
* @param finishOnEnd * @param finishOnEnd
*/ */
public abstract void execute(boolean finishOnEnd); public abstract void execute(boolean finishOnEnd);
/** /**
* Executes the GitCommand in an async task after creating the authentication * Executes the GitCommand in an async task after creating the authentication
* @param connectionMode the server-connection mode *
* @param connectionMode the server-connection mode
* @param username the username * @param username the username
* @param sshKey the ssh-key file * @param sshKey the ssh-key file
* @param finishOnEnd * @param finishOnEnd
@ -93,7 +95,8 @@ public abstract class GitOperation {
/** /**
* Executes the GitCommand in an async task after creating the authentication * Executes the GitCommand in an async task after creating the authentication
* @param connectionMode the server-connection mode *
* @param connectionMode the server-connection mode
* @param username the username * @param username the username
* @param sshKey the ssh-key file * @param sshKey the ssh-key file
* @param showError show the passphrase edit text in red * @param showError show the passphrase edit text in red
@ -168,6 +171,7 @@ public abstract class GitOperation {
if (keyPair.decrypt(passphrase.getText().toString())) { if (keyPair.decrypt(passphrase.getText().toString())) {
// Authenticate using the ssh-key and then execute the command // Authenticate using the ssh-key and then execute the command
setAuthentication(sshKey, username, passphrase.getText().toString()).execute(finishOnEnd); setAuthentication(sshKey, username, passphrase.getText().toString()).execute(finishOnEnd);
callingActivity.finish();
} else { } else {
// call back the method // call back the method
executeAfterAuthentication(connectionMode, username, sshKey, true, finishOnEnd); executeAfterAuthentication(connectionMode, username, sshKey, true, finishOnEnd);
@ -175,11 +179,12 @@ public abstract class GitOperation {
} }
}).setNegativeButton(callingActivity.getResources().getString(R.string.dialog_cancel), new DialogInterface.OnClickListener() { }).setNegativeButton(callingActivity.getResources().getString(R.string.dialog_cancel), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) { public void onClick(DialogInterface dialog, int whichButton) {
// Do nothing. callingActivity.finish();
} }
}).show(); }).show();
} else { } else {
setAuthentication(sshKey, username, "").execute(finishOnEnd); setAuthentication(sshKey, username, "").execute(finishOnEnd);
callingActivity.finish();
} }
} catch (JSchException e) { } catch (JSchException e) {
new AlertDialog.Builder(callingActivity) new AlertDialog.Builder(callingActivity)

View file

@ -40,7 +40,7 @@ public class PullOperation extends GitOperation {
if (this.provider != null) { if (this.provider != null) {
((PullCommand) this.command).setCredentialsProvider(this.provider); ((PullCommand) this.command).setCredentialsProvider(this.provider);
} }
new GitAsyncTask(callingActivity, true, false, this).execute(this.command); new GitAsyncTask(callingActivity, finishOnEnd, false, this).execute(this.command);
} }
@Override @Override

View file

@ -40,7 +40,7 @@ public class PushOperation extends GitOperation {
if (this.provider != null) { if (this.provider != null) {
((PushCommand) this.command).setCredentialsProvider(this.provider); ((PushCommand) this.command).setCredentialsProvider(this.provider);
} }
new GitAsyncTask(callingActivity, true, false, this).execute(this.command); new GitAsyncTask(callingActivity, finishOnEnd, false, this).execute(this.command);
} }
@Override @Override