diff --git a/res/layout/otr_fingerprint.xml b/res/layout/otr_fingerprint.xml
new file mode 100644
index 000000000..28b6a5558
--- /dev/null
+++ b/res/layout/otr_fingerprint.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
diff --git a/res/menu/manageaccounts_context.xml b/res/menu/manageaccounts_context.xml
index 765ed4e92..da8c8bf2a 100644
--- a/res/menu/manageaccounts_context.xml
+++ b/res/menu/manageaccounts_context.xml
@@ -1,34 +1,36 @@
+
\ No newline at end of file
diff --git a/res/values/strings.xml b/res/values/strings.xml
index aa53d081a..062b2b0d7 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -27,4 +27,6 @@
Register new account on server
Share with
Click to ask again
+ OTR fingerprint
+ No OTR Fingerprint generated. Just go ahead an start an encrypted conversation
diff --git a/src/eu/siacs/conversations/crypto/OtrEngine.java b/src/eu/siacs/conversations/crypto/OtrEngine.java
index ca6230e1b..32cd26b6c 100644
--- a/src/eu/siacs/conversations/crypto/OtrEngine.java
+++ b/src/eu/siacs/conversations/crypto/OtrEngine.java
@@ -119,6 +119,9 @@ public class OtrEngine implements OtrEngineHost {
}
public PublicKey getPublicKey() {
+ if (this.keyPair == null) {
+ return null;
+ }
return this.keyPair.getPublic();
}
diff --git a/src/eu/siacs/conversations/entities/Account.java b/src/eu/siacs/conversations/entities/Account.java
index d9a3ef03b..41d94fee9 100644
--- a/src/eu/siacs/conversations/entities/Account.java
+++ b/src/eu/siacs/conversations/entities/Account.java
@@ -217,6 +217,9 @@ public class Account extends AbstractEntity{
if (this.otrFingerprint == null) {
try {
DSAPublicKey pubkey = (DSAPublicKey) this.otrEngine.getPublicKey();
+ if (pubkey == null) {
+ return null;
+ }
StringBuilder builder = new StringBuilder(new OtrCryptoEngineImpl().getFingerprint(pubkey));
builder.insert(8, " ");
builder.insert(17, " ");
@@ -241,4 +244,9 @@ public class Account extends AbstractEntity{
public void setRosterVersion(String version) {
this.rosterVersion = version;
}
+
+ public String getOtrFingerprint(Context applicationContext) {
+ this.getOtrEngine(applicationContext);
+ return this.getOtrFingerprint();
+ }
}
diff --git a/src/eu/siacs/conversations/ui/ManageAccountActivity.java b/src/eu/siacs/conversations/ui/ManageAccountActivity.java
index 7cf39e783..8798a74cf 100644
--- a/src/eu/siacs/conversations/ui/ManageAccountActivity.java
+++ b/src/eu/siacs/conversations/ui/ManageAccountActivity.java
@@ -12,6 +12,7 @@ import eu.siacs.conversations.xmpp.OnTLSExceptionReceived;
import eu.siacs.conversations.xmpp.XmppConnection;
import android.app.Activity;
import android.app.AlertDialog;
+import android.content.ClipData.Item;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
@@ -286,6 +287,18 @@ public class ManageAccountActivity extends XmppActivity {
}
}
}
+ } else if (item.getItemId() == R.id.mgmt_otr_key) {
+ AlertDialog.Builder builder = new AlertDialog.Builder(activity);
+ builder.setTitle("OTR Fingerprint");
+ String fingerprintTxt = selectedAccountForActionMode.getOtrFingerprint(getApplicationContext());
+ View view = (View) getLayoutInflater().inflate(R.layout.otr_fingerprint, null);
+ if (fingerprintTxt!=null) {
+ TextView fingerprint = (TextView) view.findViewById(R.id.otr_fingerprint);
+ fingerprint.setText(fingerprintTxt);
+ }
+ builder.setView(view);
+ builder.setPositiveButton("Done", null);
+ builder.create().show();
} else if (item.getItemId() == R.id.mgmt_account_info) {
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setTitle(getString(R.string.account_info));