added display of own fingerprint
This commit is contained in:
parent
bae7418756
commit
4e4a767743
17
res/layout/otr_fingerprint.xml
Normal file
17
res/layout/otr_fingerprint.xml
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="8dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/otr_fingerprint"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:typeface="monospace"
|
||||||
|
android:text="@string/no_otr_fingerprint"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
|
@ -1,34 +1,36 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
|
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/mgmt_account_edit"
|
android:id="@+id/mgmt_account_edit"
|
||||||
android:icon="@drawable/ic_action_edit"
|
android:icon="@drawable/ic_action_edit"
|
||||||
android:title="Edit Account"
|
android:showAsAction="always"
|
||||||
android:showAsAction="always" />
|
android:title="Edit Account"/>
|
||||||
<item
|
<item
|
||||||
android:id="@+id/mgmt_account_delete"
|
android:id="@+id/mgmt_account_delete"
|
||||||
android:icon="@drawable/ic_action_delete"
|
android:icon="@drawable/ic_action_delete"
|
||||||
android:title="Delete"
|
|
||||||
android:showAsAction="always"
|
android:showAsAction="always"
|
||||||
/>
|
android:title="Delete"/>
|
||||||
<item
|
<item
|
||||||
android:id="@+id/mgmt_account_disable"
|
android:id="@+id/mgmt_account_disable"
|
||||||
android:title="Temporarily disable"
|
android:showAsAction="never"
|
||||||
android:showAsAction="never"/>
|
android:title="Temporarily disable"/>
|
||||||
<item
|
<item
|
||||||
android:id="@+id/mgmt_account_enable"
|
android:id="@+id/mgmt_account_enable"
|
||||||
android:title="Enable"
|
|
||||||
android:showAsAction="never"
|
android:showAsAction="never"
|
||||||
|
android:title="Enable"
|
||||||
android:visible="false"/>
|
android:visible="false"/>
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/mgmt_account_announce_pgp"
|
android:id="@+id/mgmt_account_announce_pgp"
|
||||||
android:showAsAction="never"
|
android:showAsAction="never"
|
||||||
android:title="@string/announce_pgp" />
|
android:title="@string/announce_pgp"/>
|
||||||
|
<item
|
||||||
|
android:id="@+id/mgmt_otr_key"
|
||||||
|
android:showAsAction="never"
|
||||||
|
android:title="@string/show_otr_key"/>
|
||||||
<item
|
<item
|
||||||
android:id="@+id/mgmt_account_info"
|
android:id="@+id/mgmt_account_info"
|
||||||
android:title="@string/account_info"
|
|
||||||
android:showAsAction="never"
|
android:showAsAction="never"
|
||||||
/>
|
android:title="@string/account_info"/>
|
||||||
|
|
||||||
</menu>
|
</menu>
|
|
@ -27,4 +27,6 @@
|
||||||
<string name="register_account">Register new account on server</string>
|
<string name="register_account">Register new account on server</string>
|
||||||
<string name="share_with">Share with</string>
|
<string name="share_with">Share with</string>
|
||||||
<string name="ask_again"><u>Click to ask again</u></string>
|
<string name="ask_again"><u>Click to ask again</u></string>
|
||||||
|
<string name="show_otr_key">OTR fingerprint</string>
|
||||||
|
<string name="no_otr_fingerprint">No OTR Fingerprint generated. Just go ahead an start an encrypted conversation</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -119,6 +119,9 @@ public class OtrEngine implements OtrEngineHost {
|
||||||
}
|
}
|
||||||
|
|
||||||
public PublicKey getPublicKey() {
|
public PublicKey getPublicKey() {
|
||||||
|
if (this.keyPair == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return this.keyPair.getPublic();
|
return this.keyPair.getPublic();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -217,6 +217,9 @@ public class Account extends AbstractEntity{
|
||||||
if (this.otrFingerprint == null) {
|
if (this.otrFingerprint == null) {
|
||||||
try {
|
try {
|
||||||
DSAPublicKey pubkey = (DSAPublicKey) this.otrEngine.getPublicKey();
|
DSAPublicKey pubkey = (DSAPublicKey) this.otrEngine.getPublicKey();
|
||||||
|
if (pubkey == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
StringBuilder builder = new StringBuilder(new OtrCryptoEngineImpl().getFingerprint(pubkey));
|
StringBuilder builder = new StringBuilder(new OtrCryptoEngineImpl().getFingerprint(pubkey));
|
||||||
builder.insert(8, " ");
|
builder.insert(8, " ");
|
||||||
builder.insert(17, " ");
|
builder.insert(17, " ");
|
||||||
|
@ -241,4 +244,9 @@ public class Account extends AbstractEntity{
|
||||||
public void setRosterVersion(String version) {
|
public void setRosterVersion(String version) {
|
||||||
this.rosterVersion = version;
|
this.rosterVersion = version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getOtrFingerprint(Context applicationContext) {
|
||||||
|
this.getOtrEngine(applicationContext);
|
||||||
|
return this.getOtrFingerprint();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ import eu.siacs.conversations.xmpp.OnTLSExceptionReceived;
|
||||||
import eu.siacs.conversations.xmpp.XmppConnection;
|
import eu.siacs.conversations.xmpp.XmppConnection;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
|
import android.content.ClipData.Item;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.DialogInterface.OnClickListener;
|
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) {
|
} else if (item.getItemId() == R.id.mgmt_account_info) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||||
builder.setTitle(getString(R.string.account_info));
|
builder.setTitle(getString(R.string.account_info));
|
||||||
|
|
Loading…
Reference in a new issue