Compare commits

...

30 commits

Author SHA1 Message Date
Bohdan Horbeshko f5773b645d hru+kudah 2024-10-23 03:29:38 +02:00
kosyak b18f042b8b don't create secret chat for OTR messages without resource 2024-10-14 22:14:22 +02:00
kosyak a66fa08be4 fix conversation from db restoring 2024-10-13 23:42:38 +02:00
kosyak 07c730098e dont show annoying toast about history fetching policy 2024-10-13 23:42:07 +02:00
kosyak 0a99844a71 hide verify encryption footer after blind trust 2024-10-13 23:41:39 +02:00
kosyak c4bda2baf1 otr blind trust 2024-10-13 18:51:31 +02:00
kosyak 88ad3f6940 icon for secret chats 2024-10-13 17:45:43 +02:00
kosyak 1a33af7c15 don't show raw otr message in notifications 2024-10-12 13:50:04 +02:00
kosyak 5920533cf5 proper title for secret chat 2024-10-12 13:39:44 +02:00
kosyak 701c21ae4a fix empty OTR verification window 2024-10-10 01:01:17 +02:00
kosyak 28c633deb8 Revert "debug"
This reverts commit 635e5675d1.
2024-10-10 00:24:03 +02:00
kosyak a1cc201ae7 decrease toolbar title size 2024-10-10 00:23:49 +02:00
kosyak d6f162fc65 bump version 2024-10-10 00:19:44 +02:00
kosyak 635e5675d1 debug 2024-10-10 00:12:17 +02:00
kosyak 9529831f80 tune toolbar texts sizes 2024-10-09 23:20:08 +02:00
kosyak d970679064 get rid of debug logs 2024-10-06 23:26:03 +02:00
kosyak cf9ca3cc46 hide contact presence indicator when related account went offline 2024-10-06 18:55:17 +02:00
kosyak d88d858069 smaller text size for contact status 2024-10-06 18:54:14 +02:00
kosyak 4431eccc98 dont show start secret chat button inside secret chat 2024-10-01 19:59:46 +02:00
kosyak 973a48ef62 otr conversations implementation 2024-09-30 05:47:13 +02:00
kosyak 389074e802 Reapply "OTR implementation"
This reverts commit c145a6b8e5.

# Conflicts:
#	src/main/java/eu/siacs/conversations/ui/ConversationsActivity.java
#	src/main/res/values/strings.xml
2024-09-29 23:36:50 +02:00
kosyak 1a751b8a80 don't check if muc pm was archived in case of new message 2024-09-09 00:03:31 +02:00
kosyak c32809b963 allow to disable presence and account indicators 2024-09-08 23:51:05 +02:00
kosyak c64e0925f4 fallback on message uuid to fix missed reply id for single mode conversations 2024-09-06 01:02:52 +02:00
kosyak 95ee8459b8 don't use jabber last seen in status calculations 2024-09-02 22:16:05 +02:00
kosyak 021552b1d4 try to fix wired jump to bottom button behavior 2024-09-02 01:10:32 +02:00
kosyak e3542ccf72 take last seen into account during status indicator calculation 2024-09-02 01:08:27 +02:00
kosyak ffbdad7503 show participants count/last seen in toolbar indicator 2024-09-02 01:00:39 +02:00
kosyak 00817b79be account color selector 2024-09-02 00:12:42 +02:00
kosyak 4dab5156e1 small muc subject improvements 2024-09-01 22:57:59 +02:00
54 changed files with 2236 additions and 97 deletions

View file

