display open pgp key id in account details and allow to delete. fixes #2470
This commit is contained in:
parent
839178b269
commit
f98888d796
|
@ -304,9 +304,6 @@ public class PgpEngine {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public PendingIntent getIntentForKey(Contact contact) {
|
|
||||||
return getIntentForKey(contact.getPgpKeyId());
|
|
||||||
}
|
|
||||||
|
|
||||||
public PendingIntent getIntentForKey(long pgpKeyId) {
|
public PendingIntent getIntentForKey(long pgpKeyId) {
|
||||||
Intent params = new Intent();
|
Intent params = new Intent();
|
||||||
|
|
|
@ -551,7 +551,11 @@ public class Account extends AbstractEntity {
|
||||||
public boolean setPgpSignId(long pgpID) {
|
public boolean setPgpSignId(long pgpID) {
|
||||||
synchronized (this.keys) {
|
synchronized (this.keys) {
|
||||||
try {
|
try {
|
||||||
keys.put(KEY_PGP_ID, pgpID);
|
if (pgpID == 0) {
|
||||||
|
keys.remove(KEY_PGP_ID);
|
||||||
|
} else {
|
||||||
|
keys.put(KEY_PGP_ID, pgpID);
|
||||||
|
}
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
package eu.siacs.conversations.ui;
|
package eu.siacs.conversations.ui;
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.PendingIntent;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentSender.SendIntentException;
|
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
@ -451,7 +449,7 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp
|
||||||
.findViewById(R.id.button_remove);
|
.findViewById(R.id.button_remove);
|
||||||
removeButton.setVisibility(View.VISIBLE);
|
removeButton.setVisibility(View.VISIBLE);
|
||||||
key.setText(CryptoHelper.prettifyFingerprint(otrFingerprint));
|
key.setText(CryptoHelper.prettifyFingerprint(otrFingerprint));
|
||||||
if (otrFingerprint != null && otrFingerprint.equals(messageFingerprint)) {
|
if (otrFingerprint != null && otrFingerprint.equalsIgnoreCase(messageFingerprint)) {
|
||||||
keyType.setText(R.string.otr_fingerprint_selected_message);
|
keyType.setText(R.string.otr_fingerprint_selected_message);
|
||||||
keyType.setTextColor(ContextCompat.getColor(this, R.color.accent));
|
keyType.setTextColor(ContextCompat.getColor(this, R.color.accent));
|
||||||
} else {
|
} else {
|
||||||
|
@ -509,14 +507,7 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
PgpEngine pgp = ContactDetailsActivity.this.xmppConnectionService.getPgpEngine();
|
launchOpenKeyChain(contact.getPgpKeyId());
|
||||||
try {
|
|
||||||
startIntentSenderForResult(
|
|
||||||
pgp.getIntentForKey(contact).getIntentSender(), 0, null, 0,
|
|
||||||
0, 0);
|
|
||||||
} catch (Throwable e) {
|
|
||||||
Toast.makeText(ContactDetailsActivity.this,R.string.openpgp_error,Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
view.setOnClickListener(openKey);
|
view.setOnClickListener(openKey);
|
||||||
|
|
|
@ -514,6 +514,8 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
|
||||||
if (message.getEncryption() == Message.ENCRYPTION_PGP
|
if (message.getEncryption() == Message.ENCRYPTION_PGP
|
||||||
|| message.getEncryption() == Message.ENCRYPTION_DECRYPTED) {
|
|| message.getEncryption() == Message.ENCRYPTION_DECRYPTED) {
|
||||||
fingerprint = "pgp";
|
fingerprint = "pgp";
|
||||||
|
} else if (message.getEncryption() == Message.ENCRYPTION_OTR) {
|
||||||
|
fingerprint = "otr";
|
||||||
} else {
|
} else {
|
||||||
fingerprint = message.getFingerprint();
|
fingerprint = message.getFingerprint();
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,8 @@ import android.widget.TableRow;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import org.openintents.openpgp.util.OpenPgpUtils;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -93,13 +95,18 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
|
||||||
private TextView mSessionEst;
|
private TextView mSessionEst;
|
||||||
private TextView mOtrFingerprint;
|
private TextView mOtrFingerprint;
|
||||||
private TextView mAxolotlFingerprint;
|
private TextView mAxolotlFingerprint;
|
||||||
|
private TextView mPgpFingerprint;
|
||||||
private TextView mOwnFingerprintDesc;
|
private TextView mOwnFingerprintDesc;
|
||||||
|
private TextView mOtrFingerprintDesc;
|
||||||
|
private TextView getmPgpFingerprintDesc;
|
||||||
private TextView mAccountJidLabel;
|
private TextView mAccountJidLabel;
|
||||||
private ImageView mAvatar;
|
private ImageView mAvatar;
|
||||||
private RelativeLayout mOtrFingerprintBox;
|
private RelativeLayout mOtrFingerprintBox;
|
||||||
private RelativeLayout mAxolotlFingerprintBox;
|
private RelativeLayout mAxolotlFingerprintBox;
|
||||||
|
private RelativeLayout mPgpFingerprintBox;
|
||||||
private ImageButton mOtrFingerprintToClipboardButton;
|
private ImageButton mOtrFingerprintToClipboardButton;
|
||||||
private ImageButton mAxolotlFingerprintToClipboardButton;
|
private ImageButton mAxolotlFingerprintToClipboardButton;
|
||||||
|
private ImageButton mPgpDeleteFingerprintButton;
|
||||||
private LinearLayout keys;
|
private LinearLayout keys;
|
||||||
private LinearLayout keysCard;
|
private LinearLayout keysCard;
|
||||||
private LinearLayout mNamePort;
|
private LinearLayout mNamePort;
|
||||||
|
@ -505,7 +512,12 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
|
||||||
this.mServerInfoHttpUpload = (TextView) findViewById(R.id.server_info_http_upload);
|
this.mServerInfoHttpUpload = (TextView) findViewById(R.id.server_info_http_upload);
|
||||||
this.mPushRow = (TableRow) findViewById(R.id.push_row);
|
this.mPushRow = (TableRow) findViewById(R.id.push_row);
|
||||||
this.mServerInfoPush = (TextView) findViewById(R.id.server_info_push);
|
this.mServerInfoPush = (TextView) findViewById(R.id.server_info_push);
|
||||||
|
this.mPgpFingerprintBox = (RelativeLayout) findViewById(R.id.pgp_fingerprint_box);
|
||||||
|
this.mPgpFingerprint = (TextView) findViewById(R.id.pgp_fingerprint);
|
||||||
|
this.getmPgpFingerprintDesc = (TextView) findViewById(R.id.pgp_fingerprint_desc);
|
||||||
|
this.mPgpDeleteFingerprintButton = (ImageButton) findViewById(R.id.action_delete_pgp);
|
||||||
this.mOtrFingerprint = (TextView) findViewById(R.id.otr_fingerprint);
|
this.mOtrFingerprint = (TextView) findViewById(R.id.otr_fingerprint);
|
||||||
|
this.mOtrFingerprintDesc = (TextView) findViewById(R.id.otr_fingerprint_desc);
|
||||||
this.mOtrFingerprintBox = (RelativeLayout) findViewById(R.id.otr_fingerprint_box);
|
this.mOtrFingerprintBox = (RelativeLayout) findViewById(R.id.otr_fingerprint_box);
|
||||||
this.mOtrFingerprintToClipboardButton = (ImageButton) findViewById(R.id.action_copy_to_clipboard);
|
this.mOtrFingerprintToClipboardButton = (ImageButton) findViewById(R.id.action_copy_to_clipboard);
|
||||||
this.mAxolotlFingerprint = (TextView) findViewById(R.id.axolotl_fingerprint);
|
this.mAxolotlFingerprint = (TextView) findViewById(R.id.axolotl_fingerprint);
|
||||||
|
@ -896,8 +908,36 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
|
||||||
} else {
|
} else {
|
||||||
this.mServerInfoPush.setText(R.string.server_info_unavailable);
|
this.mServerInfoPush.setText(R.string.server_info_unavailable);
|
||||||
}
|
}
|
||||||
|
final long pgpKeyId = this.mAccount.getPgpId();
|
||||||
|
if (pgpKeyId != 0 && Config.supportOpenPgp()) {
|
||||||
|
OnClickListener openPgp = new OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
launchOpenKeyChain(pgpKeyId);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
OnClickListener delete = new OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
showDeletePgpDialog();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
this.mPgpFingerprintBox.setVisibility(View.VISIBLE);
|
||||||
|
this.mPgpFingerprint.setText(OpenPgpUtils.convertKeyIdToHex(pgpKeyId));
|
||||||
|
this.mPgpFingerprint.setOnClickListener(openPgp);
|
||||||
|
if ("pgp".equals(messageFingerprint)) {
|
||||||
|
this.getmPgpFingerprintDesc.setTextColor(ContextCompat.getColor(this, R.color.accent));
|
||||||
|
}
|
||||||
|
this.getmPgpFingerprintDesc.setOnClickListener(openPgp);
|
||||||
|
this.mPgpDeleteFingerprintButton.setOnClickListener(delete);
|
||||||
|
} else {
|
||||||
|
this.mPgpFingerprintBox.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
final String otrFingerprint = this.mAccount.getOtrFingerprint();
|
final String otrFingerprint = this.mAccount.getOtrFingerprint();
|
||||||
if (otrFingerprint != null && Config.supportOtr()) {
|
if (otrFingerprint != null && Config.supportOtr()) {
|
||||||
|
if ("otr".equals(messageFingerprint)) {
|
||||||
|
this.mOtrFingerprintDesc.setTextColor(ContextCompat.getColor(this, R.color.accent));
|
||||||
|
}
|
||||||
this.mOtrFingerprintBox.setVisibility(View.VISIBLE);
|
this.mOtrFingerprintBox.setVisibility(View.VISIBLE);
|
||||||
this.mOtrFingerprint.setText(CryptoHelper.prettifyFingerprint(otrFingerprint));
|
this.mOtrFingerprint.setText(CryptoHelper.prettifyFingerprint(otrFingerprint));
|
||||||
this.mOtrFingerprintToClipboardButton
|
this.mOtrFingerprintToClipboardButton
|
||||||
|
@ -986,6 +1026,24 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void showDeletePgpDialog() {
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||||
|
builder.setTitle(R.string.unpublish_pgp);
|
||||||
|
builder.setMessage(R.string.unpublish_pgp_message);
|
||||||
|
builder.setNegativeButton(R.string.cancel,null);
|
||||||
|
builder.setPositiveButton(R.string.confirm, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialogInterface, int i) {
|
||||||
|
mAccount.setPgpSignId(0);
|
||||||
|
mAccount.unsetPgpSignature();
|
||||||
|
xmppConnectionService.databaseBackend.updateAccount(mAccount);
|
||||||
|
xmppConnectionService.sendPresence(mAccount);
|
||||||
|
refreshUiReal();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
builder.create().show();
|
||||||
|
}
|
||||||
|
|
||||||
private void showOsOptimizationWarning(boolean showBatteryWarning, boolean showDataSaverWarning) {
|
private void showOsOptimizationWarning(boolean showBatteryWarning, boolean showDataSaverWarning) {
|
||||||
this.mOsOptimizations.setVisibility(showBatteryWarning || showDataSaverWarning ? View.VISIBLE : View.GONE);
|
this.mOsOptimizations.setVisibility(showBatteryWarning || showDataSaverWarning ? View.VISIBLE : View.GONE);
|
||||||
if (showDataSaverWarning) {
|
if (showDataSaverWarning) {
|
||||||
|
|
|
@ -66,6 +66,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
import eu.siacs.conversations.Config;
|
import eu.siacs.conversations.Config;
|
||||||
import eu.siacs.conversations.R;
|
import eu.siacs.conversations.R;
|
||||||
|
import eu.siacs.conversations.crypto.PgpEngine;
|
||||||
import eu.siacs.conversations.entities.Account;
|
import eu.siacs.conversations.entities.Account;
|
||||||
import eu.siacs.conversations.entities.Contact;
|
import eu.siacs.conversations.entities.Contact;
|
||||||
import eu.siacs.conversations.entities.Conversation;
|
import eu.siacs.conversations.entities.Conversation;
|
||||||
|
@ -1017,6 +1018,17 @@ public abstract class XmppActivity extends Activity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void launchOpenKeyChain(long keyId) {
|
||||||
|
PgpEngine pgp = XmppActivity.this.xmppConnectionService.getPgpEngine();
|
||||||
|
try {
|
||||||
|
startIntentSenderForResult(
|
||||||
|
pgp.getIntentForKey(keyId).getIntentSender(), 0, null, 0,
|
||||||
|
0, 0);
|
||||||
|
} catch (Throwable e) {
|
||||||
|
Toast.makeText(XmppActivity.this,R.string.openpgp_error,Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
|
@ -475,7 +475,7 @@
|
||||||
</TableLayout>
|
</TableLayout>
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:id="@+id/otr_fingerprint_box"
|
android:id="@+id/pgp_fingerprint_box"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_marginTop="32dp">
|
android:layout_marginTop="32dp">
|
||||||
|
@ -484,6 +484,52 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentLeft="true"
|
android:layout_alignParentLeft="true"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:layout_toLeftOf="@+id/action_delete_pgp"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/pgp_fingerprint"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:fontFamily="monospace"
|
||||||
|
android:textColor="?attr/color_text_primary"
|
||||||
|
android:textSize="?attr/TextSizeBody"
|
||||||
|
android:typeface="monospace"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/pgp_fingerprint_desc"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/openpgp_key_id"
|
||||||
|
android:textColor="?attr/color_text_secondary"
|
||||||
|
android:textSize="?attr/TextSizeInfo"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/action_delete_pgp"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:background="?android:selectableItemBackground"
|
||||||
|
android:padding="@dimen/image_button_padding"
|
||||||
|
android:src="?attr/icon_remove"
|
||||||
|
android:alpha="?attr/icon_alpha"
|
||||||
|
android:visibility="visible"/>
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:id="@+id/otr_fingerprint_box"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_marginTop="24dp">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentLeft="true"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
android:layout_toLeftOf="@+id/action_copy_to_clipboard"
|
android:layout_toLeftOf="@+id/action_copy_to_clipboard"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
@ -497,6 +543,7 @@
|
||||||
android:typeface="monospace"/>
|
android:typeface="monospace"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
android:id="@+id/otr_fingerprint_desc"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/otr_fingerprint"
|
android:text="@string/otr_fingerprint"
|
||||||
|
@ -521,12 +568,13 @@
|
||||||
android:id="@+id/axolotl_fingerprint_box"
|
android:id="@+id/axolotl_fingerprint_box"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_marginTop="32dp">
|
android:layout_marginTop="24dp">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentLeft="true"
|
android:layout_alignParentLeft="true"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
android:layout_toLeftOf="@+id/axolotl_actions"
|
android:layout_toLeftOf="@+id/axolotl_actions"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
|
|
@ -171,6 +171,8 @@
|
||||||
<string name="mgmt_account_disable">Temporarily disable</string>
|
<string name="mgmt_account_disable">Temporarily disable</string>
|
||||||
<string name="mgmt_account_publish_avatar">Publish avatar</string>
|
<string name="mgmt_account_publish_avatar">Publish avatar</string>
|
||||||
<string name="mgmt_account_publish_pgp">Publish OpenPGP public key</string>
|
<string name="mgmt_account_publish_pgp">Publish OpenPGP public key</string>
|
||||||
|
<string name="unpublish_pgp">Remove OpenPGP public key</string>
|
||||||
|
<string name="unpublish_pgp_message">Are you sure you want to remove your OpenPGP public key from your presence announcement?\nYour contacts will no longer be able to send you OpenPGP encrypted messages.</string>
|
||||||
<string name="openpgp_has_been_published">OpenPGP public key has been published.</string>
|
<string name="openpgp_has_been_published">OpenPGP public key has been published.</string>
|
||||||
<string name="republish_pgp_keys">Remember to republish your OpenPGP public keys!</string>
|
<string name="republish_pgp_keys">Remember to republish your OpenPGP public keys!</string>
|
||||||
<string name="mgmt_account_enable">Enable account</string>
|
<string name="mgmt_account_enable">Enable account</string>
|
||||||
|
|
Loading…
Reference in a new issue