Merge remote-tracking branch 'origin/dev' into closed_groups

# Conflicts:
#	gradle.properties
This commit is contained in:
SessionHero01 2024-09-12 09:39:26 +10:00
commit 952479a564
No known key found for this signature in database
4 changed files with 32 additions and 47 deletions

View File

@ -72,7 +72,7 @@ android {
} }
composeOptions { composeOptions {
kotlinCompilerExtensionVersion '1.5.14' kotlinCompilerExtensionVersion '1.5.15'
} }
defaultConfig { defaultConfig {
@ -359,15 +359,21 @@ dependencies {
testImplementation 'org.conscrypt:conscrypt-openjdk-uber:2.5.2' // For Robolectric testImplementation 'org.conscrypt:conscrypt-openjdk-uber:2.5.2' // For Robolectric
testImplementation 'app.cash.turbine:turbine:1.1.0' testImplementation 'app.cash.turbine:turbine:1.1.0'
implementation 'com.github.bumptech.glide:compose:1.0.0-alpha.5' // compose
implementation "androidx.compose.ui:ui:$composeVersion" Dependency composeBom = platform('androidx.compose:compose-bom:2024.09.01')
implementation "androidx.compose.animation:animation:$composeVersion" implementation composeBom
implementation "androidx.compose.ui:ui-tooling:$composeVersion" testImplementation composeBom
implementation "androidx.compose.runtime:runtime-livedata:$composeVersion" androidTestImplementation composeBom
implementation "androidx.compose.foundation:foundation-layout:$composeVersion"
implementation "androidx.compose.material3:material3:1.2.1" implementation "androidx.compose.ui:ui"
androidTestImplementation "androidx.compose.ui:ui-test-junit4-android:$composeVersion" implementation "androidx.compose.animation:animation"
debugImplementation "androidx.compose.ui:ui-test-manifest:$composeVersion" 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 // Navigation
implementation "androidx.navigation:navigation-fragment-ktx:$navVersion" implementation "androidx.navigation:navigation-fragment-ktx:$navVersion"

View File

@ -149,9 +149,11 @@ fun ColumnScope.DebugCell(
) { ) {
Spacer(modifier = Modifier.height(LocalDimensions.current.smallSpacing)) Spacer(modifier = Modifier.height(LocalDimensions.current.smallSpacing))
Cell { Cell(
modifier = modifier
) {
Column( Column(
modifier = modifier.padding(LocalDimensions.current.spacing) modifier = Modifier.padding(LocalDimensions.current.spacing)
) { ) {
Text( Text(
text = title, text = title,

View File

@ -3,8 +3,16 @@ package org.thoughtcrime.securesms.ui.components
import android.content.res.Resources import android.content.res.Resources
import android.graphics.Typeface import android.graphics.Typeface
import android.text.Spanned import android.text.Spanned
import android.text.SpannedString import android.text.style.AbsoluteSizeSpan
import android.text.style.* 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 android.util.Log
import androidx.annotation.StringRes import androidx.annotation.StringRes
import androidx.compose.runtime.Composable 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.LocalConfiguration
import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.AnnotatedString import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.SpanStyle import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.buildAnnotatedString 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.Density
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.em 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 // Utilities for AnnotatedStrings,
// which allows Stylized string in string resources // like converting the old view system's SpannableString to AnnotatedString
@Composable @Composable
@ReadOnlyComposable @ReadOnlyComposable
private fun resources(): Resources { private fun resources(): Resources {
@ -40,31 +43,6 @@ private fun resources(): Resources {
return LocalContext.current.resources return LocalContext.current.resources
} }
fun Spanned.toHtmlWithoutParagraphs(): String {
return HtmlCompat.toHtml(this, HtmlCompat.TO_HTML_PARAGRAPH_LINES_CONSECUTIVE)
.substringAfter("<p dir=\"ltr\">").substringBeforeLast("</p>")
}
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 @Composable
fun annotatedStringResource(@StringRes id: Int): AnnotatedString { fun annotatedStringResource(@StringRes id: Int): AnnotatedString {
val resources = resources() val resources = resources()

View File

@ -24,7 +24,6 @@ navVersion=2.8.0-beta05
android.useAndroidX=true android.useAndroidX=true
appcompatVersion=1.6.1 appcompatVersion=1.6.1
coreVersion=1.13.1 coreVersion=1.13.1
composeVersion=1.6.8
coroutinesVersion=1.6.4 coroutinesVersion=1.6.4
curve25519Version=0.6.0 curve25519Version=0.6.0
jetpackHiltVersion=1.2.0 jetpackHiltVersion=1.2.0