Highlight selected message's fingerprint in list

This commit is contained in:
Andreas Straub 2015-07-29 20:21:37 +02:00
parent e07853ea62
commit 2b3bb02261
7 changed files with 34 additions and 13 deletions

View file

@ -110,6 +110,7 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd
private LinearLayout keys; private LinearLayout keys;
private LinearLayout tags; private LinearLayout tags;
private boolean showDynamicTags; private boolean showDynamicTags;
private String messageFingerprint;
private DialogInterface.OnClickListener addToPhonebook = new DialogInterface.OnClickListener() { private DialogInterface.OnClickListener addToPhonebook = new DialogInterface.OnClickListener() {
@ -192,6 +193,7 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd
} catch (final InvalidJidException ignored) { } catch (final InvalidJidException ignored) {
} }
} }
this.messageFingerprint = getIntent().getStringExtra("fingerprint");
setContentView(R.layout.activity_contact_details); setContentView(R.layout.activity_contact_details);
contactJidTv = (TextView) findViewById(R.id.details_contactjid); contactJidTv = (TextView) findViewById(R.id.details_contactjid);
@ -385,7 +387,8 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd
} }
for(final IdentityKey identityKey : xmppConnectionService.databaseBackend.loadIdentityKeys( for(final IdentityKey identityKey : xmppConnectionService.databaseBackend.loadIdentityKeys(
contact.getAccount(), contact.getJid().toBareJid().toString())) { contact.getAccount(), contact.getJid().toBareJid().toString())) {
hasKeys |= addFingerprintRow(keys, contact.getAccount(), identityKey); boolean highlight = identityKey.getFingerprint().replaceAll("\\s", "").equals(messageFingerprint);
hasKeys |= addFingerprintRow(keys, contact.getAccount(), identityKey, highlight);
} }
if (contact.getPgpKeyId() != 0) { if (contact.getPgpKeyId() != 0) {
hasKeys = true; hasKeys = true;

View file

@ -392,12 +392,13 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
highlightInConference(user); highlightInConference(user);
} }
} else { } else {
activity.switchToContactDetails(message.getContact()); activity.switchToContactDetails(message.getContact(), message.getAxolotlFingerprint());
} }
} else { } else {
Account account = message.getConversation().getAccount(); Account account = message.getConversation().getAccount();
Intent intent = new Intent(activity, EditAccountActivity.class); Intent intent = new Intent(activity, EditAccountActivity.class);
intent.putExtra("jid", account.getJid().toBareJid().toString()); intent.putExtra("jid", account.getJid().toBareJid().toString());
intent.putExtra("fingerprint", message.getAxolotlFingerprint());
startActivity(intent); startActivity(intent);
} }
} }

View file

