diff --git a/app/src/main/java/org/thoughtcrime/securesms/loki/protocol/ClosedGroupUpdateMessageSendJobV2.kt b/app/src/main/java/org/thoughtcrime/securesms/loki/protocol/ClosedGroupUpdateMessageSendJobV2.kt index 896364f409..ba692a041e 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/loki/protocol/ClosedGroupUpdateMessageSendJobV2.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/loki/protocol/ClosedGroupUpdateMessageSendJobV2.kt @@ -6,6 +6,8 @@ import kotlinx.serialization.decodeFromString import kotlinx.serialization.encodeToString import kotlinx.serialization.json.Json 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.DjbECPublicKey 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.jobs.BaseJob import org.session.libsignal.utilities.logging.Log -import org.thoughtcrime.securesms.loki.utilities.recipient import org.session.libsignal.utilities.Hex import java.util.concurrent.TimeUnit @@ -228,7 +229,7 @@ class ClosedGroupUpdateMessageSendJobV2 private constructor(parameters: Paramete val serializedContentMessage = contentMessage.build().toByteArray() val messageSender = ApplicationContext.getInstance(context).communicationModule.provideSignalMessageSender() 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 ttl = when (kind) { is Kind.EncryptionKeyPair -> 4 * 24 * 60 * 60 * 1000 diff --git a/app/src/main/java/org/thoughtcrime/securesms/loki/protocol/MultiDeviceProtocol.kt b/app/src/main/java/org/thoughtcrime/securesms/loki/protocol/MultiDeviceProtocol.kt index e921f08062..5fdd20210b 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/loki/protocol/MultiDeviceProtocol.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/loki/protocol/MultiDeviceProtocol.kt @@ -4,6 +4,8 @@ import android.content.Context import com.google.protobuf.ByteString import org.session.libsession.messaging.MessagingConfiguration 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.libsignal.libsignal.util.guava.Optional 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.crypto.UnidentifiedAccessUtil import org.thoughtcrime.securesms.loki.utilities.OpenGroupUtilities -import org.thoughtcrime.securesms.loki.utilities.recipient import java.util.* object MultiDeviceProtocol { @@ -31,7 +32,7 @@ object MultiDeviceProtocol { val serializedMessage = configurationMessage.toProto()!!.toByteArray() val messageSender = ApplicationContext.getInstance(context).communicationModule.provideSignalMessageSender() val address = SignalServiceAddress(userPublicKey) - val recipient = recipient(context, userPublicKey) + val recipient = Recipient.from(context, Address.fromSerialized(userPublicKey), false) val udAccess = UnidentifiedAccessUtil.getAccessFor(context, recipient) try { messageSender.sendMessage(0, address, udAccess, @@ -50,7 +51,7 @@ object MultiDeviceProtocol { val serializedMessage = configurationMessage.toProto()!!.toByteArray() val messageSender = ApplicationContext.getInstance(context).communicationModule.provideSignalMessageSender() val address = SignalServiceAddress(userPublicKey) - val recipient = recipient(context, userPublicKey) + val recipient = Recipient.from(context, Address.fromSerialized(userPublicKey), false) val udAccess = UnidentifiedAccessUtil.getAccessFor(context, recipient) try { messageSender.sendMessage(0, address, udAccess, diff --git a/app/src/main/java/org/thoughtcrime/securesms/loki/utilities/GeneralUtilities.kt b/app/src/main/java/org/thoughtcrime/securesms/loki/utilities/GeneralUtilities.kt index 37bc30c395..6bb7a7a9e0 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/loki/utilities/GeneralUtilities.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/loki/utilities/GeneralUtilities.kt @@ -1,10 +1,8 @@ package org.thoughtcrime.securesms.loki.utilities -import android.content.Context import android.content.res.Resources import android.os.Build import androidx.annotation.ColorRes -import org.thoughtcrime.securesms.database.DatabaseFactory import kotlin.math.roundToInt fun Resources.getColorWithID(@ColorRes id: Int, theme: Resources.Theme?): Int { diff --git a/app/src/main/java/org/thoughtcrime/securesms/loki/utilities/MnemonicUtilities.kt b/app/src/main/java/org/thoughtcrime/securesms/loki/utilities/MnemonicUtilities.kt index 948eaa16b9..27a2a78cfc 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/loki/utilities/MnemonicUtilities.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/loki/utilities/MnemonicUtilities.kt @@ -16,9 +16,4 @@ object MnemonicUtilities { inputStream.close() return String(buffer) } - - @JvmStatic - public fun getFirst3Words(codec: MnemonicCodec, hexEncodedPublicKey: String): String { - return codec.encode(hexEncodedPublicKey.removing05PrefixIfNeeded()).split(" ").slice(0 until 3).joinToString(" ") - } } \ No newline at end of file diff --git a/app/src/main/java/org/thoughtcrime/securesms/loki/utilities/RecipientUtilities.kt b/app/src/main/java/org/thoughtcrime/securesms/loki/utilities/RecipientUtilities.kt deleted file mode 100644 index 18a5f44096..0000000000 --- a/app/src/main/java/org/thoughtcrime/securesms/loki/utilities/RecipientUtilities.kt +++ /dev/null @@ -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) -} \ No newline at end of file diff --git a/app/src/main/java/org/thoughtcrime/securesms/loki/views/TapJacking.kt b/app/src/main/java/org/thoughtcrime/securesms/loki/views/TapJacking.kt deleted file mode 100644 index 516b7654f6..0000000000 --- a/app/src/main/java/org/thoughtcrime/securesms/loki/views/TapJacking.kt +++ /dev/null @@ -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) - } - } -} \ No newline at end of file