Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ jobs:
cache: gradle

- name: Run Detekt
run: ./gradlew :app:detekt --no-daemon --stacktrace --console=plain
run: ./gradlew :app:detektDebug --no-daemon --stacktrace --console=plain

- name: Upload Detekt reports
if: failure()
Expand Down
22 changes: 22 additions & 0 deletions config/detekt/detekt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ config:

complexity:
LongParameterList:
active: false
ignoreDefaultParameters: true
ignoreAnnotated:
- Composable
TooManyFunctions:
allowedFunctionsPerClass: 60
allowedFunctionsPerFile: 15
Expand All @@ -17,15 +20,34 @@ complexity:
- Preview
- PreviewLightDark

coroutines:
InjectDispatcher:
active: false
ignoreAnnotated:
- Provides

naming:
FunctionNaming:
ignoreAnnotated:
- Composable

style:
AbstractClassCanBeInterface:
ignoreAnnotated:
- Module

ForbiddenComment:
active: false

ForbiddenMethodCall:
active: true
methods:
- reason: >-
Does not cover the display cutout, so content slides under the camera
notch in landscape. Use bottomBarInsets(), imeAwareBottomBarInsets()
or safeDrawingContentPadding() from WindowInsetsExtensions instead.
value: 'androidx.compose.foundation.layout.navigationBarsPadding'

MagicNumber:
ignoreCompanionObjectPropertyDeclaration: true
ignorePropertyDeclaration: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,7 @@ internal class ContactsRepositoryImpl @Inject constructor(
kind = kind,
destinationColumnName = destinationColumnName,
)
}
?: emptyList()
}.orEmpty()
}

private fun mapDestinationRows(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,6 @@ internal class ConversationsRepositoryImpl @Inject constructor(
add(ConversationMessageData().apply { bind(reversedCursor) })
}
}
}
?: emptyList()
}.orEmpty()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ internal class ConversationMediaRepositoryImpl @Inject constructor(
add(item)
}
}
} ?: emptyList()
}.orEmpty()
}

private fun createRecentMediaQueryArgs(limit: Int): Bundle {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,7 @@ internal class PhotoViewerRepositoryImpl @Inject constructor(
}
}
}
}
?: emptyList()
}.orEmpty()
}