@ -71,6 +71,7 @@ dependencies {
implementation 'com.google.guava:guava:32.1.3-android' implementation 'com.google.guava:guava:32.1.3-android'
implementation 'io.michaelrocks:libphonenumber-android:8.13.17' implementation 'io.michaelrocks:libphonenumber-android:8.13.17'
implementation 'im.conversations.webrtc:webrtc-android:119.0.0' implementation 'im.conversations.webrtc:webrtc-android:119.0.0'
implementation 'org.jitsi:org.otr4j:0.23'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation "androidx.recyclerview:recyclerview:1.2.1" implementation "androidx.recyclerview:recyclerview:1.2.1"
@ -83,6 +84,7 @@ dependencies {
implementation 'com.github.singpolyma:TokenAutoComplete:bfa93780e0' implementation 'com.github.singpolyma:TokenAutoComplete:bfa93780e0'
implementation 'com.github.kizitonwose.colorpreference:core:1.1.0'
implementation 'com.github.kizitonwose.colorpreference:support:1.1.0' implementation 'com.github.kizitonwose.colorpreference:support:1.1.0'
implementation 'com.caverock:androidsvg-aar:1.4' implementation 'com.caverock:androidsvg-aar:1.4'
implementation 'com.github.singpolyma:Better-Link-Movement-Method:4df081e1e4' implementation 'com.github.singpolyma:Better-Link-Movement-Method:4df081e1e4'
@ -102,8 +104,8 @@ android {
defaultConfig { defaultConfig {
minSdkVersion 24 minSdkVersion 24
targetSdkVersion 34 targetSdkVersion 34
versionCode 42115 versionCode 42116
versionName "2.3.1" versionName "2.3.2"
archivesBaseName += "-$versionName" archivesBaseName += "-$versionName"
applicationId "eu.siacs.conversations.classic" applicationId "eu.siacs.conversations.classic"
resValue "string", "applicationId", applicationId resValue "string", "applicationId", applicationId

View file

@ -36,6 +36,7 @@ import eu.siacs.conversations.services.XmppConnectionService;
import eu.siacs.conversations.services.XmppConnectionService.OnAccountUpdate; import eu.siacs.conversations.services.XmppConnectionService.OnAccountUpdate;
import eu.siacs.conversations.ui.adapter.AccountAdapter; import eu.siacs.conversations.ui.adapter.AccountAdapter;
import eu.siacs.conversations.ui.util.MenuDoubleTabUtil; import eu.siacs.conversations.ui.util.MenuDoubleTabUtil;
import eu.siacs.conversations.utils.UIHelper;
import eu.siacs.conversations.xmpp.Jid; import eu.siacs.conversations.xmpp.Jid;
import eu.siacs.conversations.xmpp.XmppConnection; import eu.siacs.conversations.xmpp.XmppConnection;
@ -44,8 +45,14 @@ import static eu.siacs.conversations.utils.PermissionUtils.writeGranted;
import com.google.android.material.bottomnavigation.BottomNavigationView; import com.google.android.material.bottomnavigation.BottomNavigationView;
import com.google.android.material.navigation.NavigationBarView; import com.google.android.material.navigation.NavigationBarView;
import com.kizitonwose.colorpreference.ColorDialog;
import com.kizitonwose.colorpreference.ColorShape;
public class ManageAccountActivity extends XmppActivity implements OnAccountUpdate, KeyChainAliasCallback, XmppConnectionService.OnAccountCreated, AccountAdapter.OnTglAccountState { public class ManageAccountActivity extends XmppActivity implements OnAccountUpdate,
KeyChainAliasCallback,
XmppConnectionService.OnAccountCreated,
AccountAdapter.OnTglAccountState,
ColorDialog.OnColorSelectedListener {
private final String STATE_SELECTED_ACCOUNT = "selected_account"; private final String STATE_SELECTED_ACCOUNT = "selected_account";
@ -61,6 +68,18 @@ public class ManageAccountActivity extends XmppActivity implements OnAccountUpda
protected Pair<Integer, Intent> mPostponedActivityResult = null; protected Pair<Integer, Intent> mPostponedActivityResult = null;
private AccountAdapter.ColorSelectorListener colorSelectorListener = new AccountAdapter.ColorSelectorListener() {
@Override
public void onColorPickerRequested(Jid accountJid, int currentColor) {
new ColorDialog.Builder(ManageAccountActivity.this)
.setColorShape(ColorShape.CIRCLE)
.setColorChoices(R.array.themeColorsOverride)
.setSelectedColor(currentColor)
.setTag(accountJid.asBareJid().toEscapedString())
.show();
}
};
@Override @Override
public void onAccountUpdate() { public void onAccountUpdate() {
refreshUi(); refreshUi();
@ -102,7 +121,7 @@ public class ManageAccountActivity extends XmppActivity implements OnAccountUpda
} }
accountListView = findViewById(R.id.account_list); accountListView = findViewById(R.id.account_list);
this.mAccountAdapter = new AccountAdapter(this, accountList); this.mAccountAdapter = new AccountAdapter(this, accountList, colorSelectorListener);
accountListView.setAdapter(this.mAccountAdapter); accountListView.setAdapter(this.mAccountAdapter);
accountListView.setOnItemClickListener((arg0, view, position, arg3) -> switchToAccount(accountList.get(position))); accountListView.setOnItemClickListener((arg0, view, position, arg3) -> switchToAccount(accountList.get(position)));
registerForContextMenu(accountListView); registerForContextMenu(accountListView);
@ -158,6 +177,13 @@ public class ManageAccountActivity extends XmppActivity implements OnAccountUpda
super.onSaveInstanceState(savedInstanceState); super.onSaveInstanceState(savedInstanceState);
} }
@Override
protected void onDestroy() {
super.onDestroy();
colorSelectorListener = null;
mAccountAdapter.colorSelectorListener = null;
}
@Override @Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo); super.onCreateContextMenu(menu, v, menuInfo);
@ -349,6 +375,12 @@ public class ManageAccountActivity extends XmppActivity implements OnAccountUpda
} }
} }
@Override
public void onColorSelected(int newColor, String tag) {
UIHelper.overrideAccountColor(this, tag, newColor);
refreshUiReal();
}
private void addAccountFromKey() { private void addAccountFromKey() {
try { try {
KeyChain.choosePrivateKeyAlias(this, this, null, null, null, -1, null); KeyChain.choosePrivateKeyAlias(this, this, null, null, null, -1, null);

View file

@ -299,6 +299,11 @@
<activity <activity
android:name=".ui.PublishGroupChatProfilePictureActivity" android:name=".ui.PublishGroupChatProfilePictureActivity"
android:label="@string/group_chat_avatar" /> android:label="@string/group_chat_avatar" />
<activity
android:name=".ui.VerifyOTRActivity"
android:label="@string/verify_otr"
android:exported="false"
android:windowSoftInputMode="stateHidden" />
<activity <activity
android:name=".ui.ShareWithActivity" android:name=".ui.ShareWithActivity"
android:exported="true" android:exported="true"

View file

@ -15,9 +15,10 @@ import eu.siacs.conversations.xmpp.chatstate.ChatState;
public final class Config { public final class Config {
private static final int UNENCRYPTED = 1; private static final int UNENCRYPTED = 1;
private static final int OPENPGP = 2; private static final int OPENPGP = 2;
private static final int OTR = 4;
private static final int OMEMO = 8; private static final int OMEMO = 8;
private static final int ENCRYPTION_MASK = UNENCRYPTED | OPENPGP | OMEMO; private static final int ENCRYPTION_MASK = UNENCRYPTED | OPENPGP | OTR | OMEMO;
public static boolean supportUnencrypted() { public static boolean supportUnencrypted() {
return (ENCRYPTION_MASK & UNENCRYPTED) != 0; return (ENCRYPTION_MASK & UNENCRYPTED) != 0;
@ -31,6 +32,10 @@ public final class Config {
return (ENCRYPTION_MASK & OMEMO) != 0; return (ENCRYPTION_MASK & OMEMO) != 0;
} }
public static boolean supportOtr() {
return (ENCRYPTION_MASK & OTR) != 0;
}
public static boolean omemoOnly() { public static boolean omemoOnly() {
return !multipleEncryptionChoices() && supportOmemo(); return !multipleEncryptionChoices() && supportOmemo();
} }

View file

@ -0,0 +1,312 @@
package eu.siacs.conversations.crypto;
import android.util.Log;
import net.java.otr4j.OtrEngineHost;
import net.java.otr4j.OtrException;
import net.java.otr4j.OtrPolicy;
import net.java.otr4j.OtrPolicyImpl;
import net.java.otr4j.crypto.OtrCryptoEngineImpl;
import net.java.otr4j.crypto.OtrCryptoException;
import net.java.otr4j.session.FragmenterInstructions;
import net.java.otr4j.session.InstanceTag;
import net.java.otr4j.session.SessionID;
import org.json.JSONException;
import org.json.JSONObject;
import java.math.BigInteger;
import java.security.KeyFactory;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.spec.DSAPrivateKeySpec;
import java.security.spec.DSAPublicKeySpec;
import java.security.spec.InvalidKeySpecException;
import eu.siacs.conversations.Config;
import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.entities.Conversation;
import eu.siacs.conversations.generator.MessageGenerator;
import eu.siacs.conversations.services.XmppConnectionService;
import eu.siacs.conversations.xmpp.Jid;
import eu.siacs.conversations.xmpp.chatstate.ChatState;
import eu.siacs.conversations.xmpp.jid.OtrJidHelper;
import eu.siacs.conversations.xmpp.stanzas.MessagePacket;
public class OtrService extends OtrCryptoEngineImpl implements OtrEngineHost {
private Account account;
private OtrPolicy otrPolicy;
private KeyPair keyPair;
private XmppConnectionService mXmppConnectionService;
public OtrService(XmppConnectionService service, Account account) {
this.account = account;
this.otrPolicy = new OtrPolicyImpl();
this.otrPolicy.setAllowV1(false);
this.otrPolicy.setAllowV2(true);
this.otrPolicy.setAllowV3(true);
this.keyPair = loadKey(account.getKeys());
this.mXmppConnectionService = service;
}
private KeyPair loadKey(final JSONObject keys) {
if (keys == null) {
return null;
}
synchronized (keys) {
try {
BigInteger x = new BigInteger(keys.getString("otr_x"), 16);
BigInteger y = new BigInteger(keys.getString("otr_y"), 16);
BigInteger p = new BigInteger(keys.getString("otr_p"), 16);
BigInteger q = new BigInteger(keys.getString("otr_q"), 16);
BigInteger g = new BigInteger(keys.getString("otr_g"), 16);
KeyFactory keyFactory = KeyFactory.getInstance("DSA");
DSAPublicKeySpec pubKeySpec = new DSAPublicKeySpec(y, p, q, g);
DSAPrivateKeySpec privateKeySpec = new DSAPrivateKeySpec(x, p, q, g);
PublicKey publicKey = keyFactory.generatePublic(pubKeySpec);
PrivateKey privateKey = keyFactory.generatePrivate(privateKeySpec);
return new KeyPair(publicKey, privateKey);
} catch (JSONException e) {
return null;
} catch (NoSuchAlgorithmException e) {
return null;
} catch (InvalidKeySpecException e) {
return null;
}
}
}
private void saveKey() {
PublicKey publicKey = keyPair.getPublic();
PrivateKey privateKey = keyPair.getPrivate();
KeyFactory keyFactory;
try {
keyFactory = KeyFactory.getInstance("DSA");
DSAPrivateKeySpec privateKeySpec = keyFactory.getKeySpec(
privateKey, DSAPrivateKeySpec.class);
DSAPublicKeySpec publicKeySpec = keyFactory.getKeySpec(publicKey,
DSAPublicKeySpec.class);
this.account.setKey("otr_x", privateKeySpec.getX().toString(16));
this.account.setKey("otr_g", privateKeySpec.getG().toString(16));
this.account.setKey("otr_p", privateKeySpec.getP().toString(16));
this.account.setKey("otr_q", privateKeySpec.getQ().toString(16));
this.account.setKey("otr_y", publicKeySpec.getY().toString(16));
} catch (final NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (final InvalidKeySpecException e) {
e.printStackTrace();
}
}
@Override
public void askForSecret(SessionID id, InstanceTag instanceTag, String question) {
try {
final Jid jid = OtrJidHelper.fromSessionID(id);
Conversation conversation = this.mXmppConnectionService.find(this.account, jid, null);
if (conversation != null) {
conversation.smp().hint = question;
conversation.smp().status = Conversation.Smp.STATUS_CONTACT_REQUESTED;
mXmppConnectionService.updateConversationUi();
}
} catch (IllegalArgumentException e) {
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": smp in invalid session " + id.toString());
}
}
@Override
public void finishedSessionMessage(SessionID arg0, String arg1)
throws OtrException {
}
@Override
public String getFallbackMessage(SessionID arg0) {
return MessageGenerator.OTR_FALLBACK_MESSAGE;
}
@Override
public byte[] getLocalFingerprintRaw(SessionID arg0) {
try {
return getFingerprintRaw(getPublicKey());
} catch (OtrCryptoException e) {
return null;
}
}
public PublicKey getPublicKey() {
if (this.keyPair == null) {
return null;
}
return this.keyPair.getPublic();
}
@Override
public KeyPair getLocalKeyPair(SessionID arg0) throws OtrException {
if (this.keyPair == null) {
KeyPairGenerator kg;
try {
kg = KeyPairGenerator.getInstance("DSA");
this.keyPair = kg.genKeyPair();
this.saveKey();
mXmppConnectionService.databaseBackend.updateAccount(account);
} catch (NoSuchAlgorithmException e) {
Log.d(Config.LOGTAG,
"error generating key pair " + e.getMessage());
}
}
return this.keyPair;
}
@Override
public String getReplyForUnreadableMessage(SessionID arg0) {
// TODO Auto-generated method stub
return null;
}
@Override
public OtrPolicy getSessionPolicy(SessionID arg0) {
return otrPolicy;
}
@Override
public void injectMessage(SessionID session, String body)
throws OtrException {
MessagePacket packet = new MessagePacket();
packet.setFrom(account.getJid());
if (session.getUserID().isEmpty()) {
packet.setAttribute("to", session.getAccountID());
} else {
packet.setAttribute("to", session.getAccountID() + "/" + session.getUserID());
}
packet.setBody(body);
MessageGenerator.addMessageHints(packet);
try {
Jid jid = OtrJidHelper.fromSessionID(session);
Conversation conversation = mXmppConnectionService.find(account, jid, null);
if (conversation != null && conversation.setOutgoingChatState(Config.DEFAULT_CHAT_STATE)) {
if (mXmppConnectionService.sendChatStates()) {
packet.addChild(ChatState.toElement(conversation.getOutgoingChatState()));
}
}
} catch (final IllegalArgumentException ignored) {
}
packet.setType(MessagePacket.TYPE_CHAT);
packet.addChild("encryption", "urn:xmpp:eme:0").setAttribute("namespace", "urn:xmpp:otr:0");
account.getXmppConnection().sendMessagePacket(packet);
}
@Override
public void messageFromAnotherInstanceReceived(SessionID session) {
sendOtrErrorMessage(session, "Message from another OTR-instance received");
}
@Override
public void multipleInstancesDetected(SessionID arg0) {
// TODO Auto-generated method stub
}
@Override
public void requireEncryptedMessage(SessionID arg0, String arg1)
throws OtrException {
// TODO Auto-generated method stub
}
@Override
public void showError(SessionID arg0, String arg1) throws OtrException {
Log.d(Config.LOGTAG, "show error");
}
@Override
public void smpAborted(SessionID id) throws OtrException {
setSmpStatus(id, Conversation.Smp.STATUS_NONE);
}
private void setSmpStatus(SessionID id, int status) {
try {
final Jid jid = OtrJidHelper.fromSessionID(id);
Conversation conversation = this.mXmppConnectionService.find(this.account, jid, null);
if (conversation != null) {
conversation.smp().status = status;
mXmppConnectionService.updateConversationUi();
}
} catch (final IllegalArgumentException ignored) {
}
}
@Override
public void smpError(SessionID id, int arg1, boolean arg2)
throws OtrException {
setSmpStatus(id, Conversation.Smp.STATUS_NONE);
}
@Override
public void unencryptedMessageReceived(SessionID arg0, String arg1)
throws OtrException {
throw new OtrException(new Exception("unencrypted message received"));
}
@Override
public void unreadableMessageReceived(SessionID session) throws OtrException {
Log.d(Config.LOGTAG, "unreadable message received");
sendOtrErrorMessage(session, "You sent me an unreadable OTR-encrypted message");
}
public void sendOtrErrorMessage(SessionID session, String errorText) {
try {
Jid jid = OtrJidHelper.fromSessionID(session);
Conversation conversation = mXmppConnectionService.find(account, jid, null);
String id = conversation == null ? null : conversation.getLastReceivedOtrMessageId();
if (id != null) {
MessagePacket packet = mXmppConnectionService.getMessageGenerator()
.generateOtrError(jid, id, errorText);
packet.setFrom(account.getJid());
mXmppConnectionService.sendMessagePacket(account, packet);
Log.d(Config.LOGTAG, packet.toString());
Log.d(Config.LOGTAG, account.getJid().asBareJid().toString()
+ ": unreadable OTR message in " + conversation.getName());
}
} catch (IllegalArgumentException e) {
return;
}
}
@Override
public void unverify(SessionID id, String arg1) {
setSmpStatus(id, Conversation.Smp.STATUS_FAILED);
}
@Override
public void verify(SessionID id, String fingerprint, boolean approved) {
Log.d(Config.LOGTAG, "OtrService.verify(" + id.toString() + "," + fingerprint + "," + String.valueOf(approved) + ")");
try {
final Jid jid = OtrJidHelper.fromSessionID(id);
Conversation conversation = this.mXmppConnectionService.find(this.account, jid, null);
if (conversation != null) {
if (approved) {
conversation.getContact().addOtrFingerprint(fingerprint);
}
conversation.smp().hint = null;
conversation.smp().status = Conversation.Smp.STATUS_VERIFIED;
mXmppConnectionService.updateConversationUi();
mXmppConnectionService.syncRosterToDisk(conversation.getAccount());
}
} catch (final IllegalArgumentException ignored) {
}
}
@Override
public FragmenterInstructions getFragmenterInstructions(SessionID sessionID) {
return null;
}
}

View file

@ -8,20 +8,27 @@ import android.util.Log;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import net.java.otr4j.crypto.OtrCryptoEngineImpl;
import net.java.otr4j.crypto.OtrCryptoException;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import java.security.PublicKey;
import java.security.interfaces.DSAPublicKey;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.concurrent.CopyOnWriteArraySet; import java.util.concurrent.CopyOnWriteArraySet;
import eu.siacs.conversations.Config; import eu.siacs.conversations.Config;
import eu.siacs.conversations.R; import eu.siacs.conversations.R;
import eu.siacs.conversations.crypto.OtrService;
import eu.siacs.conversations.crypto.PgpDecryptionService; import eu.siacs.conversations.crypto.PgpDecryptionService;
import eu.siacs.conversations.crypto.axolotl.AxolotlService; import eu.siacs.conversations.crypto.axolotl.AxolotlService;
import eu.siacs.conversations.crypto.axolotl.XmppAxolotlSession; import eu.siacs.conversations.crypto.axolotl.XmppAxolotlSession;
@ -93,6 +100,7 @@ public class Account extends AbstractEntity implements AvatarService.Avatarable
protected String avatar; protected String avatar;
protected String hostname = null; protected String hostname = null;
protected int port = 5222; protected int port = 5222;
private OtrService mOtrService = null;
protected boolean online = false; protected boolean online = false;
private String rosterVersion; private String rosterVersion;
private String displayName = null; private String displayName = null;
@ -100,6 +108,7 @@ public class Account extends AbstractEntity implements AvatarService.Avatarable
private PgpDecryptionService pgpDecryptionService = null; private PgpDecryptionService pgpDecryptionService = null;
private XmppConnection xmppConnection = null; private XmppConnection xmppConnection = null;
private long mEndGracePeriod = 0L; private long mEndGracePeriod = 0L;
private String otrFingerprint;
private final Map<Jid, Bookmark> bookmarks = new HashMap<>(); private final Map<Jid, Bookmark> bookmarks = new HashMap<>();
private Presence.Status presenceStatus; private Presence.Status presenceStatus;
private String presenceStatusMessage; private String presenceStatusMessage;
@ -535,6 +544,7 @@ public class Account extends AbstractEntity implements AvatarService.Avatarable
} }
public void initAccountServices(final XmppConnectionService context) { public void initAccountServices(final XmppConnectionService context) {
this.mOtrService = new OtrService(context, this);
this.axolotlService = new AxolotlService(this, context); this.axolotlService = new AxolotlService(this, context);
this.pgpDecryptionService = new PgpDecryptionService(context); this.pgpDecryptionService = new PgpDecryptionService(context);
if (xmppConnection != null) { if (xmppConnection != null) {
@ -542,6 +552,10 @@ public class Account extends AbstractEntity implements AvatarService.Avatarable
} }
} }
public OtrService getOtrService() {
return this.mOtrService;
}
public PgpDecryptionService getPgpDecryptionService() { public PgpDecryptionService getPgpDecryptionService() {
return this.pgpDecryptionService; return this.pgpDecryptionService;
} }
@ -554,6 +568,27 @@ public class Account extends AbstractEntity implements AvatarService.Avatarable
this.xmppConnection = connection; this.xmppConnection = connection;
} }
public String getOtrFingerprint() {
if (this.otrFingerprint == null) {
try {
if (this.mOtrService == null) {
return null;
}
final PublicKey publicKey = this.mOtrService.getPublicKey();
if (publicKey == null || !(publicKey instanceof DSAPublicKey)) {
return null;
}
this.otrFingerprint = new OtrCryptoEngineImpl().getFingerprint(publicKey).toLowerCase(Locale.US);
return this.otrFingerprint;
} catch (final OtrCryptoException ignored) {
return null;
}
} else {
return this.otrFingerprint;
}
}
public String getRosterVersion() { public String getRosterVersion() {
if (this.rosterVersion == null) { if (this.rosterVersion == null) {
return ""; return "";
@ -721,6 +756,10 @@ public class Account extends AbstractEntity implements AvatarService.Avatarable
private List<XmppUri.Fingerprint> getFingerprints() { private List<XmppUri.Fingerprint> getFingerprints() {
ArrayList<XmppUri.Fingerprint> fingerprints = new ArrayList<>(); ArrayList<XmppUri.Fingerprint> fingerprints = new ArrayList<>();
final String otr = this.getOtrFingerprint();
if (otr != null) {
fingerprints.add(new XmppUri.Fingerprint(XmppUri.FingerprintType.OTR, otr));
}
if (axolotlService == null) { if (axolotlService == null) {
return fingerprints; return fingerprints;
} }

View file

@ -348,6 +348,47 @@ public class Contact implements ListItem, Blockable {
return groups; return groups;
} }
public ArrayList<String> getOtrFingerprints() {
synchronized (this.keys) {
final ArrayList<String> fingerprints = new ArrayList<String>();
try {
if (this.keys.has("otr_fingerprints")) {
final JSONArray prints = this.keys.getJSONArray("otr_fingerprints");
for (int i = 0; i < prints.length(); ++i) {
final String print = prints.isNull(i) ? null : prints.getString(i);
if (print != null && !print.isEmpty()) {
fingerprints.add(prints.getString(i).toLowerCase(Locale.US));
}
}
}
} catch (final JSONException ignored) {
}
return fingerprints;
}
}
public boolean addOtrFingerprint(String print) {
synchronized (this.keys) {
if (getOtrFingerprints().contains(print)) {
return false;
}
try {
JSONArray fingerprints;
if (!this.keys.has("otr_fingerprints")) {
fingerprints = new JSONArray();
} else {
fingerprints = this.keys.getJSONArray("otr_fingerprints");
}
fingerprints.put(print);
this.keys.put("otr_fingerprints", fingerprints);
return true;
} catch (final JSONException ignored) {
return false;
}
}
}
public long getPgpKeyId() { public long getPgpKeyId() {
synchronized (this.keys) { synchronized (this.keys) {
if (this.keys.has("pgp_keyid")) { if (this.keys.has("pgp_keyid")) {

View file

@ -71,6 +71,7 @@ import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.security.interfaces.DSAPublicKey;
import java.time.ZoneId; import java.time.ZoneId;
import java.time.ZonedDateTime; import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
@ -81,6 +82,7 @@ import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.ListIterator; import java.util.ListIterator;
import java.util.Locale;
import java.util.Objects; import java.util.Objects;
import java.util.Set; import java.util.Set;
import java.util.Timer; import java.util.Timer;
@ -132,6 +134,12 @@ import me.saket.bettermovementmethod.BetterLinkMovementMethod;
import static eu.siacs.conversations.entities.Bookmark.printableValue; import static eu.siacs.conversations.entities.Bookmark.printableValue;
import net.java.otr4j.OtrException;
import net.java.otr4j.crypto.OtrCryptoException;
import net.java.otr4j.session.SessionID;
import net.java.otr4j.session.SessionImpl;
import net.java.otr4j.session.SessionStatus;
public class Conversation extends AbstractEntity implements Blockable, Comparable<Conversation>, Conversational, AvatarService.Avatarable { public class Conversation extends AbstractEntity implements Blockable, Comparable<Conversation>, Conversational, AvatarService.Avatarable {
public static final String TABLENAME = "conversations"; public static final String TABLENAME = "conversations";
@ -180,10 +188,16 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
private int mode; private int mode;
private JSONObject attributes; private JSONObject attributes;
private Jid nextCounterpart; private Jid nextCounterpart;
private boolean hasPermanentCounterpart;
private transient SessionImpl otrSession;
private transient String otrFingerprint = null;
private Smp mSmp = new Smp();
private transient MucOptions mucOptions = null; private transient MucOptions mucOptions = null;
private byte[] symmetricKey;
private boolean messagesLeftOnServer = true; private boolean messagesLeftOnServer = true;
private ChatState mOutgoingChatState = Config.DEFAULT_CHAT_STATE; private ChatState mOutgoingChatState = Config.DEFAULT_CHAT_STATE;
private ChatState mIncomingChatState = Config.DEFAULT_CHAT_STATE; private ChatState mIncomingChatState = Config.DEFAULT_CHAT_STATE;
private String mLastReceivedOtrMessageId = null;
private String mFirstMamReference = null; private String mFirstMamReference = null;
protected Message replyTo = null; protected Message replyTo = null;
protected int mCurrentTab = -1; protected int mCurrentTab = -1;
@ -216,6 +230,9 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
this.attributes = new JSONObject(); this.attributes = new JSONObject();
} }
this.nextCounterpart = nextCounterpart; this.nextCounterpart = nextCounterpart;
if (nextCounterpart != null) {
hasPermanentCounterpart = true;
}
} }
public String getContactUuid() { public String getContactUuid() {
@ -490,6 +507,17 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
} }
} }
public void findUnsentMessagesWithEncryption(int encryptionType, OnMessageFound onMessageFound) {
synchronized (this.messages) {
for (Message message : this.messages) {
if ((message.getStatus() == Message.STATUS_UNSEND || message.getStatus() == Message.STATUS_WAITING)
&& (message.getEncryption() == encryptionType)) {
onMessageFound.onMessageFound(message);
}
}
}
}
public void findUnsentTextMessages(OnMessageFound onMessageFound) { public void findUnsentTextMessages(OnMessageFound onMessageFound) {
final ArrayList<Message> results = new ArrayList<>(); final ArrayList<Message> results = new ArrayList<>();
synchronized (this.messages) { synchronized (this.messages) {
@ -662,6 +690,14 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
return getContact().getBlockedJid(); return getContact().getBlockedJid();
} }
public String getLastReceivedOtrMessageId() {
return this.mLastReceivedOtrMessageId;
}
public void setLastReceivedOtrMessageId(String id) {
this.mLastReceivedOtrMessageId = id;
}
public int countMessages() { public int countMessages() {
synchronized (this.messages) { synchronized (this.messages) {
return this.messages.size(); return this.messages.size();
@ -905,7 +941,7 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
values.put(STATUS, status); values.put(STATUS, status);
values.put(MODE, mode); values.put(MODE, mode);
if (nextCounterpart != null) { if (nextCounterpart != null && hasPermanentCounterpart) {
values.put(NEXT_COUNTERPART, nextCounterpart.toString()); values.put(NEXT_COUNTERPART, nextCounterpart.toString());
} }
@ -923,6 +959,124 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
this.mode = mode; this.mode = mode;
} }
public SessionImpl startOtrSession(String presence, boolean sendStart) {
if (this.otrSession != null) {
return this.otrSession;
} else {
final SessionID sessionId = new SessionID(this.getJid().asBareJid().toString(),
presence,
"xmpp");
this.otrSession = new SessionImpl(sessionId, getAccount().getOtrService());
try {
if (sendStart) {
this.otrSession.startSession();
return this.otrSession;
}
return this.otrSession;
} catch (OtrException e) {
return null;
}
}
}
public SessionImpl getOtrSession() {
return this.otrSession;
}
public void resetOtrSession() {
this.otrFingerprint = null;
this.otrSession = null;
this.mSmp.hint = null;
this.mSmp.secret = null;
this.mSmp.status = Smp.STATUS_NONE;
}
public Smp smp() {
return mSmp;
}
public boolean startOtrIfNeeded() {
if (this.otrSession != null && this.otrSession.getSessionStatus() != SessionStatus.ENCRYPTED) {
try {
this.otrSession.startSession();
return true;
} catch (OtrException e) {
this.resetOtrSession();
return false;
}
} else {
return true;
}
}
public boolean endOtrIfNeeded() {
if (this.otrSession != null) {
if (this.otrSession.getSessionStatus() == SessionStatus.ENCRYPTED) {
try {
this.otrSession.endSession();
this.resetOtrSession();
return true;
} catch (OtrException e) {
this.resetOtrSession();
return false;
}
} else {
this.resetOtrSession();
return false;
}
} else {
return false;
}
}
public boolean hasValidOtrSession() {
return this.otrSession != null;
}
public synchronized String getOtrFingerprint() {
if (this.otrFingerprint == null) {
try {
if (getOtrSession() == null || getOtrSession().getSessionStatus() != SessionStatus.ENCRYPTED) {
return null;
}
DSAPublicKey remotePubKey = (DSAPublicKey) getOtrSession().getRemotePublicKey();
this.otrFingerprint = getAccount().getOtrService().getFingerprint(remotePubKey).toLowerCase(Locale.US);
} catch (final OtrCryptoException ignored) {
return null;
} catch (final UnsupportedOperationException ignored) {
return null;
}
}
return this.otrFingerprint;
}
public boolean verifyOtrFingerprint() {
final String fingerprint = getOtrFingerprint();
if (fingerprint != null) {
getContact().addOtrFingerprint(fingerprint);
return true;
} else {
return false;
}
}
public boolean isOtrFingerprintVerified() {
return getContact().getOtrFingerprints().contains(getOtrFingerprint());
}
public class Smp {
public static final int STATUS_NONE = 0;
public static final int STATUS_CONTACT_REQUESTED = 1;
public static final int STATUS_WE_REQUESTED = 2;
public static final int STATUS_FAILED = 3;
public static final int STATUS_VERIFIED = 4;
public String secret = null;
public String hint = null;
public int status = 0;
}
/** /**
* short for is Private and Non-anonymous * short for is Private and Non-anonymous
*/ */
@ -959,14 +1113,23 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
return this.nextCounterpart; return this.nextCounterpart;
} }
public boolean hasPermanentCounterpart() {
return hasPermanentCounterpart;
}
public void setNextCounterpart(Jid jid) { public void setNextCounterpart(Jid jid) {
this.nextCounterpart = jid; this.nextCounterpart = jid;
} }
public int getNextEncryption() { public int getNextEncryption() {
if (!Config.supportOmemo() && !Config.supportOpenPgp()) { if (!Config.supportOmemo() && !Config.supportOpenPgp() && !Config.supportOtr()) {
return Message.ENCRYPTION_NONE; return Message.ENCRYPTION_NONE;
} }
if (Config.supportOtr() && nextCounterpart != null && getMode() == MODE_SINGLE && hasPermanentCounterpart) {
return Message.ENCRYPTION_OTR;
}
if (OmemoSetting.isAlways()) { if (OmemoSetting.isAlways()) {
return suitableForOmemoByDefault(this) ? Message.ENCRYPTION_AXOLOTL : Message.ENCRYPTION_NONE; return suitableForOmemoByDefault(this) ? Message.ENCRYPTION_AXOLOTL : Message.ENCRYPTION_NONE;
} }
@ -977,7 +1140,7 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
defaultEncryption = Message.ENCRYPTION_NONE; defaultEncryption = Message.ENCRYPTION_NONE;
} }
int encryption = this.getIntAttribute(ATTRIBUTE_NEXT_ENCRYPTION, defaultEncryption); int encryption = this.getIntAttribute(ATTRIBUTE_NEXT_ENCRYPTION, defaultEncryption);
if (encryption == Message.ENCRYPTION_OTR || encryption < 0) { if (encryption < 0) {
return defaultEncryption; return defaultEncryption;
} else { } else {
return encryption; return encryption;
@ -993,6 +1156,10 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
return nextMessage == null ? "" : nextMessage; return nextMessage == null ? "" : nextMessage;
} }
public boolean smpRequested() {
return smp().status == Smp.STATUS_CONTACT_REQUESTED;
}
public @Nullable public @Nullable
Draft getDraft() { Draft getDraft() {
long timestamp = getLongAttribute(ATTRIBUTE_NEXT_MESSAGE_TIMESTAMP, 0); long timestamp = getLongAttribute(ATTRIBUTE_NEXT_MESSAGE_TIMESTAMP, 0);
@ -1015,6 +1182,14 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
return changed; return changed;
} }
public void setSymmetricKey(byte[] key) {
this.symmetricKey = key;
}
public byte[] getSymmetricKey() {
return this.symmetricKey;
}
public Bookmark getBookmark() { public Bookmark getBookmark() {
return this.account.getBookmark(this.contactJid); return this.account.getBookmark(this.contactJid);
} }
@ -1231,14 +1406,14 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
String res2 = nextCounterpart == null ? null : nextCounterpart.getResource(); String res2 = nextCounterpart == null ? null : nextCounterpart.getResource();
if (nextCounterpart == null) { if (nextCounterpart == null) {
if (!message.isPrivateMessage()) { if (!message.isPrivateMessage() && message.encryption != Message.ENCRYPTION_OTR) {
synchronized (this.messages) { synchronized (this.messages) {
this.messages.add(message); this.messages.add(message);
actualizeReplyMessages(this.messages, List.of(message)); actualizeReplyMessages(this.messages, List.of(message));
} }
} }
} else { } else {
if (message.isPrivateMessage() && Objects.equals(res1, res2)) { if ((message.isPrivateMessage() || message.encryption == Message.ENCRYPTION_OTR) && Objects.equals(res1, res2)) {
synchronized (this.messages) { synchronized (this.messages) {
this.messages.add(message); this.messages.add(message);
actualizeReplyMessages(this.messages, List.of(message)); actualizeReplyMessages(this.messages, List.of(message));
@ -1260,14 +1435,14 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
} }
if (nextCounterpart == null) { if (nextCounterpart == null) {
if (!message.isPrivateMessage()) { if (!message.isPrivateMessage() && message.encryption != Message.ENCRYPTION_OTR) {
synchronized (this.messages) { synchronized (this.messages) {
properListToAdd.add(Math.min(offset, properListToAdd.size()), message); properListToAdd.add(Math.min(offset, properListToAdd.size()), message);
actualizeReplyMessages(properListToAdd, List.of(message)); actualizeReplyMessages(properListToAdd, List.of(message));
} }
} }
} else { } else {
if (message.isPrivateMessage() && Objects.equals(res1, res2)) { if ((message.isPrivateMessage() || message.encryption == Message.ENCRYPTION_OTR) && Objects.equals(res1, res2)) {
synchronized (this.messages) { synchronized (this.messages) {
properListToAdd.add(Math.min(offset, properListToAdd.size()), message); properListToAdd.add(Math.min(offset, properListToAdd.size()), message);
actualizeReplyMessages(properListToAdd, List.of(message)); actualizeReplyMessages(properListToAdd, List.of(message));
@ -1291,7 +1466,7 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
if (nextCounterpart == null) { if (nextCounterpart == null) {
for(Message m : messages) { for(Message m : messages) {
if (!m.isPrivateMessage()) { if (!m.isPrivateMessage() && m.encryption != Message.ENCRYPTION_OTR) {
newM.add(m); newM.add(m);
} }
} }
@ -1302,7 +1477,7 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
String res2 = nextCounterpart == null ? null : nextCounterpart.getResource(); String res2 = nextCounterpart == null ? null : nextCounterpart.getResource();
if (m.isPrivateMessage() && Objects.equals(res1, res2)) { if ((m.isPrivateMessage() || m.encryption == Message.ENCRYPTION_OTR) && Objects.equals(res1, res2)) {
newM.add(m); newM.add(m);
} }
} }

View file

@ -352,7 +352,10 @@ public class Message extends AbstractEntity implements AvatarService.Avatarable
} }
public String replyId() { public String replyId() {
return conversation.getMode() == Conversation.MODE_MULTI || getRemoteMsgId() == null ? getServerMsgId() : getRemoteMsgId(); if (conversation.getMode() == Conversation.MODE_MULTI) return getServerMsgId();
final String remote = getRemoteMsgId();
if (remote == null && getStatus() > STATUS_RECEIVED) return getUuid();
return remote;
} }
public Message reply() { public Message reply() {

View file

@ -6,7 +6,7 @@ import java.util.List;
public interface Transferable { public interface Transferable {
List<String> VALID_IMAGE_EXTENSIONS = Arrays.asList("webp", "jpeg", "jpg", "png", "jpe"); List<String> VALID_IMAGE_EXTENSIONS = Arrays.asList("webp", "jpeg", "jpg", "png", "jpe");
List<String> VALID_CRYPTO_EXTENSIONS = Arrays.asList("pgp", "gpg"); List<String> VALID_CRYPTO_EXTENSIONS = Arrays.asList("pgp", "gpg", "otr");
int STATUS_UNKNOWN = 0x200; int STATUS_UNKNOWN = 0x200;
int STATUS_CHECKING = 0x201; int STATUS_CHECKING = 0x201;

View file

@ -57,6 +57,9 @@ public abstract class AbstractGenerator {
private final String[] PRIVACY_SENSITIVE = { private final String[] PRIVACY_SENSITIVE = {
"urn:xmpp:time" //XEP-0202: Entity Time leaks time zone "urn:xmpp:time" //XEP-0202: Entity Time leaks time zone
}; };
private final String[] OTR = {
"urn:xmpp:otr:0"
};
private final String[] VOIP_NAMESPACES = { private final String[] VOIP_NAMESPACES = {
Namespace.JINGLE_TRANSPORT_ICE_UDP, Namespace.JINGLE_TRANSPORT_ICE_UDP,
Namespace.JINGLE_FEATURE_AUDIO, Namespace.JINGLE_FEATURE_AUDIO,
@ -125,6 +128,9 @@ public abstract class AbstractGenerator {
features.addAll(Arrays.asList(PRIVACY_SENSITIVE)); features.addAll(Arrays.asList(PRIVACY_SENSITIVE));
features.addAll(Arrays.asList(VOIP_NAMESPACES)); features.addAll(Arrays.asList(VOIP_NAMESPACES));
} }
if (Config.supportOtr()) {
features.addAll(Arrays.asList(OTR));
}
if (mXmppConnectionService.broadcastLastActivity()) { if (mXmppConnectionService.broadcastLastActivity()) {
features.add(Namespace.IDLE); features.add(Namespace.IDLE);
} }

View file

@ -1,5 +1,8 @@
package eu.siacs.conversations.generator; package eu.siacs.conversations.generator;
import net.java.otr4j.OtrException;
import net.java.otr4j.session.Session;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
@ -24,6 +27,7 @@ import eu.siacs.conversations.xmpp.jingle.Media;
import eu.siacs.conversations.xmpp.stanzas.MessagePacket; import eu.siacs.conversations.xmpp.stanzas.MessagePacket;
public class MessageGenerator extends AbstractGenerator { public class MessageGenerator extends AbstractGenerator {
public static final String OTR_FALLBACK_MESSAGE = "I would like to start a private (OTR encrypted) conversation but your client doesnt seem to support that";
private static final String OMEMO_FALLBACK_MESSAGE = "I sent you an OMEMO encrypted message but your client doesnt seem to support that. Find more information on https://conversations.im/omemo"; private static final String OMEMO_FALLBACK_MESSAGE = "I sent you an OMEMO encrypted message but your client doesnt seem to support that. Find more information on https://conversations.im/omemo";
private static final String PGP_FALLBACK_MESSAGE = "I sent you a PGP encrypted message but your client doesnt seem to support that."; private static final String PGP_FALLBACK_MESSAGE = "I sent you a PGP encrypted message but your client doesnt seem to support that.";
@ -102,6 +106,36 @@ public class MessageGenerator extends AbstractGenerator {
return packet; return packet;
} }
public static void addMessageHints(MessagePacket packet) {
packet.addChild("private", "urn:xmpp:carbons:2");
packet.addChild("no-copy", "urn:xmpp:hints");
packet.addChild("no-permanent-store", "urn:xmpp:hints");
packet.addChild("no-permanent-storage", "urn:xmpp:hints"); //do not copy this. this is wrong. it is *store*
}
public MessagePacket generateOtrChat(Message message) {
Conversation conversation = (Conversation) message.getConversation();
Session otrSession = conversation.getOtrSession();
if (otrSession == null) {
return null;
}
MessagePacket packet = preparePacket(message);
addMessageHints(packet);
try {
String content;
if (message.hasFileOnRemoteHost()) {
content = message.getFileParams().url.toString();
} else {
content = message.getBody();
}
packet.setBody(otrSession.transformSending(content)[0]);
packet.addChild("encryption", "urn:xmpp:eme:0").setAttribute("namespace", "urn:xmpp:otr:0");
return packet;
} catch (OtrException e) {
return null;
}
}
public MessagePacket generateChat(Message message) { public MessagePacket generateChat(Message message) {
MessagePacket packet = preparePacket(message); MessagePacket packet = preparePacket(message);
String content; String content;
@ -233,6 +267,19 @@ public class MessageGenerator extends AbstractGenerator {
return packet; return packet;
} }
public MessagePacket generateOtrError(Jid to, String id, String errorText) {
MessagePacket packet = new MessagePacket();
packet.setType(MessagePacket.TYPE_ERROR);
packet.setAttribute("id", id);
packet.setTo(to);
Element error = packet.addChild("error");
error.setAttribute("code", "406");
error.setAttribute("type", "modify");
error.addChild("not-acceptable", "urn:ietf:params:xml:ns:xmpp-stanzas");
error.addChild("text").setContent("?OTR Error:" + errorText);
return packet;
}
public MessagePacket sessionProposal(final JingleConnectionManager.RtpSessionProposal proposal) { public MessagePacket sessionProposal(final JingleConnectionManager.RtpSessionProposal proposal) {
final MessagePacket packet = new MessagePacket(); final MessagePacket packet = new MessagePacket();
packet.setType(MessagePacket.TYPE_CHAT); //we want to carbon copy those packet.setType(MessagePacket.TYPE_CHAT); //we want to carbon copy those

View file

@ -1,8 +1,15 @@
package eu.siacs.conversations.parser; package eu.siacs.conversations.parser;
import android.os.Build;
import android.text.Html;
import android.util.Log; import android.util.Log;
import android.util.Pair; import android.util.Pair;
import com.google.common.base.Strings;
import net.java.otr4j.session.Session;
import net.java.otr4j.session.SessionStatus;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -16,6 +23,7 @@ import java.util.UUID;
import eu.siacs.conversations.Config; import eu.siacs.conversations.Config;
import eu.siacs.conversations.R; import eu.siacs.conversations.R;
import eu.siacs.conversations.crypto.OtrService;
import eu.siacs.conversations.crypto.axolotl.AxolotlService; import eu.siacs.conversations.crypto.axolotl.AxolotlService;
import eu.siacs.conversations.crypto.axolotl.BrokenSessionException; import eu.siacs.conversations.crypto.axolotl.BrokenSessionException;
import eu.siacs.conversations.crypto.axolotl.NotEncryptedForThisDeviceException; import eu.siacs.conversations.crypto.axolotl.NotEncryptedForThisDeviceException;
@ -28,9 +36,11 @@ import eu.siacs.conversations.entities.Conversation;
import eu.siacs.conversations.entities.Conversational; import eu.siacs.conversations.entities.Conversational;
import eu.siacs.conversations.entities.Message; import eu.siacs.conversations.entities.Message;
import eu.siacs.conversations.entities.MucOptions; import eu.siacs.conversations.entities.MucOptions;
import eu.siacs.conversations.entities.Presence;
import eu.siacs.conversations.entities.ReadByMarker; import eu.siacs.conversations.entities.ReadByMarker;
import eu.siacs.conversations.entities.ReceiptRequest; import eu.siacs.conversations.entities.ReceiptRequest;
import eu.siacs.conversations.entities.RtpSessionStatus; import eu.siacs.conversations.entities.RtpSessionStatus;
import eu.siacs.conversations.entities.ServiceDiscoveryResult;
import eu.siacs.conversations.http.HttpConnectionManager; import eu.siacs.conversations.http.HttpConnectionManager;
import eu.siacs.conversations.services.MessageArchiveService; import eu.siacs.conversations.services.MessageArchiveService;
import eu.siacs.conversations.services.QuickConversationsService; import eu.siacs.conversations.services.QuickConversationsService;
@ -49,6 +59,7 @@ import eu.siacs.conversations.xmpp.pep.Avatar;
import eu.siacs.conversations.xmpp.stanzas.MessagePacket; import eu.siacs.conversations.xmpp.stanzas.MessagePacket;
public class MessageParser extends AbstractParser implements OnMessagePacketReceived { public class MessageParser extends AbstractParser implements OnMessagePacketReceived {
private static final List<String> CLIENTS_SENDING_HTML_IN_OTR = Arrays.asList("Pidgin", "Adium", "Trillian");
private static final SimpleDateFormat TIME_FORMAT = new SimpleDateFormat("HH:mm:ss", Locale.ENGLISH); private static final SimpleDateFormat TIME_FORMAT = new SimpleDateFormat("HH:mm:ss", Locale.ENGLISH);
@ -95,6 +106,30 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
return result != null ? result : fallback; return result != null ? result : fallback;
} }
private static boolean clientMightSendHtml(Account account, Jid from) {
String resource = from.getResource();
if (resource == null) {
return false;
}
Presence presence = account.getRoster().getContact(from).getPresences().getPresencesMap().get(resource);
ServiceDiscoveryResult disco = presence == null ? null : presence.getServiceDiscoveryResult();
if (disco == null) {
return false;
}
return hasIdentityKnowForSendingHtml(disco.getIdentities());
}
private static boolean hasIdentityKnowForSendingHtml(List<ServiceDiscoveryResult.Identity> identities) {
for (ServiceDiscoveryResult.Identity identity : identities) {
if (identity.getName() != null) {
if (CLIENTS_SENDING_HTML_IN_OTR.contains(identity.getName())) {
return true;
}
}
}
return false;
}
private boolean extractChatState(Conversation c, final boolean isTypeGroupChat, final MessagePacket packet) { private boolean extractChatState(Conversation c, final boolean isTypeGroupChat, final MessagePacket packet) {
ChatState state = ChatState.parse(packet); ChatState state = ChatState.parse(packet);
if (state != null && c != null) { if (state != null && c != null) {
@ -126,6 +161,66 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
return false; return false;
} }
private Message parseOtrChat(String body, Jid from, String id, Conversation conversation) {
String presence;
if (from.isBareJid()) {
presence = "";
} else {
presence = from.getResource();
}
if (body.matches("^\\?OTRv\\d{1,2}\\?.*")) {
conversation.endOtrIfNeeded();
}
if (!conversation.hasValidOtrSession()) {
conversation.startOtrSession(presence, false);
} else {
String foreignPresence = conversation.getOtrSession().getSessionID().getUserID();
if (!foreignPresence.equals(presence)) {
conversation.endOtrIfNeeded();
conversation.startOtrSession(presence, false);
}
}
try {
conversation.setLastReceivedOtrMessageId(id);
Session otrSession = conversation.getOtrSession();
body = otrSession.transformReceiving(body);
SessionStatus status = otrSession.getSessionStatus();
if (body == null && status == SessionStatus.ENCRYPTED) {
mXmppConnectionService.onOtrSessionEstablished(conversation);
return null;
} else if (body == null && status == SessionStatus.FINISHED) {
conversation.resetOtrSession();
mXmppConnectionService.updateConversationUi();
return null;
} else if (body == null || (body.isEmpty())) {
return null;
}
if (body.startsWith(CryptoHelper.FILETRANSFER)) {
String key = body.substring(CryptoHelper.FILETRANSFER.length());
conversation.setSymmetricKey(CryptoHelper.hexToBytes(key));
return null;
}
if (clientMightSendHtml(conversation.getAccount(), from)) {
Log.d(Config.LOGTAG, conversation.getAccount().getJid().asBareJid() + ": received OTR message from bad behaving client. escaping HTML…");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
body = Html.fromHtml(body, Html.FROM_HTML_MODE_LEGACY).toString();
} else {
body = Html.fromHtml(body).toString();
}
}
final OtrService otrService = conversation.getAccount().getOtrService();
Message finishedMessage = new Message(conversation, body, Message.ENCRYPTION_OTR, Message.STATUS_RECEIVED);
finishedMessage.setFingerprint(otrService.getFingerprint(otrSession.getRemotePublicKey()));
conversation.setLastReceivedOtrMessageId(null);
return finishedMessage;
} catch (Exception e) {
conversation.resetOtrSession();
return null;
}
}
private Message parseAxolotlChat(Element axolotlMessage, Jid from, Conversation conversation, int status, final boolean checkedForDuplicates, boolean postpone) { private Message parseAxolotlChat(Element axolotlMessage, Jid from, Conversation conversation, int status, final boolean checkedForDuplicates, boolean postpone) {
final AxolotlService service = conversation.getAccount().getAxolotlService(); final AxolotlService service = conversation.getAccount().getAxolotlService();
final XmppAxolotlMessage xmppAxolotlMessage; final XmppAxolotlMessage xmppAxolotlMessage;
@ -327,6 +422,11 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
final Jid from = packet.getFrom(); final Jid from = packet.getFrom();
final String id = packet.getId(); final String id = packet.getId();
if (from != null && id != null) { if (from != null && id != null) {
final Message message = mXmppConnectionService.markMessage(account,
from.asBareJid(),
packet.getId(),
Message.STATUS_SEND_FAILED,
extractErrorMessage(packet));
if (id.startsWith(JingleRtpConnection.JINGLE_MESSAGE_PROPOSE_ID_PREFIX)) { if (id.startsWith(JingleRtpConnection.JINGLE_MESSAGE_PROPOSE_ID_PREFIX)) {
final String sessionId = id.substring(JingleRtpConnection.JINGLE_MESSAGE_PROPOSE_ID_PREFIX.length()); final String sessionId = id.substring(JingleRtpConnection.JINGLE_MESSAGE_PROPOSE_ID_PREFIX.length());
mXmppConnectionService.getJingleConnectionManager() mXmppConnectionService.getJingleConnectionManager()
@ -335,8 +435,8 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
} }
if (id.startsWith(JingleRtpConnection.JINGLE_MESSAGE_PROCEED_ID_PREFIX)) { if (id.startsWith(JingleRtpConnection.JINGLE_MESSAGE_PROCEED_ID_PREFIX)) {
final String sessionId = id.substring(JingleRtpConnection.JINGLE_MESSAGE_PROCEED_ID_PREFIX.length()); final String sessionId = id.substring(JingleRtpConnection.JINGLE_MESSAGE_PROCEED_ID_PREFIX.length());
final String message = extractErrorMessage(packet); final String errorMessage = extractErrorMessage(packet);
mXmppConnectionService.getJingleConnectionManager().failProceed(account, from, sessionId, message); mXmppConnectionService.getJingleConnectionManager().failProceed(account, from, sessionId, errorMessage);
return true; return true;
} }
mXmppConnectionService.markMessage(account, mXmppConnectionService.markMessage(account,
@ -355,6 +455,13 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
} }
} }
} }
if (message != null) {
if (message.getEncryption() == Message.ENCRYPTION_OTR) {
Conversation conversation = (Conversation) message.getConversation();
conversation.endOtrIfNeeded();
}
}
} }
return true; return true;
} }
@ -368,6 +475,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
} }
final MessagePacket packet; final MessagePacket packet;
Long timestamp = null; Long timestamp = null;
final boolean isForwarded;
boolean isCarbon = false; boolean isCarbon = false;
String serverMsgId = null; String serverMsgId = null;
final Element fin = original.findChild("fin", MessageArchiveService.Version.MAM_0.namespace); final Element fin = original.findChild("fin", MessageArchiveService.Version.MAM_0.namespace);
@ -385,7 +493,9 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
} }
timestamp = f.second; timestamp = f.second;
packet = f.first; packet = f.first;
isForwarded = true;
serverMsgId = result.getAttribute("id"); serverMsgId = result.getAttribute("id");
query.incrementMessageCount(); query.incrementMessageCount();
if (handleErrorMessage(account, packet)) { if (handleErrorMessage(account, packet)) {
return; return;
@ -403,8 +513,10 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
} }
timestamp = f != null ? f.second : null; timestamp = f != null ? f.second : null;
isCarbon = f != null; isCarbon = f != null;
isForwarded = isCarbon;
} else { } else {
packet = original; packet = original;
isForwarded = false;
} }
if (timestamp == null) { if (timestamp == null) {
@ -449,6 +561,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
Log.e(Config.LOGTAG, account.getJid().asBareJid() + ": received groupchat (" + from + ") message on regular MAM request. skipping"); Log.e(Config.LOGTAG, account.getJid().asBareJid() + ": received groupchat (" + from + ") message on regular MAM request. skipping");
return; return;
} }
boolean isProperlyAddressed = (to != null) && (!to.isBareJid() || account.countPresences() == 0);
boolean isMucStatusMessage = InvalidJid.hasValidFrom(packet) && from.isBareJid() && mucUserElement != null && mucUserElement.hasChild("status"); boolean isMucStatusMessage = InvalidJid.hasValidFrom(packet) && from.isBareJid() && mucUserElement != null && mucUserElement.hasChild("status");
boolean selfAddressed; boolean selfAddressed;
if (packet.fromAccount(account)) { if (packet.fromAccount(account)) {
@ -483,7 +596,10 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
final boolean conversationIsProbablyMuc = isTypeGroupChat || mucUserElement != null || account.getXmppConnection().getMucServersWithholdAccount().contains(counterpart.getDomain().toEscapedString()); final boolean conversationIsProbablyMuc = isTypeGroupChat || mucUserElement != null || account.getXmppConnection().getMucServersWithholdAccount().contains(counterpart.getDomain().toEscapedString());
if (conversationIsProbablyMuc && !isTypeGroupChat) { final boolean isOTR = body != null && body.content.startsWith("?OTR") && Config.supportOtr();
final boolean correctOTR = !isForwarded && !isTypeGroupChat && isProperlyAddressed;
if ((conversationIsProbablyMuc && !isTypeGroupChat) || (!Strings.isNullOrEmpty(counterpart.getResource()) && isOTR && correctOTR)) {
nextCounterpart = counterpart; nextCounterpart = counterpart;
} }
@ -508,10 +624,6 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
} }
} }
if (nextCounterpart != null && mXmppConnectionService.checkIsArchived(account, counterpart.asBareJid(), nextCounterpart)) {
return;
}
if ((body != null || pgpEncrypted != null || (axolotlEncrypted != null && axolotlEncrypted.hasChild("payload")) || oobUrl != null) && !isMucStatusMessage) { if ((body != null || pgpEncrypted != null || (axolotlEncrypted != null && axolotlEncrypted.hasChild("payload")) || oobUrl != null) && !isMucStatusMessage) {
final Conversation conversation = mXmppConnectionService.findOrCreateConversation(account, counterpart.asBareJid(), null, conversationIsProbablyMuc, nextCounterpart != null, false, nextCounterpart); final Conversation conversation = mXmppConnectionService.findOrCreateConversation(account, counterpart.asBareJid(), null, conversationIsProbablyMuc, nextCounterpart != null, false, nextCounterpart);
final boolean conversationMultiMode = conversation.getMode() == Conversation.MODE_MULTI; final boolean conversationMultiMode = conversation.getMode() == Conversation.MODE_MULTI;
@ -551,7 +663,17 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
} }
} }
final Message message; final Message message;
if (pgpEncrypted != null && Config.supportOpenPgp()) { if (isOTR) {
if (correctOTR && !conversationMultiMode) {
message = parseOtrChat(body.content, from, remoteMsgId, conversation);
if (message == null) {
return;
}
} else {
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": ignoring OTR message from " + from + " isForwarded=" + Boolean.toString(isForwarded) + ", isProperlyAddressed=" + Boolean.valueOf(isProperlyAddressed));
message = null;
}
} else if (pgpEncrypted != null && Config.supportOpenPgp()) {
message = new Message(conversation, pgpEncrypted, Message.ENCRYPTION_PGP, status); message = new Message(conversation, pgpEncrypted, Message.ENCRYPTION_PGP, status);
} else if (axolotlEncrypted != null && Config.supportOmemo()) { } else if (axolotlEncrypted != null && Config.supportOmemo()) {
Jid origin; Jid origin;
@ -800,6 +922,13 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
processMessageReceipts(account, packet, remoteMsgId, query); processMessageReceipts(account, packet, remoteMsgId, query);
} }
if (message.getStatus() == Message.STATUS_RECEIVED
&& conversation.getOtrSession() != null
&& !conversation.getOtrSession().getSessionID().getUserID()
.equals(message.getCounterpart().getResource())) {
conversation.endOtrIfNeeded();
}
mXmppConnectionService.databaseBackend.createMessage(message); mXmppConnectionService.databaseBackend.createMessage(message);
final HttpConnectionManager manager = this.mXmppConnectionService.getHttpConnectionManager(); final HttpConnectionManager manager = this.mXmppConnectionService.getHttpConnectionManager();
if (message.trusted() && message.treatAsDownloadable() && manager.getAutoAcceptFileSize() > 0) { if (message.trusted() && message.treatAsDownloadable() && manager.getAutoAcceptFileSize() > 0) {

View file

@ -50,6 +50,7 @@ import eu.siacs.conversations.crypto.axolotl.SQLiteAxolotlStore;
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.Conversation; import eu.siacs.conversations.entities.Conversation;
import eu.siacs.conversations.entities.Conversational;
import eu.siacs.conversations.entities.Message; import eu.siacs.conversations.entities.Message;
import eu.siacs.conversations.entities.PresenceTemplate; import eu.siacs.conversations.entities.PresenceTemplate;
import eu.siacs.conversations.entities.Roster; import eu.siacs.conversations.entities.Roster;
@ -887,30 +888,40 @@ public class DatabaseBackend extends SQLiteOpenHelper {
String comparsionOperation = isForward ? ">?" : "<?"; String comparsionOperation = isForward ? ">?" : "<?";
String sorting = isForward ? " ASC" : " DESC"; String sorting = isForward ? " ASC" : " DESC";
if (timestamp == -1) { if (timestamp == -1) {
if (conversation.getNextCounterpart() == null) { if (conversation.getNextCounterpart() != null && conversation.hasPermanentCounterpart() && conversation.getMode() == Conversational.MODE_MULTI) {
String[] selectionArgs = {conversation.getUuid()};
cursor = db.query(Message.TABLENAME, null, Message.CONVERSATION
+ "=?", selectionArgs, null, null, Message.TIME_SENT
+ sorting, String.valueOf(limit));
} else {
String[] selectionArgs = {conversation.getUuid(), String.valueOf(Message.TYPE_PRIVATE), String.valueOf(Message.TYPE_PRIVATE_FILE), conversation.getNextCounterpart().toString()}; String[] selectionArgs = {conversation.getUuid(), String.valueOf(Message.TYPE_PRIVATE), String.valueOf(Message.TYPE_PRIVATE_FILE), conversation.getNextCounterpart().toString()};
cursor = db.query(Message.TABLENAME, null, Message.CONVERSATION cursor = db.query(Message.TABLENAME, null, Message.CONVERSATION
+ "=? and (" + Message.TYPE + "=? or " + Message.TYPE + "=?) and " + Message.COUNTERPART + "=?" , selectionArgs, null, null, Message.TIME_SENT + "=? and (" + Message.TYPE + "=? or " + Message.TYPE + "=?) and " + Message.COUNTERPART + "=?" , selectionArgs, null, null, Message.TIME_SENT
+ sorting, String.valueOf(limit)); + sorting, String.valueOf(limit));
} else if (conversation.getNextCounterpart() != null && conversation.hasPermanentCounterpart()) {
String[] selectionArgs = {conversation.getUuid(), String.valueOf(Message.ENCRYPTION_OTR), conversation.getNextCounterpart().toString()};
cursor = db.query(Message.TABLENAME, null, Message.CONVERSATION
+ "=? and " + Message.ENCRYPTION + "=? and " + Message.COUNTERPART + "=?" , selectionArgs, null, null, Message.TIME_SENT
+ sorting, String.valueOf(limit));
} else {
String[] selectionArgs = {conversation.getUuid()};
cursor = db.query(Message.TABLENAME, null, Message.CONVERSATION
+ "=?", selectionArgs, null, null, Message.TIME_SENT
+ sorting, String.valueOf(limit));
} }
} else { } else {
if (conversation.getNextCounterpart() == null) { if (conversation.getNextCounterpart() != null && conversation.hasPermanentCounterpart() && conversation.getMode() == Conversational.MODE_MULTI) {
String[] selectionArgs = {conversation.getUuid(), String.valueOf(Message.TYPE_PRIVATE), String.valueOf(Message.TYPE_PRIVATE_FILE), conversation.getNextCounterpart().toString(), Long.toString(timestamp)};
cursor = db.query(Message.TABLENAME, null, Message.CONVERSATION
+ "=? and (" + Message.TYPE + "=? or " + Message.TYPE + "=?) and " + Message.COUNTERPART + "=? and " + Message.TIME_SENT + comparsionOperation, selectionArgs, null, null, Message.TIME_SENT
+ sorting, String.valueOf(limit));
} else if (conversation.getNextCounterpart() != null && conversation.hasPermanentCounterpart()) {
String[] selectionArgs = {conversation.getUuid(), String.valueOf(Message.ENCRYPTION_OTR), conversation.getNextCounterpart().toString(), Long.toString(timestamp)};
cursor = db.query(Message.TABLENAME, null, Message.CONVERSATION
+ "=? and " + Message.ENCRYPTION + "=? and " + Message.COUNTERPART + "=? and " + Message.TIME_SENT + comparsionOperation, selectionArgs, null, null, Message.TIME_SENT
+ sorting, String.valueOf(limit));
} else {
String[] selectionArgs = {conversation.getUuid(), String[] selectionArgs = {conversation.getUuid(),
Long.toString(timestamp)}; Long.toString(timestamp)};
cursor = db.query(Message.TABLENAME, null, Message.CONVERSATION cursor = db.query(Message.TABLENAME, null, Message.CONVERSATION
+ "=? and " + Message.TIME_SENT + comparsionOperation, selectionArgs, + "=? and " + Message.TIME_SENT + comparsionOperation, selectionArgs,
null, null, Message.TIME_SENT + sorting, null, null, Message.TIME_SENT + sorting,
String.valueOf(limit)); String.valueOf(limit));
} else {
String[] selectionArgs = {conversation.getUuid(), String.valueOf(Message.TYPE_PRIVATE), String.valueOf(Message.TYPE_PRIVATE_FILE), conversation.getNextCounterpart().toString(), Long.toString(timestamp)};
cursor = db.query(Message.TABLENAME, null, Message.CONVERSATION
+ "=? and (" + Message.TYPE + "=? or " + Message.TYPE + "=?) and " + Message.COUNTERPART + "=? and " + Message.TIME_SENT + comparsionOperation, selectionArgs, null, null, Message.TIME_SENT
+ sorting, String.valueOf(limit));
} }
} }
CursorUtils.upgradeCursorWindowSize(cursor); CursorUtils.upgradeCursorWindowSize(cursor);
@ -1084,7 +1095,7 @@ public class DatabaseBackend extends SQLiteOpenHelper {
try(final Cursor cursor = db.query(Conversation.TABLENAME, null, try(final Cursor cursor = db.query(Conversation.TABLENAME, null,
Conversation.ACCOUNT + "=? AND (" + Conversation.CONTACTJID Conversation.ACCOUNT + "=? AND (" + Conversation.CONTACTJID
+ " like ? OR " + Conversation.CONTACTJID + "=?)", selectionArgs, null, null, null)) { + " like ? OR " + Conversation.CONTACTJID + "=?) AND " + Conversation.NEXT_COUNTERPART + " =NULL", selectionArgs, null, null, null)) {
if (cursor.getCount() == 0) { if (cursor.getCount() == 0) {
return null; return null;
} }

View file

@ -61,6 +61,11 @@ import com.google.common.base.Objects;
import com.google.common.base.Optional; import com.google.common.base.Optional;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import net.java.otr4j.session.Session;
import net.java.otr4j.session.SessionID;
import net.java.otr4j.session.SessionImpl;
import net.java.otr4j.session.SessionStatus;
import org.conscrypt.Conscrypt; import org.conscrypt.Conscrypt;
import org.jxmpp.stringprep.libidn.LibIdnXmppStringprep; import org.jxmpp.stringprep.libidn.LibIdnXmppStringprep;
import org.openintents.openpgp.IOpenPgpService2; import org.openintents.openpgp.IOpenPgpService2;
@ -171,6 +176,7 @@ import eu.siacs.conversations.xmpp.OnUpdateBlocklist;
import eu.siacs.conversations.xmpp.XmppConnection; import eu.siacs.conversations.xmpp.XmppConnection;
import eu.siacs.conversations.xmpp.chatstate.ChatState; import eu.siacs.conversations.xmpp.chatstate.ChatState;
import eu.siacs.conversations.xmpp.forms.Data; import eu.siacs.conversations.xmpp.forms.Data;
import eu.siacs.conversations.xmpp.jid.OtrJidHelper;
import eu.siacs.conversations.xmpp.jingle.AbstractJingleConnection; import eu.siacs.conversations.xmpp.jingle.AbstractJingleConnection;
import eu.siacs.conversations.xmpp.jingle.JingleConnectionManager; import eu.siacs.conversations.xmpp.jingle.JingleConnectionManager;
import eu.siacs.conversations.xmpp.jingle.JingleRtpConnection; import eu.siacs.conversations.xmpp.jingle.JingleRtpConnection;
@ -255,9 +261,18 @@ public class XmppConnectionService extends Service {
Conversation conversation = find(getConversations(), contact); Conversation conversation = find(getConversations(), contact);
if (conversation != null) { if (conversation != null) {
if (online) { if (online) {
conversation.endOtrIfNeeded();
if (contact.getPresences().size() == 1) { if (contact.getPresences().size() == 1) {
sendUnsentMessages(conversation); sendUnsentMessages(conversation);
} }
} else {
//check if the resource we are haveing a conversation with is still online
if (conversation.hasValidOtrSession()) {
String otrResource = conversation.getOtrSession().getSessionID().getUserID();
if (!(Arrays.asList(contact.getPresences().toResourceArray()).contains(otrResource))) {
conversation.endOtrIfNeeded();
}
}
} }
} }
}; };
@ -447,6 +462,9 @@ public class XmppConnectionService extends Service {
if (conversation.getAccount() == account if (conversation.getAccount() == account
&& !pendingJoin && !pendingJoin
&& !inProgressJoin) { && !inProgressJoin) {
if (!conversation.startOtrIfNeeded()) {
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": couldn't start OTR with " + conversation.getContact().getJid() + " when needed");
}
sendUnsentMessages(conversation); sendUnsentMessages(conversation);
} }
} }
@ -1704,6 +1722,12 @@ public class XmppConnectionService extends Service {
} }
} }
if (!resend && message.getEncryption() != Message.ENCRYPTION_OTR) {
conversation.endOtrIfNeeded();
conversation.findUnsentMessagesWithEncryption(Message.ENCRYPTION_OTR,
message1 -> markMessage(message1, Message.STATUS_SEND_FAILED));
}
final boolean inProgressJoin = isJoinInProgress(conversation); final boolean inProgressJoin = isJoinInProgress(conversation);
@ -1736,6 +1760,30 @@ public class XmppConnectionService extends Service {
packet = mMessageGenerator.generatePgpChat(message); packet = mMessageGenerator.generatePgpChat(message);
} }
break; break;
case Message.ENCRYPTION_OTR:
SessionImpl otrSession = conversation.getOtrSession();
if (otrSession != null && otrSession.getSessionStatus() == SessionStatus.ENCRYPTED) {
try {
message.setCounterpart(OtrJidHelper.fromSessionID(otrSession.getSessionID()));
} catch (IllegalArgumentException e) {
break;
}
if (message.needsUploading()) {
mJingleConnectionManager.startJingleFileTransfer(message);
} else {
packet = mMessageGenerator.generateOtrChat(message);
}
} else if (otrSession == null) {
if (message.fixCounterpart()) {
conversation.startOtrSession(message.getCounterpart().getResource(), true);
} else {
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": could not fix counterpart for OTR message to contact " + message.getCounterpart());
break;
}
} else {
Log.d(Config.LOGTAG, account.getJid().asBareJid() + " OTR session with " + message.getContact() + " is in wrong state: " + otrSession.getSessionStatus().toString());
}
break;
case Message.ENCRYPTION_AXOLOTL: case Message.ENCRYPTION_AXOLOTL:
message.setFingerprint(account.getAxolotlService().getOwnFingerprint()); message.setFingerprint(account.getAxolotlService().getOwnFingerprint());
if (message.needsUploading()) { if (message.needsUploading()) {
@ -1789,6 +1837,12 @@ public class XmppConnectionService extends Service {
} }
} }
break; break;
case Message.ENCRYPTION_OTR:
if (!conversation.hasValidOtrSession() && message.getCounterpart() != null) {
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": create otr session without starting for " + message.getContact().getJid());
conversation.startOtrSession(message.getCounterpart().getResource(), false);
}
break;
case Message.ENCRYPTION_AXOLOTL: case Message.ENCRYPTION_AXOLOTL:
message.setFingerprint(account.getAxolotlService().getOwnFingerprint()); message.setFingerprint(account.getAxolotlService().getOwnFingerprint());
break; break;
@ -2446,8 +2500,10 @@ public class XmppConnectionService extends Service {
query.setCallback(callback); query.setCallback(callback);
callback.informUser(R.string.fetching_history_from_server); callback.informUser(R.string.fetching_history_from_server);
} else { } else {
if (conversation.getMode() != Conversational.MODE_SINGLE || !conversation.hasPermanentCounterpart()) {
callback.informUser(R.string.not_fetching_history_retention_period); callback.informUser(R.string.not_fetching_history_retention_period);
} }
}
} }
} }
@ -2496,6 +2552,7 @@ public class XmppConnectionService extends Service {
if ((account == null || conversation.getAccount() == account) if ((account == null || conversation.getAccount() == account)
&& (conversation.getJid().asBareJid().equals(jid.asBareJid())) && (conversation.getJid().asBareJid().equals(jid.asBareJid()))
&& Objects.equal(conversation.getNextCounterpart(), counterpart) && Objects.equal(conversation.getNextCounterpart(), counterpart)
&& conversation.hasPermanentCounterpart()
) { ) {
return conversation; return conversation;
} }
@ -2504,7 +2561,7 @@ public class XmppConnectionService extends Service {
for (final Conversation conversation : haystack) { for (final Conversation conversation : haystack) {
if ((account == null || conversation.getAccount() == account) if ((account == null || conversation.getAccount() == account)
&& (conversation.getJid().asBareJid().equals(jid.asBareJid())) && (conversation.getJid().asBareJid().equals(jid.asBareJid()))
&& conversation.getNextCounterpart() == null && (conversation.getNextCounterpart() == null || !conversation.hasPermanentCounterpart())
) { ) {
return conversation; return conversation;
} }
@ -2566,6 +2623,7 @@ public class XmppConnectionService extends Service {
if (conversation != null) { if (conversation != null) {
return conversation; return conversation;
} }
conversation = databaseBackend.findConversation(account, jid, counterpart); conversation = databaseBackend.findConversation(account, jid, counterpart);
final boolean loadMessagesFromDb; final boolean loadMessagesFromDb;
if (conversation != null) { if (conversation != null) {
@ -3922,6 +3980,12 @@ public class XmppConnectionService extends Service {
if (conversation.getAccount() == account) { if (conversation.getAccount() == account) {
if (conversation.getMode() == Conversation.MODE_MULTI) { if (conversation.getMode() == Conversation.MODE_MULTI) {
leaveMuc(conversation, true); leaveMuc(conversation, true);
} else {
if (conversation.endOtrIfNeeded()) {
Log.d(Config.LOGTAG, account.getJid().asBareJid()
+ ": ended otr session with "
+ conversation.getJid());
}
} }
} }
} }
@ -3978,6 +4042,39 @@ public class XmppConnectionService extends Service {
pushContactToServer(contact, preAuth); pushContactToServer(contact, preAuth);
} }
public void onOtrSessionEstablished(Conversation conversation) {
final Account account = conversation.getAccount();
final Session otrSession = conversation.getOtrSession();
Log.d(Config.LOGTAG,
account.getJid().asBareJid() + " otr session established with "
+ conversation.getJid() + "/"
+ otrSession.getSessionID().getUserID());
conversation.findUnsentMessagesWithEncryption(Message.ENCRYPTION_OTR, new Conversation.OnMessageFound() {
@Override
public void onMessageFound(Message message) {
SessionID id = otrSession.getSessionID();
try {
message.setCounterpart(Jid.of(id.getAccountID() + "/" + id.getUserID()));
} catch (IllegalArgumentException e) {
return;
}
if (message.needsUploading()) {
mJingleConnectionManager.startJingleFileTransfer(message);
} else {
MessagePacket outPacket = mMessageGenerator.generateOtrChat(message);
if (outPacket != null) {
mMessageGenerator.addDelay(outPacket, message.getTimeSent());
message.setStatus(Message.STATUS_SEND);
databaseBackend.updateMessage(message, false);
sendMessagePacket(account, outPacket);
}
}
updateConversationUi();
}
});
}
public void pushContactToServer(final Contact contact) { public void pushContactToServer(final Contact contact) {
pushContactToServer(contact, null); pushContactToServer(contact, null);
} }
@ -4503,6 +4600,7 @@ public class XmppConnectionService extends Service {
return false; return false;
} else { } else {
final Message message = conversation.findSentMessageWithUuid(uuid); final Message message = conversation.findSentMessageWithUuid(uuid);
if (message != null) { if (message != null) {
if (message.getServerMsgId() == null) { if (message.getServerMsgId() == null) {
message.setServerMsgId(serverMessageId); message.setServerMsgId(serverMessageId);
@ -4805,6 +4903,11 @@ public class XmppConnectionService extends Service {
setMemorizingTrustManager(tm); setMemorizingTrustManager(tm);
} }
public void syncRosterToDisk(final Account account) {
Runnable runnable = () -> databaseBackend.writeRoster(account.getRoster());
mDatabaseWriterExecutor.execute(runnable);
}
public LruCache<String, Bitmap> getBitmapCache() { public LruCache<String, Bitmap> getBitmapCache() {
return this.mBitmapCache; return this.mBitmapCache;
} }
@ -5272,10 +5375,14 @@ public class XmppConnectionService extends Service {
} }
public boolean verifyFingerprints(Contact contact, List<XmppUri.Fingerprint> fingerprints) { public boolean verifyFingerprints(Contact contact, List<XmppUri.Fingerprint> fingerprints) {
boolean needsRosterWrite = false;
boolean performedVerification = false; boolean performedVerification = false;
final AxolotlService axolotlService = contact.getAccount().getAxolotlService(); final AxolotlService axolotlService = contact.getAccount().getAxolotlService();
for (XmppUri.Fingerprint fp : fingerprints) { for (XmppUri.Fingerprint fp : fingerprints) {
if (fp.type == XmppUri.FingerprintType.OMEMO) { if (fp.type == XmppUri.FingerprintType.OTR) {
performedVerification |= contact.addOtrFingerprint(fp.fingerprint);
needsRosterWrite |= performedVerification;
} else if (fp.type == XmppUri.FingerprintType.OMEMO) {
String fingerprint = "05" + fp.fingerprint.replaceAll("\\s", ""); String fingerprint = "05" + fp.fingerprint.replaceAll("\\s", "");
FingerprintStatus fingerprintStatus = axolotlService.getFingerprintTrust(fingerprint); FingerprintStatus fingerprintStatus = axolotlService.getFingerprintTrust(fingerprint);
if (fingerprintStatus != null) { if (fingerprintStatus != null) {
@ -5288,6 +5395,11 @@ public class XmppConnectionService extends Service {
} }
} }
} }
if (needsRosterWrite) {
syncRosterToDisk(contact.getAccount());
}
return performedVerification; return performedVerification;
} }

View file

@ -504,7 +504,7 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp
&& contact.getLastseen() > 0 && contact.getLastseen() > 0
&& contact.getPresences().allOrNonSupport(Namespace.IDLE)) { && contact.getPresences().allOrNonSupport(Namespace.IDLE)) {
binding.detailsLastseen.setVisibility(View.VISIBLE); binding.detailsLastseen.setVisibility(View.VISIBLE);
binding.detailsLastseen.setText(UIHelper.lastseen(getApplicationContext(), contact.isActive(), contact.getLastseen())); binding.detailsLastseen.setText(UIHelper.lastseen(getApplicationContext(), contact.isActive(), contact.getLastseen(), false));
} else { } else {
binding.detailsLastseen.setVisibility(View.GONE); binding.detailsLastseen.setVisibility(View.GONE);
} }
@ -523,7 +523,7 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp
AvatarWorkerTask.loadAvatar(contact, binding.detailsContactBadge, R.dimen.avatar_on_details_screen_size); AvatarWorkerTask.loadAvatar(contact, binding.detailsContactBadge, R.dimen.avatar_on_details_screen_size);
binding.detailsContactBadge.setOnClickListener(this::onBadgeClick); binding.detailsContactBadge.setOnClickListener(this::onBadgeClick);
binding.presenceIndicator.setStatus(contact.getShownStatus()); binding.presenceIndicator.setStatus(contact);
binding.detailsContactKeys.removeAllViews(); binding.detailsContactKeys.removeAllViews();
boolean hasKeys = false; boolean hasKeys = false;

View file

@ -79,6 +79,8 @@ import androidx.viewpager.widget.PagerAdapter;
import com.google.common.base.Optional; import com.google.common.base.Optional;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import net.java.otr4j.session.SessionStatus;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.io.File; import java.io.File;
@ -223,6 +225,14 @@ public class ConversationFragment extends XmppFragment
private ConversationsActivity activity; private ConversationsActivity activity;
private Vibrator vibrator; private Vibrator vibrator;
private boolean reInitRequiredOnStart = true; private boolean reInitRequiredOnStart = true;
protected OnClickListener clickToVerify = new OnClickListener() {
@Override
public void onClick(View v) {
activity.verifyOtrSessionDialog(conversation, v);
}
};
@ColorInt @ColorInt
private int primaryColor = -1; private int primaryColor = -1;
@ -534,6 +544,20 @@ public class ConversationFragment extends XmppFragment
} }
} }
}; };
private OnClickListener mAnswerSmpClickListener = new OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(activity, VerifyOTRActivity.class);
intent.setAction(VerifyOTRActivity.ACTION_VERIFY_CONTACT);
intent.putExtra(EXTRA_ACCOUNT, conversation.getAccount().getJid().asBareJid().toString());
intent.putExtra(VerifyOTRActivity.EXTRA_ACCOUNT, conversation.getAccount().getJid().asBareJid().toString());
intent.putExtra("mode", VerifyOTRActivity.MODE_ANSWER_QUESTION);
startActivity(intent);
activity.overridePendingTransition(R.animator.fade_in, R.animator.fade_out);
}
};
protected OnClickListener clickToDecryptListener = protected OnClickListener clickToDecryptListener =
new OnClickListener() { new OnClickListener() {
@ -590,7 +614,7 @@ public class ConversationFragment extends XmppFragment
public void onClick(View v) { public void onClick(View v) {
stopScrolling(); stopScrolling();
if (previousClickedReply != null) { /*if (previousClickedReply != null) {
int lastVisiblePosition = binding.messagesView.getLastVisiblePosition(); int lastVisiblePosition = binding.messagesView.getLastVisiblePosition();
Message lastVisibleMessage = messageListAdapter.getItem(lastVisiblePosition); Message lastVisibleMessage = messageListAdapter.getItem(lastVisiblePosition);
Message jump = previousClickedReply; Message jump = previousClickedReply;
@ -602,7 +626,7 @@ public class ConversationFragment extends XmppFragment
return; return;
} }
} }
} }*/
if (conversation.isInHistoryPart()) { if (conversation.isInHistoryPart()) {
conversation.jumpToLatest(); conversation.jumpToLatest();
@ -1064,6 +1088,9 @@ public class ConversationFragment extends XmppFragment
message.setUuid(UUID.randomUUID().toString()); message.setUuid(UUID.randomUUID().toString());
} }
switch (conversation.getNextEncryption()) { switch (conversation.getNextEncryption()) {
case Message.ENCRYPTION_OTR:
sendOtrMessage(message);
break;
case Message.ENCRYPTION_PGP: case Message.ENCRYPTION_PGP:
sendPgpMessage(message); sendPgpMessage(message);
break; break;
@ -1380,8 +1407,13 @@ public class ConversationFragment extends XmppFragment
final MenuItem menuVideoCall = menu.findItem(R.id.action_video_call); final MenuItem menuVideoCall = menu.findItem(R.id.action_video_call);
final MenuItem menuTogglePinned = menu.findItem(R.id.action_toggle_pinned); final MenuItem menuTogglePinned = menu.findItem(R.id.action_toggle_pinned);
final MenuItem deleteCustomBg = menu.findItem(R.id.action_delete_custom_bg); final MenuItem deleteCustomBg = menu.findItem(R.id.action_delete_custom_bg);
final MenuItem startSecretChat = menu.findItem(R.id.action_start_secret_chat);
final MenuItem encryption = menu.findItem(R.id.action_security);
if (conversation != null) { if (conversation != null) {
boolean considerAsSecretChat = conversation.getMode() == Conversational.MODE_SINGLE &&
conversation.getNextCounterpart() != null && conversation.hasPermanentCounterpart();
if (conversation.getMode() == Conversation.MODE_MULTI) { if (conversation.getMode() == Conversation.MODE_MULTI) {
menuContactDetails.setVisible(false); menuContactDetails.setVisible(false);
menuInviteContact.setVisible(conversation.getMucOptions().canInvite() && conversation.getNextCounterpart() == null); menuInviteContact.setVisible(conversation.getMucOptions().canInvite() && conversation.getNextCounterpart() == null);
@ -1391,7 +1423,11 @@ public class ConversationFragment extends XmppFragment
: R.string.channel_details); : R.string.channel_details);
menuCall.setVisible(false); menuCall.setVisible(false);
menuOngoingCall.setVisible(false); menuOngoingCall.setVisible(false);
startSecretChat.setVisible(false);
} else { } else {
if (considerAsSecretChat) {
startSecretChat.setVisible(false);
}
menuMucParticipants.setVisible(false); menuMucParticipants.setVisible(false);
final XmppConnectionService service = final XmppConnectionService service =
activity == null ? null : activity.xmppConnectionService; activity == null ? null : activity.xmppConnectionService;
@ -1432,6 +1468,10 @@ public class ConversationFragment extends XmppFragment
menuTogglePinned.setTitle(R.string.add_to_favorites); menuTogglePinned.setTitle(R.string.add_to_favorites);
} }
if (considerAsSecretChat) {
encryption.setVisible(false);
}
deleteCustomBg.setVisible(ChatBackgroundHelper.getBgFile(activity, conversation.getUuid()).exists()); deleteCustomBg.setVisible(ChatBackgroundHelper.getBgFile(activity, conversation.getUuid()).exists());
} }
@ -2022,6 +2062,9 @@ public class ConversationFragment extends XmppFragment
case R.id.action_archive: case R.id.action_archive:
activity.xmppConnectionService.archiveConversation(conversation); activity.xmppConnectionService.archiveConversation(conversation);
break; break;
case R.id.action_start_secret_chat:
startOtrChat();
break;
case R.id.action_contact_details: case R.id.action_contact_details:
activity.switchToContactDetails(conversation.getContact()); activity.switchToContactDetails(conversation.getContact());
break; break;
@ -3550,6 +3593,14 @@ public class ConversationFragment extends XmppFragment
} }
} else if (account.hasPendingPgpIntent(conversation)) { } else if (account.hasPendingPgpIntent(conversation)) {
showSnackbar(R.string.openpgp_messages_found, R.string.decrypt, clickToDecryptListener); showSnackbar(R.string.openpgp_messages_found, R.string.decrypt, clickToDecryptListener);
} else if (mode == Conversation.MODE_SINGLE
&& conversation.smpRequested()) {
showSnackbar(R.string.smp_requested, R.string.verify, this.mAnswerSmpClickListener);
} else if (mode == Conversation.MODE_SINGLE
&& conversation.hasValidOtrSession()
&& (conversation.getOtrSession().getSessionStatus() == SessionStatus.ENCRYPTED)
&& (!conversation.isOtrFingerprintVerified())) {
showSnackbar(R.string.unknown_otr_fingerprint, R.string.verify, clickToVerify);
} else if (connection != null } else if (connection != null
&& connection.getFeatures().blocking() && connection.getFeatures().blocking()
&& conversation.countMessages() != 0 && conversation.countMessages() != 0
@ -3610,7 +3661,7 @@ public class ConversationFragment extends XmppFragment
conversation.refreshSessions(); conversation.refreshSessions();
if (conversation != null && conversation.getMode() == Conversational.MODE_MULTI) { if (conversation != null && conversation.getMode() == Conversational.MODE_MULTI && conversation.getNextCounterpart() == null) {
String subject = conversation.getMucOptions().getSubject(); String subject = conversation.getMucOptions().getSubject();
Boolean hidden = conversation.getMucOptions().subjectHidden(); Boolean hidden = conversation.getMucOptions().subjectHidden();
@ -3650,6 +3701,11 @@ public class ConversationFragment extends XmppFragment
new Handler() new Handler()
.post( .post(
() -> { () -> {
if (conversation.isInHistoryPart()) {
conversation.jumpToLatest();
refresh(false);
}
int size = messageList.size(); int size = messageList.size();
this.binding.messagesView.setSelection(size - 1); this.binding.messagesView.setSelection(size - 1);
}); });
@ -3937,6 +3993,26 @@ public class ConversationFragment extends XmppFragment
messageSent(); messageSent();
} }
protected void sendOtrMessage(final Message message) {
final ConversationsActivity activity = (ConversationsActivity) getActivity();
final XmppConnectionService xmppService = activity.xmppConnectionService;
message.setCounterpart(conversation.getNextCounterpart());
xmppService.sendMessage(message);
messageSent();
}
protected void startOtrChat() {
final ConversationsActivity activity = (ConversationsActivity) getActivity();
activity.selectPresence(conversation,
() -> {
Conversation c = activity.xmppConnectionService.findOrCreateConversation(conversation.getAccount(), conversation.getJid(), null, false, false, false, conversation.getNextCounterpart());
conversation.setNextCounterpart(null);
if (c != conversation) {
activity.switchToConversation(c);
}
});
}
protected void sendPgpMessage(final Message message) { protected void sendPgpMessage(final Message message) {
final XmppConnectionService xmppService = activity.xmppConnectionService; final XmppConnectionService xmppService = activity.xmppConnectionService;
final Contact contact = message.getConversation().getContact(); final Contact contact = message.getConversation().getContact();

View file

@ -42,10 +42,14 @@ import android.app.FragmentTransaction;
import android.content.ActivityNotFoundException; import android.content.ActivityNotFoundException;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.net.Uri; import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.preference.PreferenceManager;
import android.provider.Settings; import android.provider.Settings;
import android.util.Log; import android.util.Log;
import android.view.KeyEvent; import android.view.KeyEvent;
@ -59,9 +63,12 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.widget.PopupMenu;
import androidx.core.app.ActivityCompat; import androidx.core.app.ActivityCompat;
import androidx.databinding.DataBindingUtil; import androidx.databinding.DataBindingUtil;
import net.java.otr4j.session.SessionStatus;
import com.google.android.material.bottomnavigation.BottomNavigationView; import com.google.android.material.bottomnavigation.BottomNavigationView;
import com.google.android.material.navigation.NavigationBarView; import com.google.android.material.navigation.NavigationBarView;
@ -95,10 +102,13 @@ import eu.siacs.conversations.ui.util.PendingItem;
import eu.siacs.conversations.utils.ExceptionHelper; import eu.siacs.conversations.utils.ExceptionHelper;
import eu.siacs.conversations.utils.PhoneNumberUtilWrapper; import eu.siacs.conversations.utils.PhoneNumberUtilWrapper;
import eu.siacs.conversations.utils.SignupUtils; import eu.siacs.conversations.utils.SignupUtils;
import eu.siacs.conversations.utils.UIHelper;
import eu.siacs.conversations.utils.XmppUri; import eu.siacs.conversations.utils.XmppUri;
import eu.siacs.conversations.xml.Namespace;
import eu.siacs.conversations.xmpp.Jid; import eu.siacs.conversations.xmpp.Jid;
import eu.siacs.conversations.xmpp.OnUpdateBlocklist; import eu.siacs.conversations.xmpp.OnUpdateBlocklist;
import io.michaelrocks.libphonenumber.android.NumberParseException; import io.michaelrocks.libphonenumber.android.NumberParseException;
import me.drakeet.support.toast.ToastCompat;
public class ConversationsActivity extends XmppActivity implements OnConversationSelected, OnConversationArchived, OnConversationsListItemUpdated, OnConversationRead, XmppConnectionService.OnAccountUpdate, XmppConnectionService.OnConversationUpdate, XmppConnectionService.OnRosterUpdate, OnUpdateBlocklist, XmppConnectionService.OnShowErrorToast, XmppConnectionService.OnAffiliationChanged { public class ConversationsActivity extends XmppActivity implements OnConversationSelected, OnConversationArchived, OnConversationsListItemUpdated, OnConversationRead, XmppConnectionService.OnAccountUpdate, XmppConnectionService.OnConversationUpdate, XmppConnectionService.OnRosterUpdate, OnUpdateBlocklist, XmppConnectionService.OnShowErrorToast, XmppConnectionService.OnAffiliationChanged {
@ -135,6 +145,10 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio
private boolean mActivityPaused = true; private boolean mActivityPaused = true;
private final AtomicBoolean mRedirectInProcess = new AtomicBoolean(false); private final AtomicBoolean mRedirectInProcess = new AtomicBoolean(false);
private final Handler handler = new Handler(Looper.getMainLooper());
private final Runnable refreshTitleRunnable = this::invalidateActionBarTitle;
private boolean showLastSeen = false;
private static boolean isViewOrShareIntent(Intent i) { private static boolean isViewOrShareIntent(Intent i) {
Log.d(Config.LOGTAG, "action: " + (i == null ? null : i.getAction())); Log.d(Config.LOGTAG, "action: " + (i == null ? null : i.getAction()));
return i != null && VIEW_AND_SHARE_ACTIONS.contains(i.getAction()) && i.hasExtra(EXTRA_CONVERSATION); return i != null && VIEW_AND_SHARE_ACTIONS.contains(i.getAction()) && i.hasExtra(EXTRA_CONVERSATION);
@ -660,6 +674,8 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio
this.mSkipBackgroundBinding = false; this.mSkipBackgroundBinding = false;
} }
mRedirectInProcess.set(false); mRedirectInProcess.set(false);
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
this.showLastSeen = preferences.getBoolean("last_activity", false);
BottomNavigationView bottomNavigationView = findViewById(R.id.bottom_navigation); BottomNavigationView bottomNavigationView = findViewById(R.id.bottom_navigation);
bottomNavigationView.setSelectedItemId(R.id.chats); bottomNavigationView.setSelectedItemId(R.id.chats);
@ -735,13 +751,18 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio
if (actionBar == null) { if (actionBar == null) {
return; return;
} }
final FragmentManager fragmentManager = getFragmentManager(); final FragmentManager fragmentManager = getFragmentManager();
final Fragment mainFragment = fragmentManager.findFragmentById(R.id.main_fragment); final Fragment mainFragment = fragmentManager.findFragmentById(R.id.main_fragment);
if (mainFragment instanceof ConversationFragment) { if (mainFragment instanceof ConversationFragment) {
final Conversation conversation = ((ConversationFragment) mainFragment).getConversation(); final Conversation conversation = ((ConversationFragment) mainFragment).getConversation();
if (conversation != null) { if (conversation != null) {
if (conversation.getNextCounterpart() != null) { if (conversation.getNextCounterpart() != null && conversation.hasPermanentCounterpart()) {
if (conversation.getMode() == Conversational.MODE_MULTI) {
actionBar.setTitle(getString(R.string.muc_private_conversation_title, conversation.getNextCounterpart().getResource(), conversation.getName())); actionBar.setTitle(getString(R.string.muc_private_conversation_title, conversation.getNextCounterpart().getResource(), conversation.getName()));
} else {
actionBar.setTitle(getString(R.string.secret_chat_title_no_resource, conversation.getName()));
}
} else { } else {
actionBar.setTitle(conversation.getName()); actionBar.setTitle(conversation.getName());
} }
@ -750,10 +771,40 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio
binding.toolbar, binding.toolbar,
(v) -> openConversationDetails(conversation) (v) -> openConversationDetails(conversation)
); );
if (conversation.getMode() == Conversation.MODE_MULTI && conversation.getNextCounterpart() == null) {
int usersCount = conversation.getMucOptions().getUserCount();
if (usersCount > 0) {
actionBar.setSubtitle(getResources().getQuantityString(R.plurals.x_participants, conversation.getMucOptions().getUserCount(), conversation.getMucOptions().getUserCount()));
} else {
actionBar.setSubtitle("");
}
handler.postDelayed(refreshTitleRunnable, 5000L);
} else if (conversation.getMode() == Conversation.MODE_SINGLE) {
Contact contact = conversation.getContact();
List<String> statuses = contact.getPresences().getStatusMessages();
if (conversation.getNextCounterpart() != null && conversation.hasPermanentCounterpart()) {
actionBar.setSubtitle(conversation.getNextCounterpart().getResource());
} else if (!statuses.isEmpty() && !statuses.get(0).isBlank()) {
actionBar.setSubtitle(statuses.get(0));
handler.postDelayed(refreshTitleRunnable, 5000L);
} else {
actionBar.setSubtitle("");
handler.removeCallbacks(refreshTitleRunnable);
}
} else {
actionBar.setSubtitle("");
handler.removeCallbacks(refreshTitleRunnable);
}
return; return;
} }
} }
handler.removeCallbacks(refreshTitleRunnable);
actionBar.setTitle(R.string.app_name); actionBar.setTitle(R.string.app_name);
actionBar.setSubtitle("");
actionBar.setDisplayHomeAsUpEnabled(false); actionBar.setDisplayHomeAsUpEnabled(false);
ActionBarUtil.resetActionBarOnClickListeners(binding.toolbar); ActionBarUtil.resetActionBarOnClickListeners(binding.toolbar);
} }
@ -771,6 +822,41 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio
} }
} }
public void verifyOtrSessionDialog(final Conversation conversation, View view) {
if (!conversation.hasValidOtrSession() || conversation.getOtrSession().getSessionStatus() != SessionStatus.ENCRYPTED) {
ToastCompat.makeText(this, R.string.otr_session_not_started, Toast.LENGTH_LONG).show();
return;
}
if (view == null) {
return;
}
PopupMenu popup = new PopupMenu(this, view);
popup.inflate(R.menu.verification_choices);
popup.setOnMenuItemClickListener(menuItem -> {
if (menuItem.getItemId() == R.id.blind_trust) {
conversation.verifyOtrFingerprint();
xmppConnectionService.syncRosterToDisk(conversation.getAccount());
refreshUiReal();
return true;
}
Intent intent = new Intent(ConversationsActivity.this, VerifyOTRActivity.class);
intent.setAction(VerifyOTRActivity.ACTION_VERIFY_CONTACT);
intent.putExtra("contact", conversation.getContact().getJid().asBareJid().toString());
intent.putExtra("counterpart", conversation.getNextCounterpart().toString());
intent.putExtra(EXTRA_ACCOUNT, conversation.getAccount().getJid().asBareJid().toString());
switch (menuItem.getItemId()) {
case R.id.ask_question:
intent.putExtra("mode", VerifyOTRActivity.MODE_ASK_QUESTION);
break;
}
startActivity(intent);
overridePendingTransition(R.animator.fade_in, R.animator.fade_out);
return true;
});
popup.show();
}
@Override @Override
public void onConversationArchived(Conversation conversation) { public void onConversationArchived(Conversation conversation) {
if (performRedirectIfNecessary(conversation, false)) { if (performRedirectIfNecessary(conversation, false)) {

View file

@ -265,7 +265,6 @@ public class SendLogActivity extends ActionBarActivity {
log.insert(0, mAdditonalInfo); log.insert(0, mAdditonalInfo);
} }
android.util.Log.e("35fd", log.toString());
writer.write(log.toString()); writer.write(log.toString());
} }
catch (IOException e){ catch (IOException e){

View file

@ -0,0 +1,450 @@
package eu.siacs.conversations.ui;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AlertDialog;
import net.java.otr4j.OtrException;
import net.java.otr4j.session.Session;
import eu.siacs.conversations.Config;
import eu.siacs.conversations.R;
import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.entities.Contact;
import eu.siacs.conversations.entities.Conversation;
import eu.siacs.conversations.services.XmppConnectionService;
import eu.siacs.conversations.utils.CryptoHelper;
import eu.siacs.conversations.utils.XmppUri;
import eu.siacs.conversations.xmpp.Jid;
import me.drakeet.support.toast.ToastCompat;
public class VerifyOTRActivity extends XmppActivity implements XmppConnectionService.OnConversationUpdate {
public static final String ACTION_VERIFY_CONTACT = "verify_contact";
public static final int MODE_SCAN_FINGERPRINT = -0x0502;
public static final int MODE_ASK_QUESTION = 0x0503;
public static final int MODE_ANSWER_QUESTION = 0x0504;
public static final int MODE_MANUAL_VERIFICATION = 0x0505;
private LinearLayout mManualVerificationArea;
private LinearLayout mSmpVerificationArea;
private TextView mRemoteFingerprint;
private TextView mYourFingerprint;
private TextView mVerificationExplain;
private TextView mStatusMessage;
private TextView mSharedSecretHint;
private EditText mSharedSecretHintEditable;
private EditText mSharedSecretSecret;
private Button mLeftButton;
private Button mRightButton;
private Account mAccount;
private Conversation mConversation;
private int mode = MODE_MANUAL_VERIFICATION;
private XmppUri mPendingUri = null;
private DialogInterface.OnClickListener mVerifyFingerprintListener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int click) {
mConversation.verifyOtrFingerprint();
xmppConnectionService.syncRosterToDisk(mConversation.getAccount());
ToastCompat.makeText(VerifyOTRActivity.this, R.string.verified, Toast.LENGTH_SHORT).show();
finish();
}
};
private View.OnClickListener mCreateSharedSecretListener = new View.OnClickListener() {
@Override
public void onClick(final View view) {
if (isAccountOnline()) {
final String question = mSharedSecretHintEditable.getText().toString();
final String secret = mSharedSecretSecret.getText().toString();
if (question.trim().isEmpty()) {
mSharedSecretHintEditable.requestFocus();
mSharedSecretHintEditable.setError(getString(R.string.shared_secret_hint_should_not_be_empty));
} else if (secret.trim().isEmpty()) {
mSharedSecretSecret.requestFocus();
mSharedSecretSecret.setError(getString(R.string.shared_secret_can_not_be_empty));
} else {
mSharedSecretSecret.setError(null);
mSharedSecretHintEditable.setError(null);
initSmp(question, secret);
updateView();
}
}
}
};
private View.OnClickListener mCancelSharedSecretListener = new View.OnClickListener() {
@Override
public void onClick(View view) {
if (isAccountOnline()) {
abortSmp();
updateView();
}
}
};
private View.OnClickListener mRespondSharedSecretListener = new View.OnClickListener() {
@Override
public void onClick(View view) {
if (isAccountOnline()) {
final String question = mSharedSecretHintEditable.getText().toString();
final String secret = mSharedSecretSecret.getText().toString();
respondSmp(question, secret);
updateView();
}
}
};
private View.OnClickListener mRetrySharedSecretListener = new View.OnClickListener() {
@Override
public void onClick(View view) {
mConversation.smp().status = Conversation.Smp.STATUS_NONE;
mConversation.smp().hint = null;
mConversation.smp().secret = null;
updateView();
}
};
private View.OnClickListener mFinishListener = new View.OnClickListener() {
@Override
public void onClick(View view) {
mConversation.smp().status = Conversation.Smp.STATUS_NONE;
finish();
}
};
protected boolean initSmp(final String question, final String secret) {
final Session session = mConversation.getOtrSession();
if (session != null) {
try {
session.initSmp(question, secret);
mConversation.smp().status = Conversation.Smp.STATUS_WE_REQUESTED;
mConversation.smp().secret = secret;
mConversation.smp().hint = question;
return true;
} catch (OtrException e) {
return false;
}
} else {
return false;
}
}
protected boolean abortSmp() {
final Session session = mConversation.getOtrSession();
if (session != null) {
try {
session.abortSmp();
mConversation.smp().status = Conversation.Smp.STATUS_NONE;
mConversation.smp().hint = null;
mConversation.smp().secret = null;
return true;
} catch (OtrException e) {
return false;
}
} else {
return false;
}
}
protected boolean respondSmp(final String question, final String secret) {
final Session session = mConversation.getOtrSession();
if (session != null) {
try {
session.respondSmp(question, secret);
return true;
} catch (OtrException e) {
return false;
}
} else {
return false;
}
}
protected boolean verifyWithUri(XmppUri uri) {
Contact contact = mConversation.getContact();
if (this.mConversation.getContact().getJid().equals(uri.getJid()) && uri.hasFingerprints()) {
xmppConnectionService.verifyFingerprints(contact, uri.getFingerprints());
ToastCompat.makeText(this, R.string.verified, Toast.LENGTH_SHORT).show();
updateView();
return true;
} else {
ToastCompat.makeText(this, R.string.could_not_verify_fingerprint, Toast.LENGTH_SHORT).show();
return false;
}
}
protected boolean isAccountOnline() {
if (this.mAccount.getStatus() != Account.State.ONLINE) {
ToastCompat.makeText(this, R.string.not_connected_try_again, Toast.LENGTH_SHORT).show();
return false;
} else {
return true;
}
}
protected boolean handleIntent(Intent intent) {
if (intent != null && intent.getAction().equals(ACTION_VERIFY_CONTACT)) {
this.mAccount = extractAccount(intent);
if (this.mAccount == null) {
return false;
}
try {
this.mConversation = this.xmppConnectionService.find(this.mAccount, Jid.of(intent.getExtras().getString("contact")), Jid.of(intent.getExtras().getString("counterpart")));
if (this.mConversation == null) {
return false;
}
} catch (final IllegalArgumentException ignored) {
ignored.printStackTrace();
return false;
} catch (Exception e) {
e.printStackTrace();
return false;
}
this.mode = intent.getIntExtra("mode", MODE_MANUAL_VERIFICATION);
// todo scan OTR fingerprint
if (this.mode == MODE_SCAN_FINGERPRINT) {
Log.d(Config.LOGTAG, "Scan OTR fingerprint is not implemented in this version");
//new IntentIntegrator(this).initiateScan();
return false;
}
return true;
} else {
return false;
}
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
// todo onActivityResult for OTR scan
Log.d(Config.LOGTAG, "Scan OTR fingerprint result is not implemented in this version");
/*if ((requestCode & 0xFFFF) == IntentIntegrator.REQUEST_CODE) {
IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);
if (scanResult != null && scanResult.getFormatName() != null) {
String data = scanResult.getContents();
XmppUri uri = new XmppUri(data);
if (xmppConnectionServiceBound) {
verifyWithUri(uri);
finish();
} else {
this.mPendingUri = uri;
}
} else {
finish();
}
}*/
super.onActivityResult(requestCode, requestCode, intent);
}
@Override
protected void onBackendConnected() {
if (handleIntent(getIntent())) {
updateView();
} else if (mPendingUri != null) {
verifyWithUri(mPendingUri);
finish();
mPendingUri = null;
}
setIntent(null);
}
protected void updateView() {
if (this.mConversation != null && this.mConversation.hasValidOtrSession()) {
final ActionBar actionBar = getSupportActionBar();
this.mVerificationExplain.setText(R.string.no_otr_session_found);
invalidateOptionsMenu();
switch (this.mode) {
case MODE_ASK_QUESTION:
if (actionBar != null) {
actionBar.setTitle(R.string.ask_question);
}
this.updateViewAskQuestion();
break;
case MODE_ANSWER_QUESTION:
if (actionBar != null) {
actionBar.setTitle(R.string.smp_requested);
}
this.updateViewAnswerQuestion();
break;
case MODE_MANUAL_VERIFICATION:
default:
if (actionBar != null) {
actionBar.setTitle(R.string.manually_verify);
}
this.updateViewManualVerification();
break;
}
} else {
this.mManualVerificationArea.setVisibility(View.GONE);
this.mSmpVerificationArea.setVisibility(View.GONE);
}
}
protected void updateViewManualVerification() {
this.mVerificationExplain.setText(R.string.manual_verification_explanation);
this.mManualVerificationArea.setVisibility(View.VISIBLE);
this.mSmpVerificationArea.setVisibility(View.GONE);
this.mYourFingerprint.setText(CryptoHelper.prettifyFingerprint(this.mAccount.getOtrFingerprint()));
this.mRemoteFingerprint.setText(CryptoHelper.prettifyFingerprint(this.mConversation.getOtrFingerprint()));
if (this.mConversation.isOtrFingerprintVerified()) {
deactivateButton(this.mRightButton, R.string.verified);
activateButton(this.mLeftButton, R.string.cancel, this.mFinishListener);
} else {
activateButton(this.mLeftButton, R.string.cancel, this.mFinishListener);
activateButton(this.mRightButton, R.string.verify, new View.OnClickListener() {
@Override
public void onClick(View view) {
showManuallyVerifyDialog();
}
});
}
}
protected void updateViewAskQuestion() {
this.mManualVerificationArea.setVisibility(View.GONE);
this.mSmpVerificationArea.setVisibility(View.VISIBLE);
this.mVerificationExplain.setText(R.string.smp_explain_question);
final int smpStatus = this.mConversation.smp().status;
switch (smpStatus) {
case Conversation.Smp.STATUS_WE_REQUESTED:
this.mStatusMessage.setVisibility(View.GONE);
this.mSharedSecretHintEditable.setVisibility(View.VISIBLE);
this.mSharedSecretSecret.setVisibility(View.VISIBLE);
this.mSharedSecretHintEditable.setText(this.mConversation.smp().hint);
this.mSharedSecretSecret.setText(this.mConversation.smp().secret);
this.activateButton(this.mLeftButton, R.string.cancel, this.mCancelSharedSecretListener);
this.deactivateButton(this.mRightButton, R.string.in_progress);
break;
case Conversation.Smp.STATUS_FAILED:
this.mStatusMessage.setVisibility(View.GONE);
this.mSharedSecretHintEditable.setVisibility(View.VISIBLE);
this.mSharedSecretSecret.setVisibility(View.VISIBLE);
this.mSharedSecretSecret.requestFocus();
this.mSharedSecretSecret.setError(getString(R.string.secrets_do_not_match));
this.deactivateButton(this.mLeftButton, R.string.cancel);
this.activateButton(this.mRightButton, R.string.try_again, this.mRetrySharedSecretListener);
break;
case Conversation.Smp.STATUS_VERIFIED:
this.mSharedSecretHintEditable.setText("");
this.mSharedSecretHintEditable.setVisibility(View.GONE);
this.mSharedSecretSecret.setText("");
this.mSharedSecretSecret.setVisibility(View.GONE);
this.mStatusMessage.setVisibility(View.VISIBLE);
this.deactivateButton(this.mLeftButton, R.string.cancel);
this.activateButton(this.mRightButton, R.string.finish, this.mFinishListener);
break;
default:
this.mStatusMessage.setVisibility(View.GONE);
this.mSharedSecretHintEditable.setVisibility(View.VISIBLE);
this.mSharedSecretSecret.setVisibility(View.VISIBLE);
this.activateButton(this.mLeftButton, R.string.cancel, this.mFinishListener);
this.activateButton(this.mRightButton, R.string.ask_question, this.mCreateSharedSecretListener);
break;
}
}
protected void updateViewAnswerQuestion() {
this.mManualVerificationArea.setVisibility(View.GONE);
this.mSmpVerificationArea.setVisibility(View.VISIBLE);
this.mVerificationExplain.setText(R.string.smp_explain_answer);
this.mSharedSecretHintEditable.setVisibility(View.GONE);
this.mSharedSecretHint.setVisibility(View.VISIBLE);
this.deactivateButton(this.mLeftButton, R.string.cancel);
final int smpStatus = this.mConversation.smp().status;
switch (smpStatus) {
case Conversation.Smp.STATUS_CONTACT_REQUESTED:
this.mStatusMessage.setVisibility(View.GONE);
this.mSharedSecretHint.setText(this.mConversation.smp().hint);
this.activateButton(this.mRightButton, R.string.respond, this.mRespondSharedSecretListener);
break;
case Conversation.Smp.STATUS_VERIFIED:
this.mSharedSecretHintEditable.setText("");
this.mSharedSecretHintEditable.setVisibility(View.GONE);
this.mSharedSecretHint.setVisibility(View.GONE);
this.mSharedSecretSecret.setText("");
this.mSharedSecretSecret.setVisibility(View.GONE);
this.mStatusMessage.setVisibility(View.VISIBLE);
this.activateButton(this.mRightButton, R.string.finish, this.mFinishListener);
break;
case Conversation.Smp.STATUS_FAILED:
default:
this.mSharedSecretSecret.requestFocus();
this.mSharedSecretSecret.setError(getString(R.string.secrets_do_not_match));
this.activateButton(this.mRightButton, R.string.finish, this.mFinishListener);
break;
}
}
protected void activateButton(Button button, int text, View.OnClickListener listener) {
button.setEnabled(true);
button.setText(text);
button.setOnClickListener(listener);
}
protected void deactivateButton(Button button, int text) {
button.setEnabled(false);
button.setText(text);
button.setOnClickListener(null);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_verify_otr);
this.mRemoteFingerprint = findViewById(R.id.remote_fingerprint);
this.mYourFingerprint = findViewById(R.id.your_fingerprint);
this.mLeftButton = findViewById(R.id.left_button);
this.mRightButton = findViewById(R.id.right_button);
this.mVerificationExplain = findViewById(R.id.verification_explanation);
this.mStatusMessage = findViewById(R.id.status_message);
this.mSharedSecretSecret = findViewById(R.id.shared_secret_secret);
this.mSharedSecretHintEditable = findViewById(R.id.shared_secret_hint_editable);
this.mSharedSecretHint = findViewById(R.id.shared_secret_hint);
this.mManualVerificationArea = findViewById(R.id.manual_verification_area);
this.mSmpVerificationArea = findViewById(R.id.smp_verification_area);
}
@Override
public boolean onCreateOptionsMenu(final Menu menu) {
super.onCreateOptionsMenu(menu);
getMenuInflater().inflate(R.menu.verify_otr, menu);
return true;
}
private void showManuallyVerifyDialog() {
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.manually_verify);
builder.setMessage(R.string.are_you_sure_verify_fingerprint);
builder.setNegativeButton(R.string.cancel, null);
builder.setPositiveButton(R.string.verify, mVerifyFingerprintListener);
builder.create().show();
}
@Override
protected String getShareableUri() {
if (mAccount != null) {
return mAccount.getShareableUri();
} else {
return "";
}
}
public void onConversationUpdate() {
refreshUi();
}
@Override
protected void refreshUiReal() {
updateView();
}
}

View file

@ -56,6 +56,8 @@ import androidx.databinding.DataBindingUtil;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import net.java.otr4j.session.SessionID;
import java.io.IOException; import java.io.IOException;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.util.ArrayList; import java.util.ArrayList;
@ -446,7 +448,18 @@ public abstract class XmppActivity extends ActionBarActivity {
public void selectPresence(final Conversation conversation, final PresenceSelector.OnPresenceSelected listener) { public void selectPresence(final Conversation conversation, final PresenceSelector.OnPresenceSelected listener) {
final Contact contact = conversation.getContact(); final Contact contact = conversation.getContact();
if (contact.showInRoster() || contact.isSelf()) {
if (conversation.hasValidOtrSession()) {
SessionID id = conversation.getOtrSession().getSessionID();
Jid jid;
try {
jid = Jid.of(id.getAccountID() + "/" + id.getUserID());
} catch (IllegalArgumentException e) {
jid = null;
}
conversation.setNextCounterpart(jid);
listener.onPresenceSelected();
} else if (contact.showInRoster() || contact.isSelf()) {
final Presences presences = contact.getPresences(); final Presences presences = contact.getPresences();
if (presences.size() == 0) { if (presences.size() == 0) {
if (contact.isSelf()) { if (contact.isSelf()) {

View file

@ -9,6 +9,11 @@ import android.widget.ArrayAdapter;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.databinding.DataBindingUtil; import androidx.databinding.DataBindingUtil;
import com.kizitonwose.colorpreference.ColorDialog;
import com.kizitonwose.colorpreference.ColorPreference;
import com.kizitonwose.colorpreference.ColorShape;
import com.kizitonwose.colorpreference.ColorUtils;
import java.util.List; import java.util.List;
import eu.siacs.conversations.Config; import eu.siacs.conversations.Config;
@ -19,22 +24,29 @@ import eu.siacs.conversations.ui.XmppActivity;
import eu.siacs.conversations.ui.util.AvatarWorkerTask; import eu.siacs.conversations.ui.util.AvatarWorkerTask;
import eu.siacs.conversations.ui.util.StyledAttributes; import eu.siacs.conversations.ui.util.StyledAttributes;
import eu.siacs.conversations.utils.UIHelper; import eu.siacs.conversations.utils.UIHelper;
import eu.siacs.conversations.xmpp.Jid;
public class AccountAdapter extends ArrayAdapter<Account> { public class AccountAdapter extends ArrayAdapter<Account> {
private final XmppActivity activity; private final XmppActivity activity;
private final boolean showStateButton; private final boolean showStateButton;
private final boolean showColorSelector;
public ColorSelectorListener colorSelectorListener = null;
public AccountAdapter(XmppActivity activity, List<Account> objects, boolean showStateButton) { public AccountAdapter(XmppActivity activity, List<Account> objects, boolean showStateButton) {
super(activity, 0, objects); super(activity, 0, objects);
this.activity = activity; this.activity = activity;
this.showStateButton = showStateButton; this.showStateButton = showStateButton;
this.showColorSelector = false;
} }
public AccountAdapter(XmppActivity activity, List<Account> objects) { public AccountAdapter(XmppActivity activity, List<Account> objects, ColorSelectorListener listener) {
super(activity, 0, objects); super(activity, 0, objects);
this.activity = activity; this.activity = activity;
this.showStateButton = true; this.showStateButton = true;
this.showColorSelector = true;
colorSelectorListener = listener;
} }
@Override @Override
@ -77,17 +89,27 @@ public class AccountAdapter extends ArrayAdapter<Account> {
} else { } else {
viewHolder.binding.tglAccountStatus.setVisibility(View.GONE); viewHolder.binding.tglAccountStatus.setVisibility(View.GONE);
} }
viewHolder.binding.tglAccountStatus.setOnCheckedChangeListener((compoundButton, b) -> { viewHolder.binding.tglAccountStatus.setOnCheckedChangeListener((compoundButton, b) -> {
if (b == isDisabled && activity instanceof OnTglAccountState) { if (b == isDisabled && activity instanceof OnTglAccountState) {
((OnTglAccountState) activity).onClickTglAccountState(account, b); ((OnTglAccountState) activity).onClickTglAccountState(account, b);
} }
}); });
if (activity.xmppConnectionService.getAccounts().size() > 1) { if (this.showColorSelector && activity.xmppConnectionService.getAccounts().size() > 1 &&
viewHolder.binding.accountIndicator.setBackgroundColor(UIHelper.getColorForName(account.getJid().asBareJid().getEscapedLocal())); activity.xmppConnectionService.getPreferences().getBoolean("show_account_indicator", activity.getResources().getBoolean(R.bool.show_account_indicator))) {
} else { int color = UIHelper.getAccountColor(activity, account.getJid());
viewHolder.binding.accountIndicator.setBackgroundColor(Color.TRANSPARENT); viewHolder.binding.colorView.setVisibility(View.VISIBLE);
ColorUtils.setColorViewValue(viewHolder.binding.colorView, color, false, ColorShape.CIRCLE);
viewHolder.binding.colorView.setOnClickListener(v -> {
if (colorSelectorListener != null) {
colorSelectorListener.onColorPickerRequested(account.getJid(), color);
} }
});
} else {
viewHolder.binding.colorView.setVisibility(View.GONE);
}
return view; return view;
} }
@ -106,4 +128,7 @@ public class AccountAdapter extends ArrayAdapter<Account> {
void onClickTglAccountState(Account account, boolean state); void onClickTglAccountState(Account account, boolean state);
} }
public interface ColorSelectorListener {
void onColorPickerRequested(Jid accountJid, int currentColor);
}
} }

View file

@ -338,8 +338,12 @@ public class ConversationAdapter
} }
CharSequence name = conversation.getName(); CharSequence name = conversation.getName();
if (conversation.getNextCounterpart() != null) { if (conversation.getNextCounterpart() != null && conversation.hasPermanentCounterpart()) {
if (conversation.getMode() == Conversational.MODE_MULTI) {
name = viewHolder.binding.getRoot().getResources().getString(R.string.muc_private_conversation_title, conversation.getNextCounterpart().getResource(), conversation.getName()); name = viewHolder.binding.getRoot().getResources().getString(R.string.muc_private_conversation_title, conversation.getNextCounterpart().getResource(), conversation.getName());
} else {
name = viewHolder.binding.getRoot().getResources().getString(R.string.secret_chat_title, conversation.getName(), conversation.getNextCounterpart().getResource());
}
} }
if (conversation.withSelf()) { if (conversation.withSelf()) {
@ -386,6 +390,10 @@ public class ConversationAdapter
int drId = activity.getThemeResource(R.attr.ic_group_16, R.drawable.ic_group_selected_black_16); int drId = activity.getThemeResource(R.attr.ic_group_16, R.drawable.ic_group_selected_black_16);
Drawable dr = AppCompatResources.getDrawable(activity, drId); Drawable dr = AppCompatResources.getDrawable(activity, drId);
viewHolder.binding.conversationName.setCompoundDrawablesRelativeWithIntrinsicBounds(null, null, dr, null); viewHolder.binding.conversationName.setCompoundDrawablesRelativeWithIntrinsicBounds(null, null, dr, null);
} else if (conversation.getMode() == Conversation.MODE_SINGLE && conversation.hasPermanentCounterpart()) {
int drId = activity.getThemeResource(R.attr.ic_secret_chat_16, R.drawable.ic_secret_chat_16dp_black);
Drawable dr = AppCompatResources.getDrawable(activity, drId);
viewHolder.binding.conversationName.setCompoundDrawablesRelativeWithIntrinsicBounds(null, null, dr, null);
} else { } else {
viewHolder.binding.conversationName.setCompoundDrawablesRelativeWithIntrinsicBounds(null, null, null, null); viewHolder.binding.conversationName.setCompoundDrawablesRelativeWithIntrinsicBounds(null, null, null, null);
} }
@ -393,7 +401,7 @@ public class ConversationAdapter
Contact contact = conversation.getContact(); Contact contact = conversation.getContact();
if (contact != null) { if (contact != null) {
viewHolder.binding.presenceIndicator.setStatus(contact.getShownStatus()); viewHolder.binding.presenceIndicator.setStatus(contact);
} else { } else {
viewHolder.binding.presenceIndicator.setStatus(null); viewHolder.binding.presenceIndicator.setStatus(null);
} }
@ -401,7 +409,7 @@ public class ConversationAdapter
Account account = conversation.getAccount(); Account account = conversation.getAccount();
if (account != null && activity.xmppConnectionService.getAccounts().size() > 1) { if (account != null && activity.xmppConnectionService.getAccounts().size() > 1) {
viewHolder.binding.accountIndicator.setBackgroundColor(UIHelper.getColorForName(account.getJid().asBareJid().getEscapedLocal())); viewHolder.binding.accountIndicator.setBackgroundColor(UIHelper.getAccountColor(activity, account.getJid()));
} else { } else {
viewHolder.binding.accountIndicator.setBackgroundColor(Color.TRANSPARENT); viewHolder.binding.accountIndicator.setBackgroundColor(Color.TRANSPARENT);
} }

View file

@ -94,7 +94,7 @@ public class ListItemAdapter extends ArrayAdapter<ListItem> {
AvatarWorkerTask.loadAvatar(item, viewHolder.avatar, R.dimen.avatar); AvatarWorkerTask.loadAvatar(item, viewHolder.avatar, R.dimen.avatar);
if (item instanceof Contact) { if (item instanceof Contact) {
viewHolder.presenceIndicator.setStatus(((Contact) item).getShownStatus()); viewHolder.presenceIndicator.setStatus(((Contact) item));
} else { } else {
viewHolder.presenceIndicator.setStatus(null); viewHolder.presenceIndicator.setStatus(null);
} }
@ -108,7 +108,7 @@ public class ListItemAdapter extends ArrayAdapter<ListItem> {
} }
if (account != null && activity.xmppConnectionService.getAccounts().size() > 1) { if (account != null && activity.xmppConnectionService.getAccounts().size() > 1) {
viewHolder.accountIndicator.setBackgroundColor(UIHelper.getColorForName(account.getJid().asBareJid().getEscapedLocal())); viewHolder.accountIndicator.setBackgroundColor(UIHelper.getAccountColor(activity, account.getJid()));
} else { } else {
viewHolder.accountIndicator.setBackgroundColor(Color.TRANSPARENT); viewHolder.accountIndicator.setBackgroundColor(Color.TRANSPARENT);
} }

View file

@ -91,7 +91,7 @@ public class UserAdapter extends ListAdapter<MucOptions.User, UserAdapter.ViewHo
} else { } else {
viewHolder.binding.contactJid.setText(ConferenceDetailsActivity.getStatus(viewHolder.binding.getRoot().getContext(), user, advancedMode)); viewHolder.binding.contactJid.setText(ConferenceDetailsActivity.getStatus(viewHolder.binding.getRoot().getContext(), user, advancedMode));
} }
viewHolder.binding.presenceIndicator.setStatus(contact.getShownStatus()); viewHolder.binding.presenceIndicator.setStatus(contact);
} else { } else {
viewHolder.binding.contactDisplayName.setText(name == null ? "" : name); viewHolder.binding.contactDisplayName.setText(name == null ? "" : name);
viewHolder.binding.contactJid.setText(ConferenceDetailsActivity.getStatus(viewHolder.binding.getRoot().getContext(), user, advancedMode)); viewHolder.binding.contactJid.setText(ConferenceDetailsActivity.getStatus(viewHolder.binding.getRoot().getContext(), user, advancedMode));

View file

@ -38,7 +38,7 @@ public class UserPreviewAdapter extends ListAdapter<MucOptions.User, UserPreview
AvatarWorkerTask.loadAvatar(user, viewHolder.binding.avatar, R.dimen.media_size); AvatarWorkerTask.loadAvatar(user, viewHolder.binding.avatar, R.dimen.media_size);
Contact contact = user.getContact(); Contact contact = user.getContact();
if (contact != null) { if (contact != null) {
viewHolder.binding.presenceIndicator.setStatus(user.getContact().getShownStatus()); viewHolder.binding.presenceIndicator.setStatus(user.getContact());
} else { } else {
viewHolder.binding.presenceIndicator.setStatus(null); viewHolder.binding.presenceIndicator.setStatus(null);
} }

View file

@ -0,0 +1,37 @@
package eu.siacs.conversations.ui.widget
import android.content.Context
import android.util.AttributeSet
import android.view.View
import eu.siacs.conversations.R
import eu.siacs.conversations.ui.XmppActivity
class AccountIndicator : View {
constructor(context: Context?) : super(context)
constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs)
constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(
context,
attrs,
defStyleAttr
)
constructor(
context: Context?,
attrs: AttributeSet?,
defStyleAttr: Int,
defStyleRes: Int
) : super(context, attrs, defStyleAttr, defStyleRes)
override fun onAttachedToWindow() {
super.onAttachedToWindow()
val enabled = (context as? XmppActivity)
?.xmppConnectionService?.preferences
?.getBoolean("show_account_indicator", context.resources.getBoolean(R.bool.show_account_indicator)) ?: false
visibility = if (enabled) {
VISIBLE
} else {
INVISIBLE
}
}
}

View file

@ -8,9 +8,13 @@ import android.graphics.Paint
import android.util.AttributeSet import android.util.AttributeSet
import android.view.View import android.view.View
import android.view.ViewOutlineProvider import android.view.ViewOutlineProvider
import eu.siacs.conversations.R
import eu.siacs.conversations.entities.Contact
import eu.siacs.conversations.entities.Presence import eu.siacs.conversations.entities.Presence
import eu.siacs.conversations.ui.XmppActivity
import eu.siacs.conversations.ui.util.StyledAttributes import eu.siacs.conversations.ui.util.StyledAttributes
import eu.siacs.conversations.utils.UIHelper import eu.siacs.conversations.utils.UIHelper
import eu.siacs.conversations.xml.Namespace
class PresenceIndicator : View { class PresenceIndicator : View {
private var paint: Paint = Paint().also { private var paint: Paint = Paint().also {
@ -19,13 +23,9 @@ class PresenceIndicator : View {
it.strokeWidth = 1 * Resources.getSystem().displayMetrics.density it.strokeWidth = 1 * Resources.getSystem().displayMetrics.density
} }
var status: Presence.Status? = null private var status: Presence.Status? = null
set(value) {
if (field != value) { private var enabled = false
field = value
invalidate()
}
}
constructor(context: Context?) : super(context) constructor(context: Context?) : super(context)
constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs) constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs)
@ -51,7 +51,28 @@ class PresenceIndicator : View {
} }
} }
fun setStatus(contact: Contact?) {
val status = contact?.shownStatus?.takeIf {
contact.account?.isOnlineAndConnected == true
}
if (status != this.status) {
this.status = status
invalidate()
}
}
override fun onAttachedToWindow() {
super.onAttachedToWindow()
enabled = (context as? XmppActivity)
?.xmppConnectionService?.preferences
?.getBoolean("show_contact_status", context.resources.getBoolean(R.bool.show_contact_status)) ?: false
}
override fun onDraw(canvas: Canvas) { override fun onDraw(canvas: Canvas) {
if (!enabled) {
return
}
super.onDraw(canvas) super.onDraw(canvas)
val color: Int? = UIHelper.getColorForStatus(status); val color: Int? = UIHelper.getColorForStatus(status);

View file

@ -41,6 +41,7 @@ public final class CryptoHelper {
private static final int PW_LENGTH = 12; private static final int PW_LENGTH = 12;
private static final char[] VOWELS = "aeiou".toCharArray(); private static final char[] VOWELS = "aeiou".toCharArray();
private static final char[] CONSONANTS = "bcfghjklmnpqrstvwxyz".toCharArray(); private static final char[] CONSONANTS = "bcfghjklmnpqrstvwxyz".toCharArray();
public static final String FILETRANSFER = "?FILETRANSFERv1:";
private final static char[] hexArray = "0123456789abcdef".toCharArray(); private final static char[] hexArray = "0123456789abcdef".toCharArray();
public static String bytesToHex(byte[] bytes) { public static String bytesToHex(byte[] bytes) {

View file

@ -1,6 +1,7 @@
package eu.siacs.conversations.utils; package eu.siacs.conversations.utils;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences;
import android.text.SpannableStringBuilder; import android.text.SpannableStringBuilder;
import android.text.format.DateFormat; import android.text.format.DateFormat;
import android.text.format.DateUtils; import android.text.format.DateUtils;
@ -204,33 +205,84 @@ public class UIHelper {
.get(Calendar.DAY_OF_YEAR); .get(Calendar.DAY_OF_YEAR);
} }
public static String lastseen(Context context, boolean active, long time) { public static String lastseen(Context context, boolean active, long time, boolean shortText) {
long difference = (System.currentTimeMillis() - time) / 1000; long difference = (System.currentTimeMillis() - time) / 1000;
if (active) { if (active) {
if (shortText) {
return context.getString(R.string.online_right_now_short);
} else {
return context.getString(R.string.online_right_now); return context.getString(R.string.online_right_now);
}
} else if (difference < 60) { } else if (difference < 60) {
if (shortText) {
return context.getString(R.string.last_seen_now_short);
} else {
return context.getString(R.string.last_seen_now); return context.getString(R.string.last_seen_now);
}
} else if (difference < 60 * 2) { } else if (difference < 60 * 2) {
if (shortText) {
return context.getString(R.string.last_seen_min_short);
} else {
return context.getString(R.string.last_seen_min); return context.getString(R.string.last_seen_min);
}
} else if (difference < 60 * 60) { } else if (difference < 60 * 60) {
if (shortText) {
return context.getString(R.string.last_seen_mins_short, Math.round(difference / 60.0));
} else {
return context.getString(R.string.last_seen_mins, Math.round(difference / 60.0)); return context.getString(R.string.last_seen_mins, Math.round(difference / 60.0));
}
} else if (difference < 60 * 60 * 2) { } else if (difference < 60 * 60 * 2) {
if (shortText) {
return context.getString(R.string.last_seen_hour_short);
} else {
return context.getString(R.string.last_seen_hour); return context.getString(R.string.last_seen_hour);
}
} else if (difference < 60 * 60 * 24) { } else if (difference < 60 * 60 * 24) {
if (shortText) {
return context.getString(R.string.last_seen_hours_short,
Math.round(difference / (60.0 * 60.0)));
} else {
return context.getString(R.string.last_seen_hours, return context.getString(R.string.last_seen_hours,
Math.round(difference / (60.0 * 60.0))); Math.round(difference / (60.0 * 60.0)));
}
} else if (difference < 60 * 60 * 48) { } else if (difference < 60 * 60 * 48) {
if (shortText) {
return context.getString(R.string.last_seen_day_short);
} else {
return context.getString(R.string.last_seen_day); return context.getString(R.string.last_seen_day);
}
} else {
if (shortText) {
return context.getString(R.string.last_seen_days_short,
Math.round(difference / (60.0 * 60.0 * 24.0)));
} else { } else {
return context.getString(R.string.last_seen_days, return context.getString(R.string.last_seen_days,
Math.round(difference / (60.0 * 60.0 * 24.0))); Math.round(difference / (60.0 * 60.0 * 24.0)));
} }
} }
}
public static int getColorForName(String name) { public static int getColorForName(String name) {
return getColorForName(name, false); return getColorForName(name, false);
} }
public static int getAccountColor(Context context, Jid accountJid) {
SharedPreferences prefs = context.getSharedPreferences("accountColorsPrefs", Context.MODE_PRIVATE);
String name = accountJid.asBareJid().toEscapedString();
int overrideColor = prefs.getInt(name, -1);
if (overrideColor != -1) {
return overrideColor;
} else {
return getColorForName(name);
}
}
public static void overrideAccountColor(Context context, String accountName, int color) {
SharedPreferences prefs = context.getSharedPreferences("accountColorsPrefs", Context.MODE_PRIVATE);
prefs.edit().putInt(accountName, color).apply();
}
public static int getColorForName(String name, boolean safe) { public static int getColorForName(String name, boolean safe) {
if (Config.XEP_0392) { if (Config.XEP_0392) {
return XEP0392Helper.rgbFromNick(name); return XEP0392Helper.rgbFromNick(name);
@ -292,6 +344,8 @@ public class UIHelper {
return new Pair<>(context.getString(R.string.file_deleted), true); return new Pair<>(context.getString(R.string.file_deleted), true);
} else if (message.getEncryption() == Message.ENCRYPTION_PGP) { } else if (message.getEncryption() == Message.ENCRYPTION_PGP) {
return new Pair<>(context.getString(R.string.pgp_message), true); return new Pair<>(context.getString(R.string.pgp_message), true);
} else if (message.getEncryption() == Message.ENCRYPTION_OTR) {
return new Pair<>(context.getString(R.string.otr_message), true);
} else if (message.getEncryption() == Message.ENCRYPTION_DECRYPTION_FAILED) { } else if (message.getEncryption() == Message.ENCRYPTION_DECRYPTION_FAILED) {
return new Pair<>(context.getString(R.string.decryption_failed), true); return new Pair<>(context.getString(R.string.decryption_failed), true);
} else if (message.getEncryption() == Message.ENCRYPTION_AXOLOTL_NOT_FOR_THIS_DEVICE) { } else if (message.getEncryption() == Message.ENCRYPTION_AXOLOTL_NOT_FOR_THIS_DEVICE) {
@ -557,6 +611,8 @@ public class UIHelper {
} else { } else {
return context.getString(R.string.send_message_to_x, conversation.getName()); return context.getString(R.string.send_message_to_x, conversation.getName());
} }
case Message.ENCRYPTION_OTR:
return context.getString(R.string.send_otr_message);
case Message.ENCRYPTION_AXOLOTL: case Message.ENCRYPTION_AXOLOTL:
AxolotlService axolotlService = conversation.getAccount().getAxolotlService(); AxolotlService axolotlService = conversation.getAccount().getAxolotlService();
if (axolotlService != null && axolotlService.trustedSessionVerified(conversation)) { if (axolotlService != null && axolotlService.trustedSessionVerified(conversation)) {

View file

@ -29,6 +29,7 @@ public class XmppUri {
public static final String PARAMETER_PRE_AUTH = "preauth"; public static final String PARAMETER_PRE_AUTH = "preauth";
public static final String PARAMETER_IBR = "ibr"; public static final String PARAMETER_IBR = "ibr";
private static final String OMEMO_URI_PARAM = "omemo-sid-"; private static final String OMEMO_URI_PARAM = "omemo-sid-";
private static final String OTR_URI_PARAM = "otr-fingerprint";
protected Uri uri; protected Uri uri;
protected String jid; protected String jid;
private List<Fingerprint> fingerprints = new ArrayList<>(); private List<Fingerprint> fingerprints = new ArrayList<>();
@ -111,6 +112,8 @@ public class XmppUri {
if (type == XmppUri.FingerprintType.OMEMO) { if (type == XmppUri.FingerprintType.OMEMO) {
builder.append(XmppUri.OMEMO_URI_PARAM); builder.append(XmppUri.OMEMO_URI_PARAM);
builder.append(fingerprints.get(i).deviceId); builder.append(fingerprints.get(i).deviceId);
} else if (type == XmppUri.FingerprintType.OTR) {
builder.append(XmppUri.OTR_URI_PARAM);
} }
builder.append('='); builder.append('=');
builder.append(fingerprints.get(i).fingerprint); builder.append(fingerprints.get(i).fingerprint);
@ -241,7 +244,8 @@ public class XmppUri {
} }
public enum FingerprintType { public enum FingerprintType {
OMEMO OMEMO,
OTR
} }
public static class Fingerprint { public static class Fingerprint {
@ -249,6 +253,10 @@ public class XmppUri {
public final String fingerprint; public final String fingerprint;
final int deviceId; final int deviceId;
public Fingerprint(FingerprintType type, String fingerprint) {
this(type, fingerprint, 0);
}
public Fingerprint(FingerprintType type, String fingerprint, int deviceId) { public Fingerprint(FingerprintType type, String fingerprint, int deviceId) {
this.type = type; this.type = type;
this.fingerprint = fingerprint; this.fingerprint = fingerprint;

View file

@ -0,0 +1,17 @@
package eu.siacs.conversations.xmpp.jid;
import net.java.otr4j.session.SessionID;
import eu.siacs.conversations.xmpp.Jid;
public final class OtrJidHelper {
public static Jid fromSessionID(final SessionID id) throws IllegalArgumentException {
if (id.getUserID().isEmpty()) {
return Jid.of(id.getAccountID());
} else {
return Jid.of(id.getAccountID() + "/" + id.getUserID());
}
}
}

View file

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="16dp"
android:height="16dp"
android:viewportWidth="960"
android:viewportHeight="960">
<path
android:fillColor="#000000"
android:pathData="M263.72,864Q234,864 213,842.85Q192,821.7 192,792L192,408Q192,378.3 213.15,357.15Q234.3,336 264,336L288,336L288,240Q288,160.32 344.23,104.16Q400.45,48 480.23,48Q560,48 616,104.16Q672,160.32 672,240L672,336L696,336Q725.7,336 746.85,357.15Q768,378.3 768,408L768,792Q768,821.7 746.84,842.85Q725.68,864 695.96,864L263.72,864ZM264,792L696,792Q696,792 696,792Q696,792 696,792L696,408Q696,408 696,408Q696,408 696,408L264,408Q264,408 264,408Q264,408 264,408L264,792Q264,792 264,792Q264,792 264,792ZM480.21,672Q510,672 531,650.79Q552,629.58 552,599.79Q552,570 530.79,549Q509.58,528 479.79,528Q450,528 429,549.21Q408,570.42 408,600.21Q408,630 429.21,651Q450.42,672 480.21,672ZM360,336L600,336L600,240Q600,190 565,155Q530,120 480,120Q430,120 395,155Q360,190 360,240L360,336ZM264,792Q264,792 264,792Q264,792 264,792L264,408Q264,408 264,408Q264,408 264,408L264,408Q264,408 264,408Q264,408 264,408L264,792Q264,792 264,792Q264,792 264,792Z"/>
</vector>

View file

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="16dp"
android:height="16dp"
android:viewportWidth="960"
android:viewportHeight="960">
<path
android:fillColor="#FFFFFF"
android:pathData="M263.72,864Q234,864 213,842.85Q192,821.7 192,792L192,408Q192,378.3 213.15,357.15Q234.3,336 264,336L288,336L288,240Q288,160.32 344.23,104.16Q400.45,48 480.23,48Q560,48 616,104.16Q672,160.32 672,240L672,336L696,336Q725.7,336 746.85,357.15Q768,378.3 768,408L768,792Q768,821.7 746.84,842.85Q725.68,864 695.96,864L263.72,864ZM264,792L696,792Q696,792 696,792Q696,792 696,792L696,408Q696,408 696,408Q696,408 696,408L264,408Q264,408 264,408Q264,408 264,408L264,792Q264,792 264,792Q264,792 264,792ZM480.21,672Q510,672 531,650.79Q552,629.58 552,599.79Q552,570 530.79,549Q509.58,528 479.79,528Q450,528 429,549.21Q408,570.42 408,600.21Q408,630 429.21,651Q450.42,672 480.21,672ZM360,336L600,336L600,240Q600,190 565,155Q530,120 480,120Q430,120 395,155Q360,190 360,240L360,336ZM264,792Q264,792 264,792Q264,792 264,792L264,408Q264,408 264,408Q264,408 264,408L264,408Q264,408 264,408Q264,408 264,408L264,792Q264,792 264,792Q264,792 264,792Z"/>
</vector>

View file

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960">
<path
android:fillColor="#000000"
android:pathData="M160,760L160,680L560,680L560,760L160,760ZM160,600L160,520L800,520L800,600L160,600ZM160,440L160,360L800,360L800,440L160,440ZM160,280L160,200L800,200L800,280L160,280Z"/>
</vector>

View file

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960">
<path
android:fillColor="#ffffff"
android:pathData="M160,760L160,680L560,680L560,760L160,760ZM160,600L160,520L800,520L800,600L160,600ZM160,440L160,360L800,360L800,440L160,440ZM160,280L160,200L800,200L800,280L160,280Z"/>
</vector>

View file

@ -6,17 +6,10 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?selectableItemBackground" android:background="?selectableItemBackground"
android:clipToPadding="false"
android:paddingLeft="8dp" android:paddingLeft="8dp"
android:paddingBottom="8dp" android:paddingBottom="8dp"
android:paddingTop="8dp"> android:paddingTop="8dp">
<View
android:id="@+id/account_indicator"
android:layout_width="@dimen/account_indicator_width"
android:layout_marginStart="-4dp"
android:layout_height="48dp" />
<eu.siacs.conversations.ui.widget.AvatarView <eu.siacs.conversations.ui.widget.AvatarView
android:id="@+id/account_image" android:id="@+id/account_image"
android:layout_width="48dp" android:layout_width="48dp"
@ -31,8 +24,8 @@
android:layout_toEndOf="@+id/account_image" android:layout_toEndOf="@+id/account_image"
android:orientation="vertical" android:orientation="vertical"
android:paddingLeft="@dimen/avatar_item_distance" android:paddingLeft="@dimen/avatar_item_distance"
android:layout_toLeftOf="@+id/tgl_account_status" android:layout_toLeftOf="@+id/controls"
android:layout_toStartOf="@+id/tgl_account_status"> android:layout_toStartOf="@+id/controls">
<TextView <TextView
android:id="@+id/account_jid" android:id="@+id/account_jid"
@ -50,14 +43,31 @@
android:textAppearance="@style/TextAppearance.Conversations.Body2" /> android:textAppearance="@style/TextAppearance.Conversations.Body2" />
</LinearLayout> </LinearLayout>
<LinearLayout
android:id="@+id/controls"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical"
android:padding="16dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true">
<ImageView
android:id="@+id/color_view"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_gravity="center"
android:layout_marginEnd="12dp"
android:scaleType="fitXY" />
<androidx.appcompat.widget.SwitchCompat <androidx.appcompat.widget.SwitchCompat
android:id="@+id/tgl_account_status" android:id="@+id/tgl_account_status"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:padding="16dp"
android:focusable="false" /> android:focusable="false" />
</LinearLayout>
</RelativeLayout> </RelativeLayout>
</layout> </layout>

View file

@ -0,0 +1,148 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/color_background_tertiary">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@+id/button_bar">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="@dimen/activity_horizontal_margin"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_marginTop="@dimen/activity_vertical_margin"
android:layout_marginEnd="@dimen/activity_horizontal_margin"
android:layout_marginRight="@dimen/activity_horizontal_margin"
android:layout_marginBottom="@dimen/activity_vertical_margin"
android:orientation="vertical">
<TextView
android:id="@+id/verification_explanation"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<LinearLayout
android:id="@+id/manual_verification_area"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:orientation="vertical">
<TextView
android:id="@+id/your_fingerprint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="monospace"
android:textAppearance="@style/TextAppearance.Conversations.Body1"
android:typeface="monospace" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/your_fingerprint"
android:textAppearance="@style/TextAppearance.Conversations.Caption" />
<TextView
android:id="@+id/remote_fingerprint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:fontFamily="monospace"
android:textAppearance="@style/TextAppearance.Conversations.Body1"
android:typeface="monospace" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:text="@string/remote_fingerprint"
android:textAppearance="@style/TextAppearance.Conversations.Caption" />
</LinearLayout>
<LinearLayout
android:id="@+id/smp_verification_area"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="16dp"
android:orientation="vertical">
<TextView
android:id="@+id/status_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="@string/verified"
android:textAppearance="@style/TextAppearance.Conversations.Title"
android:textStyle="bold"
android:visibility="gone" />
<TextView
android:id="@+id/shared_secret_hint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:textAppearance="@style/TextAppearance.Conversations.Body1"
android:textStyle="bold"
android:visibility="gone" />
<eu.siacs.conversations.ui.widget.TextInputEditText
android:id="@+id/shared_secret_hint_editable"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:hint="@string/shared_secret_hint"
android:inputType="textAutoComplete"
android:textAppearance="@style/TextAppearance.Conversations.Body1"
android:textColorHint="?attr/colorAccent" />
<eu.siacs.conversations.ui.widget.TextInputEditText
android:id="@+id/shared_secret_secret"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:hint="@string/shared_secret_secret"
android:inputType="textPassword"
android:textAppearance="@style/TextAppearance.Conversations.Body1"
android:textColorHint="?attr/colorAccent" />
</LinearLayout>
</LinearLayout>
</ScrollView>
<LinearLayout
android:id="@+id/button_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true">
<Button
android:id="@+id/left_button"
style="@style/Widget.Conversations.Button.Borderless"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
<View
android:layout_width="1dp"
android:layout_height="fill_parent"
android:layout_marginTop="7dp"
android:layout_marginBottom="7dp"
android:background="?attr/color_background_primary" />
<Button
android:id="@+id/right_button"
style="@style/Widget.Conversations.Button.Borderless"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
</RelativeLayout>

View file

@ -9,7 +9,7 @@
android:clipToPadding="false" android:clipToPadding="false"
android:padding="@dimen/list_padding"> android:padding="@dimen/list_padding">
<View <eu.siacs.conversations.ui.widget.AccountIndicator
android:id="@+id/account_indicator" android:id="@+id/account_indicator"
android:layout_width="@dimen/account_indicator_width" android:layout_width="@dimen/account_indicator_width"
android:layout_marginStart="-4dp" android:layout_marginStart="-4dp"

View file

@ -20,7 +20,7 @@
android:clipToPadding="false" android:clipToPadding="false"
android:padding="8dp"> android:padding="8dp">
<View <eu.siacs.conversations.ui.widget.AccountIndicator
android:id="@+id/account_indicator" android:id="@+id/account_indicator"
android:layout_width="@dimen/account_indicator_width" android:layout_width="@dimen/account_indicator_width"
android:layout_marginStart="-4dp" android:layout_marginStart="-4dp"

View file

@ -54,7 +54,7 @@
<ImageView <ImageView
android:layout_width="24dp" android:layout_width="24dp"
android:layout_height="24dp" android:layout_height="24dp"
android:src="?attr/ic_pin" android:src="?attr/ic_subject"
android:layout_marginEnd="8dp" android:layout_marginEnd="8dp"
/> />

View file

@ -6,6 +6,8 @@
android:minHeight="?attr/actionBarSize" android:minHeight="?attr/actionBarSize"
android:elevation="@dimen/toolbar_elevation" android:elevation="@dimen/toolbar_elevation"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:titleTextAppearance="@style/ToolbarTitleAppearance"
app:subtitleTextAppearance="@style/ToolbarSubtitleAppearance"
app:popupTheme="?popupOverlayStyle" app:popupTheme="?popupOverlayStyle"
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" /> xmlns:app="http://schemas.android.com/apk/res-auto" />

View file

@ -121,6 +121,11 @@
android:orderInCategory="60" android:orderInCategory="60"
android:title="@string/action_end_conversation" android:title="@string/action_end_conversation"
app:showAsAction="never" /> app:showAsAction="never" />
<item
android:id="@+id/action_start_secret_chat"
android:orderInCategory="65"
android:title="@string/action_start_secret_chat"
app:showAsAction="never" />
<item <item
android:orderInCategory="70" android:orderInCategory="70"
android:title="@string/more_options"> android:title="@string/more_options">

View file

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/ask_question"
android:title="@string/ask_question" />
<item
android:id="@+id/manual_verification"
android:title="@string/manually_verify" />
<item
android:id="@+id/blind_trust"
android:title="@string/otr_blind_trust" />
</menu>

View file

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/action_show_qr_code"
android:title="@string/show_qr_code"
app:showAsAction="never" />
<item
android:id="@+id/action_settings"
android:orderInCategory="100"
app:showAsAction="never"
android:title="@string/action_settings" />
</menu>

View file

@ -1091,4 +1091,62 @@
<string name="pref_input_field">Поле ввода</string> <string name="pref_input_field">Поле ввода</string>
<string name="pref_show_navigation_bar">Показать панель навигации</string> <string name="pref_show_navigation_bar">Показать панель навигации</string>
<string name="pref_show_navigation_bar_summary">Использовать альтернативный способ навигации с помощью панели навигации в нижней части экрана</string> <string name="pref_show_navigation_bar_summary">Использовать альтернативный способ навигации с помощью панели навигации в нижней части экрана</string>
<string name="basic_editor">Простой редактор</string>
<string name="pref_noisy_notifications_throttling_summary">Заглушить звук и вибрацию для уведомлений, полученных из определённого разговора в течение короткого промежутка времени</string>
<string name="retract_message">Отозвать сообщение</string>
<string name="save_to_downloads_success">Файл сохранён в Загрузки</string>
<string name="action_execute">Поехали!</string>
<string name="otr_message">Сообщение из тайной беседы</string>
<string name="pref_show_contact_presence">Доступность контакта</string>
<string name="pref_show_contact_presence_details">Отображать доступность контакта возле аватара</string>
<string name="pref_show_account_indicator">Индикатор учётной записи</string>
<string name="pref_show_account_indicator_details">Отмечать разговоры разными цветами при использовании нескольких учётных записей</string>
<string name="action_start_secret_chat">Начать тайную беседу</string>
<string name="secret_chat_title">%1$s (Тайная беседа / %2$s)</string>
<string name="secret_chat_title_no_resource">%1$s (Тайная беседа)</string>
<plurals name="x_participants">
<item quantity="one">%1$d участник</item>
<item quantity="few">%1$d участника</item>
<item quantity="many">%1$d участников</item>
<item quantity="other">%1$d участников</item>
</plurals>
<string name="online_right_now_short">онлайн</string>
<string name="last_seen_now_short">только что</string>
<string name="last_seen_min_short">одну минуту назад</string>
<string name="last_seen_mins_short">%d мин. назад</string>
<string name="last_seen_hour_short">один час назад</string>
<string name="last_seen_hours_short">%d час. назад</string>
<string name="last_seen_day_short">один день назад</string>
<string name="last_seen_days_short">%d дн. назад</string>
<string name="send_otr_message">Написать сообщение…</string>
<string name="unknown_otr_fingerprint">Неизвестный OTR-отпечаток</string>
<string name="otr_fingerprint">Отпечаток OTR</string>
<string name="otr_fingerprint_selected_message">OTR-отпечаток сообщения</string>
<string name="toast_message_otr_fingerprint">Отпечаток OTR скопирован в буфер обмена!</string>
<string name="verify_otr">Проверить OTR</string>
<string name="no_otr_session_found">Не найдена валидная OTR-сессия!</string>
<string name="are_you_sure_verify_fingerprint">Вы точно хотите проверить OTR-отпечаток вашего контакта?</string>
<string name="copy_otr_clipboard_description">Скопировать OTR-отпечаток в буфер обмена</string>
<string name="otr_session_not_started">Отправьте сообщение, чтобы начать шифрованную беседу</string>
<string name="verified">Проверка пройдена!</string>
<string name="smp_requested">Контакт запросил SMP-верификацию</string>
<string name="smp_explain_question">Если вы и ваш контакт знаете общий секрет, который больше никто не знает (например, шутку для своих или просто что вы ели при последней встрече), вы можете использовать этот секрет для проверки отпечатков друг друга.\n\nВы предоставляете подсказку или вопрос вашему контакту, который должен прислать чувствительный к регистру ответ.</string>
<string name="smp_explain_answer">Ваш контакт хочет проверить ваш отпечаток путём запроса общего секрета. Ваш контакт предоставил следующую подсказку или вопрос к данному секрету.</string>
<string name="shared_secret_hint_should_not_be_empty">Ваша подсказка не должна быть пуста</string>
<string name="shared_secret_can_not_be_empty">Ваш общий секрет не может быть пуст</string>
<string name="manual_verification_explanation">Тщательно сверьте показанный ниже отпечаток с отпечатком вашего контакта.\nВы можете использовать любой доверенный канал связи, например, шифрованную электронную почту или звонок для обмена ими.</string>
<string name="could_not_verify_fingerprint">Проверка отпечатка не пройдена</string>
<string name="manually_verify">Проверить вручную</string>
<string name="otr_blind_trust">Слепое доверие</string>
<string name="secrets_do_not_match">Секреты не совпадают</string>
<string name="ask_question">Задать вопрос</string>
<string name="verify">Верифицировать</string>
<string name="in_progress">В процессе</string>
<string name="respond">Ответить</string>
<string name="failed">Неудача</string>
<string name="finish">Закончить</string>
<string name="your_fingerprint">Ваш отпечаток</string>
<string name="remote_fingerprint">Удалённый отпечаток</string>
<string name="shared_secret_hint">Подсказка или вопрос</string>
<string name="shared_secret_secret">Общий секрет</string>
</resources> </resources>

View file

@ -1155,4 +1155,57 @@
<string name="chats">Чати</string> <string name="chats">Чати</string>
<string name="pref_appearance">Вигляд</string> <string name="pref_appearance">Вигляд</string>
<string name="avater_shape_oval">Овал</string> <string name="avater_shape_oval">Овал</string>
<string name="otr_message">Повідомлення з таємної бесіди</string>
<string name="pref_show_contact_presence">Доступність контакта</string>
<string name="pref_show_contact_presence_details">Відображати доступність контакту біля аватару</string>
<string name="pref_show_account_indicator">Індикатор облікового запису</string>
<string name="pref_show_account_indicator_details">Відмічати розмови різними кольорами за використання кількох облікових записів</string>
<string name="action_start_secret_chat">Почати таємну бесіду</string>
<string name="secret_chat_title">%1$s (Таємна бесіда / %2$s)</string>
<string name="secret_chat_title_no_resource">%1$s (Таємна бесіда)</string>
<plurals name="x_participants">
<item quantity="one">%1$d учасник</item>
<item quantity="few">%1$d учасника</item>
<item quantity="many">%1$d учасників</item>
<item quantity="other">%1$d учасників</item>
</plurals>
<string name="online_right_now_short">онлайн</string>
<string name="last_seen_now_short">щойно</string>
<string name="last_seen_min_short">1 хв. тому</string>
<string name="last_seen_mins_short">%d хв. тому</string>
<string name="last_seen_hour_short">1 год. тому</string>
<string name="last_seen_hours_short">%d год. тому</string>
<string name="last_seen_day_short">1 дн. тому</string>
<string name="last_seen_days_short">%d дн. тому</string>
<string name="send_otr_message">Написати повідомлення…</string>
<string name="unknown_otr_fingerprint">Невідомий OTR-відбиток</string>
<string name="otr_fingerprint">Відбиток OTR</string>
<string name="otr_fingerprint_selected_message">OTR-відбиток повідомлення</string>
<string name="toast_message_otr_fingerprint">Відбиток OTR скопійовано до буфера обміну!</string>
<string name="verify_otr">Перевірити OTR</string>
<string name="no_otr_session_found">Не знайдено валідну OTR-сесію!</string>
<string name="are_you_sure_verify_fingerprint">Ви точно хочете перевірити OTR-відбиток вашого контакта?</string>
<string name="copy_otr_clipboard_description">Скопіювати OTR-відбиток до буфера обміну</string>
<string name="otr_session_not_started">Надішліть повідомлення, щоб почати шифровану бесіду</string>
<string name="verified">Перевірку пройдено!</string>
<string name="smp_requested">Контакт запитав SMP-верифікацію</string>
<string name="smp_explain_question">Якщо ви і ваш контакт знаєте спільний секрет, який більше ніхто не знає (приміром, жарт для своїх чи просто що ви їли за останньої зустрічі), ви можете використати цей секрет для перевірки відбитків одне одного.\n\nВи надаєте підказку чи питання вашому контакту, який має прислати чуттєву до регістру відповідь.</string>
<string name="smp_explain_answer">Ваш контакт хоче перевірити ваш відбиток шляхом запиту спільного секрета. Ваш контакт надав наступну підказку чи питання до даного секрету.</string>
<string name="shared_secret_hint_should_not_be_empty">Ваша підказка не має бути порожньою</string>
<string name="shared_secret_can_not_be_empty">Ваш спільний секрет не може бути порожнім</string>
<string name="manual_verification_explanation">Ретельно звірте показаний нижче відбиток із відбитком вашого контакта.\nВи можете використати будь-який довірений канал зв\'язку, приміром, шифровану електронну пошту чи дзвінок для обміну ними.</string>
<string name="could_not_verify_fingerprint">Перевірку відбитка не пройдено</string>
<string name="manually_verify">Перевірити вручну</string>
<string name="otr_blind_trust">Сліпа довіра</string>
<string name="secrets_do_not_match">Секрети не збігаються</string>
<string name="ask_question">Поставити питання</string>
<string name="verify">Верифікувати</string>
<string name="in_progress">В процесі</string>
<string name="respond">Відповісти</string>
<string name="failed">Невдача</string>
<string name="finish">Закінчити</string>
<string name="your_fingerprint">Ваш відбиток</string>
<string name="remote_fingerprint">Віддалений відбиток</string>
<string name="shared_secret_hint">Підказка чи питання</string>
<string name="shared_secret_secret">Спільний секрет</string>
</resources> </resources>

View file

@ -60,6 +60,7 @@
\n\nhttps://github.com/zxing/zxing\n(Apache License, Version 2.0) \n\nhttps://github.com/zxing/zxing\n(Apache License, Version 2.0)
\n\nhttps://github.com/osmdroid/osmdroid\n(Apache License, Version 2.0) \n\nhttps://github.com/osmdroid/osmdroid\n(Apache License, Version 2.0)
\n\nhttps://git.singpolyma.net/cheogram-android\n(GPLv3) \n\nhttps://git.singpolyma.net/cheogram-android\n(GPLv3)
\n\nhttps://github.com/jitsi/otr4j\n(LGPL-3.0)
\n\n\nMaps \n\n\nMaps
\n\nMaps by Open Street Map (https://www.openstreetmap.org). Copyright restrictions may apply. \n\nMaps by Open Street Map (https://www.openstreetmap.org). Copyright restrictions may apply.
</string> </string>

View file

@ -40,6 +40,7 @@
<attr name="ic_send_voice_offline" format="reference" /> <attr name="ic_send_voice_offline" format="reference" />
<attr name="ic_pin" format="reference" /> <attr name="ic_pin" format="reference" />
<attr name="ic_subject" format="reference" />
<attr name="ic_close" format="reference" /> <attr name="ic_close" format="reference" />
<attr name="ic_attach_camera" format="reference" /> <attr name="ic_attach_camera" format="reference" />
<attr name="ic_attach_videocam" format="reference" /> <attr name="ic_attach_videocam" format="reference" />
@ -133,6 +134,7 @@
<attr name="ic_group_unselected" format="reference" /> <attr name="ic_group_unselected" format="reference" />
<attr name="ic_group_selected" format="reference" /> <attr name="ic_group_selected" format="reference" />
<attr name="ic_group_16" format="reference" /> <attr name="ic_group_16" format="reference" />
<attr name="ic_secret_chat_16" format="reference" />
<attr name="dialog_horizontal_padding" format="dimension" /> <attr name="dialog_horizontal_padding" format="dimension" />
<attr name="dialog_vertical_padding" format="dimension" /> <attr name="dialog_vertical_padding" format="dimension" />

View file

@ -55,4 +55,6 @@
<bool name="always_full_timestamps">false</bool> <bool name="always_full_timestamps">false</bool>
<bool name="skip_image_editor_screen">false</bool> <bool name="skip_image_editor_screen">false</bool>
<string name="avatar_shape">rounded_square</string> <string name="avatar_shape">rounded_square</string>
<bool name="show_contact_status">true</bool>
<bool name="show_account_indicator">true</bool>
</resources> </resources>

View file

@ -6,6 +6,7 @@
<string name="action_accounts">Manage accounts</string> <string name="action_accounts">Manage accounts</string>
<string name="action_account">Manage account</string> <string name="action_account">Manage account</string>
<string name="action_end_conversation">Close conversation</string> <string name="action_end_conversation">Close conversation</string>
<string name="action_start_secret_chat">Start secret chat</string>
<string name="action_contact_details">Contact details</string> <string name="action_contact_details">Contact details</string>
<string name="action_muc_details">Group chat details</string> <string name="action_muc_details">Group chat details</string>
<string name="channel_details">Channel details</string> <string name="channel_details">Channel details</string>
@ -38,6 +39,7 @@
<string name="sending">sending…</string> <string name="sending">sending…</string>
<string name="message_decrypting">Decrypting message. Please wait…</string> <string name="message_decrypting">Decrypting message. Please wait…</string>
<string name="pgp_message">OpenPGP encrypted message</string> <string name="pgp_message">OpenPGP encrypted message</string>
<string name="otr_message">Secret chat message</string>
<string name="nick_in_use">Nickname is already in use</string> <string name="nick_in_use">Nickname is already in use</string>
<string name="invalid_muc_nick">Invalid nickname</string> <string name="invalid_muc_nick">Invalid nickname</string>
<string name="admin">Admin</string> <string name="admin">Admin</string>
@ -612,6 +614,10 @@
<string name="pref_skip_image_editor_screen_summary">Dont open image editor screen automatically for single image attachments</string> <string name="pref_skip_image_editor_screen_summary">Dont open image editor screen automatically for single image attachments</string>
<string name="unable_to_connect_to_keychain">Could not connect to OpenKeychain</string> <string name="unable_to_connect_to_keychain">Could not connect to OpenKeychain</string>
<string name="this_device_is_no_longer_in_use">This device is no longer in use</string> <string name="this_device_is_no_longer_in_use">This device is no longer in use</string>
<string name="pref_show_contact_presence">Contact presence</string>
<string name="pref_show_contact_presence_details">Show contact presence nearby contact avatar</string>
<string name="pref_show_account_indicator">Account indicator</string>
<string name="pref_show_account_indicator_details">Mark conversations with different colors in case of several account</string>
<string name="type_pc">Computer</string> <string name="type_pc">Computer</string>
<string name="type_phone">Mobile phone</string> <string name="type_phone">Mobile phone</string>
<string name="type_tablet">Tablet</string> <string name="type_tablet">Tablet</string>
@ -1085,6 +1091,8 @@
<string name="resize">resize</string> <string name="resize">resize</string>
<string name="filter">filter</string> <string name="filter">filter</string>
<string name="could_not_create_file">could_not_create_file</string> <string name="could_not_create_file">could_not_create_file</string>
<string name="secret_chat_title">%1$s (Secret Chat / %2$s)</string>
<string name="secret_chat_title_no_resource">%1$s (Secret Chat)</string>
<string name="muc_private_conversation_title">%1$s (%2$s)</string> <string name="muc_private_conversation_title">%1$s (%2$s)</string>
<string name="note_to_self_conversation_title">Note to self (%1$s)</string> <string name="note_to_self_conversation_title">Note to self (%1$s)</string>
<string name="muc_private_conversation_info_title">Private conversation with:</string> <string name="muc_private_conversation_info_title">Private conversation with:</string>
@ -1108,6 +1116,19 @@
<string name="avater_shape_rounded_square">Rounded Square</string> <string name="avater_shape_rounded_square">Rounded Square</string>
<string name="avater_shape_square">Square</string> <string name="avater_shape_square">Square</string>
<plurals name="x_participants">
<item quantity="one">%1$d participant</item>
<item quantity="other">%1$d participants</item>
</plurals>
<string name="online_right_now_short">online</string>
<string name="last_seen_now_short">just now</string>
<string name="last_seen_min_short">one minute ago</string>
<string name="last_seen_mins_short">%d minutes ago</string>
<string name="last_seen_hour_short">one hour ago</string>
<string name="last_seen_hours_short">%d hours ago</string>
<string name="last_seen_day_short">one day ago</string>
<string name="last_seen_days_short">%d days ago</string>
<string name="clarendon" translatable="false">Clarendon</string> <string name="clarendon" translatable="false">Clarendon</string>
<string name="oldman" translatable="false">OldMan</string> <string name="oldman" translatable="false">OldMan</string>
@ -1125,4 +1146,36 @@
<string name="struck" translatable="false">Struck</string> <string name="struck" translatable="false">Struck</string>
<string name="whisper" translatable="false">Whisper</string> <string name="whisper" translatable="false">Whisper</string>
<string name="lime" translatable="false">Lime</string> <string name="lime" translatable="false">Lime</string>
<string name="send_otr_message">Write message…</string>
<string name="unknown_otr_fingerprint">Unknown OTR fingerprint</string>
<string name="otr_fingerprint">OTR fingerprint</string>
<string name="otr_fingerprint_selected_message">OTR fingerprint of message</string>
<string name="toast_message_otr_fingerprint">OTR fingerprint copied to clipboard!</string>
<string name="verify_otr">Verify OTR</string>
<string name="no_otr_session_found">No valid OTR session has been found!</string>
<string name="are_you_sure_verify_fingerprint">Are you sure that you want to verify your contacts OTR fingerprint?</string>
<string name="copy_otr_clipboard_description">Copy OTR fingerprint to clipboard</string>
<string name="otr_session_not_started">Send a message to start an encrypted chat</string>
<string name="verified">Verified!</string>
<string name="smp_requested">Contact requested SMP verification</string>
<string name="smp_explain_question">If you and your contact have a secret in common that no one else knows (like an inside joke or simply what you had for lunch the last time you met) you can use that secret to verify each others fingerprints.\n\nYou provide a hint or a question for your contact who will respond with a case-sensitive answer.</string>
<string name="smp_explain_answer">Your contact would like to verify your fingerprint by challenging you with a shared secret. Your contact provided the following hint or question for that secret.</string>
<string name="shared_secret_hint_should_not_be_empty">Your hint should not be empty</string>
<string name="shared_secret_can_not_be_empty">Your shared secret can not be empty</string>
<string name="manual_verification_explanation">Carefully compare the fingerprint shown below with the fingerprint of your contact.\nYou can use any trusted form of communication like an encrypted e-mail or a telephone call to exchange those.</string>
<string name="could_not_verify_fingerprint">Could not verify fingerprint</string>
<string name="manually_verify">Manually verify</string>
<string name="otr_blind_trust">Blind trust</string>
<string name="secrets_do_not_match">Secrets do not match</string>
<string name="ask_question">Ask question</string>
<string name="verify">Verify</string>
<string name="in_progress">In progress</string>
<string name="respond">Respond</string>
<string name="failed">Failed</string>
<string name="finish">Finish</string>
<string name="your_fingerprint">Your fingerprint</string>
<string name="remote_fingerprint">Remote Fingerprint</string>
<string name="shared_secret_hint">Hint or Question</string>
<string name="shared_secret_secret">Shared Secret</string>
</resources> </resources>

View file

@ -51,6 +51,14 @@
<item name="android:textSize">?TextSizeCaption</item> <item name="android:textSize">?TextSizeCaption</item>
</style> </style>
<style name="ToolbarTitleAppearance" parent="@style/TextAppearance.Widget.AppCompat.Toolbar.Title">
<item name="android:textSize">18dp</item>
</style>
<style name="ToolbarSubtitleAppearance" parent="@style/TextAppearance.Widget.AppCompat.Toolbar.Subtitle">
<item name="android:textSize">13dp</item>
</style>
<style name="Widget.Conversations.EditText" parent="Widget.AppCompat.EditText"> <style name="Widget.Conversations.EditText" parent="Widget.AppCompat.EditText">
<item name="android:textSize">?TextSizeInput</item> <item name="android:textSize">?TextSizeInput</item>
</style> </style>

View file

@ -59,6 +59,7 @@
<item name="ic_attach_videocam" type="reference">@drawable/ic_attach_videocam</item> <item name="ic_attach_videocam" type="reference">@drawable/ic_attach_videocam</item>
<item name="ic_attach_document" type="reference">@drawable/ic_attach_document</item> <item name="ic_attach_document" type="reference">@drawable/ic_attach_document</item>
<item name="ic_pin" type="reference">@drawable/ic_pin_black</item> <item name="ic_pin" type="reference">@drawable/ic_pin_black</item>
<item name="ic_subject" type="reference">@drawable/ic_subject_black</item>
<item name="ic_close" type="reference">@drawable/ic_close_24dp_black</item> <item name="ic_close" type="reference">@drawable/ic_close_24dp_black</item>
<item name="ic_attach_location" type="reference">@drawable/ic_attach_location</item> <item name="ic_attach_location" type="reference">@drawable/ic_attach_location</item>
<item name="ic_attach_photo" type="reference">@drawable/ic_attach_photo</item> <item name="ic_attach_photo" type="reference">@drawable/ic_attach_photo</item>
@ -152,6 +153,7 @@
<item name="ic_group_unselected" type="reference">@drawable/outline_group_black_24dp</item> <item name="ic_group_unselected" type="reference">@drawable/outline_group_black_24dp</item>
<item name="ic_group_selected" type="reference">@drawable/ic_group_selected_black_24</item> <item name="ic_group_selected" type="reference">@drawable/ic_group_selected_black_24</item>
<item name="ic_group_16" type="reference">@drawable/ic_group_selected_black_16</item> <item name="ic_group_16" type="reference">@drawable/ic_group_selected_black_16</item>
<item name="ic_secret_chat_16" type="reference">@drawable/ic_secret_chat_16dp_black</item>
<item name="icon_notifications" type="reference">@drawable/ic_notifications_black_24dp <item name="icon_notifications" type="reference">@drawable/ic_notifications_black_24dp
</item> </item>
@ -239,6 +241,7 @@
<item name="ic_attach_videocam" type="reference">@drawable/ic_attach_videocam_white</item> <item name="ic_attach_videocam" type="reference">@drawable/ic_attach_videocam_white</item>
<item name="ic_attach_document" type="reference">@drawable/ic_attach_document_white</item> <item name="ic_attach_document" type="reference">@drawable/ic_attach_document_white</item>
<item name="ic_pin" type="reference">@drawable/ic_pin_white</item> <item name="ic_pin" type="reference">@drawable/ic_pin_white</item>
<item name="ic_subject" type="reference">@drawable/ic_subject_white</item>
<item name="ic_close" type="reference">@drawable/ic_close_24dp</item> <item name="ic_close" type="reference">@drawable/ic_close_24dp</item>
<item name="ic_attach_location" type="reference">@drawable/ic_attach_location_white</item> <item name="ic_attach_location" type="reference">@drawable/ic_attach_location_white</item>
<item name="ic_attach_photo" type="reference">@drawable/ic_attach_photo_white</item> <item name="ic_attach_photo" type="reference">@drawable/ic_attach_photo_white</item>
@ -329,6 +332,7 @@
<item name="ic_group_unselected" type="reference">@drawable/outline_group_white_24</item> <item name="ic_group_unselected" type="reference">@drawable/outline_group_white_24</item>
<item name="ic_group_selected" type="reference">@drawable/ic_group_selected_white_24</item> <item name="ic_group_selected" type="reference">@drawable/ic_group_selected_white_24</item>
<item name="ic_group_16" type="reference">@drawable/ic_group_selected_white_16</item> <item name="ic_group_16" type="reference">@drawable/ic_group_selected_white_16</item>
<item name="ic_secret_chat_16" type="reference">@drawable/ic_secret_chat_16dp_white</item>
<item name="icon_notifications" type="reference">@drawable/ic_notifications_white_24dp <item name="icon_notifications" type="reference">@drawable/ic_notifications_white_24dp
</item> </item>

View file

@ -64,6 +64,16 @@
android:key="always_full_timestamps" android:key="always_full_timestamps"
android:summary="@string/pref_always_show_full_timestamps_summary" android:summary="@string/pref_always_show_full_timestamps_summary"
android:title="@string/pref_always_show_full_timestamps" /> android:title="@string/pref_always_show_full_timestamps" />
<CheckBoxPreference
android:defaultValue="@bool/use_green_background"
android:key="show_contact_status"
android:summary="@string/pref_show_contact_presence_details"
android:title="@string/pref_show_contact_presence" />
<CheckBoxPreference
android:defaultValue="@bool/use_green_background"
android:key="show_account_indicator"
android:summary="@string/pref_show_account_indicator_details"
android:title="@string/pref_show_account_indicator" />
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory android:title="@string/pref_navigation"> <PreferenceCategory android:title="@string/pref_navigation">