mirror of
https://github.com/oxen-io/session-android.git
synced 2025-02-17 12:18:25 +00:00
Remove duplicated/unused code
This commit is contained in:
parent
918e1ea3cf
commit
ab83e49f93
@ -33,7 +33,6 @@ import org.thoughtcrime.securesms.database.ThreadDatabase;
|
||||
import org.thoughtcrime.securesms.database.model.ThreadRecord;
|
||||
|
||||
import org.session.libsession.messaging.threads.GroupRecord;
|
||||
import org.session.libsession.utilities.NumberUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -131,10 +130,6 @@ public class ContactsCursorLoader extends CursorLoader {
|
||||
cursorList.addAll(getContactsCursors());
|
||||
}
|
||||
|
||||
if (NumberUtil.isValidSmsOrEmail(filter)) {
|
||||
cursorList.add(getNewNumberCursor());
|
||||
}
|
||||
|
||||
return cursorList;
|
||||
}
|
||||
|
||||
|
@ -1106,8 +1106,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
|
||||
if (recipient == null || attachmentManager == null) { return; }
|
||||
|
||||
boolean isMediaMessage = recipient.isMmsGroupRecipient() || attachmentManager.isAttachmentPresent();
|
||||
|
||||
/* Loki - We don't support SMS
|
||||
if (!isSecureText && !isPushGroupConversation()) sendButton.disableTransport(Type.TEXTSECURE);
|
||||
if (recipient.isPushGroupRecipient()) sendButton.disableTransport(Type.SMS);
|
||||
|
@ -123,28 +123,6 @@ public class GroupDatabase extends Database implements LokiOpenGroupDatabaseProt
|
||||
return new Reader(cursor);
|
||||
}
|
||||
|
||||
// This function always creates a mms group
|
||||
public String getOrCreateGroupForMembers(List<Address> members, List<Address> admins) {
|
||||
Collections.sort(members);
|
||||
Collections.sort(admins);
|
||||
|
||||
Cursor cursor = databaseHelper.getReadableDatabase().query(TABLE_NAME, new String[] {GROUP_ID},
|
||||
MEMBERS + " = ? AND " + MMS + " = ?",
|
||||
new String[] {Address.toSerializedList(members, ','), "1"},
|
||||
null, null, null);
|
||||
try {
|
||||
if (cursor != null && cursor.moveToNext()) {
|
||||
return cursor.getString(cursor.getColumnIndexOrThrow(GROUP_ID));
|
||||
} else {
|
||||
String groupId = GroupUtil.getEncodedMMSGroupID(allocateGroupId());
|
||||
create(groupId, null, members, null, null, admins, System.currentTimeMillis());
|
||||
return groupId;
|
||||
}
|
||||
} finally {
|
||||
if (cursor != null) cursor.close();
|
||||
}
|
||||
}
|
||||
|
||||
public Reader getGroups() {
|
||||
@SuppressLint("Recycle")
|
||||
Cursor cursor = databaseHelper.getReadableDatabase().query(TABLE_NAME, null, null, null, null, null, null);
|
||||
@ -210,7 +188,7 @@ public class GroupDatabase extends Database implements LokiOpenGroupDatabaseProt
|
||||
contentValues.put(AVATAR_RELAY, relay);
|
||||
contentValues.put(TIMESTAMP, formationTimestamp);
|
||||
contentValues.put(ACTIVE, 1);
|
||||
contentValues.put(MMS, GroupUtil.isMmsGroup(groupId));
|
||||
contentValues.put(MMS, false);
|
||||
|
||||
if (admins != null) {
|
||||
contentValues.put(ADMINS, Address.toSerializedList(admins, ','));
|
||||
|
@ -25,8 +25,6 @@ class Address private constructor(address: String) : Parcelable, Comparable<Addr
|
||||
get() = GroupUtil.isClosedGroup(address)
|
||||
val isOpenGroup: Boolean
|
||||
get() = GroupUtil.isOpenGroup(address)
|
||||
val isMmsGroup: Boolean
|
||||
get() = GroupUtil.isMmsGroup(address)
|
||||
val isContact: Boolean
|
||||
get() = !isGroup
|
||||
|
||||
|
@ -6,10 +6,10 @@ import java.io.IOException
|
||||
import java.util.*
|
||||
|
||||
class GroupRecord(
|
||||
val encodedId: String, val title: String, members: String?, val avatar: ByteArray?,
|
||||
val avatarId: Long?, val avatarKey: ByteArray?, val avatarContentType: String?,
|
||||
val relay: String?, val isActive: Boolean, val avatarDigest: ByteArray?, val isMms: Boolean,
|
||||
val url: String?, admins: String?, val formationTimestamp: Long
|
||||
val encodedId: String, val title: String, members: String?, val avatar: ByteArray?,
|
||||
val avatarId: Long?, val avatarKey: ByteArray?, val avatarContentType: String?,
|
||||
val relay: String?, val isActive: Boolean, val avatarDigest: ByteArray?, val isMms: Boolean,
|
||||
val url: String?, admins: String?, val formationTimestamp: Long
|
||||
) {
|
||||
var members: List<Address> = LinkedList<Address>()
|
||||
var admins: List<Address> = LinkedList<Address>()
|
||||
|
@ -289,7 +289,7 @@ public class Recipient implements RecipientModifiedListener {
|
||||
String displayName = MessagingModuleConfiguration.shared.getStorage().getDisplayName(this.address.toString());
|
||||
if (displayName != null) { return displayName; }
|
||||
|
||||
if (this.name == null && isMmsGroupRecipient()) {
|
||||
if (this.name == null && isGroupRecipient()) {
|
||||
List<String> names = new LinkedList<>();
|
||||
|
||||
for (Recipient recipient : participants) {
|
||||
@ -408,12 +408,8 @@ public class Recipient implements RecipientModifiedListener {
|
||||
return address.isOpenGroup();
|
||||
}
|
||||
|
||||
public boolean isMmsGroupRecipient() {
|
||||
return address.isMmsGroup();
|
||||
}
|
||||
|
||||
public boolean isPushGroupRecipient() {
|
||||
return address.isGroup() && !address.isMmsGroup();
|
||||
return address.isGroup();
|
||||
}
|
||||
|
||||
public @NonNull synchronized List<Recipient> getParticipants() {
|
||||
@ -593,7 +589,6 @@ public class Recipient implements RecipientModifiedListener {
|
||||
|
||||
public synchronized RegisteredState getRegistered() {
|
||||
if (isPushGroupRecipient()) return RegisteredState.REGISTERED;
|
||||
else if (isMmsGroupRecipient()) return RegisteredState.NOT_REGISTERED;
|
||||
|
||||
return registered;
|
||||
}
|
||||
|
@ -148,10 +148,6 @@ class RecipientProvider {
|
||||
members.add(getRecipient(context, memberAddress, Optional.absent(), Optional.absent(), asynchronous));
|
||||
}
|
||||
|
||||
if (!groupId.isMmsGroup() && title == null) {
|
||||
title = context.getString(R.string.RecipientProvider_unnamed_group);
|
||||
}
|
||||
|
||||
if (groupRecord.get().getAvatar() != null && groupRecord.get().getAvatar().length > 0) {
|
||||
avatarId = groupRecord.get().getAvatarId();
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import nl.komponents.kovenant.*
|
||||
import nl.komponents.kovenant.functional.bind
|
||||
import nl.komponents.kovenant.functional.map
|
||||
import org.session.libsession.messaging.utilities.MessageWrapper
|
||||
import org.session.libsession.snode.utilities.getRandomElement
|
||||
import org.session.libsignal.crypto.getRandomElement
|
||||
import org.session.libsignal.protos.SignalServiceProtos
|
||||
import org.session.libsignal.utilities.Snode
|
||||
import org.session.libsignal.utilities.HTTP
|
||||
|
@ -1,19 +0,0 @@
|
||||
package org.session.libsession.snode.utilities
|
||||
|
||||
import java.security.SecureRandom
|
||||
|
||||
/**
|
||||
* Uses `SecureRandom` to pick an element from this collection.
|
||||
*/
|
||||
fun <T> Collection<T>.getRandomElementOrNull(): T? {
|
||||
if (isEmpty()) return null
|
||||
val index = SecureRandom().nextInt(size) // SecureRandom() should be cryptographically secure
|
||||
return elementAtOrNull(index)
|
||||
}
|
||||
|
||||
/**
|
||||
* Uses `SecureRandom` to pick an element from this collection.
|
||||
*/
|
||||
fun <T> Collection<T>.getRandomElement(): T {
|
||||
return getRandomElementOrNull()!!
|
||||
}
|
@ -7,7 +7,6 @@ import kotlin.jvm.Throws
|
||||
|
||||
object GroupUtil {
|
||||
const val CLOSED_GROUP_PREFIX = "__textsecure_group__!"
|
||||
const val MMS_GROUP_PREFIX = "__signal_mms_group__!"
|
||||
const val OPEN_GROUP_PREFIX = "__loki_public_chat_group__!"
|
||||
|
||||
@JvmStatic
|
||||
@ -20,11 +19,6 @@ object GroupUtil {
|
||||
return CLOSED_GROUP_PREFIX + Hex.toStringCondensed(groupID)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getEncodedMMSGroupID(groupID: ByteArray): String {
|
||||
return MMS_GROUP_PREFIX + Hex.toStringCondensed(groupID)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getEncodedId(group: SignalServiceGroup): String {
|
||||
val groupId = group.groupId
|
||||
@ -52,12 +46,7 @@ object GroupUtil {
|
||||
}
|
||||
|
||||
fun isEncodedGroup(groupId: String): Boolean {
|
||||
return groupId.startsWith(CLOSED_GROUP_PREFIX) || groupId.startsWith(MMS_GROUP_PREFIX) || groupId.startsWith(OPEN_GROUP_PREFIX)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun isMmsGroup(groupId: String): Boolean {
|
||||
return groupId.startsWith(MMS_GROUP_PREFIX)
|
||||
return groupId.startsWith(CLOSED_GROUP_PREFIX) || groupId.startsWith(OPEN_GROUP_PREFIX)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
|
@ -53,8 +53,8 @@ object KeyPairUtilities {
|
||||
}
|
||||
|
||||
data class KeyPairGenerationResult(
|
||||
val seed: ByteArray,
|
||||
val ed25519KeyPair: KeyPair,
|
||||
val x25519KeyPair: ECKeyPair
|
||||
val seed: ByteArray,
|
||||
val ed25519KeyPair: KeyPair,
|
||||
val x25519KeyPair: ECKeyPair
|
||||
)
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
package org.session.libsession.utilities
|
||||
|
||||
import android.telephony.PhoneNumberUtils
|
||||
import android.util.Patterns
|
||||
|
||||
object NumberUtil {
|
||||
private val emailPattern = Patterns.EMAIL_ADDRESS
|
||||
|
||||
@JvmStatic
|
||||
fun isValidEmail(number: String): Boolean {
|
||||
val matcher = emailPattern.matcher(number)
|
||||
return matcher.matches()
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun isValidSmsOrEmail(number: String): Boolean {
|
||||
return PhoneNumberUtils.isWellFormedSmsAddress(number) || isValidEmail(number)
|
||||
}
|
||||
}
|
@ -7,11 +7,11 @@ import org.session.libsession.messaging.threads.Address
|
||||
import org.session.libsession.messaging.threads.recipients.Recipient
|
||||
|
||||
class SSKEnvironment(
|
||||
val typingIndicators: TypingIndicatorsProtocol,
|
||||
val readReceiptManager: ReadReceiptManagerProtocol,
|
||||
val profileManager: ProfileManagerProtocol,
|
||||
val notificationManager: MessageNotifier,
|
||||
val messageExpirationManager: MessageExpirationManagerProtocol
|
||||
val typingIndicators: TypingIndicatorsProtocol,
|
||||
val readReceiptManager: ReadReceiptManagerProtocol,
|
||||
val profileManager: ProfileManagerProtocol,
|
||||
val notificationManager: MessageNotifier,
|
||||
val messageExpirationManager: MessageExpirationManagerProtocol
|
||||
) {
|
||||
|
||||
interface TypingIndicatorsProtocol {
|
||||
|
Loading…
x
Reference in New Issue
Block a user