diff options
author | Christian S <christian@pix-art.de> | 2015-09-12 10:27:21 +0200 |
---|---|---|
committer | Christian S <christian@pix-art.de> | 2015-09-12 10:27:21 +0200 |
commit | 07c1571e1eb32c1c36fe80bdb96caf17c3824dc4 (patch) | |
tree | 657fba8eebcc988c833a317834cdb30dddfd4b02 /src/main/java/eu/siacs | |
parent | c90ca66c58c37836c13075c794b1e7cad3813984 (diff) | |
parent | 15d1623ec6f1fbf6af939a5d2403e3dcc7e6839f (diff) |
Version 1.6.9
Diffstat (limited to 'src/main/java/eu/siacs')
12 files changed, 211 insertions, 71 deletions
diff --git a/src/main/java/eu/siacs/conversations/Config.java b/src/main/java/eu/siacs/conversations/Config.java index e5e15edd7..cddcd6d55 100644 --- a/src/main/java/eu/siacs/conversations/Config.java +++ b/src/main/java/eu/siacs/conversations/Config.java @@ -16,7 +16,7 @@ public final class Config { public static final int PING_MAX_INTERVAL = 300; public static final int PING_MIN_INTERVAL = 30; - public static final int PING_TIMEOUT = 10; + public static final int PING_TIMEOUT = 15; public static final int SOCKET_TIMEOUT = 15; public static final int CONNECT_TIMEOUT = 90; public static final int CARBON_GRACE_PERIOD = 90; diff --git a/src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java b/src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java index 77c9d9d7e..df7f905b2 100644 --- a/src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java +++ b/src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java @@ -190,8 +190,8 @@ public class AxolotlService { this.executor = new SerialSingleThreadExecutor(); } - public IdentityKey getOwnPublicKey() { - return axolotlStore.getIdentityKeyPair().getPublicKey(); + public String getOwnFingerprint() { + return axolotlStore.getIdentityKeyPair().getPublicKey().getFingerprint().replaceAll("\\s", ""); } public Set<IdentityKey> getKeysWithTrust(XmppAxolotlSession.Trust trust) { @@ -222,11 +222,31 @@ public class AxolotlService { return sessions; } + public Set<String> getFingerprintsForOwnSessions() { + Set<String> fingerprints = new HashSet<>(); + for (XmppAxolotlSession session : findOwnSessions()) { + fingerprints.add(session.getFingerprint()); + } + return fingerprints; + } + + public Set<String> getFingerprintsForContact(final Contact contact) { + Set<String> fingerprints = new HashSet<>(); + for (XmppAxolotlSession session : findSessionsforContact(contact)) { + fingerprints.add(session.getFingerprint()); + } + return fingerprints; + } + private boolean hasAny(Contact contact) { AxolotlAddress contactAddress = getAddressForJid(contact.getJid()); return sessions.hasAny(contactAddress); } + public boolean isPepBroken() { + return this.pepBroken; + } + public void regenerateKeys() { axolotlStore.regenerate(); sessions.clear(); @@ -310,8 +330,8 @@ public class AxolotlService { }); } - public void purgeKey(IdentityKey identityKey) { - axolotlStore.setFingerprintTrust(identityKey.getFingerprint().replaceAll("\\s", ""), XmppAxolotlSession.Trust.COMPROMISED); + public void purgeKey(final String fingerprint) { + axolotlStore.setFingerprintTrust(fingerprint.replaceAll("\\s", ""), XmppAxolotlSession.Trust.COMPROMISED); } public void publishOwnDeviceIdIfNeeded() { @@ -536,8 +556,6 @@ public class AxolotlService { bundle.getSignedPreKeyId(), bundle.getSignedPreKey(), bundle.getSignedPreKeySignature(), bundle.getIdentityKey()); - axolotlStore.saveIdentity(address.getName(), bundle.getIdentityKey()); - try { SessionBuilder builder = new SessionBuilder(axolotlStore, address); builder.process(preKeyBundle); diff --git a/src/main/java/eu/siacs/conversations/crypto/axolotl/XmppAxolotlSession.java b/src/main/java/eu/siacs/conversations/crypto/axolotl/XmppAxolotlSession.java index c4053854d..d582db40c 100644 --- a/src/main/java/eu/siacs/conversations/crypto/axolotl/XmppAxolotlSession.java +++ b/src/main/java/eu/siacs/conversations/crypto/axolotl/XmppAxolotlSession.java @@ -91,7 +91,7 @@ public class XmppAxolotlSession { public XmppAxolotlSession(Account account, SQLiteAxolotlStore store, AxolotlAddress remoteAddress, String fingerprint) { this(account, store, remoteAddress); - this.fingerprint = fingerprint; + this.fingerprint = fingerprint.replaceAll("\\s",""); } public XmppAxolotlSession(Account account, SQLiteAxolotlStore store, AxolotlAddress remoteAddress) { diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index 08d40fcba..1168e0403 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -754,7 +754,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa } break; case Message.ENCRYPTION_AXOLOTL: - message.setAxolotlFingerprint(account.getAxolotlService().getOwnPublicKey().getFingerprint().replaceAll("\\s", "")); + message.setAxolotlFingerprint(account.getAxolotlService().getOwnFingerprint()); if (message.needsUploading()) { if (account.httpUploadAvailable() || message.fixCounterpart()) { this.sendFileMessage(message,delay); @@ -799,7 +799,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa } break; case Message.ENCRYPTION_AXOLOTL: - message.setAxolotlFingerprint(account.getAxolotlService().getOwnPublicKey().getFingerprint().replaceAll("\\s", "")); + message.setAxolotlFingerprint(account.getAxolotlService().getOwnFingerprint()); break; } } diff --git a/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java b/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java index 5ef3f4b10..c610d2c89 100644 --- a/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java @@ -29,7 +29,6 @@ import android.widget.QuickContactBadge; import android.widget.TextView; import org.openintents.openpgp.util.OpenPgpUtils; -import org.whispersystems.libaxolotl.IdentityKey; import java.util.List; @@ -392,10 +391,9 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd } }); } - for(final IdentityKey identityKey : xmppConnectionService.databaseBackend.loadIdentityKeys( - contact.getAccount(), contact.getJid().toBareJid().toString())) { - boolean highlight = identityKey.getFingerprint().replaceAll("\\s", "").equals(messageFingerprint); - hasKeys |= addFingerprintRow(keys, contact.getAccount(), identityKey, highlight); + for (final String fingerprint : contact.getAccount().getAxolotlService().getFingerprintsForContact(contact)) { + boolean highlight = fingerprint.equals(messageFingerprint); + hasKeys |= addFingerprintRow(keys, contact.getAccount(), fingerprint, highlight); } if (contact.getPgpKeyId() != 0) { hasKeys = true; diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java index 071db609d..17faaf383 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java @@ -18,8 +18,10 @@ import android.support.v4.widget.SlidingPaneLayout; import android.support.v4.widget.SlidingPaneLayout.PanelSlideListener; import android.util.Log; import android.util.TypedValue; +import android.view.KeyEvent; import android.view.Menu; import android.view.MenuItem; +import android.view.Surface; import android.view.View; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; @@ -90,6 +92,8 @@ public class ConversationActivity extends XmppActivity private Uri mPendingGeoUri = null; private boolean forbidProcessingPendings = false; + private boolean conversationWasSelectedByKeyboard = false; + private View mContentView; private List<Conversation> conversationList = new ArrayList<>(); @@ -186,17 +190,18 @@ public class ConversationActivity extends XmppActivity listView.setOnItemClickListener(new OnItemClickListener() { - @Override - public void onItemClick(AdapterView<?> arg0, View clickedView, - int position, long arg3) { - if (getSelectedConversation() != conversationList.get(position)) { - setSelectedConversation(conversationList.get(position)); - ConversationActivity.this.mConversationFragment.reInit(getSelectedConversation()); - } - hideConversationsOverview(); - openConversation(); - } - }); + @Override + public void onItemClick(AdapterView<?> arg0, View clickedView, + int position, long arg3) { + if (getSelectedConversation() != conversationList.get(position)) { + setSelectedConversation(conversationList.get(position)); + ConversationActivity.this.mConversationFragment.reInit(getSelectedConversation()); + conversationWasSelectedByKeyboard = false; + } + hideConversationsOverview(); + openConversation(); + } + }); listView.setDismissCallback(new EnhancedListView.OnDismissCallback() { @@ -493,7 +498,7 @@ public class ConversationActivity extends XmppActivity private Intent getInstallApkIntent(final String packageId) { Intent intent = new Intent(Intent.ACTION_VIEW); - intent.setData(Uri.parse("market://details?id="+packageId)); + intent.setData(Uri.parse("market://details?id=" + packageId)); if (intent.resolveActivity(getPackageManager()) != null) { return intent; } else { @@ -732,13 +737,13 @@ public class ConversationActivity extends XmppActivity intent.putExtra("account", conversation.getAccount().getJid().toBareJid().toString()); switch (menuItem.getItemId()) { case R.id.scan_fingerprint: - intent.putExtra("mode",VerifyOTRActivity.MODE_SCAN_FINGERPRINT); + intent.putExtra("mode", VerifyOTRActivity.MODE_SCAN_FINGERPRINT); break; case R.id.ask_question: - intent.putExtra("mode",VerifyOTRActivity.MODE_ASK_QUESTION); + intent.putExtra("mode", VerifyOTRActivity.MODE_ASK_QUESTION); break; case R.id.manual_verification: - intent.putExtra("mode",VerifyOTRActivity.MODE_MANUAL_VERIFICATION); + intent.putExtra("mode", VerifyOTRActivity.MODE_MANUAL_VERIFICATION); break; } startActivity(intent); @@ -876,6 +881,113 @@ public class ConversationActivity extends XmppActivity } @Override + public boolean onKeyUp(int key, KeyEvent event) { + int rotation = getWindowManager().getDefaultDisplay().getRotation(); + final int upKey; + final int downKey; + switch(rotation) { + case Surface.ROTATION_90: + upKey = KeyEvent.KEYCODE_DPAD_LEFT; + downKey = KeyEvent.KEYCODE_DPAD_RIGHT; + break; + case Surface.ROTATION_180: + upKey = KeyEvent.KEYCODE_DPAD_DOWN; + downKey = KeyEvent.KEYCODE_DPAD_UP; + break; + case Surface.ROTATION_270: + upKey = KeyEvent.KEYCODE_DPAD_RIGHT; + downKey = KeyEvent.KEYCODE_DPAD_LEFT; + break; + default: + upKey = KeyEvent.KEYCODE_DPAD_UP; + downKey = KeyEvent.KEYCODE_DPAD_DOWN; + } + final boolean modifier = event.isCtrlPressed() || event.isAltPressed(); + if (modifier && key == KeyEvent.KEYCODE_TAB && isConversationsOverviewHideable()) { + toggleConversationsOverview(); + return true; + } else if (modifier && key == downKey) { + if (isConversationsOverviewHideable() && !isConversationsOverviewVisable()) { + showConversationsOverview();; + } + return selectDownConversation(); + } else if (modifier && key == upKey) { + if (isConversationsOverviewHideable() && !isConversationsOverviewVisable()) { + showConversationsOverview(); + } + return selectUpConversation(); + } else if (modifier && key == KeyEvent.KEYCODE_1) { + return openConversationByIndex(0); + } else if (modifier && key == KeyEvent.KEYCODE_2) { + return openConversationByIndex(1); + } else if (modifier && key == KeyEvent.KEYCODE_3) { + return openConversationByIndex(2); + } else if (modifier && key == KeyEvent.KEYCODE_4) { + return openConversationByIndex(3); + } else if (modifier && key == KeyEvent.KEYCODE_5) { + return openConversationByIndex(4); + } else if (modifier && key == KeyEvent.KEYCODE_6) { + return openConversationByIndex(5); + } else if (modifier && key == KeyEvent.KEYCODE_7) { + return openConversationByIndex(6); + } else if (modifier && key == KeyEvent.KEYCODE_8) { + return openConversationByIndex(7); + } else if (modifier && key == KeyEvent.KEYCODE_9) { + return openConversationByIndex(8); + } else if (modifier && key == KeyEvent.KEYCODE_0) { + return openConversationByIndex(9); + } else { + return super.onKeyUp(key, event); + } + } + + private void toggleConversationsOverview() { + if (isConversationsOverviewVisable()) { + hideConversationsOverview(); + if (mConversationFragment != null) { + mConversationFragment.setFocusOnInputField(); + } + } else { + showConversationsOverview(); + } + } + + private boolean selectUpConversation() { + if (this.mSelectedConversation != null) { + int index = this.conversationList.indexOf(this.mSelectedConversation); + if (index > 0) { + return openConversationByIndex(index - 1); + } + } + return false; + } + + private boolean selectDownConversation() { + if (this.mSelectedConversation != null) { + int index = this.conversationList.indexOf(this.mSelectedConversation); + if (index != -1 && index < this.conversationList.size() - 1) { + return openConversationByIndex(index + 1); + } + } + return false; + } + + private boolean openConversationByIndex(int index) { + try { + this.conversationWasSelectedByKeyboard = true; + setSelectedConversation(this.conversationList.get(index)); + this.mConversationFragment.reInit(getSelectedConversation()); + if (index > listView.getLastVisiblePosition() - 1 || index < listView.getFirstVisiblePosition() + 1) { + this.listView.setSelection(index); + } + openConversation(); + return true; + } catch (IndexOutOfBoundsException e) { + return false; + } + } + + @Override protected void onNewIntent(final Intent intent) { if (xmppConnectionServiceBound) { if (intent != null && VIEW_CONVERSATION.equals(intent.getType())) { @@ -1368,4 +1480,8 @@ public class ConversationActivity extends XmppActivity } }); } + + public boolean highlightSelectedConversations() { + return !isConversationsOverviewHideable() || this.conversationWasSelectedByKeyboard; + } } diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java index f25e338b4..dbeec42ac 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java @@ -348,7 +348,9 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa } public void setupIme() { - if (activity.usingEnterKey() && activity.enterIsSend()) { + if (activity == null) { + return; + } else if (activity.usingEnterKey() && activity.enterIsSend()) { mEditMessage.setInputType(mEditMessage.getInputType() & (~InputType.TYPE_TEXT_FLAG_MULTI_LINE)); mEditMessage.setInputType(mEditMessage.getInputType() & (~InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE)); } else if (activity.usingEnterKey()) { @@ -855,6 +857,10 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa updateChatMsgHint(); } + public void setFocusOnInputField() { + mEditMessage.requestFocus(); + } + enum SendButtonAction {TEXT, TAKE_PHOTO, SEND_LOCATION, RECORD_VOICE, CANCEL, CHOOSE_PICTURE} private int getSendButtonImageResource(SendButtonAction action, int status) { @@ -1194,6 +1200,7 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa if (status == Account.State.ONLINE && conversation.setOutgoingChatState(ChatState.COMPOSING)) { activity.xmppConnectionService.sendChatState(conversation); } + activity.hideConversationsOverview(); updateSendButton(); } diff --git a/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java b/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java index 206b1864b..17a5c7f7d 100644 --- a/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java @@ -26,11 +26,10 @@ import android.widget.TextView; import android.widget.Toast; import eu.siacs.conversations.Config; import org.whispersystems.libaxolotl.IdentityKey; - import java.util.Set; - import eu.siacs.conversations.Config; import eu.siacs.conversations.R; +import eu.siacs.conversations.crypto.axolotl.AxolotlService; import eu.siacs.conversations.entities.Account; import eu.siacs.conversations.services.XmppConnectionService.OnAccountUpdate; import eu.siacs.conversations.ui.adapter.KnownHostsAdapter; @@ -540,7 +539,12 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate this.mServerInfoSm.setText(R.string.server_info_unavailable); } if (features.pep()) { - this.mServerInfoPep.setText(R.string.server_info_available); + AxolotlService axolotlService = this.mAccount.getAxolotlService(); + if (axolotlService != null && axolotlService.isPepBroken()) { + this.mServerInfoPep.setText(R.string.server_info_broken); + } else { + this.mServerInfoPep.setText(R.string.server_info_available); + } } else { this.mServerInfoPep.setText(R.string.server_info_unavailable); } @@ -572,7 +576,7 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate } else { this.mOtrFingerprintBox.setVisibility(View.GONE); } - final String axolotlFingerprint = this.mAccount.getAxolotlService().getOwnPublicKey().getFingerprint(); + final String axolotlFingerprint = this.mAccount.getAxolotlService().getOwnFingerprint(); if (axolotlFingerprint != null) { this.mAxolotlFingerprintBox.setVisibility(View.VISIBLE); this.mAxolotlFingerprint.setText(CryptoHelper.prettifyFingerprint(axolotlFingerprint)); @@ -607,16 +611,15 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate } else { this.mAxolotlFingerprintBox.setVisibility(View.GONE); } - final IdentityKey ownKey = mAccount.getAxolotlService().getOwnPublicKey(); + final String ownFingerprint = mAccount.getAxolotlService().getOwnFingerprint(); boolean hasKeys = false; keys.removeAllViews(); - for(final IdentityKey identityKey : xmppConnectionService.databaseBackend.loadIdentityKeys( - mAccount, mAccount.getJid().toBareJid().toString())) { - if(ownKey.equals(identityKey)) { + for (final String fingerprint : mAccount.getAxolotlService().getFingerprintsForOwnSessions()) { + if(ownFingerprint.equals(fingerprint)) { continue; } - boolean highlight = identityKey.getFingerprint().replaceAll("\\s", "").equals(messageFingerprint); - hasKeys |= addFingerprintRow(keys, mAccount, identityKey, highlight); + boolean highlight = fingerprint.equals(messageFingerprint); + hasKeys |= addFingerprintRow(keys, mAccount, fingerprint, highlight); } if (hasKeys) { keysCard.setVisibility(View.VISIBLE); diff --git a/src/main/java/eu/siacs/conversations/ui/TrustKeysActivity.java b/src/main/java/eu/siacs/conversations/ui/TrustKeysActivity.java index 0e685c3ee..ab3130748 100644 --- a/src/main/java/eu/siacs/conversations/ui/TrustKeysActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/TrustKeysActivity.java @@ -43,8 +43,8 @@ public class TrustKeysActivity extends XmppActivity implements OnKeyStatusUpdate private Button mSaveButton; private Button mCancelButton; - private final Map<IdentityKey, Boolean> ownKeysToTrust = new HashMap<>(); - private final Map<IdentityKey, Boolean> foreignKeysToTrust = new HashMap<>(); + private final Map<String, Boolean> ownKeysToTrust = new HashMap<>(); + private final Map<String, Boolean> foreignKeysToTrust = new HashMap<>(); private final OnClickListener mSaveButtonListener = new OnClickListener() { @Override @@ -120,28 +120,28 @@ public class TrustKeysActivity extends XmppActivity implements OnKeyStatusUpdate foreignKeys.removeAllViews(); boolean hasOwnKeys = false; boolean hasForeignKeys = false; - for(final IdentityKey identityKey : ownKeysToTrust.keySet()) { + for(final String fingerprint : ownKeysToTrust.keySet()) { hasOwnKeys = true; - addFingerprintRowWithListeners(ownKeys, contact.getAccount(), identityKey, false, - XmppAxolotlSession.Trust.fromBoolean(ownKeysToTrust.get(identityKey)), false, + addFingerprintRowWithListeners(ownKeys, contact.getAccount(), fingerprint, false, + XmppAxolotlSession.Trust.fromBoolean(ownKeysToTrust.get(fingerprint)), false, new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { - ownKeysToTrust.put(identityKey, isChecked); + ownKeysToTrust.put(fingerprint, isChecked); // own fingerprints have no impact on locked status. } }, null ); } - for(final IdentityKey identityKey : foreignKeysToTrust.keySet()) { + for(final String fingerprint : foreignKeysToTrust.keySet()) { hasForeignKeys = true; - addFingerprintRowWithListeners(foreignKeys, contact.getAccount(), identityKey, false, - XmppAxolotlSession.Trust.fromBoolean(foreignKeysToTrust.get(identityKey)), false, + addFingerprintRowWithListeners(foreignKeys, contact.getAccount(), fingerprint, false, + XmppAxolotlSession.Trust.fromBoolean(foreignKeysToTrust.get(fingerprint)), false, new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { - foreignKeysToTrust.put(identityKey, isChecked); + foreignKeysToTrust.put(fingerprint, isChecked); lockOrUnlockAsNeeded(); } }, @@ -181,12 +181,12 @@ public class TrustKeysActivity extends XmppActivity implements OnKeyStatusUpdate } for(final IdentityKey identityKey : ownKeysSet) { if(!ownKeysToTrust.containsKey(identityKey)) { - ownKeysToTrust.put(identityKey, false); + ownKeysToTrust.put(identityKey.getFingerprint().replaceAll("\\s", ""), false); } } for(final IdentityKey identityKey : foreignKeysSet) { if(!foreignKeysToTrust.containsKey(identityKey)) { - foreignKeysToTrust.put(identityKey, false); + foreignKeysToTrust.put(identityKey.getFingerprint().replaceAll("\\s", ""), false); } } } @@ -225,15 +225,15 @@ public class TrustKeysActivity extends XmppActivity implements OnKeyStatusUpdate } private void commitTrusts() { - for(IdentityKey identityKey:ownKeysToTrust.keySet()) { + for(final String fingerprint :ownKeysToTrust.keySet()) { contact.getAccount().getAxolotlService().setFingerprintTrust( - identityKey.getFingerprint().replaceAll("\\s", ""), - XmppAxolotlSession.Trust.fromBoolean(ownKeysToTrust.get(identityKey))); + fingerprint, + XmppAxolotlSession.Trust.fromBoolean(ownKeysToTrust.get(fingerprint))); } - for(IdentityKey identityKey:foreignKeysToTrust.keySet()) { + for(final String fingerprint:foreignKeysToTrust.keySet()) { contact.getAccount().getAxolotlService().setFingerprintTrust( - identityKey.getFingerprint().replaceAll("\\s", ""), - XmppAxolotlSession.Trust.fromBoolean(foreignKeysToTrust.get(identityKey))); + fingerprint, + XmppAxolotlSession.Trust.fromBoolean(foreignKeysToTrust.get(fingerprint))); } } diff --git a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java index 3d4371129..ed460740b 100644 --- a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java @@ -59,8 +59,6 @@ import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; import net.java.otr4j.session.SessionID; -import org.whispersystems.libaxolotl.IdentityKey; - import java.io.FileNotFoundException; import java.lang.ref.WeakReference; import java.util.ArrayList; @@ -616,11 +614,10 @@ public abstract class XmppActivity extends Activity { builder.create().show(); } - protected boolean addFingerprintRow(LinearLayout keys, final Account account, IdentityKey identityKey, boolean highlight) { - final String fingerprint = identityKey.getFingerprint().replaceAll("\\s", ""); + protected boolean addFingerprintRow(LinearLayout keys, final Account account, final String fingerprint, boolean highlight) { final XmppAxolotlSession.Trust trust = account.getAxolotlService() .getFingerprintTrust(fingerprint); - return addFingerprintRowWithListeners(keys, account, identityKey, highlight, trust, true, + return addFingerprintRowWithListeners(keys, account, fingerprint, highlight, trust, true, new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { @@ -642,7 +639,7 @@ public abstract class XmppActivity extends Activity { } protected boolean addFingerprintRowWithListeners(LinearLayout keys, final Account account, - final IdentityKey identityKey, + final String fingerprint, boolean highlight, XmppAxolotlSession.Trust trust, boolean showTag, @@ -662,7 +659,7 @@ public abstract class XmppActivity extends Activity { view.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { - showPurgeKeyDialog(account, identityKey); + showPurgeKeyDialog(account, fingerprint); return true; } }); @@ -710,24 +707,24 @@ public abstract class XmppActivity extends Activity { keyType.setText(getString(R.string.omemo_fingerprint)); } - key.setText(CryptoHelper.prettifyFingerprint(identityKey.getFingerprint())); + key.setText(CryptoHelper.prettifyFingerprint(fingerprint)); keys.addView(view); return true; } - public void showPurgeKeyDialog(final Account account, final IdentityKey identityKey) { + public void showPurgeKeyDialog(final Account account, final String fingerprint) { Builder builder = new Builder(this); builder.setTitle(getString(R.string.purge_key)); builder.setIconAttribute(android.R.attr.alertDialogIcon); builder.setMessage(getString(R.string.purge_key_desc_part1) - + "\n\n" + CryptoHelper.prettifyFingerprint(identityKey.getFingerprint()) + + "\n\n" + CryptoHelper.prettifyFingerprint(fingerprint) + "\n\n" + getString(R.string.purge_key_desc_part2)); builder.setNegativeButton(getString(R.string.cancel), null); builder.setPositiveButton(getString(R.string.accept), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { - account.getAxolotlService().purgeKey(identityKey); + account.getAxolotlService().purgeKey(fingerprint); refreshUi(); } }); diff --git a/src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java index 6918713e4..a4a80dc4b 100644 --- a/src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java +++ b/src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java @@ -47,7 +47,7 @@ public class ConversationAdapter extends ArrayAdapter<Conversation> { if (this.activity instanceof ConversationActivity) { View swipeableItem = view.findViewById(R.id.swipeable_item); ConversationActivity a = (ConversationActivity) this.activity; - int c = !a.isConversationsOverviewHideable() && conversation == a.getSelectedConversation() ? a.getSecondaryBackgroundColor() : a.getPrimaryBackgroundColor(); + int c = a.highlightSelectedConversations() && conversation == a.getSelectedConversation() ? a.getSecondaryBackgroundColor() : a.getPrimaryBackgroundColor(); swipeableItem.setBackgroundColor(c); } TextView convName = (TextView) view.findViewById(R.id.conversation_name); diff --git a/src/main/java/eu/siacs/conversations/utils/DNSHelper.java b/src/main/java/eu/siacs/conversations/utils/DNSHelper.java index 2cde19ae3..70bc73606 100644 --- a/src/main/java/eu/siacs/conversations/utils/DNSHelper.java +++ b/src/main/java/eu/siacs/conversations/utils/DNSHelper.java @@ -84,6 +84,7 @@ public class DNSHelper { public static Bundle queryDNS(String host, InetAddress dnsServer) { Bundle bundle = new Bundle(); try { + client.setTimeout(Config.PING_TIMEOUT * 1000); String qname = "_xmpp-client._tcp." + host; Log.d(Config.LOGTAG, "using dns server: " + dnsServer.getHostAddress() + " to look up " + host); DNSMessage message = client.query(qname, TYPE.SRV, CLASS.IN, dnsServer.getHostAddress()); |