diff options
author | lookshe <github@lookshe.org> | 2016-02-11 10:45:27 +0100 |
---|---|---|
committer | lookshe <github@lookshe.org> | 2016-02-11 10:45:27 +0100 |
commit | 3824eb172ba9a4a6b9ea84b0d1045591bc4fa0e3 (patch) | |
tree | 0286423f053440a5900732032e35810d6cc076c6 /src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java | |
parent | cec1b0f1f8d3976ab6a437ff4584ac039b64fa9a (diff) | |
parent | ae83efe4a6c1b3349147904eee200f0b617741c3 (diff) |
Merge tag '1.9.3' into trz/merge_1.9.3
Conflicts:
.travis.yml
CHANGELOG.md
README.md
art/render.rb
build.gradle
libs/openpgp-api-lib/build.gradle
settings.gradle
src/main/AndroidManifest.xml
src/main/java/eu/siacs/conversations/Config.java
src/main/java/eu/siacs/conversations/crypto/OtrService.java
src/main/java/eu/siacs/conversations/crypto/PgpEngine.java
src/main/java/eu/siacs/conversations/entities/Account.java
src/main/java/eu/siacs/conversations/entities/Contact.java
src/main/java/eu/siacs/conversations/entities/Conversation.java
src/main/java/eu/siacs/conversations/entities/DownloadableFile.java
src/main/java/eu/siacs/conversations/entities/Message.java
src/main/java/eu/siacs/conversations/entities/MucOptions.java
src/main/java/eu/siacs/conversations/entities/Transferable.java
src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java
src/main/java/eu/siacs/conversations/generator/IqGenerator.java
src/main/java/eu/siacs/conversations/generator/MessageGenerator.java
src/main/java/eu/siacs/conversations/generator/PresenceGenerator.java
src/main/java/eu/siacs/conversations/http/HttpConnectionManager.java
src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java
src/main/java/eu/siacs/conversations/http/HttpUploadConnection.java
src/main/java/eu/siacs/conversations/parser/AbstractParser.java
src/main/java/eu/siacs/conversations/parser/IqParser.java
src/main/java/eu/siacs/conversations/parser/MessageParser.java
src/main/java/eu/siacs/conversations/parser/PresenceParser.java
src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java
src/main/java/eu/siacs/conversations/persistance/FileBackend.java
src/main/java/eu/siacs/conversations/services/AbstractConnectionManager.java
src/main/java/eu/siacs/conversations/services/AvatarService.java
src/main/java/eu/siacs/conversations/services/MessageArchiveService.java
src/main/java/eu/siacs/conversations/services/NotificationService.java
src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java
src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java
src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
src/main/java/eu/siacs/conversations/ui/ConversationFragment.java
src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java
src/main/java/eu/siacs/conversations/ui/ManageAccountActivity.java
src/main/java/eu/siacs/conversations/ui/PublishProfilePictureActivity.java
src/main/java/eu/siacs/conversations/ui/SettingsActivity.java
src/main/java/eu/siacs/conversations/ui/ShareWithActivity.java
src/main/java/eu/siacs/conversations/ui/XmppActivity.java
src/main/java/eu/siacs/conversations/ui/adapter/AccountAdapter.java
src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java
src/main/java/eu/siacs/conversations/ui/adapter/ListItemAdapter.java
src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java
src/main/java/eu/siacs/conversations/utils/CryptoHelper.java
src/main/java/eu/siacs/conversations/utils/DNSHelper.java
src/main/java/eu/siacs/conversations/utils/ExceptionHelper.java
src/main/java/eu/siacs/conversations/utils/MimeUtils.java
src/main/java/eu/siacs/conversations/utils/PhoneHelper.java
src/main/java/eu/siacs/conversations/utils/UIHelper.java
src/main/java/eu/siacs/conversations/utils/Xmlns.java
src/main/java/eu/siacs/conversations/xml/XmlReader.java
src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java
src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java
src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java
src/main/java/eu/siacs/conversations/xmpp/jingle/JingleInbandTransport.java
src/main/java/eu/siacs/conversations/xmpp/jingle/JingleSocks5Transport.java
src/main/java/eu/siacs/conversations/xmpp/stanzas/MessagePacket.java
src/main/res/drawable-hdpi/ic_launcher.png
src/main/res/drawable-hdpi/ic_notification.png
src/main/res/drawable-mdpi/ic_launcher.png
src/main/res/drawable-mdpi/ic_notification.png
src/main/res/drawable-xhdpi/ic_launcher.png
src/main/res/drawable-xhdpi/ic_notification.png
src/main/res/drawable-xxhdpi/ic_launcher.png
src/main/res/drawable-xxhdpi/ic_notification.png
src/main/res/drawable-xxxhdpi/ic_launcher.png
src/main/res/drawable-xxxhdpi/ic_notification.png
src/main/res/layout/account_row.xml
src/main/res/layout/activity_about.xml
src/main/res/layout/activity_change_password.xml
src/main/res/layout/activity_contact_details.xml
src/main/res/layout/activity_edit_account.xml
src/main/res/layout/activity_muc_details.xml
src/main/res/layout/activity_publish_profile_picture.xml
src/main/res/layout/activity_verify_otr.xml
src/main/res/layout/contact.xml
src/main/res/layout/contact_key.xml
src/main/res/layout/conversation_list_row.xml
src/main/res/layout/enter_jid_dialog.xml
src/main/res/layout/fragment_conversation.xml
src/main/res/layout/join_conference_dialog.xml
src/main/res/layout/message_received.xml
src/main/res/layout/message_sent.xml
src/main/res/layout/message_status.xml
src/main/res/layout/quickedit.xml
src/main/res/values-ar-rEG/strings.xml
src/main/res/values-bg/strings.xml
src/main/res/values-ca/strings.xml
src/main/res/values-cs/strings.xml
src/main/res/values-de/strings.xml
src/main/res/values-el/strings.xml
src/main/res/values-es/strings.xml
src/main/res/values-eu/strings.xml
src/main/res/values-fa-rIR/strings.xml
src/main/res/values-fr/strings.xml
src/main/res/values-id/strings.xml
src/main/res/values-it/strings.xml
src/main/res/values-iw/strings.xml
src/main/res/values-ja/strings.xml
src/main/res/values-ko/strings.xml
src/main/res/values-nl/strings.xml
src/main/res/values-pl/strings.xml
src/main/res/values-pt/strings.xml
src/main/res/values-ru/strings.xml
src/main/res/values-sk/strings.xml
src/main/res/values-sr/strings.xml
src/main/res/values-sv/strings.xml
src/main/res/values-v21/themes.xml
src/main/res/values-zh-rCN/strings.xml
src/main/res/values/arrays.xml
src/main/res/values/colors.xml
src/main/res/values/dimens.xml
src/main/res/values/strings.xml
src/main/res/values/themes.xml
src/main/res/xml/preferences.xml
Diffstat (limited to 'src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java')
-rw-r--r-- | src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java | 89 |
1 files changed, 73 insertions, 16 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java b/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java index e408e56a..2a8bb1ce 100644 --- a/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java @@ -6,12 +6,15 @@ import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.IntentSender.SendIntentException; +import android.content.SharedPreferences; import android.net.Uri; import android.os.Bundle; +import android.preference.PreferenceManager; import android.provider.ContactsContract; import android.provider.ContactsContract.CommonDataKinds; import android.provider.ContactsContract.Contacts; import android.provider.ContactsContract.Intents; +import android.util.Log; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; @@ -25,30 +28,35 @@ import android.widget.ImageButton; import android.widget.LinearLayout; import android.widget.QuickContactBadge; import android.widget.TextView; +import android.widget.Toast; import org.openintents.openpgp.util.OpenPgpUtils; +import java.security.cert.X509Certificate; import java.util.List; import de.thedevstack.conversationsplus.ConversationsPlusPreferences; import de.thedevstack.conversationsplus.ui.listeners.ShowResourcesListDialogListener; +import eu.siacs.conversations.Config; import eu.siacs.conversations.R; import eu.siacs.conversations.crypto.PgpEngine; +import eu.siacs.conversations.crypto.axolotl.AxolotlService; +import eu.siacs.conversations.crypto.axolotl.XmppAxolotlSession; import eu.siacs.conversations.entities.Account; import eu.siacs.conversations.entities.Contact; import eu.siacs.conversations.entities.ListItem; -import eu.siacs.conversations.services.AvatarService; import eu.siacs.conversations.services.XmppConnectionService.OnAccountUpdate; import eu.siacs.conversations.services.XmppConnectionService.OnRosterUpdate; import eu.siacs.conversations.utils.CryptoHelper; import eu.siacs.conversations.utils.UIHelper; +import eu.siacs.conversations.xmpp.OnKeyStatusUpdated; import eu.siacs.conversations.xmpp.OnUpdateBlocklist; import eu.siacs.conversations.xmpp.XmppConnection; import eu.siacs.conversations.xmpp.jid.InvalidJidException; import eu.siacs.conversations.xmpp.jid.Jid; -public class ContactDetailsActivity extends XmppActivity implements OnAccountUpdate, OnRosterUpdate, OnUpdateBlocklist { +public class ContactDetailsActivity extends XmppActivity implements OnAccountUpdate, OnRosterUpdate, OnUpdateBlocklist, OnKeyStatusUpdated { public static final String ACTION_VIEW_CONTACT = "view_contact"; private Contact contact; @@ -110,6 +118,7 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd private LinearLayout keys; private LinearLayout tags; private boolean showDynamicTags; + private String messageFingerprint; private DialogInterface.OnClickListener addToPhonebook = new DialogInterface.OnClickListener() { @@ -160,6 +169,11 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd } @Override + public void OnUpdateBlocklist(final Status status) { + refreshUi(); + } + + @Override protected void refreshUiReal() { invalidateOptionsMenu(); populateView(); @@ -179,7 +193,7 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd super.onCreate(savedInstanceState); if (getIntent().getAction().equals(ACTION_VIEW_CONTACT)) { try { - this.accountJid = Jid.fromString(getIntent().getExtras().getString("account")); + this.accountJid = Jid.fromString(getIntent().getExtras().getString(EXTRA_ACCOUNT)); } catch (final InvalidJidException ignored) { } try { @@ -187,6 +201,7 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd } catch (final InvalidJidException ignored) { } } + this.messageFingerprint = getIntent().getStringExtra("fingerprint"); setContentView(R.layout.activity_contact_details); contactJidTv = (TextView) findViewById(R.id.details_contactjid); @@ -351,8 +366,14 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd } else { contactJidTv.setText(contact.getJid().toString()); } + String account; + if (Config.DOMAIN_LOCK != null) { + account = contact.getAccount().getJid().getLocalpart(); + } else { + account = contact.getAccount().getJid().toBareJid().toString(); + } contactJidTv.setOnClickListener(new ShowResourcesListDialogListener(ContactDetailsActivity.this, contact)); - accountJidTv.setText(getString(R.string.using_account, contact.getAccount().getJid().toBareJid())); + accountJidTv.setText(getString(R.string.using_account, account)); badge.setImageBitmap(AvatarService.getInstance().get(contact, getPixel(72))); badge.setOnClickListener(this.onBadgeClick); @@ -364,13 +385,13 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd View view = inflater.inflate(R.layout.contact_key, keys, false); TextView key = (TextView) view.findViewById(R.id.key); TextView keyType = (TextView) view.findViewById(R.id.key_type); - ImageButton remove = (ImageButton) view + ImageButton removeButton = (ImageButton) view .findViewById(R.id.button_remove); - remove.setVisibility(View.VISIBLE); + removeButton.setVisibility(View.VISIBLE); keyType.setText("OTR Fingerprint"); key.setText(CryptoHelper.prettifyFingerprint(otrFingerprint)); keys.addView(view); - remove.setOnClickListener(new OnClickListener() { + removeButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { @@ -378,6 +399,15 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd } }); } + for (final String fingerprint : contact.getAccount().getAxolotlService().getFingerprintsForContact(contact)) { + boolean highlight = fingerprint.equals(messageFingerprint); + hasKeys |= addFingerprintRow(keys, contact.getAccount(), fingerprint, highlight, new OnClickListener() { + @Override + public void onClick(View v) { + onOmemoKeyClicked(contact.getAccount(), fingerprint); + } + }); + } if (contact.getPgpKeyId() != 0) { hasKeys = true; View view = inflater.inflate(R.layout.contact_key, keys, false); @@ -428,6 +458,40 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd } } + private void onOmemoKeyClicked(Account account, String fingerprint) { + final XmppAxolotlSession.Trust trust = account.getAxolotlService().getFingerprintTrust(fingerprint); + if (trust != null && trust == XmppAxolotlSession.Trust.TRUSTED_X509) { + X509Certificate x509Certificate = account.getAxolotlService().getFingerprintCertificate(fingerprint); + if (x509Certificate != null) { + showCertificateInformationDialog(CryptoHelper.extractCertificateInformation(x509Certificate)); + } else { + Toast.makeText(this,R.string.certificate_not_found, Toast.LENGTH_SHORT).show(); + } + } + } + + private void showCertificateInformationDialog(Bundle bundle) { + View view = getLayoutInflater().inflate(R.layout.certificate_information, null); + final String not_available = getString(R.string.certicate_info_not_available); + TextView subject_cn = (TextView) view.findViewById(R.id.subject_cn); + TextView subject_o = (TextView) view.findViewById(R.id.subject_o); + TextView issuer_cn = (TextView) view.findViewById(R.id.issuer_cn); + TextView issuer_o = (TextView) view.findViewById(R.id.issuer_o); + TextView sha1 = (TextView) view.findViewById(R.id.sha1); + + subject_cn.setText(bundle.getString("subject_cn", not_available)); + subject_o.setText(bundle.getString("subject_o", not_available)); + issuer_cn.setText(bundle.getString("issuer_cn", not_available)); + issuer_o.setText(bundle.getString("issuer_o", not_available)); + sha1.setText(bundle.getString("sha1", not_available)); + + AlertDialog.Builder builder = new AlertDialog.Builder(this); + builder.setTitle(R.string.certificate_information); + builder.setView(view); + builder.setPositiveButton(R.string.ok, null); + builder.create().show(); + } + protected void confirmToDeleteFingerprint(final String fingerprint) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.delete_fingerprint); @@ -462,14 +526,7 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd } @Override - public void OnUpdateBlocklist(final Status status) { - runOnUiThread(new Runnable() { - - @Override - public void run() { - invalidateOptionsMenu(); - populateView(); - } - }); + public void onKeyStatusUpdated(AxolotlService.FetchStatus report) { + refreshUi(); } } |