clean up unused loki stuff

This commit is contained in:
Ryan ZHAO 2021-02-23 12:11:45 +11:00
parent c931155e83
commit fc62fe3b23
6 changed files with 7 additions and 100 deletions

View File

@ -6,6 +6,8 @@ import kotlinx.serialization.decodeFromString
import kotlinx.serialization.encodeToString import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json import kotlinx.serialization.json.Json
import org.session.libsession.messaging.jobs.Data import org.session.libsession.messaging.jobs.Data
import org.session.libsession.messaging.threads.Address
import org.session.libsession.messaging.threads.recipients.Recipient
import org.session.libsignal.libsignal.ecc.DjbECPrivateKey import org.session.libsignal.libsignal.ecc.DjbECPrivateKey
import org.session.libsignal.libsignal.ecc.DjbECPublicKey import org.session.libsignal.libsignal.ecc.DjbECPublicKey
import org.session.libsignal.libsignal.ecc.ECKeyPair import org.session.libsignal.libsignal.ecc.ECKeyPair
@ -22,7 +24,6 @@ import org.thoughtcrime.securesms.jobmanager.Job
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint
import org.thoughtcrime.securesms.jobs.BaseJob import org.thoughtcrime.securesms.jobs.BaseJob
import org.session.libsignal.utilities.logging.Log import org.session.libsignal.utilities.logging.Log
import org.thoughtcrime.securesms.loki.utilities.recipient
import org.session.libsignal.utilities.Hex import org.session.libsignal.utilities.Hex
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
@ -228,7 +229,7 @@ class ClosedGroupUpdateMessageSendJobV2 private constructor(parameters: Paramete
val serializedContentMessage = contentMessage.build().toByteArray() val serializedContentMessage = contentMessage.build().toByteArray()
val messageSender = ApplicationContext.getInstance(context).communicationModule.provideSignalMessageSender() val messageSender = ApplicationContext.getInstance(context).communicationModule.provideSignalMessageSender()
val address = SignalServiceAddress(sendDestination) val address = SignalServiceAddress(sendDestination)
val recipient = recipient(context, sendDestination) val recipient = Recipient.from(context, Address.fromSerialized(sendDestination), false)
val udAccess = UnidentifiedAccessUtil.getAccessFor(context, recipient) val udAccess = UnidentifiedAccessUtil.getAccessFor(context, recipient)
val ttl = when (kind) { val ttl = when (kind) {
is Kind.EncryptionKeyPair -> 4 * 24 * 60 * 60 * 1000 is Kind.EncryptionKeyPair -> 4 * 24 * 60 * 60 * 1000

View File

@ -4,6 +4,8 @@ import android.content.Context
import com.google.protobuf.ByteString import com.google.protobuf.ByteString
import org.session.libsession.messaging.MessagingConfiguration import org.session.libsession.messaging.MessagingConfiguration
import org.session.libsession.messaging.messages.control.ConfigurationMessage import org.session.libsession.messaging.messages.control.ConfigurationMessage
import org.session.libsession.messaging.threads.Address
import org.session.libsession.messaging.threads.recipients.Recipient
import org.session.libsession.utilities.TextSecurePreferences import org.session.libsession.utilities.TextSecurePreferences
import org.session.libsignal.libsignal.util.guava.Optional import org.session.libsignal.libsignal.util.guava.Optional
import org.session.libsignal.service.api.push.SignalServiceAddress import org.session.libsignal.service.api.push.SignalServiceAddress
@ -15,7 +17,6 @@ import org.session.libsignal.utilities.logging.Log
import org.thoughtcrime.securesms.ApplicationContext import org.thoughtcrime.securesms.ApplicationContext
import org.thoughtcrime.securesms.crypto.UnidentifiedAccessUtil import org.thoughtcrime.securesms.crypto.UnidentifiedAccessUtil
import org.thoughtcrime.securesms.loki.utilities.OpenGroupUtilities import org.thoughtcrime.securesms.loki.utilities.OpenGroupUtilities
import org.thoughtcrime.securesms.loki.utilities.recipient
import java.util.* import java.util.*
object MultiDeviceProtocol { object MultiDeviceProtocol {
@ -31,7 +32,7 @@ object MultiDeviceProtocol {
val serializedMessage = configurationMessage.toProto()!!.toByteArray() val serializedMessage = configurationMessage.toProto()!!.toByteArray()
val messageSender = ApplicationContext.getInstance(context).communicationModule.provideSignalMessageSender() val messageSender = ApplicationContext.getInstance(context).communicationModule.provideSignalMessageSender()
val address = SignalServiceAddress(userPublicKey) val address = SignalServiceAddress(userPublicKey)
val recipient = recipient(context, userPublicKey) val recipient = Recipient.from(context, Address.fromSerialized(userPublicKey), false)
val udAccess = UnidentifiedAccessUtil.getAccessFor(context, recipient) val udAccess = UnidentifiedAccessUtil.getAccessFor(context, recipient)
try { try {
messageSender.sendMessage(0, address, udAccess, messageSender.sendMessage(0, address, udAccess,
@ -50,7 +51,7 @@ object MultiDeviceProtocol {
val serializedMessage = configurationMessage.toProto()!!.toByteArray() val serializedMessage = configurationMessage.toProto()!!.toByteArray()
val messageSender = ApplicationContext.getInstance(context).communicationModule.provideSignalMessageSender() val messageSender = ApplicationContext.getInstance(context).communicationModule.provideSignalMessageSender()
val address = SignalServiceAddress(userPublicKey) val address = SignalServiceAddress(userPublicKey)
val recipient = recipient(context, userPublicKey) val recipient = Recipient.from(context, Address.fromSerialized(userPublicKey), false)
val udAccess = UnidentifiedAccessUtil.getAccessFor(context, recipient) val udAccess = UnidentifiedAccessUtil.getAccessFor(context, recipient)
try { try {
messageSender.sendMessage(0, address, udAccess, messageSender.sendMessage(0, address, udAccess,

View File

@ -1,10 +1,8 @@
package org.thoughtcrime.securesms.loki.utilities package org.thoughtcrime.securesms.loki.utilities
import android.content.Context
import android.content.res.Resources import android.content.res.Resources
import android.os.Build import android.os.Build
import androidx.annotation.ColorRes import androidx.annotation.ColorRes
import org.thoughtcrime.securesms.database.DatabaseFactory
import kotlin.math.roundToInt import kotlin.math.roundToInt
fun Resources.getColorWithID(@ColorRes id: Int, theme: Resources.Theme?): Int { fun Resources.getColorWithID(@ColorRes id: Int, theme: Resources.Theme?): Int {

View File

@ -16,9 +16,4 @@ object MnemonicUtilities {
inputStream.close() inputStream.close()
return String(buffer) return String(buffer)
} }
@JvmStatic
public fun getFirst3Words(codec: MnemonicCodec, hexEncodedPublicKey: String): String {
return codec.encode(hexEncodedPublicKey.removing05PrefixIfNeeded()).split(" ").slice(0 until 3).joinToString(" ")
}
} }

View File

@ -1,9 +0,0 @@
package org.thoughtcrime.securesms.loki.utilities
import android.content.Context
import org.session.libsession.messaging.threads.Address
import org.session.libsession.messaging.threads.recipients.Recipient
fun recipient(context: Context, publicKey: String): Recipient {
return Recipient.from(context, Address.fromSerialized(publicKey), false)
}

View File

@ -1,79 +0,0 @@
package org.thoughtcrime.securesms.loki.views
import android.content.Context
import android.util.AttributeSet
import android.view.MotionEvent
import android.widget.Button
import android.widget.LinearLayout
import android.widget.Toast
private fun isPotentialTapJack(event: MotionEvent): Boolean {
if (event.flags and MotionEvent.FLAG_WINDOW_IS_OBSCURED == MotionEvent.FLAG_WINDOW_IS_OBSCURED) { return true }
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.Q &&
(event.flags and MotionEvent.FLAG_WINDOW_IS_PARTIALLY_OBSCURED == MotionEvent.FLAG_WINDOW_IS_PARTIALLY_OBSCURED)) { return true }
return false
}
open class TapJackingProofButton : androidx.appcompat.widget.AppCompatButton {
constructor(context: Context) : super(context)
constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr)
override fun onFilterTouchEventForSecurity(event: MotionEvent): Boolean {
if (isPotentialTapJack(event)) {
Toast.makeText(context, "Interaction temporarily disabled for security purposes.", Toast.LENGTH_LONG).show()
return false
} else {
return super.onFilterTouchEventForSecurity(event)
}
}
}
open class TapJackingProofEditText : androidx.appcompat.widget.AppCompatEditText {
constructor(context: Context) : super(context)
constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr)
override fun onFilterTouchEventForSecurity(event: MotionEvent): Boolean {
if (isPotentialTapJack(event)) {
Toast.makeText(context, "Interaction temporarily disabled for security purposes.", Toast.LENGTH_LONG).show()
return false
} else {
return super.onFilterTouchEventForSecurity(event)
}
}
}
open class TapJackingProofTextView : androidx.appcompat.widget.AppCompatTextView {
constructor(context: Context) : super(context)
constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr)
override fun onFilterTouchEventForSecurity(event: MotionEvent): Boolean {
if (isPotentialTapJack(event)) {
Toast.makeText(context, "Interaction temporarily disabled for security purposes.", Toast.LENGTH_LONG).show()
return false
} else {
return super.onFilterTouchEventForSecurity(event)
}
}
}
open class TapJackingProofLinearLayout : LinearLayout {
constructor(context: Context) : super(context)
constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr)
override fun onFilterTouchEventForSecurity(event: MotionEvent): Boolean {
if (isPotentialTapJack(event)) {
Toast.makeText(context, "Interaction temporarily disabled for security purposes.", Toast.LENGTH_LONG).show()
return false
} else {
return super.onFilterTouchEventForSecurity(event)
}
}
}