diff options
author | Christian Schneppe <christian@pix-art.de> | 2017-01-02 18:47:24 +0100 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2017-01-02 18:47:24 +0100 |
commit | 712d97bf00e576abdbf143636b8588b16ae9bc19 (patch) | |
tree | 688b405bd509b9f49c80b7e1222030761d4132d5 /src/main/java/de | |
parent | feaf7f41d3ab9474da64ee59586df5bc85f39931 (diff) |
hide inactive devices by default in contact details
Diffstat (limited to 'src/main/java/de')
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java | 45 |
1 files changed, 41 insertions, 4 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java b/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java index 9b00b7ae9..349051399 100644 --- a/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java @@ -39,6 +39,7 @@ import de.pixart.messenger.Config; import de.pixart.messenger.R; import de.pixart.messenger.crypto.PgpEngine; import de.pixart.messenger.crypto.axolotl.AxolotlService; +import de.pixart.messenger.crypto.axolotl.FingerprintStatus; import de.pixart.messenger.crypto.axolotl.XmppAxolotlSession; import de.pixart.messenger.entities.Account; import de.pixart.messenger.entities.Contact; @@ -113,11 +114,13 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp private CheckBox send; private CheckBox receive; private Button addContactButton; + private Button mShowInactiveDevicesButton; private QuickContactBadge badge; private LinearLayout keys; private FlowLayout tags; private boolean showDynamicTags = false; private boolean showLastSeen = false; + private boolean showInactiveOmemo = false; private String messageFingerprint; private DialogInterface.OnClickListener addToPhonebook = new DialogInterface.OnClickListener() { @@ -189,6 +192,7 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp @Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); + showInactiveOmemo = savedInstanceState != null && savedInstanceState.getBoolean("show_inactive_omemo", false); if (getIntent().getAction().equals(ACTION_VIEW_CONTACT)) { try { this.accountJid = Jid.fromString(getIntent().getExtras().getString(EXTRA_ACCOUNT)); @@ -218,10 +222,24 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp }); keys = (LinearLayout) findViewById(R.id.details_contact_keys); tags = (FlowLayout) findViewById(R.id.tags); + mShowInactiveDevicesButton = (Button) findViewById(R.id.show_inactive_devices); if (getActionBar() != null) { getActionBar().setHomeButtonEnabled(true); getActionBar().setDisplayHomeAsUpEnabled(true); } + mShowInactiveDevicesButton.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + showInactiveOmemo = !showInactiveOmemo; + populateView(); + } + }); + } + + @Override + public void onSaveInstanceState(final Bundle savedInstanceState) { + savedInstanceState.putBoolean("show_inactive_omemo", showInactiveOmemo); + super.onSaveInstanceState(savedInstanceState); } @Override @@ -458,13 +476,32 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp } } if (Config.supportOmemo()) { + boolean skippedInactive = false; + boolean showsInactive = false; for (final XmppAxolotlSession session : contact.getAccount().getAxolotlService().findSessionsForContact(contact)) { - if (!session.getTrust().isCompromised()) { + final FingerprintStatus trust = session.getTrust(); + if (!trust.isActive()) { + if (showInactiveOmemo) { + showsInactive = true; + } else { + skippedInactive = true; + continue; + } + } + if (!trust.isCompromised()) { boolean highlight = session.getFingerprint().equals(messageFingerprint); hasKeys = true; addFingerprintRow(keys, session, highlight); } } + if (showsInactive || skippedInactive) { + mShowInactiveDevicesButton.setText(showsInactive ? R.string.hide_inactive_devices : R.string.show_inactive_devices); + mShowInactiveDevicesButton.setVisibility(View.VISIBLE); + } else { + mShowInactiveDevicesButton.setVisibility(View.GONE); + } + } else { + mShowInactiveDevicesButton.setVisibility(View.GONE); } if (Config.supportOpenPgp() && contact.getPgpKeyId() != 0) { hasKeys = true; @@ -562,11 +599,11 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp @Override protected void processFingerprintVerification(XmppUri uri) { if (contact != null && contact.getJid().toBareJid().equals(uri.getJid()) && uri.hasFingerprints()) { - if (xmppConnectionService.verifyFingerprints(contact,uri.getFingerprints())) { - Toast.makeText(this,R.string.verified_fingerprints,Toast.LENGTH_SHORT).show(); + if (xmppConnectionService.verifyFingerprints(contact, uri.getFingerprints())) { + Toast.makeText(this, R.string.verified_fingerprints, Toast.LENGTH_SHORT).show(); } } else { - Toast.makeText(this,R.string.invalid_barcode,Toast.LENGTH_SHORT).show(); + Toast.makeText(this, R.string.invalid_barcode, Toast.LENGTH_SHORT).show(); } } } |