aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Wong <wongma@protonmail.ch>2015-07-14 22:42:55 -0400
committerMatthew Wong <wongma@protonmail.ch>2015-07-14 22:42:55 -0400
commit56cbade066eb21817a1f7f9a3b1a4c57f808828f (patch)
treec2c22d3a36f229e164c2a35a554e6dd5de97b5d5
parent6f25a8bb232833e78c23ca67f157f75d109d421b (diff)
Add preference to start ssh keygen
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/UserPreference.java19
-rw-r--r--app/src/main/res/xml/preference.xml3
2 files changed, 22 insertions, 0 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/UserPreference.java b/app/src/main/java/com/zeapo/pwdstore/UserPreference.java
index ff6f5048..dc535990 100644
--- a/app/src/main/java/com/zeapo/pwdstore/UserPreference.java
+++ b/app/src/main/java/com/zeapo/pwdstore/UserPreference.java
@@ -82,6 +82,14 @@ public class UserPreference extends AppCompatActivity {
}
});
+ findPreference("ssh_keygen").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
+ @Override
+ public boolean onPreferenceClick(Preference preference) {
+ callingActivity.makeSshKey();
+ return true;
+ }
+ });
+
findPreference("git_server_info").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
@@ -174,6 +182,9 @@ public class UserPreference extends AppCompatActivity {
case "get_ssh_key":
getSshKey();
break;
+ case "make_ssh_key":
+ makeSshKey();
+ break;
case "git_external":
selectExternalGitRepository();
break;
@@ -219,6 +230,14 @@ public class UserPreference extends AppCompatActivity {
startActivityForResult(intent, IMPORT_SSH_KEY);
}
+ /**
+ * Opens a key generator to generate a public/private key pair
+ */
+ public void makeSshKey() {
+ Intent intent = new Intent(getApplicationContext(), SshKeyGen.class);
+ startActivity(intent);
+ }
+
private void copySshKey(Uri uri) throws IOException {
InputStream sshKey = this.getContentResolver().openInputStream(uri);
byte[] privateKey = IOUtils.toByteArray(sshKey);
diff --git a/app/src/main/res/xml/preference.xml b/app/src/main/res/xml/preference.xml
index 1ddcde41..e8772616 100644
--- a/app/src/main/res/xml/preference.xml
+++ b/app/src/main/res/xml/preference.xml
@@ -8,6 +8,9 @@
android:key="ssh_key"
android:title="@string/pref_ssh_title" />
<Preference
+ android:key="ssh_keygen"
+ android:title="@string/pref_ssh_keygen_title" />
+ <Preference
android:key="git_delete_repo"
android:summary="Deletes local repository"
android:title="@string/pref_git_delete_repo" />