Add preference to start ssh keygen
This commit is contained in:
parent
6f25a8bb23
commit
56cbade066
2 changed files with 22 additions and 0 deletions
|
@ -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() {
|
findPreference("git_server_info").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
|
@ -174,6 +182,9 @@ public class UserPreference extends AppCompatActivity {
|
||||||
case "get_ssh_key":
|
case "get_ssh_key":
|
||||||
getSshKey();
|
getSshKey();
|
||||||
break;
|
break;
|
||||||
|
case "make_ssh_key":
|
||||||
|
makeSshKey();
|
||||||
|
break;
|
||||||
case "git_external":
|
case "git_external":
|
||||||
selectExternalGitRepository();
|
selectExternalGitRepository();
|
||||||
break;
|
break;
|
||||||
|
@ -219,6 +230,14 @@ public class UserPreference extends AppCompatActivity {
|
||||||
startActivityForResult(intent, IMPORT_SSH_KEY);
|
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 {
|
private void copySshKey(Uri uri) throws IOException {
|
||||||
InputStream sshKey = this.getContentResolver().openInputStream(uri);
|
InputStream sshKey = this.getContentResolver().openInputStream(uri);
|
||||||
byte[] privateKey = IOUtils.toByteArray(sshKey);
|
byte[] privateKey = IOUtils.toByteArray(sshKey);
|
||||||
|
|
|
@ -7,6 +7,9 @@
|
||||||
<Preference
|
<Preference
|
||||||
android:key="ssh_key"
|
android:key="ssh_key"
|
||||||
android:title="@string/pref_ssh_title" />
|
android:title="@string/pref_ssh_title" />
|
||||||
|
<Preference
|
||||||
|
android:key="ssh_keygen"
|
||||||
|
android:title="@string/pref_ssh_keygen_title" />
|
||||||
<Preference
|
<Preference
|
||||||
android:key="git_delete_repo"
|
android:key="git_delete_repo"
|
||||||
android:summary="Deletes local repository"
|
android:summary="Deletes local repository"
|
||||||
|
|
Loading…
Reference in a new issue