aboutsummaryrefslogtreecommitdiffstats
path: root/app/src/main/java/com/zeapo/pwdstore/git
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/com/zeapo/pwdstore/git')
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/git/CloneOperation.java8
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/git/GitActivity.java131
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/git/GitAsyncTask.java4
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/git/GitOperation.java120
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/git/PullOperation.java12
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/git/PushOperation.java11
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/git/SyncOperation.java10
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/git/config/GitConfigSessionFactory.java4
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/git/config/SshConfigSessionFactory.java1
9 files changed, 111 insertions, 190 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/git/CloneOperation.java b/app/src/main/java/com/zeapo/pwdstore/git/CloneOperation.java
index c3f22a64..e3de3f05 100644
--- a/app/src/main/java/com/zeapo/pwdstore/git/CloneOperation.java
+++ b/app/src/main/java/com/zeapo/pwdstore/git/CloneOperation.java
@@ -2,10 +2,7 @@ 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.CloneCommand;
import org.eclipse.jgit.api.Git;
@@ -79,10 +76,7 @@ public class CloneOperation extends GitOperation {
+ callingActivity.getResources().getString(R.string.jgit_error_dialog_text)
+ errorMessage
+ "\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) {
- }
+ setPositiveButton(callingActivity.getResources().getString(R.string.dialog_ok), (dialogInterface, i) -> {
}).show();
}
}
diff --git a/app/src/main/java/com/zeapo/pwdstore/git/GitActivity.java b/app/src/main/java/com/zeapo/pwdstore/git/GitActivity.java
index b6e9af82..ca451247 100644
--- a/app/src/main/java/com/zeapo/pwdstore/git/GitActivity.java
+++ b/app/src/main/java/com/zeapo/pwdstore/git/GitActivity.java
@@ -2,13 +2,10 @@ package com.zeapo.pwdstore.git;
import android.app.Activity;
import android.content.Context;
-import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
-import androidx.appcompat.app.AlertDialog;
-import androidx.appcompat.app.AppCompatActivity;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
@@ -20,11 +17,11 @@ import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;
-
+import androidx.appcompat.app.AlertDialog;
+import androidx.appcompat.app.AppCompatActivity;
import com.zeapo.pwdstore.R;
import com.zeapo.pwdstore.UserPreference;
import com.zeapo.pwdstore.utils.PasswordRepository;
-
import org.apache.commons.io.FileUtils;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.RebaseCommand;
@@ -39,29 +36,24 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class GitActivity extends AppCompatActivity {
+ public static final int REQUEST_PULL = 101;
+ public static final int REQUEST_PUSH = 102;
+ public static final int REQUEST_CLONE = 103;
+ public static final int REQUEST_INIT = 104;
+ public static final int EDIT_SERVER = 105;
+ public static final int REQUEST_SYNC = 106;
+ public static final int REQUEST_CREATE = 107;
+ public static final int EDIT_GIT_CONFIG = 108;
private static final String TAG = "GitAct";
private static final String emailPattern = "^[^@]+@[^@]+$";
-
private Activity activity;
private Context context;
-
private String protocol;
private String connectionMode;
-
private File localDir;
private String hostname;
-
private SharedPreferences settings;
- public static final int REQUEST_PULL = 101;
- public static final int REQUEST_PUSH = 102;
- public static final int REQUEST_CLONE = 103;
- public static final int REQUEST_INIT = 104;
- public static final int EDIT_SERVER = 105;
- public static final int REQUEST_SYNC = 106;
- public static final int REQUEST_CREATE = 107;
- public static final int EDIT_GIT_CONFIG = 108;
-
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -83,8 +75,8 @@ public class GitActivity extends AppCompatActivity {
setContentView(R.layout.activity_git_clone);
setTitle(R.string.title_activity_git_clone);
- final Spinner protcol_spinner = (Spinner) findViewById(R.id.clone_protocol);
- final Spinner connection_mode_spinner = (Spinner) findViewById(R.id.connection_mode);
+ final Spinner protcol_spinner = findViewById(R.id.clone_protocol);
+ final Spinner connection_mode_spinner = findViewById(R.id.connection_mode);
// init the spinner for connection modes
final ArrayAdapter<CharSequence> connection_mode_adapter = ArrayAdapter.createFromResource(this,
@@ -157,11 +149,11 @@ public class GitActivity extends AppCompatActivity {
}
// init the server information
- final EditText server_url = ((EditText) findViewById(R.id.server_url));
- final EditText server_port = ((EditText) findViewById(R.id.server_port));
- final EditText server_path = ((EditText) findViewById(R.id.server_path));
- final EditText server_user = ((EditText) findViewById(R.id.server_user));
- final EditText server_uri = ((EditText) findViewById(R.id.clone_uri));
+ final EditText server_url = findViewById(R.id.server_url);
+ final EditText server_port = findViewById(R.id.server_port);
+ final EditText server_path = findViewById(R.id.server_path);
+ final EditText server_user = findViewById(R.id.server_user);
+ final EditText server_uri = findViewById(R.id.clone_uri);
server_url.setText(settings.getString("git_remote_server", ""));
server_port.setText(settings.getString("git_remote_port", ""));
@@ -282,11 +274,11 @@ public class GitActivity extends AppCompatActivity {
* Fills in the server_uri field with the information coming from other fields
*/
private void updateURI() {
- EditText uri = (EditText) findViewById(R.id.clone_uri);
- EditText server_url = ((EditText) findViewById(R.id.server_url));
- EditText server_port = ((EditText) findViewById(R.id.server_port));
- EditText server_path = ((EditText) findViewById(R.id.server_path));
- EditText server_user = ((EditText) findViewById(R.id.server_user));
+ EditText uri = findViewById(R.id.clone_uri);
+ EditText server_url = findViewById(R.id.server_url);
+ EditText server_port = findViewById(R.id.server_port);
+ EditText server_path = findViewById(R.id.server_path);
+ EditText server_user = findViewById(R.id.server_user);
if (uri != null) {
switch (protocol) {
@@ -301,7 +293,7 @@ public class GitActivity extends AppCompatActivity {
findViewById(R.id.warn_url).setVisibility(View.GONE);
} else {
- TextView warn_url = (TextView) findViewById(R.id.warn_url);
+ TextView warn_url = findViewById(R.id.warn_url);
if (!server_path.getText().toString().matches("/.*") && !server_port.getText().toString().isEmpty()) {
warn_url.setText(R.string.warn_malformed_url_port);
warn_url.setVisibility(View.VISIBLE);
@@ -342,11 +334,11 @@ public class GitActivity extends AppCompatActivity {
* Splits the information in server_uri into the other fields
*/
private void splitURI() {
- EditText server_uri = (EditText) findViewById(R.id.clone_uri);
- EditText server_url = ((EditText) findViewById(R.id.server_url));
- EditText server_port = ((EditText) findViewById(R.id.server_port));
- EditText server_path = ((EditText) findViewById(R.id.server_path));
- EditText server_user = ((EditText) findViewById(R.id.server_user));
+ EditText server_uri = findViewById(R.id.clone_uri);
+ EditText server_url = findViewById(R.id.server_url);
+ EditText server_port = findViewById(R.id.server_port);
+ EditText server_path = findViewById(R.id.server_path);
+ EditText server_user = findViewById(R.id.server_user);
String uri = server_uri.getText().toString();
Pattern pattern = Pattern.compile("(.+)@([\\w\\d\\.]+):([\\d]+)*(.*)");
@@ -361,7 +353,7 @@ public class GitActivity extends AppCompatActivity {
server_port.setText(matcher.group(3));
server_path.setText(matcher.group(4));
- TextView warn_url = (TextView) findViewById(R.id.warn_url);
+ TextView warn_url = findViewById(R.id.warn_url);
if (!server_path.getText().toString().matches("/.*") && !server_port.getText().toString().isEmpty()) {
warn_url.setText(R.string.warn_malformed_url_port);
warn_url.setVisibility(View.VISIBLE);
@@ -467,8 +459,8 @@ public class GitActivity extends AppCompatActivity {
private void showGitConfig() {
// init the server information
- final EditText git_user_name = ((EditText) findViewById(R.id.git_user_name));
- final EditText git_user_email = ((EditText) findViewById(R.id.git_user_email));
+ final EditText git_user_name = findViewById(R.id.git_user_name);
+ final EditText git_user_email = findViewById(R.id.git_user_email);
git_user_name.setText(settings.getString("git_config_user_name", ""));
git_user_email.setText(settings.getString("git_config_user_email", ""));
@@ -476,7 +468,7 @@ public class GitActivity extends AppCompatActivity {
// git status
Repository repo = PasswordRepository.getRepository(PasswordRepository.getRepositoryDirectory(activity.getApplicationContext()));
if (repo != null) {
- final TextView git_commit_hash = (TextView) findViewById(R.id.git_commit_hash);
+ final TextView git_commit_hash = findViewById(R.id.git_commit_hash);
try {
ObjectId objectId = repo.resolve(Constants.HEAD);
Ref ref = repo.getRef("refs/heads/master");
@@ -532,6 +524,7 @@ public class GitActivity extends AppCompatActivity {
GitAsyncTask tasks = new GitAsyncTask(activity, false, true, this);
tasks.execute(new Git(repo).rebase().setOperation(RebaseCommand.Operation.ABORT));
}
+
@Override
public void onSuccess() {
showGitConfig();
@@ -560,36 +553,30 @@ public class GitActivity extends AppCompatActivity {
setMessage(getResources().getString(R.string.dialog_delete_msg) + " " + localDir.toString()).
setCancelable(false).
setPositiveButton(R.string.dialog_delete,
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
+ (dialog, id) -> {
+ try {
+ FileUtils.deleteDirectory(localDir);
try {
- FileUtils.deleteDirectory(localDir);
- try {
- new CloneOperation(localDir, activity)
- .setCommand(hostname)
- .executeAfterAuthentication(connectionMode, settings.getString("git_remote_username", "git"), new File(getFilesDir() + "/.ssh_key"));
- } catch (Exception e) {
- //This is what happens when jgit fails :(
- //TODO Handle the diffent cases of exceptions
- e.printStackTrace();
- new AlertDialog.Builder(GitActivity.this).setMessage(e.getMessage()).show();
- }
- } catch (IOException e) {
- //TODO Handle the exception correctly if we are unable to delete the directory...
+ new CloneOperation(localDir, activity)
+ .setCommand(hostname)
+ .executeAfterAuthentication(connectionMode, settings.getString("git_remote_username", "git"), new File(getFilesDir() + "/.ssh_key"));
+ } catch (Exception e) {
+ //This is what happens when jgit fails :(
+ //TODO Handle the diffent cases of exceptions
e.printStackTrace();
new AlertDialog.Builder(GitActivity.this).setMessage(e.getMessage()).show();
}
-
- dialog.cancel();
+ } catch (IOException e) {
+ //TODO Handle the exception correctly if we are unable to delete the directory...
+ e.printStackTrace();
+ new AlertDialog.Builder(GitActivity.this).setMessage(e.getMessage()).show();
}
+
+ dialog.cancel();
}
).
setNegativeButton(R.string.dialog_do_not_delete,
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- dialog.cancel();
- }
- }
+ (dialog, id) -> dialog.cancel()
).
show();
} else {
@@ -626,20 +613,14 @@ public class GitActivity extends AppCompatActivity {
settings.getString("git_remote_location", "").isEmpty())
new AlertDialog.Builder(this)
.setMessage(activity.getResources().getString(R.string.set_information_dialog_text))
- .setPositiveButton(activity.getResources().getString(R.string.dialog_positive), new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialogInterface, int i) {
- Intent intent = new Intent(activity, UserPreference.class);
- startActivityForResult(intent, REQUEST_PULL);
- }
+ .setPositiveButton(activity.getResources().getString(R.string.dialog_positive), (dialogInterface, i) -> {
+ Intent intent = new Intent(activity, UserPreference.class);
+ startActivityForResult(intent, REQUEST_PULL);
})
- .setNegativeButton(activity.getResources().getString(R.string.dialog_negative), new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialogInterface, int i) {
- // do nothing :(
- setResult(RESULT_OK);
- finish();
- }
+ .setNegativeButton(activity.getResources().getString(R.string.dialog_negative), (dialogInterface, i) -> {
+ // do nothing :(
+ setResult(RESULT_OK);
+ finish();
})
.show();
diff --git a/app/src/main/java/com/zeapo/pwdstore/git/GitAsyncTask.java b/app/src/main/java/com/zeapo/pwdstore/git/GitAsyncTask.java
index 7fe31979..79234a32 100644
--- a/app/src/main/java/com/zeapo/pwdstore/git/GitAsyncTask.java
+++ b/app/src/main/java/com/zeapo/pwdstore/git/GitAsyncTask.java
@@ -4,10 +4,8 @@ import android.app.Activity;
import android.app.ProgressDialog;
import android.os.AsyncTask;
import android.util.Log;
-
import com.zeapo.pwdstore.PasswordStore;
import com.zeapo.pwdstore.R;
-
import org.eclipse.jgit.api.CommitCommand;
import org.eclipse.jgit.api.GitCommand;
import org.eclipse.jgit.api.PushCommand;
@@ -52,7 +50,7 @@ public class GitAsyncTask extends AsyncTask<GitCommand, Integer, String> {
// the previous status will eventually be used to avoid a commit
if (nbChanges == null || nbChanges > 0)
command.call();
- }else if (command instanceof PushCommand) {
+ } else if (command instanceof PushCommand) {
for (final PushResult result : ((PushCommand) command).call()) {
// Code imported (modified) from Gerrit PushOp, license Apache v2
for (final RemoteRefUpdate rru : result.getRemoteUpdates()) {
diff --git a/app/src/main/java/com/zeapo/pwdstore/git/GitOperation.java b/app/src/main/java/com/zeapo/pwdstore/git/GitOperation.java
index a0da14ab..7f6ecd81 100644
--- a/app/src/main/java/com/zeapo/pwdstore/git/GitOperation.java
+++ b/app/src/main/java/com/zeapo/pwdstore/git/GitOperation.java
@@ -2,19 +2,17 @@ package com.zeapo.pwdstore.git;
import android.annotation.SuppressLint;
import android.app.Activity;
-import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
-import androidx.annotation.Nullable;
-import androidx.appcompat.app.AlertDialog;
import android.text.InputType;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.LinearLayout;
-
+import androidx.annotation.Nullable;
+import androidx.appcompat.app.AlertDialog;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.KeyPair;
@@ -23,7 +21,6 @@ import com.zeapo.pwdstore.UserPreference;
import com.zeapo.pwdstore.git.config.GitConfigSessionFactory;
import com.zeapo.pwdstore.git.config.SshConfigSessionFactory;
import com.zeapo.pwdstore.utils.PasswordRepository;
-
import org.eclipse.jgit.api.GitCommand;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.transport.JschConfigSessionFactory;
@@ -109,46 +106,37 @@ public abstract class GitOperation {
new AlertDialog.Builder(callingActivity)
.setMessage(callingActivity.getResources().getString(R.string.ssh_preferences_dialog_text))
.setTitle(callingActivity.getResources().getString(R.string.ssh_preferences_dialog_title))
- .setPositiveButton(callingActivity.getResources().getString(R.string.ssh_preferences_dialog_import), new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int id) {
- try {
- // Ask the UserPreference to provide us with the ssh-key
- // onResult has to be handled by the callingActivity
- Intent intent = new Intent(callingActivity.getApplicationContext(), UserPreference.class);
- intent.putExtra("operation", "get_ssh_key");
- callingActivity.startActivityForResult(intent, GET_SSH_KEY_FROM_CLONE);
- } catch (Exception e) {
- System.out.println("Exception caught :(");
- e.printStackTrace();
- }
+ .setPositiveButton(callingActivity.getResources().getString(R.string.ssh_preferences_dialog_import), (dialog, id) -> {
+ try {
+ // Ask the UserPreference to provide us with the ssh-key
+ // onResult has to be handled by the callingActivity
+ Intent intent = new Intent(callingActivity.getApplicationContext(), UserPreference.class);
+ intent.putExtra("operation", "get_ssh_key");
+ callingActivity.startActivityForResult(intent, GET_SSH_KEY_FROM_CLONE);
+ } catch (Exception e) {
+ System.out.println("Exception caught :(");
+ e.printStackTrace();
}
})
- .setNegativeButton(callingActivity.getResources().getString(R.string.ssh_preferences_dialog_generate), new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- try {
- // Duplicated code
- Intent intent = new Intent(callingActivity.getApplicationContext(), UserPreference.class);
- intent.putExtra("operation", "make_ssh_key");
- callingActivity.startActivityForResult(intent, GET_SSH_KEY_FROM_CLONE);
- } catch (Exception e) {
- System.out.println("Exception caught :(");
- e.printStackTrace();
- }
+ .setNegativeButton(callingActivity.getResources().getString(R.string.ssh_preferences_dialog_generate), (dialog, which) -> {
+ try {
+ // Duplicated code
+ Intent intent = new Intent(callingActivity.getApplicationContext(), UserPreference.class);
+ intent.putExtra("operation", "make_ssh_key");
+ callingActivity.startActivityForResult(intent, GET_SSH_KEY_FROM_CLONE);
+ } catch (Exception e) {
+ System.out.println("Exception caught :(");
+ e.printStackTrace();
}
})
- .setNeutralButton(callingActivity.getResources().getString(R.string.dialog_cancel), new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int id) {
- // Finish the blank GitActivity so user doesn't have to press back
- callingActivity.finish();
- }
+ .setNeutralButton(callingActivity.getResources().getString(R.string.dialog_cancel), (dialog, id) -> {
+ // Finish the blank GitActivity so user doesn't have to press back
+ callingActivity.finish();
}).show();
} else {
LayoutInflater layoutInflater = LayoutInflater.from(callingActivity.getApplicationContext());
@SuppressLint("InflateParams") final View dialogView = layoutInflater.inflate(R.layout.git_passphrase_layout, null);
- final EditText passphrase = (EditText) dialogView.findViewById(R.id.sshkey_passphrase);
+ final EditText passphrase = dialogView.findViewById(R.id.sshkey_passphrase);
final SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(callingActivity.getApplicationContext());
final String sshKeyPassphrase = settings.getString("ssh_key_passphrase", null);
if (showError) {
@@ -172,25 +160,21 @@ public abstract class GitOperation {
.setTitle(callingActivity.getResources().getString(R.string.passphrase_dialog_title))
.setMessage(callingActivity.getResources().getString(R.string.passphrase_dialog_text))
.setView(dialogView)
- .setPositiveButton(callingActivity.getResources().getString(R.string.dialog_ok), new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int whichButton) {
- if (keyPair.decrypt(passphrase.getText().toString())) {
- boolean rememberPassphrase = ((CheckBox) dialogView.findViewById(R.id.sshkey_remember_passphrase)).isChecked();
- if (rememberPassphrase) {
- settings.edit().putString("ssh_key_passphrase", passphrase.getText().toString()).apply();
- }
- // Authenticate using the ssh-key and then execute the command
- setAuthentication(sshKey, username, passphrase.getText().toString()).execute();
- } else {
- settings.edit().putString("ssh_key_passphrase", null).apply();
- // call back the method
- executeAfterAuthentication(connectionMode, username, sshKey, true);
+ .setPositiveButton(callingActivity.getResources().getString(R.string.dialog_ok), (dialog, whichButton) -> {
+ if (keyPair.decrypt(passphrase.getText().toString())) {
+ boolean rememberPassphrase = ((CheckBox) dialogView.findViewById(R.id.sshkey_remember_passphrase)).isChecked();
+ if (rememberPassphrase) {
+ settings.edit().putString("ssh_key_passphrase", passphrase.getText().toString()).apply();
}
+ // Authenticate using the ssh-key and then execute the command
+ setAuthentication(sshKey, username, passphrase.getText().toString()).execute();
+ } else {
+ settings.edit().putString("ssh_key_passphrase", null).apply();
+ // call back the method
+ executeAfterAuthentication(connectionMode, username, sshKey, true);
}
- }).setNegativeButton(callingActivity.getResources().getString(R.string.dialog_cancel), new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int whichButton) {
- // Do nothing.
- }
+ }).setNegativeButton(callingActivity.getResources().getString(R.string.dialog_cancel), (dialog, whichButton) -> {
+ // Do nothing.
}).show();
}
} else {
@@ -200,11 +184,8 @@ public abstract class GitOperation {
new AlertDialog.Builder(callingActivity)
.setTitle("Unable to open the ssh-key")
.setMessage("Please check that it was imported.")
- .setPositiveButton("Ok", new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialogInterface, int i) {
+ .setPositiveButton("Ok", (dialogInterface, i) -> {
- }
}).show();
}
}
@@ -218,16 +199,12 @@ public abstract class GitOperation {
.setTitle(callingActivity.getResources().getString(R.string.passphrase_dialog_title))
.setMessage(callingActivity.getResources().getString(R.string.password_dialog_text))
.setView(password)
- .setPositiveButton(callingActivity.getResources().getString(R.string.dialog_ok), new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int whichButton) {
- // authenticate using the user/pwd and then execute the command
- setAuthentication(username, password.getText().toString()).execute();
+ .setPositiveButton(callingActivity.getResources().getString(R.string.dialog_ok), (dialog, whichButton) -> {
+ // authenticate using the user/pwd and then execute the command
+ setAuthentication(username, password.getText().toString()).execute();
- }
- }).setNegativeButton(callingActivity.getResources().getString(R.string.dialog_cancel), new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int whichButton) {
- // Do nothing.
- }
+ }).setNegativeButton(callingActivity.getResources().getString(R.string.dialog_cancel), (dialog, whichButton) -> {
+ // Do nothing.
}).show();
}
}
@@ -239,12 +216,9 @@ public abstract class GitOperation {
new AlertDialog.Builder(callingActivity).
setTitle(callingActivity.getResources().getString(R.string.jgit_error_dialog_title)).
setMessage(callingActivity.getResources().getString(R.string.jgit_error_dialog_text) + errorMessage).
- setPositiveButton(callingActivity.getResources().getString(R.string.dialog_ok), new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialogInterface, int i) {
- callingActivity.setResult(Activity.RESULT_CANCELED);
- callingActivity.finish();
- }
+ setPositiveButton(callingActivity.getResources().getString(R.string.dialog_ok), (dialogInterface, i) -> {
+ callingActivity.setResult(Activity.RESULT_CANCELED);
+ callingActivity.finish();
}).show();
}
diff --git a/app/src/main/java/com/zeapo/pwdstore/git/PullOperation.java b/app/src/main/java/com/zeapo/pwdstore/git/PullOperation.java
index 1a903aaf..322a6206 100644
--- a/app/src/main/java/com/zeapo/pwdstore/git/PullOperation.java
+++ b/app/src/main/java/com/zeapo/pwdstore/git/PullOperation.java
@@ -2,13 +2,9 @@ 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;
-import org.eclipse.jgit.merge.MergeStrategy;
import java.io.File;
@@ -26,6 +22,7 @@ public class PullOperation extends GitOperation {
/**
* Sets the command
+ *
* @return the current object
*/
public PullOperation setCommand() {
@@ -52,11 +49,6 @@ public class PullOperation extends GitOperation {
+ callingActivity.getResources().getString(R.string.jgit_error_dialog_text)
+ errorMessage
+ "\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();
+ setPositiveButton(callingActivity.getResources().getString(R.string.dialog_ok), (dialogInterface, i) -> callingActivity.finish()).show();
}
}
diff --git a/app/src/main/java/com/zeapo/pwdstore/git/PushOperation.java b/app/src/main/java/com/zeapo/pwdstore/git/PushOperation.java
index 06eb6bb3..056b7034 100644
--- a/app/src/main/java/com/zeapo/pwdstore/git/PushOperation.java
+++ b/app/src/main/java/com/zeapo/pwdstore/git/PushOperation.java
@@ -2,10 +2,7 @@ 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.PushCommand;
@@ -25,6 +22,7 @@ public class PushOperation extends GitOperation {
/**
* Sets the command
+ *
* @return the current object
*/
public PushOperation setCommand() {
@@ -49,11 +47,6 @@ public class PushOperation extends GitOperation {
new AlertDialog.Builder(callingActivity).
setTitle(callingActivity.getResources().getString(R.string.jgit_error_dialog_title)).
setMessage(callingActivity.getString(R.string.jgit_error_push_dialog_text) + errorMessage).
- setPositiveButton(callingActivity.getResources().getString(R.string.dialog_ok), new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialogInterface, int i) {
- callingActivity.finish();
- }
- }).show();
+ setPositiveButton(callingActivity.getResources().getString(R.string.dialog_ok), (dialogInterface, i) -> callingActivity.finish()).show();
}
}
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 9dd43cb9..4e7f037d 100644
--- a/app/src/main/java/com/zeapo/pwdstore/git/SyncOperation.java
+++ b/app/src/main/java/com/zeapo/pwdstore/git/SyncOperation.java
@@ -2,10 +2,7 @@ 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.AddCommand;
import org.eclipse.jgit.api.CommitCommand;
import org.eclipse.jgit.api.Git;
@@ -64,11 +61,6 @@ public class SyncOperation extends GitOperation {
+ callingActivity.getResources().getString(R.string.jgit_error_dialog_text)
+ errorMessage
+ "\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();
+ setPositiveButton(callingActivity.getResources().getString(R.string.dialog_ok), (dialogInterface, i) -> callingActivity.finish()).show();
}
}
diff --git a/app/src/main/java/com/zeapo/pwdstore/git/config/GitConfigSessionFactory.java b/app/src/main/java/com/zeapo/pwdstore/git/config/GitConfigSessionFactory.java
index ab23361e..58762888 100644
--- a/app/src/main/java/com/zeapo/pwdstore/git/config/GitConfigSessionFactory.java
+++ b/app/src/main/java/com/zeapo/pwdstore/git/config/GitConfigSessionFactory.java
@@ -3,7 +3,6 @@ package com.zeapo.pwdstore.git.config;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.Session;
-
import org.eclipse.jgit.transport.JschConfigSessionFactory;
import org.eclipse.jgit.transport.OpenSshConfig;
import org.eclipse.jgit.util.FS;
@@ -15,8 +14,7 @@ public class GitConfigSessionFactory extends JschConfigSessionFactory {
}
@Override
- protected JSch
- getJSch(final OpenSshConfig.Host hc, FS fs) throws JSchException {
+ protected JSch getJSch(final OpenSshConfig.Host hc, FS fs) throws JSchException {
JSch jsch = super.getJSch(hc, fs);
jsch.removeAllIdentity();
return jsch;
diff --git a/app/src/main/java/com/zeapo/pwdstore/git/config/SshConfigSessionFactory.java b/app/src/main/java/com/zeapo/pwdstore/git/config/SshConfigSessionFactory.java
index b958546e..38c5fb7e 100644
--- a/app/src/main/java/com/zeapo/pwdstore/git/config/SshConfigSessionFactory.java
+++ b/app/src/main/java/com/zeapo/pwdstore/git/config/SshConfigSessionFactory.java
@@ -4,7 +4,6 @@ import com.jcraft.jsch.JSch;
import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.Session;
import com.jcraft.jsch.UserInfo;
-
import org.eclipse.jgit.errors.UnsupportedCredentialItem;
import org.eclipse.jgit.transport.CredentialItem;
import org.eclipse.jgit.transport.CredentialsProvider;