mirror of
https://github.com/android-password-store/Android-Password-Store
synced 2025-08-31 06:15:48 +00:00
corrected a major bug with kitkat when selecting sshkey
This commit is contained in:
@@ -75,6 +75,8 @@ public class GitHandler extends Activity {
|
|||||||
public static final int REQUEST_CLONE = 103;
|
public static final int REQUEST_CLONE = 103;
|
||||||
public static final int REQUEST_INIT = 104;
|
public static final int REQUEST_INIT = 104;
|
||||||
|
|
||||||
|
private static final int GET_SSH_KEY = 201;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@@ -582,7 +584,7 @@ public class GitHandler extends Activity {
|
|||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
try {
|
try {
|
||||||
Intent intent = new Intent(getApplicationContext(), UserPreference.class);
|
Intent intent = new Intent(getApplicationContext(), UserPreference.class);
|
||||||
startActivity(intent);
|
startActivityForResult(intent, GET_SSH_KEY);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.out.println("Exception caught :(");
|
System.out.println("Exception caught :(");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@@ -691,6 +693,8 @@ public class GitHandler extends Activity {
|
|||||||
case REQUEST_PUSH:
|
case REQUEST_PUSH:
|
||||||
authenticateAndRun("pushOperation");
|
authenticateAndRun("pushOperation");
|
||||||
break;
|
break;
|
||||||
|
case GET_SSH_KEY:
|
||||||
|
authenticateAndRun("pullOperation");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -15,8 +15,11 @@ import com.zeapo.pwdstore.crypto.PgpHandler;
|
|||||||
import com.zeapo.pwdstore.utils.PasswordRepository;
|
import com.zeapo.pwdstore.utils.PasswordRepository;
|
||||||
|
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
|
||||||
public class UserPreference extends PreferenceActivity implements Preference.OnPreferenceClickListener {
|
public class UserPreference extends PreferenceActivity implements Preference.OnPreferenceClickListener {
|
||||||
@@ -49,7 +52,6 @@ public class UserPreference extends PreferenceActivity implements Preference.OnP
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceClick(Preference pref) {
|
public boolean onPreferenceClick(Preference pref) {
|
||||||
System.out.println(pref);
|
|
||||||
if (pref.getKey().equals("openpgp_key_id")) {
|
if (pref.getKey().equals("openpgp_key_id")) {
|
||||||
Intent intent = new Intent(this, PgpHandler.class);
|
Intent intent = new Intent(this, PgpHandler.class);
|
||||||
intent.putExtra("Operation", "GET_KEY_ID");
|
intent.putExtra("Operation", "GET_KEY_ID");
|
||||||
@@ -66,11 +68,16 @@ public class UserPreference extends PreferenceActivity implements Preference.OnP
|
|||||||
Intent data) {
|
Intent data) {
|
||||||
if (resultCode == RESULT_OK) {
|
if (resultCode == RESULT_OK) {
|
||||||
if (requestCode == 1) {
|
if (requestCode == 1) {
|
||||||
Uri sshFile = data.getData();
|
// Uri sshFile = data.getData();
|
||||||
try {
|
try {
|
||||||
FileUtils.copyFile(new File(sshFile.getPath()), new File(getFilesDir() + "/.ssh_key"));
|
byte[] privateKey = IOUtils.toByteArray(this.getContentResolver().openInputStream(data.getData()));
|
||||||
} catch (Exception e) {
|
FileUtils.writeByteArrayToFile(new File(getFilesDir() + "/.ssh_key"), privateKey);
|
||||||
|
|
||||||
|
Log.i("PREF", "Got key");
|
||||||
|
setResult(RESULT_OK);
|
||||||
|
finish();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user