mirror of
https://github.com/oxen-io/session-android.git
synced 2025-08-12 10:37:44 +00:00
Remove duplicated/unused code
This commit is contained in:
@@ -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 {
|
||||
|
Reference in New Issue
Block a user