summaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/GitHandler.java8
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/PasswordStore.java57
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java23
3 files changed, 60 insertions, 28 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/GitHandler.java b/app/src/main/java/com/zeapo/pwdstore/GitHandler.java
index 619c0611..2544efe5 100644
--- a/app/src/main/java/com/zeapo/pwdstore/GitHandler.java
+++ b/app/src/main/java/com/zeapo/pwdstore/GitHandler.java
@@ -166,7 +166,7 @@ public class GitHandler extends Activity {
String hostname =
settings.getString("git_remote_username", "")
+ "@" +
- settings.getString("git_remote_server", "")
+ settings.getString("git_remote_server", "").trim()
+ ":" +
settings.getString("git_remote_location", "");
@@ -483,7 +483,7 @@ public class GitHandler extends Activity {
// check that the remote origin is here, else add it
PasswordRepository.addRemote("origin", settings.getString("git_remote_username", "user")
+ "@" +
- settings.getString("git_remote_server", "server.com")
+ settings.getString("git_remote_server", "server.com").trim()
+ ":" +
settings.getString("git_remote_location", "path/to/repository"));
@@ -507,7 +507,7 @@ public class GitHandler extends Activity {
public void pushOperation(UsernamePasswordCredentialsProvider provider) {
if (settings.getString("git_remote_username", "user").isEmpty() ||
- settings.getString("git_remote_server", "server.com").isEmpty() ||
+ settings.getString("git_remote_server", "server.com").trim().isEmpty() ||
settings.getString("git_remote_location", "path/to/repository").isEmpty() )
new AlertDialog.Builder(this)
.setMessage("You have to set the information about the server before synchronizing with the server")
@@ -532,7 +532,7 @@ public class GitHandler extends Activity {
// check that the remote origin is here, else add it
PasswordRepository.addRemote("origin", settings.getString("git_remote_username", "user")
+ "@" +
- settings.getString("git_remote_server", "server.com")
+ settings.getString("git_remote_server", "server.com").trim()
+ ":" +
settings.getString("git_remote_location", "path/to/repository"));
diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java
index dff6721d..cc9d4b6d 100644
--- a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java
+++ b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java
@@ -15,6 +15,7 @@ import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
+import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.ExpandableListView;
import android.widget.LinearLayout;
@@ -138,12 +139,30 @@ public class PasswordStore extends Activity implements ToCloneOrNot.OnFragmentI
startActivity(intent);
}
+ private void createRepository() {
+ final String keyId = settings.getString("openpgp_key_ids", "");
+
+ File localDir = new File(getFilesDir() + "/store/");
+ localDir.mkdir();
+ try {
+ // we take only the first key-id, we have to think about how to handle multiple keys, and why should we do that...
+ // also, for compatibility use short-version of the key-id
+ FileUtils.writeStringToFile(new File(localDir.getAbsolutePath() + "/.gpg-id"),
+ keyId.substring(keyId.length() - 8));
+ } catch (Exception e) {
+ localDir.delete();
+ return;
+ }
+ PasswordRepository.createRepository(localDir);
+ checkLocalRepository();
+ }
+
public void initRepository(View view) {
- String keyId = settings.getString("openpgp_key_ids", "");
+ final String keyId = settings.getString("openpgp_key_ids", "");
if (keyId.isEmpty())
new AlertDialog.Builder(this)
- .setMessage("You have to set the information about the server before synchronizing with the server")
+ .setMessage("You have to select your \"PGP-Key ID\" before initializing the repository")
.setPositiveButton("On my way!", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
@@ -160,19 +179,27 @@ public class PasswordStore extends Activity implements ToCloneOrNot.OnFragmentI
.show();
else {
- File localDir = new File(getFilesDir() + "/store/");
- localDir.mkdir();
- try {
- // we take only the first key-id, we have to think about how to handle multiple keys, and why should we do that...
- // also, for compatibility use short-version of the key-id
- FileUtils.writeStringToFile(new File(localDir.getAbsolutePath() + "/.gpg-id"),
- keyId.substring(keyId.length() - 8));
- } catch (Exception e) {
- localDir.delete();
- return;
- }
- PasswordRepository.createRepository(localDir);
- checkLocalRepository();
+ new AlertDialog.Builder(this)
+ .setMessage("Which connection method do you prefer?")
+ .setPositiveButton("ssh-key", new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialogInterface, int i) {
+ settings.edit().putString("git_remote_auth", "ssh-key").apply();
+ createRepository();
+ }
+ })
+ .setNegativeButton("username/password", new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialogInterface, int i) {
+ settings.edit().putString("git_remote_auth", "username/password").apply();
+ createRepository();
+ }
+ })
+ .setCancelable(false)
+
+
+ .show();
+
}
}
diff --git a/app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java b/app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java
index 47d21834..32f1237e 100644
--- a/app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java
+++ b/app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java
@@ -250,6 +250,9 @@ public class PgpHandler extends Activity implements OpenPgpServiceConnection.OnB
decryptAndVerify(data);
break;
}
+ case REQUEST_CODE_GET_KEY_IDS:
+ getKeyIds(data);
+ break;
}
} else if (resultCode == RESULT_CANCELED) {
bindingDialog.dismiss();
@@ -332,13 +335,14 @@ public class PgpHandler extends Activity implements OpenPgpServiceConnection.OnB
}
keyIDs = StringUtils.join(keys, ", ");
- settings.edit().putString("openpgp_key_ids", keyIDs).commit();
-
if (!keyIDs.isEmpty()) {
String mKeys = keyIDs.split(",").length > 1 ? keyIDs : keyIDs.split(",")[0];
- ((TextView) findViewById(R.id.crypto_key_ids)).setText(mKeys);
+// ((TextView) findViewById(R.id.crypto_key_ids)).setText(mKeys);
+ settings.edit().putString("openpgp_key_ids", keyIDs).apply();
+ Log.i("PGP", mKeys);
}
-
+ setResult(RESULT_OK);
+ finish();
}
break;
}
@@ -481,12 +485,13 @@ public class PgpHandler extends Activity implements OpenPgpServiceConnection.OnB
((TextView) findViewById(R.id.crypto_password_category)).setText(cat);
} else if (extra.getString("Operation").equals("GET_KEY_ID")) {
bindingDialog.dismiss();
+ getKeyIds(new Intent());
- setContentView(R.layout.key_id);
- if (!keyIDs.isEmpty()) {
- String keys = keyIDs.split(",").length > 1 ? keyIDs : keyIDs.split(",")[0];
- ((TextView) findViewById(R.id.crypto_key_ids)).setText(keys);
- }
+// setContentView(R.layout.key_id);
+// if (!keyIDs.isEmpty()) {
+// String keys = keyIDs.split(",").length > 1 ? keyIDs : keyIDs.split(",")[0];
+// ((TextView) findViewById(R.id.crypto_key_ids)).setText(keys);
+// }
}
}