From 6983ef4f82a85cae1e7f83638ce2f5ec37e96ef0 Mon Sep 17 00:00:00 2001 From: Mohamed Zenadi Date: Sat, 4 Apr 2015 16:17:10 +0200 Subject: [PATCH] Show the pgp key selected in preferences Fix #76 --- .../com/zeapo/pwdstore/UserPreference.java | 5 ++- .../com/zeapo/pwdstore/crypto/PgpHandler.java | 37 +++++++++---------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/app/src/main/java/com/zeapo/pwdstore/UserPreference.java b/app/src/main/java/com/zeapo/pwdstore/UserPreference.java index 48175167..becf44ea 100644 --- a/app/src/main/java/com/zeapo/pwdstore/UserPreference.java +++ b/app/src/main/java/com/zeapo/pwdstore/UserPreference.java @@ -9,7 +9,6 @@ import android.preference.Preference; import android.preference.PreferenceFragment; import android.preference.PreferenceManager; import android.support.v7.app.ActionBarActivity; -import android.util.Log; import android.view.MenuItem; import android.widget.Toast; @@ -35,7 +34,9 @@ public class UserPreference extends ActionBarActivity implements Preference.OnPr super.onCreate(savedInstanceState); // Load the preferences from an XML resource addPreferencesFromResource(R.xml.preference); - findPreference("openpgp_key_id").setOnPreferenceClickListener((UserPreference) getActivity()); + Preference keyPref = findPreference("openpgp_key_id"); + keyPref.setSummary(getPreferenceManager().getSharedPreferences().getString("openpgp_key_ids", "No key selected")); + keyPref.setOnPreferenceClickListener((UserPreference) getActivity()); findPreference("ssh_key").setOnPreferenceClickListener((UserPreference) getActivity()); findPreference("git_server_info").setOnPreferenceClickListener((UserPreference) getActivity()); findPreference("git_delete_repo").setOnPreferenceClickListener((UserPreference) getActivity()); 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 6915ebd4..7cd76c4a 100644 --- a/app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java +++ b/app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java @@ -1,27 +1,8 @@ package com.zeapo.pwdstore.crypto; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.UnsupportedEncodingException; -import java.text.ParseException; -import java.util.ArrayList; - -import org.apache.commons.io.FileUtils; -import org.eclipse.jgit.util.StringUtils; -import org.openintents.openpgp.IOpenPgpService; -import org.openintents.openpgp.OpenPgpError; -import org.openintents.openpgp.util.OpenPgpApi; -import org.openintents.openpgp.util.OpenPgpServiceConnection; -import org.openintents.openpgp.util.OpenPgpUtils; - -import android.app.ActionBar; import android.app.Activity; import android.app.AlertDialog; import android.app.PendingIntent; -import android.app.ProgressDialog; import android.content.ClipData; import android.content.ClipboardManager; import android.content.DialogInterface; @@ -48,6 +29,22 @@ import com.zeapo.pwdstore.R; import com.zeapo.pwdstore.UserPreference; import com.zeapo.pwdstore.utils.PasswordRepository; +import org.apache.commons.io.FileUtils; +import org.eclipse.jgit.util.StringUtils; +import org.openintents.openpgp.IOpenPgpService; +import org.openintents.openpgp.OpenPgpError; +import org.openintents.openpgp.util.OpenPgpApi; +import org.openintents.openpgp.util.OpenPgpServiceConnection; +import org.openintents.openpgp.util.OpenPgpUtils; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.UnsupportedEncodingException; +import java.util.ArrayList; + public class PgpHandler extends ActionBarActivity implements OpenPgpServiceConnection.OnBound{ @@ -378,6 +375,8 @@ public class PgpHandler extends ActionBarActivity implements OpenPgpServiceConne // ((TextView) findViewById(R.id.crypto_key_ids)).setText(mKeys); settings.edit().putString("openpgp_key_ids", keyIDs).apply(); } + + showToast("PGP key selected"); setResult(RESULT_OK); finish(); }