summaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
authorknuthy <knuthy@gmail.com>2014-09-20 20:56:14 +0200
committerknuthy <knuthy@gmail.com>2014-09-20 20:56:14 +0200
commit3764db17c9e6bf229bd404080abf86743bba4a8e (patch)
tree7ad02384f1df7b06d94e270190f636accfbdd45d /app/src/main/java
parent5c53fcb4a0bceeded4d620870a863b8b514bc4e0 (diff)
Corrected an issue on kitkat when opening ssh-key
This happens when you select a file using kitkat's file manager
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/GitAsyncTask.java1
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/GitHandler.java19
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/PasswordStore.java7
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/UserPreference.java4
4 files changed, 17 insertions, 14 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/GitAsyncTask.java b/app/src/main/java/com/zeapo/pwdstore/GitAsyncTask.java
index 11071018..c2a6f28f 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<GitCommand, Integer, Integer> {
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 ecbf68af..ba42f867 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 9819edef..3234c1f6 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 09e61fbf..26b3c3fa 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);