WIP make things compile

This commit is contained in:
Ryan ZHAO 2021-01-14 14:05:51 +11:00
parent fcb71961d6
commit e3fb097581
5 changed files with 19 additions and 19 deletions

View File

@ -7,6 +7,7 @@ import androidx.annotation.Nullable;
import com.google.protobuf.ByteString;
import org.session.libsession.messaging.threads.GroupRecord;
import org.thoughtcrime.securesms.ApplicationContext;
import org.session.libsession.messaging.threads.Address;
import org.thoughtcrime.securesms.database.DatabaseFactory;
@ -40,7 +41,6 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import static org.thoughtcrime.securesms.database.GroupDatabase.GroupRecord;
import static org.session.libsignal.service.internal.push.SignalServiceProtos.AttachmentPointer;
import static org.session.libsignal.service.internal.push.SignalServiceProtos.GroupContext;
@ -93,14 +93,14 @@ public class GroupMessageProcessor {
if (group.getMembers().isPresent()) {
for (String member : group.getMembers().get()) {
members.add(Address.fromExternal(context, member));
members.add(Address.Companion.fromExternal(context, member));
}
}
// Loki - Parse admins
if (group.getAdmins().isPresent()) {
for (String admin : group.getAdmins().get()) {
admins.add(Address.fromExternal(context, admin));
admins.add(Address.Companion.fromExternal(context, admin));
}
}
@ -131,13 +131,13 @@ public class GroupMessageProcessor {
// Loki - Only update the group if the group admin sent the message
String masterDevice = MultiDeviceProtocol.shared.getMasterDevice(content.getSender());
if (masterDevice == null) { masterDevice = content.getSender(); }
if (!groupRecord.getAdmins().contains(Address.fromSerialized(masterDevice))) {
if (!groupRecord.getAdmins().contains(Address.Companion.fromSerialized(masterDevice))) {
Log.d("Loki", "Received a group update message from a non-admin user for: " + id +"; ignoring.");
return null;
}
// Loki - Only process update messages if we're part of the group
Address userMasterDeviceAddress = Address.fromSerialized(userMasterDevice);
Address userMasterDeviceAddress = Address.Companion.fromSerialized(userMasterDevice);
if (!groupRecord.getMembers().contains(userMasterDeviceAddress) &&
!group.getMembers().or(Collections.emptyList()).contains(userMasterDevice)) {
Log.d("Loki", "Received a group update message from a group we're not a member of: " + id + "; ignoring.");
@ -150,7 +150,7 @@ public class GroupMessageProcessor {
Set<Address> newMembers = new HashSet<>();
for (String messageMember : group.getMembers().get()) {
newMembers.add(Address.fromExternal(context, messageMember));
newMembers.add(Address.Companion.fromExternal(context, messageMember));
}
// Added members are the members who are present in newMembers but not in currentMembers
@ -189,7 +189,7 @@ public class GroupMessageProcessor {
}
// If we were removed then we need to disable the chat
if (removedMembers.contains(Address.fromSerialized(userMasterDevice))) {
if (removedMembers.contains(Address.Companion.fromSerialized(userMasterDevice))) {
database.setActive(id, false);
} else {
if (!groupRecord.isActive()) database.setActive(id, true);
@ -209,7 +209,7 @@ public class GroupMessageProcessor {
{
String masterDevice = MultiDeviceProtocol.shared.getMasterDevice(content.getSender());
if (masterDevice == null) { masterDevice = content.getSender(); }
if (record.getMembers().contains(Address.fromSerialized(masterDevice))) {
if (record.getMembers().contains(Address.Companion.fromSerialized(masterDevice))) {
ApplicationContext.getInstance(context)
.getJobManager()
.add(new PushGroupUpdateJob(content.getSender(), group.getGroupId()));
@ -232,8 +232,8 @@ public class GroupMessageProcessor {
String masterDevice = MultiDeviceProtocol.shared.getMasterDevice(content.getSender());
if (masterDevice == null) { masterDevice = content.getSender(); }
if (members.contains(Address.fromExternal(context, masterDevice))) {
database.removeMember(id, Address.fromExternal(context, masterDevice));
if (members.contains(Address.Companion.fromExternal(context, masterDevice))) {
database.removeMember(id, Address.Companion.fromExternal(context, masterDevice));
if (outgoing) database.setActive(id, false);
return storeMessage(context, content, group, builder.build(), outgoing);
@ -257,7 +257,7 @@ public class GroupMessageProcessor {
try {
if (outgoing) {
MmsDatabase mmsDatabase = DatabaseFactory.getMmsDatabase(context);
Address address = Address.fromExternal(context, GroupUtil.getEncodedId(group));
Address address = Address.Companion.fromExternal(context, GroupUtil.getEncodedId(group));
Recipient recipient = Recipient.from(context, address, false);
OutgoingGroupMediaMessage outgoingMessage = new OutgoingGroupMediaMessage(recipient, storage, null, content.getTimestamp(), 0, null, Collections.emptyList(), Collections.emptyList());
long threadId = DatabaseFactory.getThreadDatabase(context).getOrCreateThreadIdFor(recipient);
@ -269,7 +269,7 @@ public class GroupMessageProcessor {
} else {
SmsDatabase smsDatabase = DatabaseFactory.getSmsDatabase(context);
String body = Base64.encodeBytes(storage.toByteArray());
IncomingTextMessage incoming = new IncomingTextMessage(Address.fromExternal(context, content.getSender()), content.getSenderDevice(), content.getTimestamp(), body, Optional.of(group), 0, content.isNeedsReceipt());
IncomingTextMessage incoming = new IncomingTextMessage(Address.Companion.fromExternal(context, content.getSender()), content.getSenderDevice(), content.getTimestamp(), body, Optional.of(group), 0, content.isNeedsReceipt());
IncomingGroupMessage groupMessage = new IncomingGroupMessage(incoming, storage, body);
Optional<InsertResult> insertResult = smsDatabase.insertMessageInbox(groupMessage);

View File

@ -11,9 +11,9 @@ import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import network.loki.messenger.R;
import org.thoughtcrime.securesms.database.RecipientDatabase;
import org.thoughtcrime.securesms.preferences.widgets.NotificationPrivacyPreference;
import org.session.libsession.messaging.threads.recipients.Recipient;
import org.session.libsession.messaging.threads.recipients.Recipient.*;
import org.thoughtcrime.securesms.util.TextSecurePreferences;
import org.thoughtcrime.securesms.util.Util;
@ -46,15 +46,15 @@ public abstract class AbstractNotificationBuilder extends NotificationCompat.Bui
return builder;
}
public void setAlarms(@Nullable Uri ringtone, RecipientDatabase.VibrateState vibrate) {
public void setAlarms(@Nullable Uri ringtone, VibrateState vibrate) {
Uri defaultRingtone = NotificationChannels.supported() ? NotificationChannels.getMessageRingtone(context) : TextSecurePreferences.getNotificationRingtone(context);
boolean defaultVibrate = NotificationChannels.supported() ? NotificationChannels.getMessageVibrate(context) : TextSecurePreferences.isNotificationVibrateEnabled(context);
if (ringtone == null && !TextUtils.isEmpty(defaultRingtone.toString())) setSound(defaultRingtone);
else if (ringtone != null && !ringtone.toString().isEmpty()) setSound(ringtone);
if (vibrate == RecipientDatabase.VibrateState.ENABLED ||
(vibrate == RecipientDatabase.VibrateState.DEFAULT && defaultVibrate))
if (vibrate == VibrateState.ENABLED ||
(vibrate == VibrateState.DEFAULT && defaultVibrate))
{
setDefaults(Notification.DEFAULT_VIBRATE);
}

View File

@ -25,8 +25,8 @@ import network.loki.messenger.R;
import org.session.libsession.messaging.threads.Address;
import org.thoughtcrime.securesms.database.DatabaseFactory;
import org.thoughtcrime.securesms.database.RecipientDatabase;
import org.thoughtcrime.securesms.database.RecipientDatabase.VibrateState;
import org.session.libsession.messaging.threads.recipients.Recipient;
import org.session.libsession.messaging.threads.recipients.Recipient.*;
import org.thoughtcrime.securesms.util.ServiceUtil;
import org.thoughtcrime.securesms.util.TextSecurePreferences;
import org.session.libsignal.libsignal.logging.Log;

View File

@ -9,9 +9,9 @@ import androidx.annotation.Nullable;
import org.thoughtcrime.securesms.conversation.ConversationActivity;
import org.thoughtcrime.securesms.conversation.ConversationPopupActivity;
import org.thoughtcrime.securesms.database.RecipientDatabase.VibrateState;
import org.thoughtcrime.securesms.logging.Log;
import org.session.libsession.messaging.threads.recipients.Recipient;
import org.session.libsession.messaging.threads.recipients.Recipient.*;
import java.util.LinkedHashSet;
import java.util.LinkedList;

View File

@ -48,7 +48,7 @@ import com.google.android.exoplayer2.upstream.BandwidthMeter;
import com.google.android.exoplayer2.upstream.DefaultBandwidthMeter;
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
import org.session.libsession.messaging.sending_receiving.attachments.AttachmentServer;
import org.thoughtcrime.securesms.attachments.AttachmentServer;
import org.thoughtcrime.securesms.logging.Log;
import org.thoughtcrime.securesms.mms.PartAuthority;
import org.thoughtcrime.securesms.mms.VideoSlide;