From bbb1b2b5170a59921167fae04790d34d123225a8 Mon Sep 17 00:00:00 2001 From: ThomasSession Date: Thu, 4 Jul 2024 17:50:17 +1000 Subject: [PATCH 1/6] Fix issue with span being the full length (#1528) --- .../securesms/util/RoundedBackgroundSpan.kt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/util/RoundedBackgroundSpan.kt b/app/src/main/java/org/thoughtcrime/securesms/util/RoundedBackgroundSpan.kt index ebefc9c50c..a4cf1b1e96 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/util/RoundedBackgroundSpan.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/util/RoundedBackgroundSpan.kt @@ -1,7 +1,6 @@ package org.thoughtcrime.securesms.util import android.content.Context -import android.content.res.Resources import android.graphics.Canvas import android.graphics.Paint import android.graphics.RectF @@ -50,6 +49,17 @@ class RoundedBackgroundSpan( override fun getSize( paint: Paint, text: CharSequence?, start: Int, end: Int, fm: Paint.FontMetricsInt? ): Int { + // If the span covers the whole text, and the height is not set, draw() will not be called for the span. + // To help with that we need to take the font metric into account + val metrics = paint.fontMetricsInt + if (fm != null) { + fm.top = metrics.top + fm.ascent = metrics.ascent + fm.descent = metrics.descent + + fm.bottom = metrics.bottom + } + return (paint.measureText(text, start, end) + 2 * paddingHorizontal).toInt() } From 15b3b18321211a0d03e90d90362b31ba0683d467 Mon Sep 17 00:00:00 2001 From: ThomasSession Date: Fri, 5 Jul 2024 10:48:51 +1000 Subject: [PATCH 2/6] Proper display of unresolved names in mentions (#1530) * Fix issue with span being the full length * Making sure a mention with a username without a resolved name still displayed with the appropriate style with the truncated is --- .../securesms/conversation/v2/utilities/MentionUtilities.kt | 3 ++- .../src/main/java/org/session/libsession/utilities/IdUtil.kt | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/utilities/MentionUtilities.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/utilities/MentionUtilities.kt index 3edfcffc97..3a4bfd6816 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/utilities/MentionUtilities.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/utilities/MentionUtilities.kt @@ -18,6 +18,7 @@ import org.session.libsession.messaging.utilities.SodiumUtilities import org.session.libsession.utilities.TextSecurePreferences import org.session.libsession.utilities.ThemeUtil import org.session.libsession.utilities.getColorFromAttr +import org.session.libsession.utilities.truncateIdForDisplay import org.thoughtcrime.securesms.dependencies.DatabaseComponent import org.thoughtcrime.securesms.util.RoundedBackgroundSpan import org.thoughtcrime.securesms.util.getAccentColor @@ -67,7 +68,7 @@ object MentionUtilities { } else { val contact = DatabaseComponent.get(context).sessionContactDatabase().getContactWithSessionID(publicKey) @Suppress("NAME_SHADOWING") val context = if (openGroup != null) Contact.ContactContext.OPEN_GROUP else Contact.ContactContext.REGULAR - contact?.displayName(context) + contact?.displayName(context) ?: truncateIdForDisplay(publicKey) } if (userDisplayName != null) { val mention = "@$userDisplayName" diff --git a/libsession/src/main/java/org/session/libsession/utilities/IdUtil.kt b/libsession/src/main/java/org/session/libsession/utilities/IdUtil.kt index ccaa31c2f9..1902b6e0ab 100644 --- a/libsession/src/main/java/org/session/libsession/utilities/IdUtil.kt +++ b/libsession/src/main/java/org/session/libsession/utilities/IdUtil.kt @@ -1,4 +1,4 @@ package org.session.libsession.utilities fun truncateIdForDisplay(id: String): String = - id.takeIf { it.length > 8 }?.apply{ "${take(4)}…${takeLast(4)}" } ?: id + id.takeIf { it.length > 8 }?.run{ "${take(4)}…${takeLast(4)}" } ?: id From e1f1372e17e57f4a00e95679cef41a3540a55408 Mon Sep 17 00:00:00 2001 From: Fanchao Liu <273191+simophin@users.noreply.github.com> Date: Mon, 8 Jul 2024 10:34:13 +1000 Subject: [PATCH 3/6] Testnet build (#1532) Co-authored-by: fanchao --- .../src/main/java/org/session/libsession/snode/SnodeAPI.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsession/src/main/java/org/session/libsession/snode/SnodeAPI.kt b/libsession/src/main/java/org/session/libsession/snode/SnodeAPI.kt index d2cfa2de35..146630b7dd 100644 --- a/libsession/src/main/java/org/session/libsession/snode/SnodeAPI.kt +++ b/libsession/src/main/java/org/session/libsession/snode/SnodeAPI.kt @@ -86,7 +86,7 @@ object SnodeAPI { private const val snodeFailureThreshold = 3 private const val useOnionRequests = true - const val useTestnet = false + const val useTestnet = true // Error internal sealed class Error(val description: String) : Exception(description) { From 075341abe199c2f7a65d5234467259c9156a025d Mon Sep 17 00:00:00 2001 From: Fanchao Liu <273191+simophin@users.noreply.github.com> Date: Mon, 8 Jul 2024 11:24:37 +1000 Subject: [PATCH 4/6] Allow "public.loki.foundation" to be accessed by http (#1534) Co-authored-by: fanchao --- app/src/main/res/xml/network_security_configuration.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/res/xml/network_security_configuration.xml b/app/src/main/res/xml/network_security_configuration.xml index f3a7419b55..7469ebe106 100644 --- a/app/src/main/res/xml/network_security_configuration.xml +++ b/app/src/main/res/xml/network_security_configuration.xml @@ -2,6 +2,7 @@ 127.0.0.1 + public.loki.foundation seed1.getsession.org From 2b27b7d5e0ed0c2593b68b272dbf7d37bc7c07ef Mon Sep 17 00:00:00 2001 From: ThomasSession Date: Tue, 9 Jul 2024 09:33:06 +1000 Subject: [PATCH 5/6] Bumping the version code and name --- app/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index aa3ad4e779..2e52adddd5 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -31,8 +31,8 @@ configurations.all { exclude module: "commons-logging" } -def canonicalVersionCode = 373 -def canonicalVersionName = "1.18.4" +def canonicalVersionCode = 374 +def canonicalVersionName = "1.18.5" def postFixSize = 10 def abiPostFix = ['armeabi-v7a' : 1, From 0300be25f6c63efa799011c85bd290084f0af03d Mon Sep 17 00:00:00 2001 From: ThomasSession Date: Tue, 9 Jul 2024 09:58:49 +1000 Subject: [PATCH 6/6] Reverting temporary change --- .../src/main/java/org/session/libsession/snode/SnodeAPI.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsession/src/main/java/org/session/libsession/snode/SnodeAPI.kt b/libsession/src/main/java/org/session/libsession/snode/SnodeAPI.kt index 146630b7dd..d2cfa2de35 100644 --- a/libsession/src/main/java/org/session/libsession/snode/SnodeAPI.kt +++ b/libsession/src/main/java/org/session/libsession/snode/SnodeAPI.kt @@ -86,7 +86,7 @@ object SnodeAPI { private const val snodeFailureThreshold = 3 private const val useOnionRequests = true - const val useTestnet = true + const val useTestnet = false // Error internal sealed class Error(val description: String) : Exception(description) {