Remove OpenInProtonCalendarBanner

ET-3977
This commit is contained in:
Stefanija Boshkovska
2025-08-06 16:42:10 +02:00
committed by MargeBot
parent e1fd5a38b6
commit c832d07bc5
8 changed files with 1 additions and 161 deletions
@@ -18,7 +18,6 @@
package ch.protonmail.android.maildetail.presentation.mapper
import ch.protonmail.android.mailattachments.domain.model.isCalendarAttachment
import ch.protonmail.android.mailmessage.domain.model.AttachmentListExpandCollapseMode
import ch.protonmail.android.mailmessage.domain.model.DecryptedMessageBody
import ch.protonmail.android.mailmessage.domain.model.GetMessageBodyError
@@ -35,7 +34,7 @@ class MessageBodyUiModelMapper @Inject constructor(
private val attachmentGroupUiModelMapper: AttachmentGroupUiModelMapper
) {
suspend fun toUiModel(
fun toUiModel(
decryptedMessageBody: DecryptedMessageBody,
attachmentListExpandCollapseMode: AttachmentListExpandCollapseMode?,
existingMessageBodyUiModel: MessageBodyUiModel? = null
@@ -61,7 +60,6 @@ class MessageBodyUiModelMapper @Inject constructor(
shouldShowEmbeddedImagesBanner = hasEmbeddedImagesBlocked,
shouldShowRemoteContentBanner = hasRemoteContentBlocked,
shouldShowExpandCollapseButton = hasExpandCollapseButton,
shouldShowOpenInProtonCalendar = decryptedMessageBody.attachments.any { it.isCalendarAttachment() },
attachments = if (decryptedMessageBody.attachments.isNotEmpty()) {
attachmentGroupUiModelMapper.toUiModel(
decryptedMessageBody.attachments,
@@ -79,7 +77,6 @@ class MessageBodyUiModelMapper @Inject constructor(
shouldShowEmbeddedImagesBanner = false,
shouldShowRemoteContentBanner = false,
shouldShowExpandCollapseButton = false,
shouldShowOpenInProtonCalendar = false,
attachments = null,
viewModePreference = ViewModePreference.ThemeDefault
)
@@ -64,7 +64,6 @@ object MessageDetailBodyUiModelSample {
mimeType: MimeTypeUiModel = MimeTypeUiModel.Html,
shouldShowEmbeddedImagesBanner: Boolean = false,
shouldShowRemoteContentBanner: Boolean = false,
shouldShowOpenInProtonCalendar: Boolean = false,
attachments: AttachmentGroupUiModel? = null
) = MessageBodyUiModel(
messageId = messageId,
@@ -73,7 +72,6 @@ object MessageDetailBodyUiModelSample {
shouldShowEmbeddedImagesBanner = shouldShowEmbeddedImagesBanner,
shouldShowRemoteContentBanner = shouldShowRemoteContentBanner,
shouldShowExpandCollapseButton = false,
shouldShowOpenInProtonCalendar = shouldShowOpenInProtonCalendar,
attachments = attachments,
viewModePreference = ViewModePreference.ThemeDefault
)
@@ -306,7 +306,6 @@ private fun ColumnScope.ConversationDetailExpandedItem(
onLoadRemoteContent = { actions.onLoadRemoteContent(it) },
onLoadEmbeddedImages = { actions.onLoadEmbeddedImages(it) },
onLoadRemoteAndEmbeddedContent = { actions.onLoadRemoteAndEmbeddedContent(it) },
onOpenInProtonCalendar = { actions.onOpenInProtonCalendar(it) },
onPrint = { actions.onPrint(it) }
),
onMessageBodyLoaded = { id: MessageId, i: Int ->
@@ -84,13 +84,6 @@ fun MessageBody(
}
}
if (messageBodyUiModel.shouldShowOpenInProtonCalendar) {
OpenInProtonCalendarBanner(
modifier = Modifier.testTag(MessageBodyTestTags.MessageBodyBannerProtonCalendar),
onOpenInProtonCalendarClick = { actions.onOpenInProtonCalendar(messageBodyUiModel.messageId) }
)
}
MailDivider(modifier = Modifier.padding(top = ProtonDimens.Spacing.Standard))
if (hasWebView) {
@@ -185,7 +178,6 @@ object MessageBody {
val onLoadRemoteContent: (MessageId) -> Unit,
val onLoadEmbeddedImages: (MessageId) -> Unit,
val onLoadRemoteAndEmbeddedContent: (MessageId) -> Unit,
val onOpenInProtonCalendar: (MessageId) -> Unit,
val onPrint: (MessageId) -> Unit
)
}
@@ -1,131 +0,0 @@
/*
* Copyright (c) 2022 Proton Technologies AG
* This file is part of Proton Technologies AG and Proton Mail.
*
* Proton Mail is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Proton Mail is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Proton Mail. If not, see <https://www.gnu.org/licenses/>.
*/
package ch.protonmail.android.maildetail.presentation.ui
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.Image
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.Icon
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.shadow
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import ch.protonmail.android.design.compose.theme.ProtonDimens
import ch.protonmail.android.design.compose.theme.ProtonTheme
import ch.protonmail.android.mailcommon.presentation.NO_CONTENT_DESCRIPTION
import ch.protonmail.android.mailcommon.presentation.compose.MailDimens
import ch.protonmail.android.maildetail.presentation.R
import ch.protonmail.android.design.compose.R as design
@Composable
fun OpenInProtonCalendarBanner(modifier: Modifier = Modifier, onOpenInProtonCalendarClick: () -> Unit) {
Button(
shape = ProtonTheme.shapes.extraLarge,
colors = ButtonDefaults.buttonColors().copy(
containerColor = ProtonTheme.colors.backgroundNorm
),
contentPadding = PaddingValues(ProtonDimens.Spacing.Large),
border = BorderStroke(MailDimens.DefaultBorder, ProtonTheme.colors.borderNorm),
modifier = modifier
.padding(
start = ProtonDimens.Spacing.Large,
end = ProtonDimens.Spacing.Large,
bottom = ProtonDimens.Spacing.Standard
)
.fillMaxWidth()
.shadow(
elevation = ProtonDimens.ShadowElevation.Soft,
shape = ProtonTheme.shapes.extraLarge,
spotColor = ProtonTheme.colors.shadowSoft,
ambientColor = ProtonTheme.colors.shadowSoft
),
onClick = onOpenInProtonCalendarClick
) {
Row(modifier = Modifier.fillMaxWidth()) {
Box(
modifier = Modifier
.size(MailDimens.ProtonCalendarIconSize)
.border(
ProtonDimens.OutlinedBorderSize, ProtonTheme.colors.borderNorm,
shape = ProtonTheme.shapes.large
)
) {
Image(
modifier = Modifier.align(Alignment.Center),
painter = painterResource(id = R.drawable.ic_logo_calendar),
contentDescription = NO_CONTENT_DESCRIPTION
)
}
Spacer(modifier = Modifier.size(ProtonDimens.Spacing.Large))
Column(
modifier = Modifier.weight(1f),
verticalArrangement = Arrangement.Center
) {
Text(
style = ProtonTheme.typography.bodyMedium,
color = ProtonTheme.colors.textAccent,
maxLines = 1,
text = stringResource(id = R.string.open_on_protoncalendar_banner_title)
)
Spacer(modifier = Modifier.size(ProtonDimens.Spacing.Tiny))
Text(
style = ProtonTheme.typography.bodySmall,
color = ProtonTheme.colors.textWeak,
maxLines = 1,
text = stringResource(id = R.string.open_on_protoncalendar_banner_description)
)
}
Box(modifier = Modifier.size(MailDimens.ProtonCalendarIconSize)) {
Icon(
modifier = Modifier.align(Alignment.Center),
painter = painterResource(id = design.drawable.ic_proton_arrow_out_square_new),
contentDescription = NO_CONTENT_DESCRIPTION,
tint = ProtonTheme.colors.iconHint
)
}
}
}
}
@Preview(showBackground = true)
@Composable
private fun OpenInProtonCalendarBannerPreview() {
ProtonTheme {
Box {
OpenInProtonCalendarBanner(onOpenInProtonCalendarClick = {})
}
}
}
@@ -40,7 +40,6 @@ import kotlin.test.assertEquals
class MessageBodyUiModelMapperTest {
private val decryptedMessageBody = "Decrypted message body."
private val decryptedMessageBodyWithCss = "Decrypted message body with CSS."
private val attachmentGroupUiModelMapper = mockk<AttachmentGroupUiModelMapper> {
every { this@mockk.toUiModel(listOf(AttachmentMetadataSamples.Invoice), any()) } returns AttachmentGroupUiModel(
@@ -111,7 +110,6 @@ class MessageBodyUiModelMapperTest {
shouldShowEmbeddedImagesBanner = false,
shouldShowRemoteContentBanner = false,
shouldShowExpandCollapseButton = false,
shouldShowOpenInProtonCalendar = false,
attachments = null,
viewModePreference = ViewModePreference.ThemeDefault
)
@@ -151,7 +149,6 @@ class MessageBodyUiModelMapperTest {
shouldShowEmbeddedImagesBanner = false,
shouldShowRemoteContentBanner = false,
shouldShowExpandCollapseButton = false,
shouldShowOpenInProtonCalendar = false,
attachments = AttachmentGroupUiModel(
attachments = listOf(
AttachmentMetadataUiModelSamples.Invoice,
@@ -194,7 +191,6 @@ class MessageBodyUiModelMapperTest {
shouldShowEmbeddedImagesBanner = false,
shouldShowRemoteContentBanner = false,
shouldShowExpandCollapseButton = false,
shouldShowOpenInProtonCalendar = true,
attachments = AttachmentGroupUiModel(
attachments = listOf(
AttachmentMetadataUiModelSamples.Calendar
@@ -235,7 +231,6 @@ class MessageBodyUiModelMapperTest {
shouldShowEmbeddedImagesBanner = false,
shouldShowRemoteContentBanner = false,
shouldShowExpandCollapseButton = false,
shouldShowOpenInProtonCalendar = false,
attachments = AttachmentGroupUiModel(
attachments = listOf(
AttachmentMetadataUiModelSamples.InvoiceWithBinaryContentType
@@ -282,7 +277,6 @@ class MessageBodyUiModelMapperTest {
shouldShowEmbeddedImagesBanner = false,
shouldShowRemoteContentBanner = false,
shouldShowExpandCollapseButton = false,
shouldShowOpenInProtonCalendar = false,
attachments = null,
viewModePreference = ViewModePreference.ThemeDefault
)
@@ -315,7 +309,6 @@ class MessageBodyUiModelMapperTest {
shouldShowEmbeddedImagesBanner = false,
shouldShowRemoteContentBanner = false,
shouldShowExpandCollapseButton = false,
shouldShowOpenInProtonCalendar = false,
attachments = null,
viewModePreference = ViewModePreference.ThemeDefault
)
@@ -348,7 +341,6 @@ class MessageBodyUiModelMapperTest {
shouldShowEmbeddedImagesBanner = false,
shouldShowRemoteContentBanner = true,
shouldShowExpandCollapseButton = false,
shouldShowOpenInProtonCalendar = false,
attachments = null,
viewModePreference = ViewModePreference.ThemeDefault
)
@@ -381,7 +373,6 @@ class MessageBodyUiModelMapperTest {
shouldShowEmbeddedImagesBanner = false,
shouldShowRemoteContentBanner = false,
shouldShowExpandCollapseButton = false,
shouldShowOpenInProtonCalendar = false,
attachments = null,
viewModePreference = ViewModePreference.ThemeDefault
)
@@ -414,7 +405,6 @@ class MessageBodyUiModelMapperTest {
shouldShowEmbeddedImagesBanner = true,
shouldShowRemoteContentBanner = false,
shouldShowExpandCollapseButton = false,
shouldShowOpenInProtonCalendar = false,
attachments = null,
viewModePreference = ViewModePreference.ThemeDefault
)
@@ -438,7 +428,6 @@ class MessageBodyUiModelMapperTest {
shouldShowEmbeddedImagesBanner = false,
shouldShowRemoteContentBanner = false,
shouldShowExpandCollapseButton = false,
shouldShowOpenInProtonCalendar = false,
attachments = null,
viewModePreference = ViewModePreference.ThemeDefault
)
@@ -470,7 +459,6 @@ class MessageBodyUiModelMapperTest {
shouldShowEmbeddedImagesBanner = false,
shouldShowRemoteContentBanner = true,
shouldShowExpandCollapseButton = false,
shouldShowOpenInProtonCalendar = false,
attachments = null,
viewModePreference = ViewModePreference.ThemeDefault
)
@@ -28,7 +28,6 @@ data class MessageBodyUiModel(
val shouldShowEmbeddedImagesBanner: Boolean,
val shouldShowRemoteContentBanner: Boolean,
val shouldShowExpandCollapseButton: Boolean,
val shouldShowOpenInProtonCalendar: Boolean,
val attachments: AttachmentGroupUiModel?,
val viewModePreference: ViewModePreference
)
@@ -108,7 +108,6 @@ object MessageBodyUiModelTestData {
mimeType: MimeTypeUiModel = MimeTypeUiModel.PlainText,
shouldShowEmbeddedImagesBanner: Boolean = false,
shouldShowRemoteContentBanner: Boolean = false,
shouldShowOpenInProtonCalendar: Boolean = false,
attachments: AttachmentGroupUiModel? = null,
viewModePreference: ViewModePreference = ViewModePreference.ThemeDefault
): MessageBodyUiModel {
@@ -119,7 +118,6 @@ object MessageBodyUiModelTestData {
shouldShowEmbeddedImagesBanner = shouldShowEmbeddedImagesBanner,
shouldShowRemoteContentBanner = shouldShowRemoteContentBanner,
shouldShowExpandCollapseButton = false,
shouldShowOpenInProtonCalendar = shouldShowOpenInProtonCalendar,
attachments = attachments,
viewModePreference = viewModePreference
)