mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-11 18:54:21 +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);
|
sendTextMessage(forceSms, expiresIn, subscriptionId, initiating);
|
||||||
}
|
}
|
||||||
} catch (RecipientFormattingException ex) {
|
} 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);
|
Log.w(TAG, ex);
|
||||||
} catch (InvalidMessageException ex) {
|
} catch (InvalidMessageException ex) {
|
||||||
// Toast.makeText(ConversationActivity.this, R.string.ConversationActivity_message_is_empty_exclamation,
|
|
||||||
// Toast.LENGTH_SHORT).show();
|
|
||||||
Log.w(TAG, ex);
|
Log.w(TAG, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -283,7 +283,6 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (shouldIgnore(content)) {
|
if (shouldIgnore(content)) {
|
||||||
Log.i(TAG, "Ignoring message.");
|
Log.i(TAG, "Ignoring message.");
|
||||||
return;
|
return;
|
||||||
@ -913,12 +912,12 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
|
|||||||
MessageNotifier.updateNotification(context, insertResult.get().getThreadId());
|
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(() -> {
|
AsyncTask.execute(() -> {
|
||||||
// Loki - Store message server ID
|
// Loki - Store message server ID
|
||||||
updateGroupChatMessageServerID(messageServerIDOrNull, insertResult);
|
updateGroupChatMessageServerID(messageServerIDOrNull, insertResult);
|
||||||
|
|
||||||
// Loki - Update mapping of message to original thread id
|
// Loki - Update mapping of message to original thread ID
|
||||||
if (insertResult.isPresent()) {
|
if (insertResult.isPresent()) {
|
||||||
ThreadDatabase threadDatabase = DatabaseFactory.getThreadDatabase(context);
|
ThreadDatabase threadDatabase = DatabaseFactory.getThreadDatabase(context);
|
||||||
LokiMessageDatabase lokiMessageDatabase = DatabaseFactory.getLokiMessageDatabase(context);
|
LokiMessageDatabase lokiMessageDatabase = DatabaseFactory.getLokiMessageDatabase(context);
|
||||||
@ -1062,14 +1061,14 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
|
|||||||
// Ignore messages from ourselves
|
// Ignore messages from ourselves
|
||||||
if (sender.serialize().equalsIgnoreCase(TextSecurePreferences.getLocalNumber(context))) { return; }
|
if (sender.serialize().equalsIgnoreCase(TextSecurePreferences.getLocalNumber(context))) { return; }
|
||||||
|
|
||||||
IncomingTextMessage _textMessage = new IncomingTextMessage(sender,
|
IncomingTextMessage tm = new IncomingTextMessage(sender,
|
||||||
content.getSenderDevice(),
|
content.getSenderDevice(),
|
||||||
message.getTimestamp(), body,
|
message.getTimestamp(), body,
|
||||||
message.getGroupInfo(),
|
message.getGroupInfo(),
|
||||||
message.getExpiresInSeconds() * 1000L,
|
message.getExpiresInSeconds() * 1000L,
|
||||||
content.isNeedsReceipt());
|
content.isNeedsReceipt());
|
||||||
|
|
||||||
IncomingEncryptedMessage textMessage = new IncomingEncryptedMessage(_textMessage, body);
|
IncomingEncryptedMessage textMessage = new IncomingEncryptedMessage(tm, body);
|
||||||
|
|
||||||
// Ignore the message if the body is empty
|
// Ignore the message if the body is empty
|
||||||
if (textMessage.getMessageBody().length() == 0) { return; }
|
if (textMessage.getMessageBody().length() == 0) { return; }
|
||||||
@ -1087,7 +1086,7 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
|
|||||||
MessageNotifier.updateNotification(context, threadId);
|
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(() -> {
|
AsyncTask.execute(() -> {
|
||||||
if (insertResult.isPresent()) {
|
if (insertResult.isPresent()) {
|
||||||
InsertResult result = insertResult.get();
|
InsertResult result = insertResult.get();
|
||||||
@ -1098,7 +1097,7 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
|
|||||||
// Loki - Store message server ID
|
// Loki - Store message server ID
|
||||||
updateGroupChatMessageServerID(messageServerIDOrNull, insertResult);
|
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) {
|
if (result.getMessageId() > -1) {
|
||||||
ThreadDatabase threadDatabase = DatabaseFactory.getThreadDatabase(context);
|
ThreadDatabase threadDatabase = DatabaseFactory.getThreadDatabase(context);
|
||||||
LokiMessageDatabase lokiMessageDatabase = DatabaseFactory.getLokiMessageDatabase(context);
|
LokiMessageDatabase lokiMessageDatabase = DatabaseFactory.getLokiMessageDatabase(context);
|
||||||
|
@ -289,11 +289,11 @@ public class PushMediaSendJob extends PushSendJob implements InjectableType {
|
|||||||
} else {
|
} else {
|
||||||
LokiSyncMessage syncMessage = null;
|
LokiSyncMessage syncMessage = null;
|
||||||
if (shouldSendSyncMessage) {
|
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
|
// 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 primaryDevice = PromiseUtil.get(LokiDeviceLinkUtilities.INSTANCE.getMasterHexEncodedPublicKey(address.getNumber()), null);
|
String masterDevice = PromiseUtil.get(LokiDeviceLinkUtilities.INSTANCE.getMasterHexEncodedPublicKey(address.getNumber()), null);
|
||||||
SignalServiceAddress primaryAddress = primaryDevice == null ? address : new SignalServiceAddress(primaryDevice);
|
SignalServiceAddress masterAddress = masterDevice == null ? address : new SignalServiceAddress(masterDevice);
|
||||||
// We also need to use the original message id and not -1
|
// We also need to use the original message ID and not -1
|
||||||
syncMessage = new LokiSyncMessage(primaryAddress, templateMessageId);
|
syncMessage = new LokiSyncMessage(masterAddress, templateMessageId);
|
||||||
}
|
}
|
||||||
return messageSender.sendMessage(messageId, address, UnidentifiedAccessUtil.getAccessFor(context, recipient), mediaMessage, Optional.fromNullable(syncMessage)).getSuccess().isUnidentified();
|
return messageSender.sendMessage(messageId, address, UnidentifiedAccessUtil.getAccessFor(context, recipient), mediaMessage, Optional.fromNullable(syncMessage)).getSuccess().isUnidentified();
|
||||||
}
|
}
|
||||||
|
@ -235,11 +235,11 @@ public class PushTextSendJob extends PushSendJob implements InjectableType {
|
|||||||
} else {
|
} else {
|
||||||
LokiSyncMessage syncMessage = null;
|
LokiSyncMessage syncMessage = null;
|
||||||
if (shouldSendSyncMessage) {
|
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
|
// 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 primaryDevice = PromiseUtil.get(LokiDeviceLinkUtilities.INSTANCE.getMasterHexEncodedPublicKey(address.getNumber()), null);
|
String masterDevice = PromiseUtil.get(LokiDeviceLinkUtilities.INSTANCE.getMasterHexEncodedPublicKey(address.getNumber()), null);
|
||||||
SignalServiceAddress primaryAddress = primaryDevice == null ? address : new SignalServiceAddress(primaryDevice);
|
SignalServiceAddress masterAddress = masterDevice == null ? address : new SignalServiceAddress(masterDevice);
|
||||||
// We also need to use the original message id and not -1
|
// We also need to use the original message ID and not -1
|
||||||
syncMessage = new LokiSyncMessage(primaryAddress, templateMessageId);
|
syncMessage = new LokiSyncMessage(masterAddress, templateMessageId);
|
||||||
}
|
}
|
||||||
return messageSender.sendMessage(messageId, address, unidentifiedAccess, textSecureMessage, Optional.fromNullable(syncMessage)).getSuccess().isUnidentified();
|
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();
|
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
|
// 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();
|
String recipientHexEncodedPublicKey = recipient.getAddress().serialize();
|
||||||
if (GeneralUtilitiesKt.isPublicChat(context, recipientPublicKey) || PromiseUtil.get(MultiDeviceUtilities.isOneOfOurDevices(context, recipient.getAddress()), false)) {
|
if (GeneralUtilitiesKt.isPublicChat(context, recipientHexEncodedPublicKey) || PromiseUtil.get(MultiDeviceUtilities.isOneOfOurDevices(context, recipient.getAddress()), false)) {
|
||||||
if (type == MessageType.MEDIA) {
|
if (type == MessageType.MEDIA) {
|
||||||
PushMediaSendJob.enqueue(context, jobManager, messageId, recipient.getAddress(), false);
|
PushMediaSendJob.enqueue(context, jobManager, messageId, recipient.getAddress(), false);
|
||||||
} else {
|
} 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
|
// If we get here then we are sending a message to a device that is not ours
|
||||||
boolean[] hasSentSyncMessage = { false };
|
boolean[] hasSentSyncMessage = { false };
|
||||||
MultiDeviceUtilities.getAllDevicePublicKeysWithFriendStatus(context, recipientPublicKey).success(devices -> {
|
MultiDeviceUtilities.getAllDevicePublicKeysWithFriendStatus(context, recipientHexEncodedPublicKey).success(devices -> {
|
||||||
int friendCount = MultiDeviceUtilities.getFriendCount(context, devices.keySet());
|
int friendCount = MultiDeviceUtilities.getFriendCount(context, devices.keySet());
|
||||||
Util.runOnMain(() -> {
|
Util.runOnMain(() -> {
|
||||||
ArrayList<Job> jobs = new ArrayList<>();
|
ArrayList<Job> jobs = new ArrayList<>();
|
||||||
for (Map.Entry<String, Boolean> entry : devices.entrySet()) {
|
for (Map.Entry<String, Boolean> entry : devices.entrySet()) {
|
||||||
String devicePublicKey = entry.getKey();
|
String deviceHexEncodedPublicKey = entry.getKey();
|
||||||
boolean isFriend = entry.getValue();
|
boolean isFriend = entry.getValue();
|
||||||
|
|
||||||
Address address = Address.fromSerialized(devicePublicKey);
|
Address address = Address.fromSerialized(deviceHexEncodedPublicKey);
|
||||||
long messageIDToUse = recipientPublicKey.equals(devicePublicKey) ? messageId : -1L;
|
long messageIDToUse = recipientHexEncodedPublicKey.equals(deviceHexEncodedPublicKey) ? messageId : -1L;
|
||||||
|
|
||||||
if (isFriend) {
|
if (isFriend) {
|
||||||
// Send a normal message if the user is friends with the recipient
|
// Send a normal message if the user is friends with the recipient
|
||||||
@ -340,7 +340,7 @@ public class MessageSender {
|
|||||||
}
|
}
|
||||||
if (shouldSendSyncMessage) { hasSentSyncMessage[0] = true; }
|
if (shouldSendSyncMessage) { hasSentSyncMessage[0] = true; }
|
||||||
} else {
|
} 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.
|
// of the devices then send out a default friend request message.
|
||||||
boolean isFriendsWithAny = (friendCount > 0);
|
boolean isFriendsWithAny = (friendCount > 0);
|
||||||
String defaultFriendRequestMessage = isFriendsWithAny ? "Please accept to enable messages to be synced across devices" : null;
|
String defaultFriendRequestMessage = isFriendsWithAny ? "Please accept to enable messages to be synced across devices" : null;
|
||||||
|
Loading…
Reference in New Issue
Block a user