diff options
author | knuthy <knuthy@gmail.com> | 2014-09-20 20:30:24 +0200 |
---|---|---|
committer | knuthy <knuthy@gmail.com> | 2014-09-20 20:30:24 +0200 |
commit | c73517056c227e056831ccfca837633e5a97532e (patch) | |
tree | 09a880af68d14766e679e6cf6da075616eae6479 /app/src/main/java | |
parent | ac6522cb9405d5d12a93fe955d2fc24351380c11 (diff) |
corrected a major bug with kitkat when selecting sshkey
Diffstat (limited to 'app/src/main/java')
-rw-r--r-- | app/src/main/java/com/zeapo/pwdstore/GitHandler.java | 6 | ||||
-rw-r--r-- | app/src/main/java/com/zeapo/pwdstore/UserPreference.java | 15 |
2 files changed, 16 insertions, 5 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/GitHandler.java b/app/src/main/java/com/zeapo/pwdstore/GitHandler.java index 38af8a81..ecbf68af 100644 --- a/app/src/main/java/com/zeapo/pwdstore/GitHandler.java +++ b/app/src/main/java/com/zeapo/pwdstore/GitHandler.java @@ -75,6 +75,8 @@ public class GitHandler extends Activity { public static final int REQUEST_CLONE = 103; public static final int REQUEST_INIT = 104; + private static final int GET_SSH_KEY = 201; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -582,7 +584,7 @@ public class GitHandler extends Activity { public void onClick(DialogInterface dialog, int id) { try { Intent intent = new Intent(getApplicationContext(), UserPreference.class); - startActivity(intent); + startActivityForResult(intent, GET_SSH_KEY); } catch (Exception e) { System.out.println("Exception caught :("); e.printStackTrace(); @@ -691,6 +693,8 @@ public class GitHandler extends Activity { case REQUEST_PUSH: authenticateAndRun("pushOperation"); break; + case GET_SSH_KEY: + authenticateAndRun("pullOperation"); } } diff --git a/app/src/main/java/com/zeapo/pwdstore/UserPreference.java b/app/src/main/java/com/zeapo/pwdstore/UserPreference.java index 69459226..09e61fbf 100644 --- a/app/src/main/java/com/zeapo/pwdstore/UserPreference.java +++ b/app/src/main/java/com/zeapo/pwdstore/UserPreference.java @@ -15,8 +15,11 @@ import com.zeapo.pwdstore.crypto.PgpHandler; import com.zeapo.pwdstore.utils.PasswordRepository; import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; import java.io.File; +import java.io.FileOutputStream; +import java.io.InputStream; import java.net.URI; public class UserPreference extends PreferenceActivity implements Preference.OnPreferenceClickListener { @@ -49,7 +52,6 @@ public class UserPreference extends PreferenceActivity implements Preference.OnP @Override public boolean onPreferenceClick(Preference pref) { - System.out.println(pref); if (pref.getKey().equals("openpgp_key_id")) { Intent intent = new Intent(this, PgpHandler.class); intent.putExtra("Operation", "GET_KEY_ID"); @@ -66,11 +68,16 @@ public class UserPreference extends PreferenceActivity implements Preference.OnP Intent data) { if (resultCode == RESULT_OK) { if (requestCode == 1) { - Uri sshFile = data.getData(); +// Uri sshFile = data.getData(); try { - FileUtils.copyFile(new File(sshFile.getPath()), new File(getFilesDir() + "/.ssh_key")); - } catch (Exception e) { + byte[] privateKey = IOUtils.toByteArray(this.getContentResolver().openInputStream(data.getData())); + FileUtils.writeByteArrayToFile(new File(getFilesDir() + "/.ssh_key"), privateKey); + Log.i("PREF", "Got key"); + setResult(RESULT_OK); + finish(); + } catch (Exception e) { + e.printStackTrace(); } } } |