mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-25 01:07:47 +00:00
Clean
This commit is contained in:
parent
cbada40a6e
commit
a78b8a77b6
@ -2186,7 +2186,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
recipient.getAddress().isEmail() ||
|
||||
inputPanel.getQuote().isPresent() ||
|
||||
linkPreviewViewModel.hasLinkPreview() ||
|
||||
LinkPreviewUtil.isWhitelistedMediaUrl(message) ||
|
||||
LinkPreviewUtil.isWhitelistedMediaUrl(message) || // Loki - Send GIFs as media messages
|
||||
needsSplit;
|
||||
|
||||
Log.i(TAG, "isManual Selection: " + sendButton.isManualSelection());
|
||||
|
@ -95,6 +95,7 @@ public class PushGroupSendJob extends PushSendJob implements InjectableType {
|
||||
OutgoingMediaMessage message = database.getOutgoingMessage(messageId);
|
||||
List<Attachment> attachments = new LinkedList<>();
|
||||
|
||||
// Loki - For now all attachments are re-fetched by the receiver
|
||||
// attachments.addAll(message.getAttachments());
|
||||
// attachments.addAll(Stream.of(message.getLinkPreviews()).filter(p -> p.getThumbnail().isPresent()).map(p -> p.getThumbnail().get()).toList());
|
||||
attachments.addAll(Stream.of(message.getSharedContacts()).filter(c -> c.getAvatar() != null).map(c -> c.getAvatar().getAttachment()).withoutNulls().toList());
|
||||
@ -284,7 +285,7 @@ public class PushGroupSendJob extends PushSendJob implements InjectableType {
|
||||
|
||||
private @NonNull List<Address> getGroupMessageRecipients(String groupId, long messageId) {
|
||||
ArrayList<Address> result = new ArrayList<>();
|
||||
result.add(Address.fromSerialized(LokiGroupChatAPI.getPublicChatServer()));
|
||||
result.add(Address.fromSerialized(LokiGroupChatAPI.getPublicChatServer())); // Loki - All group messages should be directed to the Loki Public Chat for now
|
||||
return result;
|
||||
|
||||
/*
|
||||
|
@ -76,6 +76,7 @@ public class PushMediaSendJob extends PushSendJob implements InjectableType {
|
||||
OutgoingMediaMessage message = database.getOutgoingMessage(messageId);
|
||||
List<Attachment> attachments = new LinkedList<>();
|
||||
|
||||
// Loki - For now all attachments are re-fetched by the receiver
|
||||
// attachments.addAll(message.getAttachments());
|
||||
// attachments.addAll(Stream.of(message.getLinkPreviews()).filter(p -> p.getThumbnail().isPresent()).map(p -> p.getThumbnail().get()).toList());
|
||||
attachments.addAll(Stream.of(message.getSharedContacts()).filter(c -> c.getAvatar() != null).map(c -> c.getAvatar().getAttachment()).withoutNulls().toList());
|
||||
|
@ -18,8 +18,6 @@ class LokiMessageDatabase(context: Context, helper: SQLCipherOpenHelper) : Datab
|
||||
@JvmStatic val createTableCommand = "CREATE TABLE $tableName ($messageID INTEGER PRIMARY KEY, $serverID INTEGER DEFAULT 0, $friendRequestStatus INTEGER DEFAULT 0);"
|
||||
}
|
||||
|
||||
// TODO: Move the server ID stuff to LokiAPIDatabase?
|
||||
|
||||
fun getServerID(messageID: Long): Long? {
|
||||
val database = databaseHelper.readableDatabase
|
||||
return database.get(tableName, "${Companion.messageID} = ?", arrayOf( messageID.toString() )) { cursor ->
|
||||
|
@ -31,7 +31,7 @@ class LokiUserDatabase(context: Context, helper: SQLCipherOpenHelper) : Database
|
||||
return TextSecurePreferences.getProfileName(context)
|
||||
} else {
|
||||
val database = databaseHelper.readableDatabase
|
||||
return database.get(displayNameTable, "${Companion.hexEncodedPublicKey} = ?", arrayOf(hexEncodedPublicKey)) { cursor ->
|
||||
return database.get(displayNameTable, "${Companion.hexEncodedPublicKey} = ?", arrayOf( hexEncodedPublicKey )) { cursor ->
|
||||
cursor.getString(cursor.getColumnIndexOrThrow(displayName))
|
||||
}
|
||||
}
|
||||
@ -48,7 +48,7 @@ class LokiUserDatabase(context: Context, helper: SQLCipherOpenHelper) : Database
|
||||
|
||||
fun getServerDisplayName(serverID: String, hexEncodedPublicKey: String): String? {
|
||||
val database = databaseHelper.readableDatabase
|
||||
return database.get(serverDisplayNameTable, "${Companion.hexEncodedPublicKey} = ? AND ${Companion.serverID} = ?", arrayOf(hexEncodedPublicKey, serverID)) { cursor ->
|
||||
return database.get(serverDisplayNameTable, "${Companion.hexEncodedPublicKey} = ? AND ${Companion.serverID} = ?", arrayOf( hexEncodedPublicKey, serverID )) { cursor ->
|
||||
cursor.getString(cursor.getColumnIndexOrThrow(displayName))
|
||||
}
|
||||
}
|
||||
|
@ -4,22 +4,24 @@ class RNG(hash: Long) {
|
||||
private var seed: Long
|
||||
private val initial: Long
|
||||
|
||||
private val maxInt32 = Int.MAX_VALUE.toLong()
|
||||
|
||||
init {
|
||||
seed = hash % 2147483647
|
||||
seed = hash % maxInt32
|
||||
if (seed <= 0) {
|
||||
seed = 2147483646
|
||||
seed = maxInt32 - 1
|
||||
}
|
||||
initial = seed
|
||||
}
|
||||
|
||||
fun next(): Long {
|
||||
val newSeed = (seed * 16807) % 2147483647
|
||||
val newSeed = (seed * 16807) % maxInt32
|
||||
seed = newSeed
|
||||
return seed
|
||||
}
|
||||
|
||||
fun nextFloat(): Float {
|
||||
return (next() - 1).toFloat() / 2147483646
|
||||
return (next() - 1).toFloat() / (maxInt32 - 1)
|
||||
}
|
||||
|
||||
fun reset() {
|
||||
|
@ -109,21 +109,22 @@ public class MessageSender {
|
||||
|
||||
Recipient recipient = message.getRecipient();
|
||||
|
||||
// Loki - Turn into a GIF message if possible
|
||||
if (message.getLinkPreviews().isEmpty() && message.getAttachments().isEmpty() && LinkPreviewUtil.isWhitelistedMediaUrl(message.getBody())) {
|
||||
new LinkPreviewRepository(context).fetchGIF(context, message.getBody(), attachmentOrNull -> Util.runOnMain(() -> {
|
||||
if (attachmentOrNull.isPresent()) {
|
||||
Attachment attachment = attachmentOrNull.get();
|
||||
try {
|
||||
message.getAttachments().add(attachment);
|
||||
long messageId = database.insertMessageOutbox(message, allocatedThreadId, forceSms, insertListener);
|
||||
sendMediaMessage(context, recipient, forceSms, messageId, message.getExpiresIn());
|
||||
long messageID = database.insertMessageOutbox(message, allocatedThreadId, forceSms, insertListener);
|
||||
sendMediaMessage(context, recipient, forceSms, messageID, message.getExpiresIn());
|
||||
} catch (Exception e) {
|
||||
// TODO: Handle
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
long messageId = database.insertMessageOutbox(message, allocatedThreadId, forceSms, insertListener);
|
||||
sendMediaMessage(context, recipient, forceSms, messageId, message.getExpiresIn());
|
||||
long messageID = database.insertMessageOutbox(message, allocatedThreadId, forceSms, insertListener);
|
||||
sendMediaMessage(context, recipient, forceSms, messageID, message.getExpiresIn());
|
||||
} catch (MmsException e) {
|
||||
// TODO: Handle
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user