private fun Cursor.toPhotoViewerItem(): PhotoViewerItem? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,9 @@ internal class SendConversationDraftImpl @Inject constructor(
draft = draft,
ignoreMessageSizeLimit = ignoreMessageSizeLimit,
)
} catch (exception: CancellationException) {
throw exception
} catch (exception: Exception) {
if (exception is CancellationException) {
throw exception
}

throw exception.toSendConversationDraftException(
conversationId = conversationId,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.calculateEndPadding
import androidx.compose.foundation.layout.calculateStartPadding
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
Expand All @@ -31,7 +29,6 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.PreviewLightDark
Expand All @@ -48,7 +45,7 @@ import com.android.messaging.ui.blockedparticipants.screen.model.BlockedParticip
import com.android.messaging.ui.blockedparticipants.screen.model.BlockedParticipantsNavEvent as NavEvent
import com.android.messaging.ui.blockedparticipants.screen.model.BlockedParticipantsUiState as State
import com.android.messaging.ui.common.components.contentSurfaceShape
import com.android.messaging.ui.common.components.horizontalSafeDrawingInsets
import com.android.messaging.ui.common.components.safeDrawingContentPadding
import com.android.messaging.ui.core.MessagingPreviewTheme
import kotlinx.collections.immutable.persistentListOf
import kotlinx.collections.immutable.persistentSetOf
Expand Down Expand Up @@ -151,16 +148,12 @@ private fun BlockedParticipantsList(
onAction: (Action) -> Unit,
scaffoldContentPadding: PaddingValues,
) {
val layoutDirection = LocalLayoutDirection.current
val horizontalInsets = horizontalSafeDrawingInsets()

LazyColumn(
modifier = Modifier.fillMaxSize(),
contentPadding = PaddingValues(
contentPadding = safeDrawingContentPadding(
top = ScreenContentPadding,
bottom = ScreenContentPadding + scaffoldContentPadding.calculateBottomPadding(),
start = ScreenContentPadding + horizontalInsets.calculateStartPadding(layoutDirection),
end = ScreenContentPadding + horizontalInsets.calculateEndPadding(layoutDirection),
horizontal = ScreenContentPadding,
),
) {
itemsIndexed(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,50 @@ import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.foundation.layout.calculateEndPadding
import androidx.compose.foundation.layout.calculateStartPadding
import androidx.compose.foundation.layout.displayCutout
import androidx.compose.foundation.layout.only
import androidx.compose.foundation.layout.safeDrawing
import androidx.compose.foundation.layout.systemBars
import androidx.compose.foundation.layout.union
import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.unit.Dp

@Composable
fun horizontalSafeDrawingInsets(): PaddingValues {
return WindowInsets.safeDrawing
.only(WindowInsetsSides.Horizontal)
.asPaddingValues()
}

@Composable
fun safeDrawingContentPadding(
top: Dp,
bottom: Dp,
horizontal: Dp,
): PaddingValues {
val layoutDirection = LocalLayoutDirection.current
val horizontalInsets = horizontalSafeDrawingInsets()

return PaddingValues(
top = top,
bottom = bottom,
start = horizontal + horizontalInsets.calculateStartPadding(layoutDirection),
end = horizontal + horizontalInsets.calculateEndPadding(layoutDirection),
)
}

@Composable
fun bottomBarInsets(): WindowInsets {
return WindowInsets.systemBars
.union(WindowInsets.displayCutout)
.only(WindowInsetsSides.Horizontal + WindowInsetsSides.Bottom)
}

@Composable
fun imeAwareBottomBarInsets(): WindowInsets {
return WindowInsets.safeDrawing
.only(WindowInsetsSides.Horizontal + WindowInsetsSides.Bottom)
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.imePadding
import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.windowInsetsPadding
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
Expand Down Expand Up @@ -49,6 +48,7 @@ import androidx.compose.ui.unit.dp
import com.android.messaging.R
import com.android.messaging.domain.conversation.usecase.draft.model.ConversationDraftSendProtocol
import com.android.messaging.ui.common.components.composer.MessageComposeBar
import com.android.messaging.ui.common.components.imeAwareBottomBarInsets
import com.android.messaging.ui.conversation.CONVERSATION_ATTACHMENT_BUTTON_TEST_TAG
import com.android.messaging.ui.conversation.CONVERSATION_COMPOSE_BAR_TEST_TAG
import com.android.messaging.ui.conversation.CONVERSATION_SEGMENT_COUNTER_TEST_TAG
Expand Down Expand Up @@ -127,8 +127,7 @@ internal fun ConversationComposeBar(
Box(
modifier = modifier
.fillMaxWidth()
.imePadding()
.navigationBarsPadding()
.windowInsetsPadding(imeAwareBottomBarInsets())
.testTag(CONVERSATION_COMPOSE_BAR_TEST_TAG),
) {
ConversationComposeInputContent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.windowInsetsPadding
import androidx.compose.foundation.selection.selectable
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.Check
Expand All @@ -27,6 +27,7 @@ import androidx.compose.ui.tooling.preview.PreviewLightDark
import androidx.compose.ui.unit.dp
import com.android.messaging.R
import com.android.messaging.data.subscription.model.Subscription
import com.android.messaging.ui.common.components.bottomBarInsets
import com.android.messaging.ui.conversation.CONVERSATION_SIM_SELECTOR_SHEET_TEST_TAG
import com.android.messaging.ui.conversation.composer.model.ConversationSimSelectorUiState
import com.android.messaging.ui.conversation.conversationSimSelectorItemTestTag
Expand Down Expand Up @@ -68,7 +69,7 @@ private fun ConversationSimSelectorSheetContent(
Column(
modifier = Modifier
.fillMaxWidth()
.navigationBarsPadding()
.windowInsetsPadding(bottomBarInsets())
.padding(vertical = SHEET_VERTICAL_PADDING),
) {
Text(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import com.android.messaging.R
import com.android.messaging.data.subscription.model.Subscription
import com.android.messaging.ui.common.components.safeDrawingContentPadding
import com.android.messaging.ui.conversation.CONVERSATION_MESSAGES_LIST_TEST_TAG
import com.android.messaging.ui.conversation.conversationMessageItemTestTag
import com.android.messaging.ui.conversation.messages.model.message.ConversationMessageUiModel
Expand All @@ -48,19 +49,8 @@ import kotlinx.collections.immutable.toImmutableMap

private val MESSAGES_CONTENT_HORIZONTAL_PADDING = 16.dp
private val MESSAGES_CONTENT_TOP_PADDING = 24.dp

private val messagesContentPadding = PaddingValues(
start = MESSAGES_CONTENT_HORIZONTAL_PADDING,
top = MESSAGES_CONTENT_TOP_PADDING,
end = MESSAGES_CONTENT_HORIZONTAL_PADDING,
bottom = 24.dp,
)
private val sendSimContentPadding = PaddingValues(
start = MESSAGES_CONTENT_HORIZONTAL_PADDING,
top = MESSAGES_CONTENT_TOP_PADDING,
end = MESSAGES_CONTENT_HORIZONTAL_PADDING,
bottom = 6.dp,
)
private val MESSAGES_CONTENT_BOTTOM_PADDING = 24.dp
private val SEND_SIM_CONTENT_BOTTOM_PADDING = 6.dp

private val MESSAGES_CLUSTER_TOP_PADDING = 2.dp
private val MESSAGES_GROUP_TOP_PADDING = 12.dp
Expand Down Expand Up @@ -219,24 +209,20 @@ private fun LazyListScope.conversationSendSimIndicatorItem(
}
}

@Composable
private fun conversationMessagesContentPadding(
shouldShowSendSimIndicator: Boolean,
additionalTopContentPadding: Dp,
): PaddingValues {
val basePadding = when {
shouldShowSendSimIndicator -> sendSimContentPadding
else -> messagesContentPadding
}

if (additionalTopContentPadding <= 0.dp) {
return basePadding
val bottomPadding = when {
shouldShowSendSimIndicator -> SEND_SIM_CONTENT_BOTTOM_PADDING
else -> MESSAGES_CONTENT_BOTTOM_PADDING
}

return PaddingValues(
start = MESSAGES_CONTENT_HORIZONTAL_PADDING,
return safeDrawingContentPadding(
top = MESSAGES_CONTENT_TOP_PADDING + additionalTopContentPadding,
end = MESSAGES_CONTENT_HORIZONTAL_PADDING,
bottom = basePadding.calculateBottomPadding(),
bottom = bottomPadding,
horizontal = MESSAGES_CONTENT_HORIZONTAL_PADDING,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,10 @@ private fun Modifier.conversationScreenContentModifier(
backdropColor: Color,
): Modifier {
return this
.padding(paddingValues = contentPadding)
.padding(
top = contentPadding.calculateTopPadding(),
bottom = contentPadding.calculateBottomPadding(),
)
.background(color = backdropColor)
.clip(shape = MaterialTheme.contentSurfaceShape)
.background(color = MaterialTheme.colorScheme.background)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyListState
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.SnackbarHostState
Expand All @@ -31,6 +30,7 @@ import androidx.compose.ui.unit.dp
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.lifecycle.viewmodel.compose.viewModel
import com.android.messaging.R
import com.android.messaging.ui.common.components.contentSurfaceShape
import com.android.messaging.ui.common.components.snackbar.MessagingSnackbarHost
import com.android.messaging.ui.common.components.snackbar.showActionSnackbar
import com.android.messaging.ui.conversationlist.archived.model.ArchivedConversationListAction as Action
Expand All @@ -51,11 +51,6 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.launch

private val ContentCornerShape = RoundedCornerShape(
topStart = 28.dp,
topEnd = 28.dp,
)

private val ArchivedSwipeSpec = ConversationListSwipeSpec(
startToEnd = ConversationSwipeKind.Unarchive,
endToStart = ConversationSwipeKind.Unarchive,
Expand Down Expand Up @@ -200,7 +195,7 @@ private fun ArchivedConversationListScaffold(
.fillMaxSize()
.padding(top = contentPadding.calculateTopPadding())
.background(archivedBackdropColor(isSelectionMode))
.clip(ContentCornerShape)
.clip(MaterialTheme.contentSurfaceShape)
.background(MaterialTheme.colorScheme.background),
) {
ArchivedConversationListContent(
Expand Down
Loading
Loading