Fix up compilation issues

This commit is contained in:
SessionHero01 2024-09-12 10:51:59 +10:00
parent 952479a564
commit cc64f461ef
No known key found for this signature in database
7 changed files with 26 additions and 198 deletions

View File

@ -16,7 +16,6 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ExperimentalLayoutApi
import androidx.compose.foundation.layout.FlowRow
import androidx.compose.foundation.layout.IntrinsicSize
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.aspectRatio
@ -61,8 +60,6 @@ import org.session.libsession.database.StorageProtocol
import org.session.libsession.messaging.sending_receiving.attachments.DatabaseAttachment
import org.thoughtcrime.securesms.MediaPreviewActivity.getPreviewIntent
import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity
import org.thoughtcrime.securesms.database.Storage
import org.thoughtcrime.securesms.database.model.MediaMmsMessageRecord
import org.thoughtcrime.securesms.ui.Avatar
import org.thoughtcrime.securesms.ui.CarouselNextButton
import org.thoughtcrime.securesms.ui.CarouselPrevButton

View File

@ -138,7 +138,7 @@ fun RowScope.ContactPhoto(sessionId: String) {
val recipient = remember(sessionId) {
Recipient.from(context, Address.fromSerialized(sessionId), false)
}
Avatar(recipient)
Avatar(recipient, modifier = Modifier.size(48.dp))
}
}

View File

