Enable detekt rules UnnecessaryParentheses and cleanup the code.
This commit is contained in:
parent
2928073e22
commit
c75eabbcb0
16 changed files with 27 additions and 23 deletions
|
|
@ -29,7 +29,7 @@ fun Modifier.centerBottomEdge(scope: BoxScope): Modifier = with(scope) {
|
||||||
Modifier.align { size, space, _ ->
|
Modifier.align { size, space, _ ->
|
||||||
IntOffset(
|
IntOffset(
|
||||||
x = (space.width - size.width) / 2,
|
x = (space.width - size.width) / 2,
|
||||||
y = (space.height / 2) - size.height,
|
y = space.height / 2 - size.height,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,8 @@ data class LoginPasswordState(
|
||||||
) {
|
) {
|
||||||
val submitEnabled: Boolean
|
val submitEnabled: Boolean
|
||||||
get() = loginAction !is Async.Failure &&
|
get() = loginAction !is Async.Failure &&
|
||||||
((formState.login.isNotEmpty() && formState.password.isNotEmpty()))
|
formState.login.isNotEmpty() &&
|
||||||
|
formState.password.isNotEmpty()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Parcelize
|
@Parcelize
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ fun TimelineItem.Event.toExtraPadding(): ExtraPadding {
|
||||||
fun ExtraPadding.getStr(fontSize: TextUnit): String {
|
fun ExtraPadding.getStr(fontSize: TextUnit): String {
|
||||||
if (nbChars == 0) return ""
|
if (nbChars == 0) return ""
|
||||||
val timestampFontSize = ElementTheme.typography.fontBodyXsRegular.fontSize // 11.sp
|
val timestampFontSize = ElementTheme.typography.fontBodyXsRegular.fontSize // 11.sp
|
||||||
val nbOfSpaces = ((timestampFontSize.value / fontSize.value) * nbChars).toInt() + 1
|
val nbOfSpaces = (timestampFontSize.value / fontSize.value * nbChars).toInt() + 1
|
||||||
// A space and some unbreakable spaces
|
// A space and some unbreakable spaces
|
||||||
return " " + "\u00A0".repeat(nbOfSpaces)
|
return " " + "\u00A0".repeat(nbOfSpaces)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -351,7 +351,7 @@ private fun HtmlMxReply(
|
||||||
Surface(
|
Surface(
|
||||||
modifier = modifier
|
modifier = modifier
|
||||||
.padding(bottom = 4.dp)
|
.padding(bottom = 4.dp)
|
||||||
.offset(x = -(8.dp)),
|
.offset(x = (-8).dp),
|
||||||
color = MaterialTheme.colorScheme.background,
|
color = MaterialTheme.colorScheme.background,
|
||||||
shape = shape,
|
shape = shape,
|
||||||
) {
|
) {
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ class AttachmentsPreviewPresenterTest {
|
||||||
val loadingState = awaitItem()
|
val loadingState = awaitItem()
|
||||||
assertThat(loadingState.sendActionState).isEqualTo(SendActionState.Sending.Processing)
|
assertThat(loadingState.sendActionState).isEqualTo(SendActionState.Sending.Processing)
|
||||||
val failureState = awaitItem()
|
val failureState = awaitItem()
|
||||||
assertThat(failureState.sendActionState).isEqualTo((SendActionState.Failure(failure)))
|
assertThat(failureState.sendActionState).isEqualTo(SendActionState.Failure(failure))
|
||||||
assertThat(room.sendMediaCount).isEqualTo(0)
|
assertThat(room.sendMediaCount).isEqualTo(0)
|
||||||
failureState.eventSink(AttachmentsPreviewEvents.ClearSendState)
|
failureState.eventSink(AttachmentsPreviewEvents.ClearSendState)
|
||||||
val clearedState = awaitItem()
|
val clearedState = awaitItem()
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ class RoomInviteMembersPresenter @Inject constructor(
|
||||||
value = if (value.contains(user)) {
|
value = if (value.contains(user)) {
|
||||||
value.filterNot { it == user }
|
value.filterNot { it == user }
|
||||||
} else {
|
} else {
|
||||||
(value + user)
|
value + user
|
||||||
}.toImmutableList()
|
}.toImmutableList()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ class RoomMemberListPresenterTests {
|
||||||
loadedState.eventSink(RoomMemberListEvents.OnSearchActiveChanged(true))
|
loadedState.eventSink(RoomMemberListEvents.OnSearchActiveChanged(true))
|
||||||
|
|
||||||
val searchActiveState = awaitItem()
|
val searchActiveState = awaitItem()
|
||||||
Truth.assertThat((searchActiveState.isSearchActive)).isTrue()
|
Truth.assertThat(searchActiveState.isSearchActive).isTrue()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -88,7 +88,7 @@ class RoomMemberListPresenterTests {
|
||||||
val searchActiveState = awaitItem()
|
val searchActiveState = awaitItem()
|
||||||
loadedState.eventSink(RoomMemberListEvents.UpdateSearchQuery("something"))
|
loadedState.eventSink(RoomMemberListEvents.UpdateSearchQuery("something"))
|
||||||
val searchQueryUpdatedState = awaitItem()
|
val searchQueryUpdatedState = awaitItem()
|
||||||
Truth.assertThat((searchQueryUpdatedState.searchQuery)).isEqualTo("something")
|
Truth.assertThat(searchQueryUpdatedState.searchQuery).isEqualTo("something")
|
||||||
val searchSearchResultDelivered = awaitItem()
|
val searchSearchResultDelivered = awaitItem()
|
||||||
Truth.assertThat(searchSearchResultDelivered.searchResults).isInstanceOf(SearchBarResultState.NoResults::class.java)
|
Truth.assertThat(searchSearchResultDelivered.searchResults).isInstanceOf(SearchBarResultState.NoResults::class.java)
|
||||||
}
|
}
|
||||||
|
|
@ -106,9 +106,9 @@ class RoomMemberListPresenterTests {
|
||||||
val searchActiveState = awaitItem()
|
val searchActiveState = awaitItem()
|
||||||
loadedState.eventSink(RoomMemberListEvents.UpdateSearchQuery("Alice"))
|
loadedState.eventSink(RoomMemberListEvents.UpdateSearchQuery("Alice"))
|
||||||
val searchQueryUpdatedState = awaitItem()
|
val searchQueryUpdatedState = awaitItem()
|
||||||
Truth.assertThat((searchQueryUpdatedState.searchQuery)).isEqualTo("Alice")
|
Truth.assertThat(searchQueryUpdatedState.searchQuery).isEqualTo("Alice")
|
||||||
val searchSearchResultDelivered = awaitItem()
|
val searchSearchResultDelivered = awaitItem()
|
||||||
Truth.assertThat((searchSearchResultDelivered.searchResults)).isInstanceOf(SearchBarResultState.Results::class.java)
|
Truth.assertThat(searchSearchResultDelivered.searchResults).isInstanceOf(SearchBarResultState.Results::class.java)
|
||||||
Truth.assertThat((searchSearchResultDelivered.searchResults as SearchBarResultState.Results).results.joined.first().displayName)
|
Truth.assertThat((searchSearchResultDelivered.searchResults as SearchBarResultState.Results).results.joined.first().displayName)
|
||||||
.isEqualTo("Alice")
|
.isEqualTo("Alice")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -155,7 +155,7 @@ private fun RowScope.NameAndTimestampRow(room: RoomListRoomSummary) {
|
||||||
@Composable
|
@Composable
|
||||||
private fun RowScope.LastMessageAndIndicatorRow(room: RoomListRoomSummary) {
|
private fun RowScope.LastMessageAndIndicatorRow(room: RoomListRoomSummary) {
|
||||||
// Last Message
|
// Last Message
|
||||||
val attributedLastMessage = (room.lastMessage as? AnnotatedString)
|
val attributedLastMessage = room.lastMessage as? AnnotatedString
|
||||||
?: AnnotatedString(room.lastMessage.orEmpty().toString())
|
?: AnnotatedString(room.lastMessage.orEmpty().toString())
|
||||||
Text(
|
Text(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
|
|
@ -186,10 +186,10 @@ class PercentRectangleSizeShape(private val percent: Float) : Shape {
|
||||||
val halfPercent = percent / 2f
|
val halfPercent = percent / 2f
|
||||||
val path = Path().apply {
|
val path = Path().apply {
|
||||||
val rect = Rect(
|
val rect = Rect(
|
||||||
0f,
|
left = 0f,
|
||||||
size.height * halfPercent,
|
top = size.height * halfPercent,
|
||||||
size.width,
|
right = size.width,
|
||||||
size.height - (size.height * halfPercent)
|
bottom = size.height * (1 - halfPercent)
|
||||||
)
|
)
|
||||||
addRect(rect)
|
addRect(rect)
|
||||||
close()
|
close()
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ fun Context.isAnimationEnabled(): Boolean {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ChecksSdkIntAtLeast(api = Build.VERSION_CODES.O)
|
@ChecksSdkIntAtLeast(api = Build.VERSION_CODES.O)
|
||||||
fun supportNotificationChannels() = (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
|
fun supportNotificationChannels() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the application label of the provided package. If not found, the package is returned.
|
* Return the application label of the provided package. If not found, the package is returned.
|
||||||
|
|
|
||||||
|
|
@ -138,7 +138,7 @@ fun Modifier.shapeShadow(
|
||||||
val paint = Paint()
|
val paint = Paint()
|
||||||
val frameworkPaint = paint.asFrameworkPaint()
|
val frameworkPaint = paint.asFrameworkPaint()
|
||||||
if (blurRadius != 0.dp) {
|
if (blurRadius != 0.dp) {
|
||||||
frameworkPaint.maskFilter = (BlurMaskFilter(blurRadius.toPx(), BlurMaskFilter.Blur.NORMAL))
|
frameworkPaint.maskFilter = BlurMaskFilter(blurRadius.toPx(), BlurMaskFilter.Blur.NORMAL)
|
||||||
}
|
}
|
||||||
frameworkPaint.color = color.toArgb()
|
frameworkPaint.color = color.toArgb()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ class EventMessageMapper {
|
||||||
fun map(message: Message): MessageContent = message.use {
|
fun map(message: Message): MessageContent = message.use {
|
||||||
val type = it.msgtype().use(this::mapMessageType)
|
val type = it.msgtype().use(this::mapMessageType)
|
||||||
val inReplyToId = it.inReplyTo()?.eventId?.let(::EventId)
|
val inReplyToId = it.inReplyTo()?.eventId?.let(::EventId)
|
||||||
val inReplyToEvent: InReplyTo? = (it.inReplyTo()?.event)?.use { details ->
|
val inReplyToEvent: InReplyTo? = it.inReplyTo()?.event?.use { details ->
|
||||||
when (details) {
|
when (details) {
|
||||||
is RepliedToEventDetails.Ready -> {
|
is RepliedToEventDetails.Ready -> {
|
||||||
val senderProfile = details.senderProfile as? ProfileDetails.Ready
|
val senderProfile = details.senderProfile as? ProfileDetails.Ready
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@ fun SelectedUsersList(
|
||||||
val maxVisibleUsers = rowWidth / userWidthWithSpacing
|
val maxVisibleUsers = rowWidth / userWidthWithSpacing
|
||||||
|
|
||||||
// Round down the number of visible users to end with a state where one is half visible
|
// Round down the number of visible users to end with a state where one is half visible
|
||||||
val targetFraction = (userWidth / 2) / userWidthWithSpacing
|
val targetFraction = userWidth / 2 / userWidthWithSpacing
|
||||||
val targetUsers = floor(maxVisibleUsers - targetFraction) + targetFraction
|
val targetUsers = floor(maxVisibleUsers - targetFraction) + targetFraction
|
||||||
|
|
||||||
// Work out how much extra spacing we need to reduce the number of users that much, then split it evenly amongst the visible users
|
// Work out how much extra spacing we need to reduce the number of users that much, then split it evenly amongst the visible users
|
||||||
|
|
@ -153,7 +153,7 @@ private fun ContentToPreview() {
|
||||||
SelectedUsersList(
|
SelectedUsersList(
|
||||||
selectedUsers = aMatrixUserList().take(6).toImmutableList(),
|
selectedUsers = aMatrixUserList().take(6).toImmutableList(),
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.width((200 + (i * 20)).dp)
|
.width((200 + (i * 20).dp)
|
||||||
.border(1.dp, Color.Red)
|
.border(1.dp, Color.Red)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,7 @@ class ImageCompressor @Inject constructor(
|
||||||
) {
|
) {
|
||||||
val (width, height) = when (resizeMode) {
|
val (width, height) = when (resizeMode) {
|
||||||
is ResizeMode.Approximate -> resizeMode.desiredWidth to resizeMode.desiredHeight
|
is ResizeMode.Approximate -> resizeMode.desiredWidth to resizeMode.desiredHeight
|
||||||
is ResizeMode.Strict -> (resizeMode.maxWidth / 2) to (resizeMode.maxHeight / 2)
|
is ResizeMode.Strict -> resizeMode.maxWidth / 2 to resizeMode.maxHeight / 2
|
||||||
is ResizeMode.None -> return
|
is ResizeMode.None -> return
|
||||||
}
|
}
|
||||||
// Read bounds only
|
// Read bounds only
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ class RoomGroupMessageCreator @Inject constructor(
|
||||||
|
|
||||||
val lastMessageTimestamp = events.last().timestamp
|
val lastMessageTimestamp = events.last().timestamp
|
||||||
val smartReplyErrors = events.filter { it.isSmartReplyError() }
|
val smartReplyErrors = events.filter { it.isSmartReplyError() }
|
||||||
val messageCount = (events.size - smartReplyErrors.size)
|
val messageCount = events.size - smartReplyErrors.size
|
||||||
val meta = RoomNotification.Message.Meta(
|
val meta = RoomNotification.Message.Meta(
|
||||||
summaryLine = createRoomMessagesGroupSummaryLine(events, roomName, roomIsDirect = !roomIsGroup),
|
summaryLine = createRoomMessagesGroupSummaryLine(events, roomName, roomIsDirect = !roomIsGroup),
|
||||||
messageCount = messageCount,
|
messageCount = messageCount,
|
||||||
|
|
|
||||||
|
|
@ -162,7 +162,7 @@ class NotificationChannels @Inject constructor(
|
||||||
private const val CALL_NOTIFICATION_CHANNEL_ID = "CALL_NOTIFICATION_CHANNEL_ID_V2"
|
private const val CALL_NOTIFICATION_CHANNEL_ID = "CALL_NOTIFICATION_CHANNEL_ID_V2"
|
||||||
|
|
||||||
@ChecksSdkIntAtLeast(api = Build.VERSION_CODES.O)
|
@ChecksSdkIntAtLeast(api = Build.VERSION_CODES.O)
|
||||||
private fun supportNotificationChannels() = (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
|
private fun supportNotificationChannels() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
|
||||||
|
|
||||||
fun openSystemSettingsForSilentCategory(activity: Activity) {
|
fun openSystemSettingsForSilentCategory(activity: Activity) {
|
||||||
activity.startNotificationChannelSettingsIntent(SILENT_NOTIFICATION_CHANNEL_ID)
|
activity.startNotificationChannelSettingsIntent(SILENT_NOTIFICATION_CHANNEL_ID)
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,9 @@ style:
|
||||||
active: true
|
active: true
|
||||||
UnusedParameter:
|
UnusedParameter:
|
||||||
active: true
|
active: true
|
||||||
|
UnnecessaryParentheses:
|
||||||
|
active: true
|
||||||
|
allowForUnclearPrecedence: false
|
||||||
UnusedImports:
|
UnusedImports:
|
||||||
active: true
|
active: true
|
||||||
UnusedPrivateProperty:
|
UnusedPrivateProperty:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue