diff --git a/app/app-debug.apk b/app/app-debug.apk index 4622e5aa2..4586e48cd 100644 Binary files a/app/app-debug.apk and b/app/app-debug.apk differ diff --git a/app/app-release.apk b/app/app-release.apk index a633ffc2d..25ec54805 100644 Binary files a/app/app-release.apk and b/app/app-release.apk differ diff --git a/app/build.gradle b/app/build.gradle index f44b837aa..26a2cd042 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -8,8 +8,8 @@ android { applicationId "com.zeapo.pwdstore" minSdkVersion 15 targetSdkVersion 19 - versionCode 9 - versionName "1.1-b4" + versionCode 11 + versionName "1.1-b5" } buildTypes { release { diff --git a/app/src/main/java/com/zeapo/pwdstore/GitAsyncTask.java b/app/src/main/java/com/zeapo/pwdstore/GitAsyncTask.java index 110710180..c2a6f28f5 100644 --- a/app/src/main/java/com/zeapo/pwdstore/GitAsyncTask.java +++ b/app/src/main/java/com/zeapo/pwdstore/GitAsyncTask.java @@ -51,6 +51,7 @@ public class GitAsyncTask extends AsyncTask { return -2; } catch (Exception e) { e.printStackTrace(); + return -98; } totalSize++; } diff --git a/app/src/main/java/com/zeapo/pwdstore/GitHandler.java b/app/src/main/java/com/zeapo/pwdstore/GitHandler.java index ecbf68aff..ba42f867e 100644 --- a/app/src/main/java/com/zeapo/pwdstore/GitHandler.java +++ b/app/src/main/java/com/zeapo/pwdstore/GitHandler.java @@ -11,13 +11,11 @@ import android.os.AsyncTask; import android.os.Bundle; import android.preference.PreferenceManager; import android.text.InputType; -import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; -import android.widget.Button; import android.widget.EditText; import android.widget.LinearLayout; import android.widget.Spinner; @@ -27,7 +25,6 @@ import com.jcraft.jsch.JSch; import com.jcraft.jsch.JSchException; import com.jcraft.jsch.Session; import com.jcraft.jsch.UserInfo; -import com.zeapo.pwdstore.crypto.PgpHandler; import com.zeapo.pwdstore.utils.PasswordRepository; import org.eclipse.jgit.api.CloneCommand; @@ -39,7 +36,6 @@ import org.eclipse.jgit.api.errors.InvalidRemoteException; import org.eclipse.jgit.api.errors.JGitInternalException; import org.eclipse.jgit.api.errors.TransportException; import org.eclipse.jgit.errors.UnsupportedCredentialItem; -import org.eclipse.jgit.merge.MergeStrategy; import org.eclipse.jgit.transport.CredentialItem; import org.eclipse.jgit.transport.CredentialsProvider; import org.eclipse.jgit.transport.CredentialsProviderUserInfo; @@ -75,7 +71,7 @@ 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; + private static final int GET_SSH_KEY_FROM_CLONE = 201; @Override protected void onCreate(Bundle savedInstanceState) { @@ -199,6 +195,7 @@ public class GitHandler extends Activity { e.printStackTrace(); } return true; + } return super.onOptionsItemSelected(item); } @@ -460,9 +457,9 @@ public class GitHandler extends Activity { public void pullOperation(UsernamePasswordCredentialsProvider provider) { - if (settings.getString("git_remote_username", "user").isEmpty() || - settings.getString("git_remote_server", "server.com").isEmpty() || - settings.getString("git_remote_location", "path/to/repository").isEmpty() ) + if (settings.getString("git_remote_username", "").isEmpty() || + settings.getString("git_remote_server", "").isEmpty() || + settings.getString("git_remote_location", "").isEmpty() ) new AlertDialog.Builder(this) .setMessage("You have to set the information about the server before synchronizing with the server") .setPositiveButton("On my way!", new DialogInterface.OnClickListener() { @@ -584,7 +581,7 @@ public class GitHandler extends Activity { public void onClick(DialogInterface dialog, int id) { try { Intent intent = new Intent(getApplicationContext(), UserPreference.class); - startActivityForResult(intent, GET_SSH_KEY); + startActivityForResult(intent, GET_SSH_KEY_FROM_CLONE); } catch (Exception e) { System.out.println("Exception caught :("); e.printStackTrace(); @@ -693,8 +690,8 @@ public class GitHandler extends Activity { case REQUEST_PUSH: authenticateAndRun("pushOperation"); break; - case GET_SSH_KEY: - authenticateAndRun("pullOperation"); + case GET_SSH_KEY_FROM_CLONE: + authenticateAndRun("cloneOperation"); } } diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java index 9819edef6..3234c1f65 100644 --- a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java +++ b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java @@ -137,7 +137,7 @@ public class PasswordStore extends Activity implements ToCloneOrNot.OnFragmentI public void getClone(View view){ Intent intent = new Intent(this, GitHandler.class); intent.putExtra("Operation", GitHandler.REQUEST_CLONE); - startActivity(intent); + startActivityForResult(intent, GitHandler.REQUEST_CLONE); } private void createRepository() { @@ -358,7 +358,10 @@ public class PasswordStore extends Activity implements ToCloneOrNot.OnFragmentI refreshListAdapter(); if (resultCode == RESULT_OK) { - refreshListAdapter(); + if (requestCode == GitHandler.REQUEST_CLONE) + checkLocalRepository(); + else + refreshListAdapter(); switch (requestCode) { case PgpHandler.REQUEST_CODE_ENCRYPT : diff --git a/app/src/main/java/com/zeapo/pwdstore/UserPreference.java b/app/src/main/java/com/zeapo/pwdstore/UserPreference.java index 09e61fbf8..26b3c3fae 100644 --- a/app/src/main/java/com/zeapo/pwdstore/UserPreference.java +++ b/app/src/main/java/com/zeapo/pwdstore/UserPreference.java @@ -70,8 +70,10 @@ public class UserPreference extends PreferenceActivity implements Preference.OnP if (requestCode == 1) { // Uri sshFile = data.getData(); try { - byte[] privateKey = IOUtils.toByteArray(this.getContentResolver().openInputStream(data.getData())); + InputStream sshKey = this.getContentResolver().openInputStream(data.getData()); + byte[] privateKey = IOUtils.toByteArray(sshKey); FileUtils.writeByteArrayToFile(new File(getFilesDir() + "/.ssh_key"), privateKey); + sshKey.close(); Log.i("PREF", "Got key"); setResult(RESULT_OK); diff --git a/libraries/openpgp-api-lib b/libraries/openpgp-api-lib index e515a4902..6aaf8fde5 160000 --- a/libraries/openpgp-api-lib +++ b/libraries/openpgp-api-lib @@ -1 +1 @@ -Subproject commit e515a49027fc5de36b8977cf8b096afc9838a9be +Subproject commit 6aaf8fde5e2541a614b1b0f8633372588eaee710