@ -7,6 +7,7 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.widthIn
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
@ -24,10 +25,9 @@ import org.session.libsession.messaging.contacts.Contact
import org.thoughtcrime.securesms.groups.ContactItem
import org.thoughtcrime.securesms.groups.CreateGroupEvent
import org.thoughtcrime.securesms.groups.CreateGroupViewModel
import org.thoughtcrime.securesms.ui.CloseIcon
import org.thoughtcrime.securesms.ui.LoadingArcOr
import org.thoughtcrime.securesms.ui.NavigationBar
import org.thoughtcrime.securesms.ui.SearchBar
import org.thoughtcrime.securesms.ui.components.BackAppBar
import org.thoughtcrime.securesms.ui.components.PrimaryOutlineButton
import org.thoughtcrime.securesms.ui.components.SessionOutlinedTextField
import org.thoughtcrime.securesms.ui.theme.LocalColors
@ -75,6 +75,7 @@ fun CreateGroupScreen(
)
}
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun CreateGroup(
groupName: String,
@ -97,10 +98,9 @@ fun CreateGroup(
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.spacedBy(16.dp)
) {
NavigationBar(
BackAppBar(
title = stringResource(id = R.string.groupCreate),
onBack = onBack,
actionElement = { CloseIcon(onClose) }
)
SessionOutlinedTextField(

View File

@ -19,8 +19,6 @@ import androidx.compose.material3.ModalBottomSheet
import androidx.compose.material3.Scaffold
import androidx.compose.material3.SheetState
import androidx.compose.material3.Snackbar
import androidx.compose.material3.SnackbarHost
import androidx.compose.material3.SnackbarHostState
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.material3.rememberModalBottomSheetState
@ -51,7 +49,8 @@ import org.thoughtcrime.securesms.groups.GroupMemberState
import org.thoughtcrime.securesms.ui.AlertDialog
import org.thoughtcrime.securesms.ui.DialogButtonModel
import org.thoughtcrime.securesms.ui.GetString
import org.thoughtcrime.securesms.ui.NavigationBar
import org.thoughtcrime.securesms.ui.components.ActionAppBar
import org.thoughtcrime.securesms.ui.components.AppBarBackIcon
import org.thoughtcrime.securesms.ui.components.PrimaryOutlineButton
import org.thoughtcrime.securesms.ui.components.SessionOutlinedTextField
import org.thoughtcrime.securesms.ui.theme.LocalColors
@ -142,10 +141,12 @@ fun EditGroup(
Scaffold(
topBar = {
NavigationBar(
ActionAppBar(
title = stringResource(id = R.string.groupEdit),
onBack = onBackClick,
actionElement = {
navigationIcon = {
AppBarBackIcon(onBack = onBackClick)
},
actions = {
TextButton(onClick = onBackClick) {
Text(
text = stringResource(id = R.string.done),
@ -153,7 +154,7 @@ fun EditGroup(
style = LocalType.current.large.bold()
)
}
}
},
)
}
) { paddingValues ->
@ -319,7 +320,7 @@ private fun ConfirmRemovingMemberDialog(
onClick = { onConfirmed(member.accountId, false) }
),
DialogButtonModel(
text = GetString(R.string.groupRemoveMessages),
text = GetString("Remove and delete messages"), //TODO: Copy
color = LocalColors.current.danger,
onClick = { onConfirmed(member.accountId, true) }
),

View File

@ -9,6 +9,7 @@ import androidx.compose.foundation.layout.defaultMinSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
@ -25,9 +26,8 @@ import network.loki.messenger.R
import org.session.libsession.messaging.contacts.Contact
import org.thoughtcrime.securesms.groups.ContactItem
import org.thoughtcrime.securesms.groups.SelectContactsViewModel
import org.thoughtcrime.securesms.ui.CloseIcon
import org.thoughtcrime.securesms.ui.NavigationBar
import org.thoughtcrime.securesms.ui.SearchBar
import org.thoughtcrime.securesms.ui.components.BackAppBar
import org.thoughtcrime.securesms.ui.components.PrimaryOutlineButton
import org.thoughtcrime.securesms.ui.theme.LocalColors
import org.thoughtcrime.securesms.ui.theme.PreviewTheme
@ -56,6 +56,7 @@ fun SelectContactsScreen(
)
}
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun SelectContacts(
contacts: List<ContactItem>,
@ -64,18 +65,12 @@ fun SelectContacts(
onSearchQueryChanged: (String) -> Unit,
onDoneClicked: () -> Unit,
onBack: () -> Unit,
onClose: (() -> Unit)? = null,
@StringRes okButtonResId: Int = R.string.ok
) {
Column(verticalArrangement = Arrangement.spacedBy(16.dp)) {
NavigationBar(
BackAppBar(
title = stringResource(id = R.string.contactSelect),
onBack = onBack,
actionElement = {
if (onClose != null) {
CloseIcon(onClose)
}
}
)
GroupMinimumVersionBanner()
@ -139,7 +134,6 @@ private fun PreviewSelectContacts() {
onSearchQueryChanged = {},
onDoneClicked = {},
onBack = {},
onClose = null
)
}
}

View File

@ -8,8 +8,6 @@ import androidx.compose.foundation.Canvas
import androidx.compose.foundation.Image
import androidx.compose.foundation.ScrollState
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxScope
import androidx.compose.foundation.layout.Column
@ -32,7 +30,6 @@ import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.BasicTextField
import androidx.compose.material.ripple.rememberRipple
import androidx.compose.material3.ButtonColors
import androidx.compose.material3.Card
import androidx.compose.material3.HorizontalDivider
@ -43,7 +40,6 @@ import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
@ -65,13 +61,9 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.compose.ui.viewinterop.AndroidView
import com.google.accompanist.drawablepainter.rememberDrawablePainter
import kotlinx.coroutines.CoroutineScope
@ -166,12 +158,7 @@ fun ItemButtonWithDrawable(
modifier = modifier,
icon = {
Image(
painter = rememberDrawablePainter(
drawable = AppCompatResources.getDrawable(
context,
icon
)
),
painter = rememberDrawablePainter(drawable = AppCompatResources.getDrawable(context, icon)),
contentDescription = null,
modifier = Modifier.align(Alignment.Center)
)
@ -573,148 +560,3 @@ fun SearchBar(
cursorBrush = SolidColor(LocalColors.current.text)
)
}
@Composable
fun NavigationBar(
title: String,
titleAlignment: Alignment = Alignment.Center,
onBack: (() -> Unit)? = null,
actionElement: (@Composable BoxScope.() -> Unit)? = null
) {
Row(
Modifier
.fillMaxWidth()
.height(64.dp)
) {
// Optional back button, layout should still take up space
Box(
modifier = Modifier
.fillMaxHeight()
.aspectRatio(1.0f, true)
.padding(16.dp)
) {
if (onBack != null) {
Icon(
painter = painterResource(id = R.drawable.ic_arrow_back_24),
contentDescription = stringResource(
id = R.string.AccessibilityId_navigateBack
),
Modifier
.clickable(
interactionSource = remember { MutableInteractionSource() },
indication = rememberRipple(bounded = false, radius = 16.dp),
) { onBack() }
.align(Alignment.Center)
)
}
}
//Main title
Box(
modifier = Modifier
.fillMaxHeight()
.weight(1f)
.padding(8.dp)
) {
Text(
text = title,
Modifier.align(titleAlignment),
overflow = TextOverflow.Ellipsis,
fontSize = 26.sp,
fontWeight = FontWeight.Bold
)
}
// Optional action
if (actionElement != null) {
Box(
modifier = Modifier
.fillMaxHeight()
.align(Alignment.CenterVertically)
.aspectRatio(1.0f, true),
contentAlignment = Alignment.Center
) {
actionElement(this)
}
}
}
}
@Composable
fun BoxScope.CloseIcon(onClose: () -> Unit) {
Icon(
painter = painterResource(id = R.drawable.ic_baseline_close_24),
contentDescription = stringResource(
id = R.string.close
),
Modifier
.clickable { onClose() }
.align(Alignment.Center)
.padding(16.dp)
)
}
@Composable
fun RowScope.WeightedOptionButton(
modifier: Modifier = Modifier,
@StringRes label: Int,
destructive: Boolean = false,
weight: Float = 1f,
onClick: () -> Unit
) {
Text(
text = stringResource(label),
modifier = modifier
.padding(16.dp)
.weight(weight)
.clickable {
onClick()
},
textAlign = TextAlign.Center,
fontSize = 16.sp,
fontWeight = FontWeight.Bold,
color = if (destructive) LocalColors.current.danger else Color.Unspecified
)
}
@Preview
@Composable
fun PreviewWeightedOptionButtons() {
Column(modifier = Modifier.fillMaxWidth()) {
// two equal sized
Row(modifier = Modifier.fillMaxWidth()) {
WeightedOptionButton(label = R.string.ok) {
}
WeightedOptionButton(label = R.string.cancel, destructive = true) {
}
}
// single left justified
Row(modifier = Modifier.fillMaxWidth()) {
WeightedOptionButton(label = R.string.cancel, destructive = true, weight = 1f) {
}
// press F to pay respects to `android:weightSum`
Box(Modifier.weight(1f))
}
}
}
@Composable
@Preview
fun PreviewNavigationBar() {
NavigationBar(title = "Create Group", onBack = {}, actionElement = {
CloseIcon {}
})
}
@Composable
@Preview
fun PreviewSearchBar() {
PreviewTheme {
Column(Modifier.background(LocalColors.current.backgroundSecondary)) {
SearchBar("Search query", {})
SearchBar("", {}, placeholder = "Hint text")
}
}
}

View File

@ -25,9 +25,6 @@ import org.session.libsession.utilities.StringSubstitutionConstants.GROUP_NAME_K
import org.session.libsession.utilities.StringSubstitutionConstants.NAME_KEY
import org.session.libsession.utilities.StringSubstitutionConstants.OTHER_NAME_KEY
import org.session.libsession.utilities.StringSubstitutionConstants.TIME_KEY
import org.session.libsession.utilities.getExpirationTypeDisplayValue
import org.session.libsession.utilities.truncateIdForDisplay
import org.session.libsignal.utilities.Log
object UpdateMessageBuilder {
const val TAG = "UpdateMessageBuilder"
@ -42,9 +39,6 @@ object UpdateMessageBuilder {
@JvmStatic
fun buildGroupUpdateMessage(context: Context, updateMessageData: UpdateMessageData, senderId: String? = null, isOutgoing: Boolean = false, isInConversation: Boolean): CharSequence {
val updateData = updateMessageData.kind ?: return ""
val senderName: String by lazy {
senderId?.let(this::getSenderName).orEmpty()
}
return when (updateData) {
// --- Group created or joined ---
@ -194,20 +188,20 @@ object UpdateMessageBuilder {
.put(NAME_KEY, context.youOrSender(updateData.sessionIds.first()))
.format()
number == 2 && containsUser -> Phrase.from(context,
R.string.groupMemberYouAndOtherNew)
R.string.groupInviteYouAndOtherNew)
.put(OTHER_NAME_KEY, context.youOrSender(updateData.sessionIds.first { it != userPublicKey }))
.format()
number == 2 -> Phrase.from(context,
R.string.groupMemberTwoNew)
R.string.groupMemberNewMultiple)
.put(NAME_KEY, context.youOrSender(updateData.sessionIds.first()))
.put(OTHER_NAME_KEY, context.youOrSender(updateData.sessionIds.last()))
.format()
containsUser -> Phrase.from(context,
R.string.groupMemberNewYouMultiple)
R.string.groupInviteYouAndMoreNew)
.put(COUNT_KEY, updateData.sessionIds.size - 1)
.format()
else -> Phrase.from(context,
R.string.groupMemberMoreNew)
R.string.groupMemberNewMultiple)
.put(NAME_KEY, context.youOrSender(updateData.sessionIds.first()))
.put(COUNT_KEY, updateData.sessionIds.size - 1)
.format()