Skip to content

Commit

Permalink
fix: design review fixes (#93)
Browse files Browse the repository at this point in the history
design review fixes
  • Loading branch information
migulyaev authored Oct 4, 2023
1 parent b32683f commit 44843ab
Show file tree
Hide file tree
Showing 30 changed files with 280 additions and 200 deletions.
1 change: 0 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:largeHeap="true"
android:hardwareAccelerated="false"
android:theme="@style/Theme.Letro">
<activity
android:name=".main.ui.MainActivity"
Expand Down
Binary file modified app/src/main/ic_launcher-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,7 @@ class ManageContactViewModel @Inject constructor(
if (!isGranted) {
_showPermissionGoToSettingsSignal.emit(Unit)
}
_uiState.update {
it.copy(
showNotificationPermissionRequestIfNoPermission = false,
)
}
onGotItClick()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
Expand All @@ -28,13 +30,14 @@ fun ContactView(
onContactClick: (() -> Unit)? = null,
) {
Box(
contentAlignment = Alignment.CenterStart,
modifier = Modifier
.fillMaxWidth()
.height(if (contact.alias != null) 64.dp else 56.dp)
.applyIf(onContactClick != null) {
clickable { onContactClick?.invoke() }
}
.padding(
vertical = if (contact.alias == null) 16.dp else 10.dp,
horizontal = 16.dp,
)
.background(MaterialTheme.colorScheme.surface),
Expand All @@ -48,6 +51,7 @@ fun ContactView(
color = MaterialTheme.colorScheme.onSurface,
style = MaterialTheme.typography.TitleMediumProminent,
)
Spacer(modifier = Modifier.height(2.dp))
}
Text(
text = contact.contactVeraId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.SnackbarHostState
import androidx.compose.material3.SnackbarResult
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
Expand All @@ -29,17 +27,14 @@ import tech.relaycorp.letro.ui.common.LetroButtonMaxWidthFilled
import tech.relaycorp.letro.ui.common.LetroInfoView
import tech.relaycorp.letro.ui.common.LetroOutlinedTextField
import tech.relaycorp.letro.ui.theme.HorizontalScreenPadding
import tech.relaycorp.letro.ui.utils.SnackbarStringsProvider
import tech.relaycorp.letro.utils.permission.rememberNotificationPermissionStateCompat

@OptIn(ExperimentalPermissionsApi::class)
@Composable
fun ManageContactScreen(
onBackClick: () -> Unit,
onEditContactCompleted: (String) -> Unit,
snackbarHostState: SnackbarHostState,
snackbarStringsProvider: SnackbarStringsProvider,
onGoToSettingsClick: () -> Unit,
showGoToSettingsPermissionSnackbar: () -> Unit,
viewModel: ManageContactViewModel = hiltViewModel(),
) {
val uiState by viewModel.uiState.collectAsState()
Expand All @@ -64,13 +59,7 @@ fun ManageContactScreen(

LaunchedEffect(Unit) {
viewModel.showPermissionGoToSettingsSignal.collect {
val result = snackbarHostState.showSnackbar(
message = snackbarStringsProvider.notificationPermissionDenied,
actionLabel = snackbarStringsProvider.goToSettings,
)
if (result == SnackbarResult.ActionPerformed) {
onGoToSettingsClick()
}
showGoToSettingsPermissionSnackbar()
}
}

Expand Down Expand Up @@ -137,13 +126,19 @@ private fun ManageContactView(
isError = errorCaption != null,
isEnabled = uiState.isVeraIdInputEnabled,
) {
Spacer(modifier = Modifier.height(6.dp))
if (errorCaption != null) {
Spacer(modifier = Modifier.height(6.dp))
Text(
text = stringResource(id = errorCaption.message),
color = MaterialTheme.colorScheme.error,
style = MaterialTheme.typography.bodySmall,
)
} else if (!uiState.isActionButtonEnabled) {
Text(
text = stringResource(id = R.string.pair_request_invalid_id),
color = MaterialTheme.colorScheme.onSurface,
style = MaterialTheme.typography.bodySmall,
)
}
}
if (uiState.isSentRequestAgainHintVisible) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,13 @@ private fun Conversation(
onConversationClick: () -> Unit,
) {
Box(
contentAlignment = Alignment.CenterStart,
modifier = Modifier
.fillMaxWidth()
.height(64.dp)
.clickable { onConversationClick() }
.padding(
horizontal = 16.dp,
vertical = 10.dp,
),
) {
Column {
Expand Down Expand Up @@ -170,6 +171,7 @@ private fun Conversation(
maxLines = 1,
)
}
Spacer(modifier = Modifier.height(2.dp))
Row {
Text(
text = conversation.subject ?: noSubjectText,
Expand All @@ -187,7 +189,7 @@ private fun Conversation(
)
val messageDisplayedText = if (conversation.messages.last().text.isNotEmptyOrBlank()) conversation.messages.last().text else conversation.messages.last().attachments.firstOrNull()?.name ?: ""
Text(
text = messageDisplayedText,
text = messageDisplayedText.replace("[\\r\\n]+".toRegex(), " "),
style = if (!conversation.isRead) MaterialTheme.typography.BodyMediumProminent else MaterialTheme.typography.bodyMedium,
color = if (!conversation.isRead) MaterialTheme.colorScheme.onSurface else MaterialTheme.colorScheme.onSurfaceVariant,
maxLines = 1,
Expand All @@ -212,8 +214,10 @@ private fun ConversationsSectionSelector(
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier
.padding(
horizontal = 16.dp,
vertical = 16.dp,
start = 16.dp,
end = 16.dp,
top = 16.dp,
bottom = 12.dp,
)
.clickable { onClick() },
) {
Expand Down Expand Up @@ -245,7 +249,8 @@ private fun EmptyConversationsView(
) {
Box(
contentAlignment = Alignment.Center,
modifier = Modifier.fillMaxSize()
modifier = Modifier
.fillMaxSize()
.padding(bottom = 48.dp),
) {
Column(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package tech.relaycorp.letro.conversation.server.processor
import tech.relaycorp.awaladroid.messaging.IncomingMessage
import tech.relaycorp.letro.awala.AwalaManager
import tech.relaycorp.letro.awala.processor.AwalaMessageProcessor
import tech.relaycorp.letro.contacts.storage.dao.ContactsDao
import tech.relaycorp.letro.conversation.attachments.AttachmentsRepository
import tech.relaycorp.letro.conversation.server.dto.ConversationAwalaWrapper
import tech.relaycorp.letro.conversation.server.dto.NewConversationIncomingMessage
Expand All @@ -12,6 +13,7 @@ import tech.relaycorp.letro.conversation.storage.dao.MessagesDao
import tech.relaycorp.letro.conversation.storage.entity.Conversation
import tech.relaycorp.letro.conversation.storage.entity.Message
import tech.relaycorp.letro.push.PushManager
import tech.relaycorp.letro.push.PushNewMessageTextFormatter
import tech.relaycorp.letro.push.model.PushAction
import tech.relaycorp.letro.push.model.PushData
import java.time.LocalDateTime
Expand All @@ -25,7 +27,9 @@ class NewConversationProcessorImpl @Inject constructor(
private val newConversationMessageParser: NewConversationMessageParser,
private val conversationsDao: ConversationsDao,
private val messagesDao: MessagesDao,
private val contactsDao: ContactsDao,
private val attachmentsRepository: AttachmentsRepository,
private val messageTextFormatter: PushNewMessageTextFormatter,
) : NewConversationProcessor {

override suspend fun process(message: IncomingMessage, awalaManager: AwalaManager) {
Expand Down Expand Up @@ -55,10 +59,15 @@ class NewConversationProcessorImpl @Inject constructor(

attachmentsRepository.saveMessageAttachments(messageId, conversationWrapper.attachments)

val senderAlias = contactsDao.getContact(
ownerVeraId = conversation.ownerVeraId,
contactVeraId = conversation.contactVeraId,
)?.alias

pushManager.showPush(
PushData(
title = conversationWrapper.senderVeraId,
text = conversationWrapper.messageText,
title = senderAlias ?: conversationWrapper.senderVeraId,
text = messageTextFormatter.getText(conversation.subject, message.text, conversationWrapper.attachments.map { it.fileName }),
action = PushAction.OpenConversation(
conversationId = conversationWrapper.conversationId,
accountId = conversation.ownerVeraId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package tech.relaycorp.letro.conversation.server.processor
import tech.relaycorp.awaladroid.messaging.IncomingMessage
import tech.relaycorp.letro.awala.AwalaManager
import tech.relaycorp.letro.awala.processor.AwalaMessageProcessor
import tech.relaycorp.letro.contacts.storage.dao.ContactsDao
import tech.relaycorp.letro.conversation.attachments.AttachmentsRepository
import tech.relaycorp.letro.conversation.server.dto.NewMessageIncomingMessage
import tech.relaycorp.letro.conversation.server.parser.NewMessageMessageParser
Expand All @@ -11,6 +12,7 @@ import tech.relaycorp.letro.conversation.storage.dao.MessagesDao
import tech.relaycorp.letro.conversation.storage.entity.Conversation
import tech.relaycorp.letro.conversation.storage.entity.Message
import tech.relaycorp.letro.push.PushManager
import tech.relaycorp.letro.push.PushNewMessageTextFormatter
import tech.relaycorp.letro.push.model.PushAction
import tech.relaycorp.letro.push.model.PushData
import java.time.LocalDateTime
Expand All @@ -25,6 +27,8 @@ class NewMessageProcessorImpl @Inject constructor(
private val conversationsDao: ConversationsDao,
private val messagesDao: MessagesDao,
private val attachmentsRepository: AttachmentsRepository,
private val contactsDao: ContactsDao,
private val messageTextFormatter: PushNewMessageTextFormatter,
) : NewMessageProcessor {

@Suppress("NAME_SHADOWING")
Expand Down Expand Up @@ -58,10 +62,15 @@ class NewMessageProcessorImpl @Inject constructor(
)
val messageId = messagesDao.insert(message)
attachmentsRepository.saveMessageAttachments(messageId, messageWrapper.attachments)

val senderAlias = contactsDao.getContact(
ownerVeraId = conversation.ownerVeraId,
contactVeraId = conversation.contactVeraId,
)?.alias
pushManager.showPush(
PushData(
title = message.senderVeraId,
text = message.text,
title = senderAlias ?: message.senderVeraId,
text = messageTextFormatter.getText(conversation.subject, message.text, messageWrapper.attachments.map { it.fileName }),
action = PushAction.OpenConversation(
conversationId = messageWrapper.conversationId,
accountId = conversation.ownerVeraId,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package tech.relaycorp.letro.conversation.viewing.ui

import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
Expand Down Expand Up @@ -51,6 +52,7 @@ import tech.relaycorp.letro.utils.compose.toDp
import tech.relaycorp.letro.utils.ext.applyIf
import java.util.UUID

@OptIn(ExperimentalFoundationApi::class)
@Composable
fun ConversationScreen(
conversationsStringsProvider: ConversationsStringsProvider,
Expand Down Expand Up @@ -86,11 +88,13 @@ fun ConversationScreen(
},
)
}
Column {
Surface(
shadowElevation = if (scrollState.canScrollBackward) Elevation2 else 0.dp,
) {
Column {
LazyColumn(
state = scrollState,
) {
stickyHeader {
Surface(
shadowElevation = if (scrollState.canScrollBackward) Elevation2 else 0.dp,
) {
ConversationToolbar(
isArchived = conversation.isArchived,
onReplyClick = onReplyClick,
Expand All @@ -101,38 +105,36 @@ fun ConversationScreen(
},
onDeleteClick = { viewModel.onDeleteConversationClick() },
)
Text(
text = conversation.subject ?: conversationsStringsProvider.noSubject,
style = MaterialTheme.typography.titleLarge,
color = MaterialTheme.colorScheme.onSurface,
modifier = Modifier
.padding(
horizontal = 16.dp,
vertical = 10.dp,
),
)
}
}
LazyColumn(
state = scrollState,
) {
items(conversation.messages.size) { position ->
val message = conversation.messages[position]
val isLastMessage = position == conversation.messages.size - 1
Message(
message = message,
isCollapsable = conversation.messages.size > 1,
isLastMessage = isLastMessage,
onAttachmentClick = { onAttachmentClick(it.fileId) },
item {
Text(
text = conversation.subject ?: conversationsStringsProvider.noSubject,
style = MaterialTheme.typography.titleLarge,
color = MaterialTheme.colorScheme.onSurface,
modifier = Modifier
.padding(
horizontal = 16.dp,
vertical = 10.dp,
),
)
}
items(conversation.messages.size) { position ->
val message = conversation.messages[position]
val isLastMessage = position == conversation.messages.size - 1
Message(
message = message,
isCollapsable = conversation.messages.size > 1,
isLastMessage = isLastMessage,
onAttachmentClick = { onAttachmentClick(it.fileId) },
)
if (!isLastMessage) {
Divider(
modifier = Modifier
.background(MaterialTheme.colorScheme.outlineVariant)
.fillMaxWidth()
.height(1.dp),
)
if (!isLastMessage) {
Divider(
modifier = Modifier
.background(MaterialTheme.colorScheme.outlineVariant)
.fillMaxWidth()
.height(1.dp),
)
}
}
}
}
Expand All @@ -153,6 +155,9 @@ private fun Message(
Column(
modifier = Modifier
.fillMaxWidth()
.applyIf(isCollapsed) {
height(CollapsedMessageHeight)
}
.applyIf(isCollapsable && isCollapsed) {
clickable { isCollapsed = !isCollapsed }
}
Expand Down Expand Up @@ -184,6 +189,7 @@ private fun Message(
)
}
if (!isCollapsed) {
Spacer(modifier = Modifier.height(2.dp))
Text(
text = stringResource(id = if (isDetailsCollapsed) R.string.show_more else R.string.show_less),
style = MaterialTheme.typography.bodySmall,
Expand Down Expand Up @@ -215,7 +221,7 @@ private fun Message(
maxLines = if (isCollapsed) 1 else Int.MAX_VALUE,
modifier = Modifier
.padding(
vertical = if (isCollapsed) 0.dp else 10.dp,
vertical = if (isCollapsed) 2.dp else 10.dp,
horizontal = 16.dp,
),
)
Expand Down Expand Up @@ -475,3 +481,5 @@ private fun MessageInfo_Preview() {
)
}
}

private val CollapsedMessageHeight = 64.dp
Loading

0 comments on commit 44843ab

Please sign in to comment.