From e7608763a052405d83c48da3fef6846ee22804a3 Mon Sep 17 00:00:00 2001 From: hjubb Date: Fri, 14 Jul 2023 18:47:10 +1000 Subject: [PATCH] fix: tests pass with forcing config --- .../java/network/loki/messenger/LibSessionTests.kt | 5 +++++ .../securesms/conversation/v2/ConversationActivityV2.kt | 3 --- .../securesms/conversation/v2/dialogs/BlockedDialog.kt | 7 ++----- .../thoughtcrime/securesms/dependencies/ConfigFactory.kt | 2 +- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/app/src/androidTest/java/network/loki/messenger/LibSessionTests.kt b/app/src/androidTest/java/network/loki/messenger/LibSessionTests.kt index 1638d83835..59cb8ede08 100644 --- a/app/src/androidTest/java/network/loki/messenger/LibSessionTests.kt +++ b/app/src/androidTest/java/network/loki/messenger/LibSessionTests.kt @@ -1,5 +1,7 @@ package network.loki.messenger +import androidx.core.content.edit +import androidx.preference.PreferenceManager import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import androidx.test.platform.app.InstrumentationRegistry @@ -62,6 +64,9 @@ class LibSessionTests { @Before fun setupUser() { + PreferenceManager.getDefaultSharedPreferences(InstrumentationRegistry.getInstrumentation().targetContext.applicationContext).edit { + putBoolean(TextSecurePreferences.HAS_FORCED_NEW_CONFIG, true).apply() + } val newBytes = randomSeedBytes().toByteArray() val context = InstrumentationRegistry.getInstrumentation().targetContext.applicationContext val kp = KeyPairUtilities.generate(newBytes) diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt index 7b742a9be9..e7b1945498 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt @@ -6,7 +6,6 @@ import android.animation.ValueAnimator import android.content.ClipData import android.content.ClipboardManager import android.content.Context -import android.content.DialogInterface import android.content.Intent import android.content.res.Resources import android.database.Cursor @@ -36,7 +35,6 @@ import android.widget.RelativeLayout import android.widget.Toast import androidx.activity.viewModels import androidx.annotation.DimenRes -import androidx.appcompat.app.AlertDialog import androidx.core.text.set import androidx.core.text.toSpannable import androidx.core.view.drawToBitmap @@ -123,7 +121,6 @@ import org.thoughtcrime.securesms.conversation.v2.messages.VisibleMessageViewDel import org.thoughtcrime.securesms.conversation.v2.search.SearchBottomBar import org.thoughtcrime.securesms.conversation.v2.search.SearchViewModel import org.thoughtcrime.securesms.conversation.v2.utilities.AttachmentManager -import org.thoughtcrime.securesms.conversation.v2.utilities.BaseDialog import org.thoughtcrime.securesms.conversation.v2.utilities.MentionManagerUtilities import org.thoughtcrime.securesms.conversation.v2.utilities.MentionUtilities import org.thoughtcrime.securesms.conversation.v2.utilities.ResendMessageUtilities diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/dialogs/BlockedDialog.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/dialogs/BlockedDialog.kt index 7479c4a9ed..c0ff1cbb1d 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/dialogs/BlockedDialog.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/dialogs/BlockedDialog.kt @@ -1,22 +1,19 @@ package org.thoughtcrime.securesms.conversation.v2.dialogs -import android.content.Context import android.app.Dialog +import android.content.Context import android.graphics.Typeface import android.os.Bundle import android.text.Spannable import android.text.SpannableStringBuilder import android.text.style.StyleSpan -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import androidx.fragment.app.DialogFragment import network.loki.messenger.R +import org.session.libsession.messaging.MessagingModuleConfiguration import org.session.libsession.messaging.contacts.Contact import org.session.libsession.utilities.recipients.Recipient import org.thoughtcrime.securesms.createSessionDialog import org.thoughtcrime.securesms.dependencies.DatabaseComponent -import org.thoughtcrime.securesms.util.ConfigurationMessageUtilities /** Shown upon sending a message to a user that's blocked. */ class BlockedDialog(private val recipient: Recipient, private val context: Context) : DialogFragment() { diff --git a/app/src/main/java/org/thoughtcrime/securesms/dependencies/ConfigFactory.kt b/app/src/main/java/org/thoughtcrime/securesms/dependencies/ConfigFactory.kt index 48eda45001..d664ffedb2 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/dependencies/ConfigFactory.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/dependencies/ConfigFactory.kt @@ -50,7 +50,7 @@ class ConfigFactory( private val userGroupsLock = Object() private var _userGroups: UserGroupsConfig? = null - private val isConfigForcedOn = TextSecurePreferences.hasForcedNewConfig(context) + private val isConfigForcedOn by lazy { TextSecurePreferences.hasForcedNewConfig(context) } private val listeners: MutableList = mutableListOf() fun registerListener(listener: ConfigFactoryUpdateListener) {