Remove duplicated/unused code
parent
918e1ea3cf
commit
ab83e49f93
@ -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()!!
|
|
||||||
}
|
|
@ -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)
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue