Add key trust toggle to ContactDetailsActivity

Can now toggle IdentityKey trust
This commit is contained in:
Andreas Straub 2015-07-10 02:56:44 +02:00
parent 35714d3d08
commit 3d33946088
13 changed files with 52 additions and 10 deletions

View file

@ -35,6 +35,7 @@ import java.util.List;
import eu.siacs.conversations.R; import eu.siacs.conversations.R;
import eu.siacs.conversations.crypto.PgpEngine; import eu.siacs.conversations.crypto.PgpEngine;
import eu.siacs.conversations.crypto.axolotl.AxolotlService;
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.ListItem; import eu.siacs.conversations.entities.ListItem;
@ -363,13 +364,13 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd
View view = inflater.inflate(R.layout.contact_key, keys, false); View view = inflater.inflate(R.layout.contact_key, keys, false);
TextView key = (TextView) view.findViewById(R.id.key); TextView key = (TextView) view.findViewById(R.id.key);
TextView keyType = (TextView) view.findViewById(R.id.key_type); TextView keyType = (TextView) view.findViewById(R.id.key_type);
ImageButton remove = (ImageButton) view ImageButton removeButton = (ImageButton) view
.findViewById(R.id.button_remove); .findViewById(R.id.button_remove);
remove.setVisibility(View.VISIBLE); removeButton.setVisibility(View.VISIBLE);
keyType.setText("OTR Fingerprint"); keyType.setText("OTR Fingerprint");
key.setText(CryptoHelper.prettifyFingerprint(otrFingerprint)); key.setText(CryptoHelper.prettifyFingerprint(otrFingerprint));
keys.addView(view); keys.addView(view);
remove.setOnClickListener(new OnClickListener() { removeButton.setOnClickListener(new OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -384,19 +385,47 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd
TextView key = (TextView) view.findViewById(R.id.key); TextView key = (TextView) view.findViewById(R.id.key);
TextView keyType = (TextView) view.findViewById(R.id.key_type); TextView keyType = (TextView) view.findViewById(R.id.key_type);
TextView keyTrust = (TextView) view.findViewById(R.id.key_trust); TextView keyTrust = (TextView) view.findViewById(R.id.key_trust);
ImageButton remove = (ImageButton) view ImageButton removeButton = (ImageButton) view
.findViewById(R.id.button_remove); .findViewById(R.id.button_remove);
remove.setVisibility(View.VISIBLE); ImageButton trustButton = (ImageButton) view
keyTrust.setVisibility(View.VISIBLE); .findViewById(R.id.button_trust);
final AxolotlService axolotlService = contact.getAccount().getAxolotlService();
final String fingerprint = identityKey.getFingerprint().replaceAll("\\s", "");
final Jid bareJid = contactJid.toBareJid();
AxolotlService.SQLiteAxolotlStore.Trust trust = contact.getAccount().getAxolotlService()
.getFingerprintTrust(bareJid.toString(), fingerprint);
switch (trust) {
case TRUSTED:
removeButton.setVisibility(View.VISIBLE);
//Log.d(Config.LOGTAG, AxolotlService.getLogprefix(contact.getAccount()) + "Setting remove button visible!");
break;
case UNDECIDED:
case UNTRUSTED:
//Log.d(Config.LOGTAG, AxolotlService.getLogprefix(contact.getAccount()) + "Setting trust button visible!");
trustButton.setVisibility(View.VISIBLE);
break;
}
keyType.setText("Axolotl Fingerprint"); keyType.setText("Axolotl Fingerprint");
key.setText(CryptoHelper.prettifyFingerprint(identityKey.getFingerprint())); key.setText(CryptoHelper.prettifyFingerprint(identityKey.getFingerprint()));
keyTrust.setText(contact.getAccount().getAxolotlService().getFingerprintTrust(contact.getJid().toBareJid().toString(), identityKey.getFingerprint().replaceAll("\\s","")).toString()); keyTrust.setText(trust.toString());
keyTrust.setVisibility(View.VISIBLE);
keys.addView(view); keys.addView(view);
remove.setOnClickListener(new OnClickListener() { removeButton.setOnClickListener(new OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
//confirmToDeleteFingerprint(otrFingerprint); axolotlService.setFingerprintTrust(bareJid.toString(), fingerprint,
AxolotlService.SQLiteAxolotlStore.Trust.UNTRUSTED);
refreshUi();
xmppConnectionService.updateConversationUi();
}
});
trustButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
axolotlService.setFingerprintTrust(bareJid.toString(), fingerprint,
AxolotlService.SQLiteAxolotlStore.Trust.TRUSTED);
refreshUi();
xmppConnectionService.updateConversationUi();
} }
}); });
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 177 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 188 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 227 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 277 B

View file

@ -50,4 +50,14 @@
android:src="?attr/icon_remove" android:src="?attr/icon_remove"
android:visibility="invisible" /> android:visibility="invisible" />
<ImageButton
android:id="@+id/button_trust"
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_done"
android:visibility="invisible" />
</RelativeLayout> </RelativeLayout>

View file

@ -18,6 +18,7 @@
<item name="attr/icon_download">@drawable/ic_file_download_white_24dp</item> <item name="attr/icon_download">@drawable/ic_file_download_white_24dp</item>
<item name="attr/icon_edit">@drawable/ic_edit_white_24dp</item> <item name="attr/icon_edit">@drawable/ic_edit_white_24dp</item>
<item name="attr/icon_edit_dark">@drawable/ic_edit_grey600_24dp</item> <item name="attr/icon_edit_dark">@drawable/ic_edit_grey600_24dp</item>
<item name="attr/icon_done">@drawable/ic_done_black_24dp</item>
<item name="attr/icon_group">@drawable/ic_group_white_24dp</item> <item name="attr/icon_group">@drawable/ic_group_white_24dp</item>
<item name="attr/icon_new">@drawable/ic_add_white_24dp</item> <item name="attr/icon_new">@drawable/ic_add_white_24dp</item>
<item name="attr/icon_new_attachment">@drawable/ic_attach_file_white_24dp</item> <item name="attr/icon_new_attachment">@drawable/ic_attach_file_white_24dp</item>

View file

@ -14,6 +14,7 @@
<attr name="icon_download" format="reference"/> <attr name="icon_download" format="reference"/>
<attr name="icon_edit" format="reference"/> <attr name="icon_edit" format="reference"/>
<attr name="icon_edit_dark" format="reference"/> <attr name="icon_edit_dark" format="reference"/>
<attr name="icon_done" format="reference"/>
<attr name="icon_group" format="reference"/> <attr name="icon_group" format="reference"/>
<attr name="icon_new" format="reference"/> <attr name="icon_new" format="reference"/>
<attr name="icon_new_attachment" format="reference"/> <attr name="icon_new_attachment" format="reference"/>

View file

@ -18,6 +18,7 @@
<item name="attr/icon_download">@drawable/ic_action_download</item> <item name="attr/icon_download">@drawable/ic_action_download</item>
<item name="attr/icon_edit">@drawable/ic_action_edit</item> <item name="attr/icon_edit">@drawable/ic_action_edit</item>
<item name="attr/icon_edit_dark">@drawable/ic_action_edit_dark</item> <item name="attr/icon_edit_dark">@drawable/ic_action_edit_dark</item>
<item name="attr/icon_done">@drawable/ic_action_done</item>
<item name="attr/icon_group">@drawable/ic_action_group</item> <item name="attr/icon_group">@drawable/ic_action_group</item>
<item name="attr/icon_new">@drawable/ic_action_new</item> <item name="attr/icon_new">@drawable/ic_action_new</item>