Skip to content

Commit 011b8ad

Browse files
committed
fix detekt warnings
1 parent c813da2 commit 011b8ad

File tree

3 files changed

+29
-38
lines changed

3 files changed

+29
-38
lines changed

android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/cell/RelayLocationCell.kt

+27-37
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import androidx.compose.ui.text.style.TextOverflow
2929
import androidx.compose.ui.tooling.preview.Preview
3030
import androidx.compose.ui.tooling.preview.PreviewParameter
3131
import androidx.compose.ui.unit.dp
32-
import mullvad_daemon.management_interface.relay
3332
import net.mullvad.mullvadvpn.R
3433
import net.mullvad.mullvadvpn.compose.component.Chevron
3534
import net.mullvad.mullvadvpn.compose.component.MullvadCheckbox
@@ -49,7 +48,10 @@ private fun PreviewCheckableRelayLocationCell(
4948
) {
5049
AppTheme {
5150
Column(Modifier.background(color = MaterialTheme.colorScheme.background)) {
52-
// relayItems.map { CheckableRelayLocationCell(item = it) }
51+
relayItems.map {
52+
CheckableRelayLocationCell(
53+
item = it, checked = false, expanded = false, depth = 0, onExpand = {})
54+
}
5355
}
5456
}
5557
}
@@ -71,14 +73,13 @@ fun StatusRelayItemCell(
7173
) {
7274

7375
RelayItemCell(
76+
modifier = modifier,
7477
item,
7578
isSelected,
7679
leadingContent = {
7780
if (isSelected) {
7881
Icon(
79-
painter = painterResource(id = R.drawable.icon_tick),
80-
contentDescription = null
81-
)
82+
painter = painterResource(id = R.drawable.icon_tick), contentDescription = null)
8283
} else {
8384
Box(
8485
modifier =
@@ -93,23 +94,21 @@ fun StatusRelayItemCell(
9394
item.active -> activeColor
9495
else -> inactiveColor
9596
},
96-
shape = CircleShape
97-
)
98-
)
97+
shape = CircleShape))
9998
}
10099
},
101100
onClick = onClick,
102101
onLongClick = onLongClick,
103102
onToggleExpand = onToggleExpand,
104103
isExpanded = isExpanded,
105104
depth = depth,
106-
modifier = modifier,
107105
)
108106
}
109107

110108
@OptIn(ExperimentalFoundationApi::class)
111109
@Composable
112110
fun RelayItemCell(
111+
modifier: Modifier = Modifier,
113112
item: RelayItem,
114113
isSelected: Boolean,
115114
leadingContent: (@Composable RowScope.() -> Unit)? = null,
@@ -118,7 +117,6 @@ fun RelayItemCell(
118117
onToggleExpand: ((Boolean) -> Unit),
119118
isExpanded: Boolean,
120119
depth: Int,
121-
modifier: Modifier = Modifier,
122120
) {
123121

124122
val leadingContentStartPadding = Dimens.cellStartPadding
@@ -135,25 +133,23 @@ fun RelayItemCell(
135133
item is RelayItem.CustomList && !item.active ->
136134
MaterialTheme.colorScheme.surfaceTint
137135
else -> depth.toBackgroundColor()
138-
}
139-
)
136+
})
140137
.combinedClickable(
141138
enabled = item.active,
142139
onClick = onClick,
143140
onLongClick = onLongClick,
144141
)
145142
.padding(start = startPadding),
146-
verticalAlignment = Alignment.CenterVertically
147-
) {
148-
if (leadingContent != null) {
149-
leadingContent()
150-
}
151-
Name(modifier = Modifier.weight(1f), relay = item)
143+
verticalAlignment = Alignment.CenterVertically) {
144+
if (leadingContent != null) {
145+
leadingContent()
146+
}
147+
Name(modifier = Modifier.weight(1f), relay = item)
152148

153-
if (item.hasChildren) {
154-
ExpandButton(isExpanded = isExpanded, onClick = { onToggleExpand(!isExpanded) })
149+
if (item.hasChildren) {
150+
ExpandButton(isExpanded = isExpanded, onClick = { onToggleExpand(!isExpanded) })
151+
}
155152
}
156-
}
157153
}
158154

