diff --git a/app/build.gradle b/app/build.gradle index da14a10dae..12d86f303d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -72,7 +72,7 @@ android { } composeOptions { - kotlinCompilerExtensionVersion '1.5.14' + kotlinCompilerExtensionVersion '1.5.15' } defaultConfig { @@ -359,15 +359,21 @@ dependencies { testImplementation 'org.conscrypt:conscrypt-openjdk-uber:2.5.2' // For Robolectric testImplementation 'app.cash.turbine:turbine:1.1.0' - implementation 'com.github.bumptech.glide:compose:1.0.0-alpha.5' - implementation "androidx.compose.ui:ui:$composeVersion" - implementation "androidx.compose.animation:animation:$composeVersion" - implementation "androidx.compose.ui:ui-tooling:$composeVersion" - implementation "androidx.compose.runtime:runtime-livedata:$composeVersion" - implementation "androidx.compose.foundation:foundation-layout:$composeVersion" - implementation "androidx.compose.material3:material3:1.2.1" - androidTestImplementation "androidx.compose.ui:ui-test-junit4-android:$composeVersion" - debugImplementation "androidx.compose.ui:ui-test-manifest:$composeVersion" + // compose + Dependency composeBom = platform('androidx.compose:compose-bom:2024.09.01') + implementation composeBom + testImplementation composeBom + androidTestImplementation composeBom + + implementation "androidx.compose.ui:ui" + implementation "androidx.compose.animation:animation" + implementation "androidx.compose.ui:ui-tooling" + implementation "androidx.compose.runtime:runtime-livedata" + implementation "androidx.compose.foundation:foundation-layout" + implementation "androidx.compose.material3:material3" + + androidTestImplementation "androidx.compose.ui:ui-test-junit4-android" + debugImplementation "androidx.compose.ui:ui-test-manifest" // Navigation implementation "androidx.navigation:navigation-fragment-ktx:$navVersion" diff --git a/app/src/main/java/org/thoughtcrime/securesms/debugmenu/DebugMenu.kt b/app/src/main/java/org/thoughtcrime/securesms/debugmenu/DebugMenu.kt index f277d1f40b..38a01a9db4 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/debugmenu/DebugMenu.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/debugmenu/DebugMenu.kt @@ -149,9 +149,11 @@ fun ColumnScope.DebugCell( ) { Spacer(modifier = Modifier.height(LocalDimensions.current.smallSpacing)) - Cell { + Cell( + modifier = modifier + ) { Column( - modifier = modifier.padding(LocalDimensions.current.spacing) + modifier = Modifier.padding(LocalDimensions.current.spacing) ) { Text( text = title, diff --git a/app/src/main/java/org/thoughtcrime/securesms/ui/components/Html.kt b/app/src/main/java/org/thoughtcrime/securesms/ui/components/AnnotatedString.kt similarity index 81% rename from app/src/main/java/org/thoughtcrime/securesms/ui/components/Html.kt rename to app/src/main/java/org/thoughtcrime/securesms/ui/components/AnnotatedString.kt index 15f0292853..68587bc9e1 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/ui/components/Html.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/ui/components/AnnotatedString.kt @@ -3,8 +3,16 @@ package org.thoughtcrime.securesms.ui.components import android.content.res.Resources import android.graphics.Typeface import android.text.Spanned -import android.text.SpannedString -import android.text.style.* +import android.text.style.AbsoluteSizeSpan +import android.text.style.BulletSpan +import android.text.style.ForegroundColorSpan +import android.text.style.RelativeSizeSpan +import android.text.style.StrikethroughSpan +import android.text.style.StyleSpan +import android.text.style.SubscriptSpan +import android.text.style.SuperscriptSpan +import android.text.style.TypefaceSpan +import android.text.style.UnderlineSpan import android.util.Log import androidx.annotation.StringRes import androidx.compose.runtime.Composable @@ -14,7 +22,6 @@ import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.LocalConfiguration import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalDensity -import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.AnnotatedString import androidx.compose.ui.text.SpanStyle import androidx.compose.ui.text.buildAnnotatedString @@ -26,13 +33,9 @@ import androidx.compose.ui.text.style.TextDecoration import androidx.compose.ui.unit.Density import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.em -import androidx.core.text.HtmlCompat -import com.squareup.phrase.Phrase -import network.loki.messenger.R -import org.session.libsession.utilities.StringSubstitutionConstants.URL_KEY -// TODO Remove this file once we update to composeVersion=1.7.0-alpha06 fixes https://issuetracker.google.com/issues/139320238?pli=1 -// which allows Stylized string in string resources +// Utilities for AnnotatedStrings, +// like converting the old view system's SpannableString to AnnotatedString @Composable @ReadOnlyComposable private fun resources(): Resources { @@ -40,31 +43,6 @@ private fun resources(): Resources { return LocalContext.current.resources } -fun Spanned.toHtmlWithoutParagraphs(): String { - return HtmlCompat.toHtml(this, HtmlCompat.TO_HTML_PARAGRAPH_LINES_CONSECUTIVE) - .substringAfter("
").substringBeforeLast("
") -} - -fun Resources.getText(@StringRes id: Int, vararg args: Any): CharSequence { - val escapedArgs = args.map { - if (it is Spanned) it.toHtmlWithoutParagraphs() else it - }.toTypedArray() - val resource = SpannedString(getText(id)) - val htmlResource = resource.toHtmlWithoutParagraphs() - val formattedHtml = String.format(htmlResource, *escapedArgs) - return HtmlCompat.fromHtml(formattedHtml, HtmlCompat.FROM_HTML_MODE_LEGACY) -} - -@Composable -fun annotatedStringResource(@StringRes id: Int, vararg formatArgs: Any): AnnotatedString { - val resources = resources() - val density = LocalDensity.current - return remember(id, formatArgs) { - val text = resources.getText(id, *formatArgs) - spannableStringToAnnotatedString(text, density) - } -} - @Composable fun annotatedStringResource(@StringRes id: Int): AnnotatedString { val resources = resources() diff --git a/gradle.properties b/gradle.properties index c9e5939450..082ca709a2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -24,7 +24,6 @@ navVersion=2.8.0-beta05 android.useAndroidX=true appcompatVersion=1.6.1 coreVersion=1.13.1 -composeVersion=1.6.8 coroutinesVersion=1.6.4 curve25519Version=0.6.0 jetpackHiltVersion=1.2.0