@ -74,6 +74,7 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate
private Jid jidToEdit; private Jid jidToEdit;
private Account mAccount; private Account mAccount;
private String messageFingerprint;
private boolean mFetchingAvatar = false; private boolean mFetchingAvatar = false;
@ -388,6 +389,7 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate
} catch (final InvalidJidException | NullPointerException ignored) { } catch (final InvalidJidException | NullPointerException ignored) {
this.jidToEdit = null; this.jidToEdit = null;
} }
this.messageFingerprint = getIntent().getStringExtra("fingerprint");
if (this.jidToEdit != null) { if (this.jidToEdit != null) {
this.mRegisterNew.setVisibility(View.GONE); this.mRegisterNew.setVisibility(View.GONE);
if (getActionBar() != null) { if (getActionBar() != null) {
@ -571,7 +573,8 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate
if(ownKey.equals(identityKey)) { if(ownKey.equals(identityKey)) {
continue; continue;
} }
hasKeys |= addFingerprintRow(keys, mAccount, identityKey); boolean highlight = identityKey.getFingerprint().replaceAll("\\s", "").equals(messageFingerprint);
hasKeys |= addFingerprintRow(keys, mAccount, identityKey, highlight);
} }
if (hasKeys) { if (hasKeys) {
keysCard.setVisibility(View.VISIBLE); keysCard.setVisibility(View.VISIBLE);

View file

@ -118,7 +118,7 @@ public class TrustKeysActivity extends XmppActivity implements OnKeyStatusUpdate
boolean hasForeignKeys = false; boolean hasForeignKeys = false;
for(final IdentityKey identityKey : ownKeysToTrust.keySet()) { for(final IdentityKey identityKey : ownKeysToTrust.keySet()) {
hasOwnKeys = true; hasOwnKeys = true;
addFingerprintRowWithListeners(ownKeys, contact.getAccount(), identityKey, addFingerprintRowWithListeners(ownKeys, contact.getAccount(), identityKey, false,
Trust.fromBoolean(ownKeysToTrust.get(identityKey)), false, Trust.fromBoolean(ownKeysToTrust.get(identityKey)), false,
new CompoundButton.OnCheckedChangeListener() { new CompoundButton.OnCheckedChangeListener() {
@Override @Override
@ -134,7 +134,7 @@ public class TrustKeysActivity extends XmppActivity implements OnKeyStatusUpdate
} }
for(final IdentityKey identityKey : foreignKeysToTrust.keySet()) { for(final IdentityKey identityKey : foreignKeysToTrust.keySet()) {
hasForeignKeys = true; hasForeignKeys = true;
addFingerprintRowWithListeners(foreignKeys, contact.getAccount(), identityKey, addFingerprintRowWithListeners(foreignKeys, contact.getAccount(), identityKey, false,
Trust.fromBoolean(foreignKeysToTrust.get(identityKey)), false, Trust.fromBoolean(foreignKeysToTrust.get(identityKey)), false,
new CompoundButton.OnCheckedChangeListener() { new CompoundButton.OnCheckedChangeListener() {
@Override @Override

View file

@ -424,10 +424,15 @@ public abstract class XmppActivity extends Activity {
} }
public void switchToContactDetails(Contact contact) { public void switchToContactDetails(Contact contact) {
switchToContactDetails(contact, null);
}
public void switchToContactDetails(Contact contact, String messageFingerprint) {
Intent intent = new Intent(this, ContactDetailsActivity.class); Intent intent = new Intent(this, ContactDetailsActivity.class);
intent.setAction(ContactDetailsActivity.ACTION_VIEW_CONTACT); intent.setAction(ContactDetailsActivity.ACTION_VIEW_CONTACT);
intent.putExtra("account", contact.getAccount().getJid().toBareJid().toString()); intent.putExtra("account", contact.getAccount().getJid().toBareJid().toString());
intent.putExtra("contact", contact.getJid().toString()); intent.putExtra("contact", contact.getJid().toString());
intent.putExtra("fingerprint", messageFingerprint);
startActivity(intent); startActivity(intent);
} }
@ -608,11 +613,11 @@ public abstract class XmppActivity extends Activity {
builder.create().show(); builder.create().show();
} }
protected boolean addFingerprintRow(LinearLayout keys, final Account account, IdentityKey identityKey) { protected boolean addFingerprintRow(LinearLayout keys, final Account account, IdentityKey identityKey, boolean highlight) {
final String fingerprint = identityKey.getFingerprint().replaceAll("\\s", ""); final String fingerprint = identityKey.getFingerprint().replaceAll("\\s", "");
final SQLiteAxolotlStore.Trust trust = account.getAxolotlService() final SQLiteAxolotlStore.Trust trust = account.getAxolotlService()
.getFingerprintTrust(fingerprint); .getFingerprintTrust(fingerprint);
return addFingerprintRowWithListeners(keys, account, identityKey, trust, true, return addFingerprintRowWithListeners(keys, account, identityKey, highlight, trust, true,
new CompoundButton.OnCheckedChangeListener() { new CompoundButton.OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
@ -637,6 +642,7 @@ public abstract class XmppActivity extends Activity {
protected boolean addFingerprintRowWithListeners(LinearLayout keys, final Account account, protected boolean addFingerprintRowWithListeners(LinearLayout keys, final Account account,
final IdentityKey identityKey, final IdentityKey identityKey,
boolean highlight,
SQLiteAxolotlStore.Trust trust, SQLiteAxolotlStore.Trust trust,
boolean showTag, boolean showTag,
CompoundButton.OnCheckedChangeListener CompoundButton.OnCheckedChangeListener
@ -688,6 +694,12 @@ public abstract class XmppActivity extends Activity {
} else { } else {
keyType.setVisibility(View.GONE); keyType.setVisibility(View.GONE);
} }
if (highlight) {
keyType.setTextColor(getResources().getColor(R.color.accent));
keyType.setText(getString(R.string.axolotl_fingerprint_selected_message));
} else {
keyType.setText(getString(R.string.axolotl_fingerprint));
}
key.setText(CryptoHelper.prettifyFingerprint(identityKey.getFingerprint())); key.setText(CryptoHelper.prettifyFingerprint(identityKey.getFingerprint()));
keys.addView(view); keys.addView(view);

View file

@ -28,6 +28,7 @@
android:textColor="@color/black54" android:textColor="@color/black54"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:layout_below="@+id/key" android:layout_below="@+id/key"
android:maxLines="1"
android:textSize="?attr/TextSizeInfo"/> android:textSize="?attr/TextSizeInfo"/>
<TextView <TextView

View file

@ -209,6 +209,7 @@
<string name="your_fingerprint">Your fingerprint</string> <string name="your_fingerprint">Your fingerprint</string>
<string name="otr_fingerprint">OTR fingerprint</string> <string name="otr_fingerprint">OTR fingerprint</string>
<string name="axolotl_fingerprint">Axolotl fingerprint</string> <string name="axolotl_fingerprint">Axolotl fingerprint</string>
<string name="axolotl_fingerprint_selected_message">Axolotl fingerprint of message</string>
<string name="this_device_axolotl_fingerprint">Own Axolotl fingerprint</string> <string name="this_device_axolotl_fingerprint">Own Axolotl fingerprint</string>
<string name="other_devices">Other devices</string> <string name="other_devices">Other devices</string>
<string name="trust_keys">Trust Axolotl Keys</string> <string name="trust_keys">Trust Axolotl Keys</string>