159155
@Composable
@@ -167,20 +163,18 @@ fun CheckableRelayLocationCell(
167163
depth: Int
168164
) {
169165
RelayItemCell(
166+
modifier = modifier,
170167
item = item,
171-
isExpanded = expanded,
172-
onToggleExpand = onExpand,
168+
isSelected = false,
173169
leadingContent = {
174170
MullvadCheckbox(
175171
checked = checked,
176-
onCheckedChange = { isChecked -> onRelayCheckedChange(isChecked) }
177-
)
172+
onCheckedChange = { isChecked -> onRelayCheckedChange(isChecked) })
178173
},
179-
modifier = modifier,
180174
onClick = { onRelayCheckedChange(!checked) },
181-
onLongClick = null,
182-
depth = depth,
183-
isSelected = false
175+
onToggleExpand = onExpand,
176+
isExpanded = expanded,
177+
depth = depth
184178
)
185179
}
186180

@@ -196,28 +190,24 @@ private fun Name(modifier: Modifier = Modifier, relay: RelayItem) {
196190
AlphaVisible
197191
} else {
198192
AlphaInactive
199-
}
200-
)
193+
})
201194
.padding(horizontal = Dimens.smallPadding, vertical = Dimens.mediumPadding),
202195
maxLines = 1,
203-
overflow = TextOverflow.Ellipsis
204-
)
196+
overflow = TextOverflow.Ellipsis)
205197
}
206198

207199
@Composable
208200
private fun RowScope.ExpandButton(isExpanded: Boolean, onClick: (expand: Boolean) -> Unit) {
209201
VerticalDivider(
210202
color = MaterialTheme.colorScheme.background,
211-
modifier = Modifier.padding(vertical = Dimens.verticalDividerPadding)
212-
)
203+
modifier = Modifier.padding(vertical = Dimens.verticalDividerPadding))
213204
Chevron(
214205
isExpanded = isExpanded,
215206
modifier =
216207
Modifier.fillMaxHeight()
217208
.clickable { onClick(!isExpanded) }
218209
.padding(horizontal = Dimens.largePadding)
219-
.align(Alignment.CenterVertically)
220-
)
210+
.align(Alignment.CenterVertically))
221211
}
222212

223213
@Suppress("MagicNumber")

android/app/src/main/kotlin/net/mullvad/mullvadvpn/usecase/customlists/FilterCustomListsRelayItemUseCase.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ class FilterCustomListsRelayItemUseCase(
2727
ownership: Constraint<Ownership>,
2828
providers: Constraint<Providers>
2929
) = mapNotNull { it.filterOnOwnershipAndProvider(ownership, providers) }
30-
}
30+
}

android/config/baseline.xml

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
<ID>ReturnCount:RelayNameComparator.kt$RelayNameComparator$private infix fun List&lt;String&gt;.compareWith(other: List&lt;String&gt;): Int</ID>
2727
<ID>ReturnCount:TalpidVpnService.kt$TalpidVpnService$private fun createTun(config: TunConfig): CreateTunResult</ID>
2828
<ID>TooManyFunctions:EditApiAccessMethodViewModel.kt$EditApiAccessMethodViewModel : ViewModel</ID>
29+
<ID>TooManyFunctions:SelectLocationViewModel.kt$SelectLocationViewModel : ViewModel</ID>
2930
<ID>TooManyFunctions:VpnSettingsViewModel.kt$VpnSettingsViewModel : ViewModel</ID>
3031
<ID>UnusedParameter:SimpleMullvadHttpClient.kt$SimpleMullvadHttpClient$body: JSONArray? = null</ID>
3132
<ID>UnusedPrivateMember:ConnectivityListener.kt$ConnectivityListener$private fun finalize()</ID>

0 commit comments

Comments
 (0)