aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/SshKeyGen.java37
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/UserPreference.java12
2 files changed, 24 insertions, 25 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/SshKeyGen.java b/app/src/main/java/com/zeapo/pwdstore/SshKeyGen.java
index 40c44065..4fb5f0e3 100644
--- a/app/src/main/java/com/zeapo/pwdstore/SshKeyGen.java
+++ b/app/src/main/java/com/zeapo/pwdstore/SshKeyGen.java
@@ -153,21 +153,19 @@ public class SshKeyGen extends AppCompatActivity {
}
}
- private class generateTask extends AsyncTask<View, Void, Exception> {
+ private class generateTask extends AsyncTask<String, Void, Exception> {
private ProgressDialog pd;
- protected Exception doInBackground(View... views) {
- InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
- imm.hideSoftInputFromWindow(views[0].getWindowToken(), 0);
-
- Spinner spinner = (Spinner) findViewById(R.id.length);
- int length = (Integer) spinner.getSelectedItem();
-
- EditText editText = (EditText) findViewById(R.id.passphrase);
- String passphrase = editText.getText().toString();
+ @Override
+ protected void onPreExecute() {
+ super.onPreExecute();
+ pd = ProgressDialog.show(SshKeyGen.this, "", "Generating keys");
+ }
- editText = (EditText) findViewById(R.id.comment);
- String comment = editText.getText().toString();
+ protected Exception doInBackground(String... strings) {
+ int length = Integer.parseInt(strings[0]);
+ String passphrase = strings[1];
+ String comment = strings[2];
JSch jsch = new JSch();
try {
@@ -193,13 +191,6 @@ public class SshKeyGen extends AppCompatActivity {
}
@Override
- protected void onPreExecute() {
- super.onPreExecute();
- pd = ProgressDialog.show(SshKeyGen.this, "", "Generating keys");
-
- }
-
- @Override
protected void onPostExecute(Exception e) {
super.onPostExecute(e);
pd.dismiss();
@@ -230,6 +221,12 @@ public class SshKeyGen extends AppCompatActivity {
// private and public key, then replaces the SshKeyGenFragment with a
// ShowSshKeyFragment which displays the public key.
public void generate(View view) {
- new generateTask().execute(view);
+ String length = Integer.toString((Integer) ((Spinner) findViewById(R.id.length)).getSelectedItem());
+ String passphrase = ((EditText) findViewById(R.id.passphrase)).getText().toString();
+ String comment = ((EditText) findViewById(R.id.comment)).getText().toString();
+ new generateTask().execute(length, passphrase, comment);
+
+ InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
+ imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
}
diff --git a/app/src/main/java/com/zeapo/pwdstore/UserPreference.java b/app/src/main/java/com/zeapo/pwdstore/UserPreference.java
index 285f2316..9a5c83d4 100644
--- a/app/src/main/java/com/zeapo/pwdstore/UserPreference.java
+++ b/app/src/main/java/com/zeapo/pwdstore/UserPreference.java
@@ -86,7 +86,7 @@ public class UserPreference extends AppCompatActivity {
findPreference("ssh_keygen").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
- callingActivity.makeSshKey();
+ callingActivity.makeSshKey(true);
return true;
}
});
@@ -202,7 +202,7 @@ public class UserPreference extends AppCompatActivity {
getSshKey();
break;
case "make_ssh_key":
- makeSshKey();
+ makeSshKey(false);
break;
case "git_external":
selectExternalGitRepository();
@@ -252,11 +252,13 @@ public class UserPreference extends AppCompatActivity {
/**
* Opens a key generator to generate a public/private key pair
*/
- public void makeSshKey() {
+ public void makeSshKey(boolean fromPreferences) {
Intent intent = new Intent(getApplicationContext(), SshKeyGen.class);
startActivity(intent);
- setResult(RESULT_OK);
- finish();
+ if (!fromPreferences) {
+ setResult(RESULT_OK);
+ finish();
+ }
}
private void copySshKey(Uri uri) throws IOException {