mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-23 18:15:22 +00:00
Clean up naming & indentation
This commit is contained in:
parent
c171a906a6
commit
526e82a9e3
@ -2413,13 +2413,8 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
sendTextMessage(forceSms, expiresIn, subscriptionId, initiating);
|
||||
}
|
||||
} catch (RecipientFormattingException ex) {
|
||||
Toast.makeText(ConversationActivity.this,
|
||||
R.string.ConversationActivity_recipient_is_not_a_valid_sms_or_email_address_exclamation,
|
||||
Toast.LENGTH_LONG).show();
|
||||
Log.w(TAG, ex);
|
||||
} catch (InvalidMessageException ex) {
|
||||
// Toast.makeText(ConversationActivity.this, R.string.ConversationActivity_message_is_empty_exclamation,
|
||||
// Toast.LENGTH_SHORT).show();
|
||||
Log.w(TAG, ex);
|
||||
}
|
||||
}
|
||||
|
@ -283,7 +283,6 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (shouldIgnore(content)) {
|
||||
Log.i(TAG, "Ignoring message.");
|
||||
return;
|
||||
@ -869,7 +868,7 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
|
||||
// Ignore messages from ourselves
|
||||
if (sender.serialize().equalsIgnoreCase(TextSecurePreferences.getLocalNumber(context))) { return; }
|
||||
|
||||
IncomingMediaMessage mediaMessage = new IncomingMediaMessage(sender, message.getTimestamp(), -1,
|
||||
IncomingMediaMessage mediaMessage = new IncomingMediaMessage(sender, message.getTimestamp(), -1,
|
||||
message.getExpiresInSeconds() * 1000L, false, content.isNeedsReceipt(), message.getBody(), message.getGroupInfo(), message.getAttachments(),
|
||||
quote, sharedContacts, linkPreviews, sticker);
|
||||
|
||||
@ -913,12 +912,12 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
|
||||
MessageNotifier.updateNotification(context, insertResult.get().getThreadId());
|
||||
}
|
||||
|
||||
// Loki - Run db updates in the background, we should look into fixing this in the future
|
||||
// Loki - Run database updates in the background, we should look into fixing this in the future
|
||||
AsyncTask.execute(() -> {
|
||||
// Loki - Store message server ID
|
||||
updateGroupChatMessageServerID(messageServerIDOrNull, insertResult);
|
||||
|
||||
// Loki - Update mapping of message to original thread id
|
||||
// Loki - Update mapping of message to original thread ID
|
||||
if (insertResult.isPresent()) {
|
||||
ThreadDatabase threadDatabase = DatabaseFactory.getThreadDatabase(context);
|
||||
LokiMessageDatabase lokiMessageDatabase = DatabaseFactory.getLokiMessageDatabase(context);
|
||||
@ -1036,10 +1035,10 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
|
||||
@NonNull Optional<Long> messageServerIDOrNull)
|
||||
throws StorageFailedException
|
||||
{
|
||||
SmsDatabase database = DatabaseFactory.getSmsDatabase(context);
|
||||
String body = message.getBody().isPresent() ? message.getBody().get() : "";
|
||||
SmsDatabase database = DatabaseFactory.getSmsDatabase(context);
|
||||
String body = message.getBody().isPresent() ? message.getBody().get() : "";
|
||||
Recipient originalRecipient = getRecipientForMessage(content, message);
|
||||
Recipient masterRecipient = getMasterRecipientForMessage(content, message);
|
||||
Recipient masterRecipient = getMasterRecipientForMessage(content, message);
|
||||
|
||||
if (message.getExpiresInSeconds() != originalRecipient.getExpireMessages()) {
|
||||
handleExpirationUpdate(content, message, Optional.absent());
|
||||
@ -1062,14 +1061,14 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
|
||||
// Ignore messages from ourselves
|
||||
if (sender.serialize().equalsIgnoreCase(TextSecurePreferences.getLocalNumber(context))) { return; }
|
||||
|
||||
IncomingTextMessage _textMessage = new IncomingTextMessage(sender,
|
||||
content.getSenderDevice(),
|
||||
message.getTimestamp(), body,
|
||||
message.getGroupInfo(),
|
||||
message.getExpiresInSeconds() * 1000L,
|
||||
content.isNeedsReceipt());
|
||||
IncomingTextMessage tm = new IncomingTextMessage(sender,
|
||||
content.getSenderDevice(),
|
||||
message.getTimestamp(), body,
|
||||
message.getGroupInfo(),
|
||||
message.getExpiresInSeconds() * 1000L,
|
||||
content.isNeedsReceipt());
|
||||
|
||||
IncomingEncryptedMessage textMessage = new IncomingEncryptedMessage(_textMessage, body);
|
||||
IncomingEncryptedMessage textMessage = new IncomingEncryptedMessage(tm, body);
|
||||
|
||||
// Ignore the message if the body is empty
|
||||
if (textMessage.getMessageBody().length() == 0) { return; }
|
||||
@ -1087,7 +1086,7 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
|
||||
MessageNotifier.updateNotification(context, threadId);
|
||||
}
|
||||
|
||||
// Loki - Run db updates in background, we should look into fixing this in the future
|
||||
// Loki - Run database updates in background, we should look into fixing this in the future
|
||||
AsyncTask.execute(() -> {
|
||||
if (insertResult.isPresent()) {
|
||||
InsertResult result = insertResult.get();
|
||||
@ -1098,7 +1097,7 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
|
||||
// Loki - Store message server ID
|
||||
updateGroupChatMessageServerID(messageServerIDOrNull, insertResult);
|
||||
|
||||
// Loki - Update mapping of message to original thread id
|
||||
// Loki - Update mapping of message to original thread ID
|
||||
if (result.getMessageId() > -1) {
|
||||
ThreadDatabase threadDatabase = DatabaseFactory.getThreadDatabase(context);
|
||||
LokiMessageDatabase lokiMessageDatabase = DatabaseFactory.getLokiMessageDatabase(context);
|
||||
|
@ -289,11 +289,11 @@ public class PushMediaSendJob extends PushSendJob implements InjectableType {
|
||||
} else {
|
||||
LokiSyncMessage syncMessage = null;
|
||||
if (shouldSendSyncMessage) {
|
||||
// Set the sync message destination the primary device, this way it will show that we sent a message to the primary device and not a secondary device
|
||||
String primaryDevice = PromiseUtil.get(LokiDeviceLinkUtilities.INSTANCE.getMasterHexEncodedPublicKey(address.getNumber()), null);
|
||||
SignalServiceAddress primaryAddress = primaryDevice == null ? address : new SignalServiceAddress(primaryDevice);
|
||||
// We also need to use the original message id and not -1
|
||||
syncMessage = new LokiSyncMessage(primaryAddress, templateMessageId);
|
||||
// Set the sync message destination to the master device, this way it will show that we sent a message to the master device and not the slave device
|
||||
String masterDevice = PromiseUtil.get(LokiDeviceLinkUtilities.INSTANCE.getMasterHexEncodedPublicKey(address.getNumber()), null);
|
||||
SignalServiceAddress masterAddress = masterDevice == null ? address : new SignalServiceAddress(masterDevice);
|
||||
// We also need to use the original message ID and not -1
|
||||
syncMessage = new LokiSyncMessage(masterAddress, templateMessageId);
|
||||
}
|
||||
return messageSender.sendMessage(messageId, address, UnidentifiedAccessUtil.getAccessFor(context, recipient), mediaMessage, Optional.fromNullable(syncMessage)).getSuccess().isUnidentified();
|
||||
}
|
||||
|
@ -200,7 +200,7 @@ public class PushTextSendJob extends PushSendJob implements InjectableType {
|
||||
{
|
||||
try {
|
||||
// rotateSenderCertificateIfNecessary();
|
||||
Recipient recipient = Recipient.from(context, destination, false);
|
||||
Recipient recipient = Recipient.from(context, destination, false);
|
||||
SignalServiceAddress address = getPushAddress(recipient.getAddress());
|
||||
Optional<byte[]> profileKey = getProfileKey(recipient);
|
||||
Optional<UnidentifiedAccessPair> unidentifiedAccess = UnidentifiedAccessUtil.getAccessFor(context, recipient);
|
||||
@ -235,11 +235,11 @@ public class PushTextSendJob extends PushSendJob implements InjectableType {
|
||||
} else {
|
||||
LokiSyncMessage syncMessage = null;
|
||||
if (shouldSendSyncMessage) {
|
||||
// Set the sync message destination to the primary device, this way it will show that we sent a message to the primary device and not a secondary device
|
||||
String primaryDevice = PromiseUtil.get(LokiDeviceLinkUtilities.INSTANCE.getMasterHexEncodedPublicKey(address.getNumber()), null);
|
||||
SignalServiceAddress primaryAddress = primaryDevice == null ? address : new SignalServiceAddress(primaryDevice);
|
||||
// We also need to use the original message id and not -1
|
||||
syncMessage = new LokiSyncMessage(primaryAddress, templateMessageId);
|
||||
// Set the sync message destination to the master device, this way it will show that we sent a message to the master device and not the slave device
|
||||
String masterDevice = PromiseUtil.get(LokiDeviceLinkUtilities.INSTANCE.getMasterHexEncodedPublicKey(address.getNumber()), null);
|
||||
SignalServiceAddress masterAddress = masterDevice == null ? address : new SignalServiceAddress(masterDevice);
|
||||
// We also need to use the original message ID and not -1
|
||||
syncMessage = new LokiSyncMessage(masterAddress, templateMessageId);
|
||||
}
|
||||
return messageSender.sendMessage(messageId, address, unidentifiedAccess, textSecureMessage, Optional.fromNullable(syncMessage)).getSuccess().isUnidentified();
|
||||
}
|
||||
|
@ -306,8 +306,8 @@ public class MessageSender {
|
||||
JobManager jobManager = ApplicationContext.getInstance(context).getJobManager();
|
||||
|
||||
// Just send the message normally if it's a group message or we're sending to one of our devices
|
||||
String recipientPublicKey = recipient.getAddress().serialize();
|
||||
if (GeneralUtilitiesKt.isPublicChat(context, recipientPublicKey) || PromiseUtil.get(MultiDeviceUtilities.isOneOfOurDevices(context, recipient.getAddress()), false)) {
|
||||
String recipientHexEncodedPublicKey = recipient.getAddress().serialize();
|
||||
if (GeneralUtilitiesKt.isPublicChat(context, recipientHexEncodedPublicKey) || PromiseUtil.get(MultiDeviceUtilities.isOneOfOurDevices(context, recipient.getAddress()), false)) {
|
||||
if (type == MessageType.MEDIA) {
|
||||
PushMediaSendJob.enqueue(context, jobManager, messageId, recipient.getAddress(), false);
|
||||
} else {
|
||||
@ -318,16 +318,16 @@ public class MessageSender {
|
||||
|
||||
// If we get here then we are sending a message to a device that is not ours
|
||||
boolean[] hasSentSyncMessage = { false };
|
||||
MultiDeviceUtilities.getAllDevicePublicKeysWithFriendStatus(context, recipientPublicKey).success(devices -> {
|
||||
MultiDeviceUtilities.getAllDevicePublicKeysWithFriendStatus(context, recipientHexEncodedPublicKey).success(devices -> {
|
||||
int friendCount = MultiDeviceUtilities.getFriendCount(context, devices.keySet());
|
||||
Util.runOnMain(() -> {
|
||||
ArrayList<Job> jobs = new ArrayList<>();
|
||||
for (Map.Entry<String, Boolean> entry : devices.entrySet()) {
|
||||
String devicePublicKey = entry.getKey();
|
||||
String deviceHexEncodedPublicKey = entry.getKey();
|
||||
boolean isFriend = entry.getValue();
|
||||
|
||||
Address address = Address.fromSerialized(devicePublicKey);
|
||||
long messageIDToUse = recipientPublicKey.equals(devicePublicKey) ? messageId : -1L;
|
||||
Address address = Address.fromSerialized(deviceHexEncodedPublicKey);
|
||||
long messageIDToUse = recipientHexEncodedPublicKey.equals(deviceHexEncodedPublicKey) ? messageId : -1L;
|
||||
|
||||
if (isFriend) {
|
||||
// Send a normal message if the user is friends with the recipient
|
||||
@ -340,7 +340,7 @@ public class MessageSender {
|
||||
}
|
||||
if (shouldSendSyncMessage) { hasSentSyncMessage[0] = true; }
|
||||
} else {
|
||||
// Send friend requests to non friends. If the user is friends with any
|
||||
// Send friend requests to non-friends. If the user is friends with any
|
||||
// of the devices then send out a default friend request message.
|
||||
boolean isFriendsWithAny = (friendCount > 0);
|
||||
String defaultFriendRequestMessage = isFriendsWithAny ? "Please accept to enable messages to be synced across devices" : null;
|
||||
|
Loading…
Reference in New Issue
Block a user