Small tweaks
This commit is contained in:
parent
102f6d9ab1
commit
98c5b7ba61
|
@ -34,7 +34,7 @@
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
tools:listitem="@layout/view_message_text_in" />
|
tools:listitem="@layout/view_message_text_in" />
|
||||||
|
|
||||||
<fragment
|
<androidx.fragment.app.FragmentContainerView
|
||||||
android:id="@+id/fragment_compose"
|
android:id="@+id/fragment_compose"
|
||||||
android:name="org.mercury_im.messenger.android.ui.chat.ChatInputFragment"
|
android:name="org.mercury_im.messenger.android.ui.chat.ChatInputFragment"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
|
@ -14,6 +14,7 @@ import org.mercury_im.messenger.entity.message.Message;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
@ -142,12 +143,18 @@ public class RxMessageRepository
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Single<Message> upsertMessage(DirectChat chat, Message message) {
|
public Single<Message> upsertMessage(DirectChat chat, Message message) {
|
||||||
return null;
|
return Single.just(message)
|
||||||
|
.map(messageMapping::toModel)
|
||||||
|
.flatMap(data()::upsert)
|
||||||
|
.map(messageMapping::toEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Single<Message> upsertMessage(GroupChat chat, Message message) {
|
public Single<Message> upsertMessage(GroupChat chat, Message message) {
|
||||||
return null;
|
return Single.just(message)
|
||||||
|
.map(messageMapping::toModel)
|
||||||
|
.flatMap(data()::upsert)
|
||||||
|
.map(messageMapping::toEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -4,6 +4,7 @@ import org.bouncycastle.openpgp.PGPException;
|
||||||
import org.jivesoftware.smack.SmackException;
|
import org.jivesoftware.smack.SmackException;
|
||||||
import org.jivesoftware.smack.XMPPException;
|
import org.jivesoftware.smack.XMPPException;
|
||||||
import org.jivesoftware.smack.chat2.ChatManager;
|
import org.jivesoftware.smack.chat2.ChatManager;
|
||||||
|
import org.jivesoftware.smack.packet.MessageBuilder;
|
||||||
import org.jivesoftware.smack.roster.Roster;
|
import org.jivesoftware.smack.roster.Roster;
|
||||||
import org.jivesoftware.smack.roster.RosterEntry;
|
import org.jivesoftware.smack.roster.RosterEntry;
|
||||||
import org.jivesoftware.smackx.ox.OpenPgpContact;
|
import org.jivesoftware.smackx.ox.OpenPgpContact;
|
||||||
|
@ -18,9 +19,13 @@ import org.mercury_im.messenger.core.exception.ContactAlreadyAddedException;
|
||||||
import org.mercury_im.messenger.core.xmpp.MercuryConnection;
|
import org.mercury_im.messenger.core.xmpp.MercuryConnection;
|
||||||
import org.mercury_im.messenger.core.xmpp.MercuryConnectionManager;
|
import org.mercury_im.messenger.core.xmpp.MercuryConnectionManager;
|
||||||
import org.mercury_im.messenger.entity.contact.Peer;
|
import org.mercury_im.messenger.entity.contact.Peer;
|
||||||
|
import org.mercury_im.messenger.entity.message.Message;
|
||||||
|
import org.mercury_im.messenger.entity.message.MessageDeliveryState;
|
||||||
|
import org.mercury_im.messenger.entity.message.MessageDirection;
|
||||||
import org.pgpainless.key.OpenPgpV4Fingerprint;
|
import org.pgpainless.key.OpenPgpV4Fingerprint;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
@ -126,11 +131,6 @@ public class Messenger {
|
||||||
MercuryConnection connection = getConnection(contact.getAccount().getId());
|
MercuryConnection connection = getConnection(contact.getAccount().getId());
|
||||||
OpenPgpManager oxManager = OpenPgpManager.getInstanceFor(connection.getConnection());
|
OpenPgpManager oxManager = OpenPgpManager.getInstanceFor(connection.getConnection());
|
||||||
OXInstantMessagingManager oximManager = OXInstantMessagingManager.getInstanceFor(connection.getConnection());
|
OXInstantMessagingManager oximManager = OXInstantMessagingManager.getInstanceFor(connection.getConnection());
|
||||||
OpenPgpContact oxContact = oxManager.getOpenPgpContact(contact.getJid());
|
|
||||||
for (OpenPgpV4Fingerprint fingerprint : oxContact.getUndecidedFingerprints()) {
|
|
||||||
oxContact.trust(fingerprint);
|
|
||||||
}
|
|
||||||
oxContact.getAnnouncedPublicKeys();
|
|
||||||
oximManager.sendOxMessage(oxManager.getOpenPgpContact(contact.getJid()), body);
|
oximManager.sendOxMessage(oxManager.getOpenPgpContact(contact.getJid()), body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ import org.mercury_im.messenger.entity.chat.GroupChat;
|
||||||
import org.mercury_im.messenger.entity.message.Message;
|
import org.mercury_im.messenger.entity.message.Message;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import io.reactivex.Completable;
|
import io.reactivex.Completable;
|
||||||
import io.reactivex.Observable;
|
import io.reactivex.Observable;
|
||||||
|
|
|
@ -7,6 +7,7 @@ import org.mercury_im.messenger.core.data.repository.DirectChatRepository;
|
||||||
import org.mercury_im.messenger.core.data.repository.MessageRepository;
|
import org.mercury_im.messenger.core.data.repository.MessageRepository;
|
||||||
import org.mercury_im.messenger.core.data.repository.PeerRepository;
|
import org.mercury_im.messenger.core.data.repository.PeerRepository;
|
||||||
import org.mercury_im.messenger.core.data.repository.Repositories;
|
import org.mercury_im.messenger.core.data.repository.Repositories;
|
||||||
|
import org.mercury_im.messenger.core.store.message.MercuryMessageStore;
|
||||||
import org.mercury_im.messenger.core.util.Optional;
|
import org.mercury_im.messenger.core.util.Optional;
|
||||||
import org.mercury_im.messenger.core.viewmodel.MercuryViewModel;
|
import org.mercury_im.messenger.core.viewmodel.MercuryViewModel;
|
||||||
import org.mercury_im.messenger.entity.chat.DirectChat;
|
import org.mercury_im.messenger.entity.chat.DirectChat;
|
||||||
|
@ -36,7 +37,7 @@ public class ChatViewModel implements MercuryViewModel {
|
||||||
@Getter
|
@Getter
|
||||||
private BehaviorSubject<Optional<Peer>> peer = BehaviorSubject.create();
|
private BehaviorSubject<Optional<Peer>> peer = BehaviorSubject.create();
|
||||||
|
|
||||||
Single<DirectChat> directChat;
|
private Single<DirectChat> directChat;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private BehaviorSubject<DirectChat> chat = BehaviorSubject.create();
|
private BehaviorSubject<DirectChat> chat = BehaviorSubject.create();
|
||||||
|
|
|
@ -32,7 +32,7 @@ public class Peer {
|
||||||
if (name != null && !name.trim().isEmpty()) {
|
if (name != null && !name.trim().isEmpty()) {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
return address.substring(0, address.indexOf('@'));
|
return getJid().getLocalpart().asUnescapedString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntityBareJid getJid() {
|
public EntityBareJid getJid() {
|
||||||
|
|
Loading…
Reference in New Issue