summaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
Diffstat (limited to 'app/src')
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java27
-rw-r--r--app/src/main/res/layout/fragment_to_clone_or_not.xml1
-rw-r--r--app/src/main/res/layout/key_id.xml44
3 files changed, 67 insertions, 5 deletions
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 754381cf..9cb1276a 100644
--- a/app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java
+++ b/app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java
@@ -32,6 +32,7 @@ import com.zeapo.pwdstore.utils.PasswordRepository;
import org.apache.commons.io.FileUtils;
import org.eclipse.jgit.api.Git;
+import org.eclipse.jgit.util.StringUtils;
import org.openintents.openpgp.OpenPgpError;
import org.openintents.openpgp.OpenPgpSignatureResult;
import org.openintents.openpgp.util.OpenPgpApi;
@@ -44,6 +45,7 @@ import java.io.File;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
public class PgpHandler extends Activity {
@@ -77,6 +79,7 @@ public class PgpHandler extends Activity {
settings = PreferenceManager.getDefaultSharedPreferences(this);
String providerPackageName = settings.getString("openpgp_provider_list", "");
accountName = settings.getString("openpgp_account_name", "");
+ keyIDs = settings.getString("openpgp_key_ids", "");
if (TextUtils.isEmpty(providerPackageName)) {
Toast.makeText(this, "No OpenPGP Provider selected!", Toast.LENGTH_LONG).show();
@@ -102,9 +105,11 @@ public class PgpHandler extends Activity {
cat = cat + "/";
((TextView) findViewById(R.id.crypto_password_category)).setText(cat);
} else if (extra.getString("Operation").equals("GET_KEY_ID")) {
- // wait until the service is bound
- while (!mServiceConnection.isBound());
- 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);
+ }
}
ActionBar actionBar = getActionBar();
@@ -146,11 +151,14 @@ public class PgpHandler extends Activity {
break;
case R.id.crypto_delete_button:
deletePassword();
+ break;
+ case R.id.crypto_get_key_ids:
+ getKeyIds(new Intent());
+ break;
default:
// should not happen
}
-// getKeyIds(new Intent());
}
private void handleError(final OpenPgpError error) {
@@ -316,11 +324,20 @@ public class PgpHandler extends Activity {
// get key ids
if (result.hasExtra(OpenPgpApi.RESULT_KEY_IDS)) {
long[] ids = result.getLongArrayExtra(OpenPgpApi.RESULT_KEY_IDS);
+ ArrayList<String> keys = new ArrayList<String>();
for (int i = 0; i < ids.length; i++) {
- keyIDs += OpenPgpUtils.convertKeyIdToHex(ids[i]) + ", ";
+ keys.add(OpenPgpUtils.convertKeyIdToHex(ids[i]));
}
+ 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);
+ }
+
}
break;
}
diff --git a/app/src/main/res/layout/fragment_to_clone_or_not.xml b/app/src/main/res/layout/fragment_to_clone_or_not.xml
index 90a1ac32..d25819e4 100644
--- a/app/src/main/res/layout/fragment_to_clone_or_not.xml
+++ b/app/src/main/res/layout/fragment_to_clone_or_not.xml
@@ -34,6 +34,7 @@
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="@android:color/holo_red_light"
+ android:onClick="initRepository"
android:text="@string/initialize"/>
</LinearLayout>
diff --git a/app/src/main/res/layout/key_id.xml b/app/src/main/res/layout/key_id.xml
new file mode 100644
index 00000000..00cbedde
--- /dev/null
+++ b/app/src/main/res/layout/key_id.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical" android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:paddingLeft="@dimen/activity_horizontal_margin"
+ android:paddingRight="@dimen/activity_horizontal_margin"
+ android:paddingTop="@dimen/activity_vertical_margin"
+ android:paddingBottom="@dimen/activity_vertical_margin"
+ android:background="#eee">
+
+ <GridLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:background="@drawable/rectangle">
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Key-id: "
+ android:layout_column="0"
+ android:layout_gravity="center_vertical"/>
+ <TextView
+ android:id="@+id/crypto_key_ids"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="No key selected"
+ android:layout_marginLeft="@dimen/activity_horizontal_margin"
+ android:textStyle="bold"
+ android:textColor="@android:color/holo_purple"
+ android:layout_column="1"
+ android:layout_gravity="center_vertical"/>
+ <ImageButton
+ android:id="@+id/crypto_get_key_ids"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_column="3"
+ android:src="@drawable/ico_key"
+ android:background="@android:color/transparent"
+ android:onClick="handleClick"
+ android:layout_gravity="center_vertical"/>
+ </GridLayout>
+
+
+</LinearLayout> \ No newline at end of file