Skip to content

Commit 766cdae

Browse files
committed
Merge branch 'android-materialize-colors'
2 parents eb978f3 + 2468105 commit 766cdae

File tree

99 files changed

+1029
-752
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+1029
-752
lines changed

android/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Line wrap the file at 100 chars. Th
2929
### Changed
3030
- Migrate underlaying communication wtih daemon to gRPC. This also implies major changes and
3131
improvements throughout the app.
32+
- Update colors in the app to be more in line with material design.
3233

3334
### Fixed
3435
- Fix VPN service being recreated multiple times when toggling certain options.

android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/button/AnimatedIconButton.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ fun AnimatedIconButton(
2020
defaultIcon: Painter,
2121
secondaryIcon: Painter,
2222
pressEffectDuration: Long = PRESS_EFFECT_TIME_SPAN,
23-
defaultIconTint: Color = Color.Unspecified,
24-
secondaryIconTint: Color = Color.Unspecified,
23+
defaultIconTint: Color,
24+
secondaryIconTint: Color,
2525
contentDescription: String,
2626
isToggleButton: Boolean = false,
2727
onClick: () -> Unit

android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/button/ApplyButton.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ private fun PreviewApplyButton() {
2424
@Composable
2525
fun ApplyButton(
2626
modifier: Modifier = Modifier,
27-
background: Color = MaterialTheme.colorScheme.background,
27+
background: Color = MaterialTheme.colorScheme.tertiary,
2828
onClick: () -> Unit,
2929
isEnabled: Boolean
3030
) {

android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/button/ConnectionButton.kt

+2-4
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ import net.mullvad.mullvadvpn.lib.model.TunnelState
3737
import net.mullvad.mullvadvpn.lib.theme.AppTheme
3838
import net.mullvad.mullvadvpn.lib.theme.Dimens
3939
import net.mullvad.mullvadvpn.lib.theme.color.AlphaDisconnectButton
40-
import net.mullvad.mullvadvpn.lib.theme.color.onVariant
41-
import net.mullvad.mullvadvpn.lib.theme.color.variant
4240

4341
@Composable
4442
fun ConnectionButton(
@@ -52,14 +50,14 @@ fun ConnectionButton(
5250
) {
5351
val containerColor =
5452
if (state is TunnelState.Disconnected) {
55-
MaterialTheme.colorScheme.variant
53+
MaterialTheme.colorScheme.tertiary
5654
} else {
5755
MaterialTheme.colorScheme.error.copy(alpha = AlphaDisconnectButton)
5856
}
5957

6058
val contentColor =
6159
if (state is TunnelState.Disconnected) {
62-
MaterialTheme.colorScheme.onVariant
60+
MaterialTheme.colorScheme.onTertiary
6361
} else {
6462
MaterialTheme.colorScheme.onError
6563
}

android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/button/MullvadButton.kt

+12-31
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,17 @@ import androidx.compose.runtime.Composable
1414
import androidx.compose.ui.Modifier
1515
import androidx.compose.ui.draw.alpha
1616
import androidx.compose.ui.graphics.Color
17-
import androidx.compose.ui.graphics.compositeOver
1817
import androidx.compose.ui.text.style.TextAlign
1918
import androidx.compose.ui.text.style.TextOverflow
2019
import androidx.compose.ui.tooling.preview.Preview
2120
import androidx.compose.ui.unit.dp
2221
import net.mullvad.mullvadvpn.lib.theme.AppTheme
2322
import net.mullvad.mullvadvpn.lib.theme.Dimens
2423
import net.mullvad.mullvadvpn.lib.theme.color.Alpha20
25-
import net.mullvad.mullvadvpn.lib.theme.color.AlphaInactive
2624
import net.mullvad.mullvadvpn.lib.theme.color.AlphaInvisible
27-
import net.mullvad.mullvadvpn.lib.theme.color.onVariant
28-
import net.mullvad.mullvadvpn.lib.theme.color.variant
25+
import net.mullvad.mullvadvpn.lib.theme.color.errorDisabled
26+
import net.mullvad.mullvadvpn.lib.theme.color.primaryDisabled
27+
import net.mullvad.mullvadvpn.lib.theme.color.tertiaryDisabled
2928

3029
@Preview
3130
@Composable
@@ -72,14 +71,8 @@ fun NegativeButton(
7271
ButtonDefaults.buttonColors(
7372
containerColor = MaterialTheme.colorScheme.error,
7473
contentColor = MaterialTheme.colorScheme.onError,
75-
disabledContentColor =
76-
MaterialTheme.colorScheme.onError
77-
.copy(alpha = AlphaInactive)
78-
.compositeOver(MaterialTheme.colorScheme.background),
79-
disabledContainerColor =
80-
MaterialTheme.colorScheme.error
81-
.copy(alpha = AlphaInactive)
82-
.compositeOver(MaterialTheme.colorScheme.background),
74+
disabledContentColor = MaterialTheme.colorScheme.onError.copy(alpha = Alpha20),
75+
disabledContainerColor = MaterialTheme.colorScheme.errorDisabled
8376
),
8477
isEnabled: Boolean = true,
8578
icon: @Composable (() -> Unit)? = null
@@ -99,19 +92,13 @@ fun VariantButton(
9992
onClick: () -> Unit,
10093
text: String,
10194
modifier: Modifier = Modifier,
102-
background: Color = MaterialTheme.colorScheme.background,
95+
background: Color = MaterialTheme.colorScheme.tertiary,
10396
colors: ButtonColors =
10497
ButtonDefaults.buttonColors(
105-
containerColor = MaterialTheme.colorScheme.variant,
106-
contentColor = MaterialTheme.colorScheme.onVariant,
107-
disabledContentColor =
108-
MaterialTheme.colorScheme.onVariant
109-
.copy(alpha = AlphaInactive)
110-
.compositeOver(background),
111-
disabledContainerColor =
112-
MaterialTheme.colorScheme.variant
113-
.copy(alpha = AlphaInactive)
114-
.compositeOver(background),
98+
containerColor = background,
99+
contentColor = MaterialTheme.colorScheme.onTertiary,
100+
disabledContentColor = MaterialTheme.colorScheme.onTertiary.copy(alpha = Alpha20),
101+
disabledContainerColor = MaterialTheme.colorScheme.tertiaryDisabled,
115102
),
116103
isEnabled: Boolean = true,
117104
icon: @Composable (() -> Unit)? = null
@@ -135,14 +122,8 @@ fun PrimaryButton(
135122
ButtonDefaults.buttonColors(
136123
containerColor = MaterialTheme.colorScheme.primary,
137124
contentColor = MaterialTheme.colorScheme.onPrimary,
138-
disabledContentColor =
139-
MaterialTheme.colorScheme.onPrimary
140-
.copy(alpha = Alpha20)
141-
.compositeOver(MaterialTheme.colorScheme.background),
142-
disabledContainerColor =
143-
MaterialTheme.colorScheme.primary
144-
.copy(alpha = AlphaInactive)
145-
.compositeOver(MaterialTheme.colorScheme.background),
125+
disabledContentColor = MaterialTheme.colorScheme.onPrimary.copy(alpha = Alpha20),
126+
disabledContainerColor = MaterialTheme.colorScheme.primaryDisabled,
146127
),
147128
isEnabled: Boolean = true,
148129
leadingIcon: @Composable (() -> Unit)? = null,

android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/button/RedeemVoucherButton.kt

+1-9
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
package net.mullvad.mullvadvpn.compose.button
22

3-
import androidx.compose.material3.MaterialTheme
43
import androidx.compose.runtime.Composable
54
import androidx.compose.ui.Modifier
6-
import androidx.compose.ui.graphics.Color
75
import androidx.compose.ui.res.stringResource
86
import androidx.compose.ui.tooling.preview.Preview
97
import net.mullvad.mullvadvpn.R
@@ -22,14 +20,8 @@ private fun PreviewRedeemVoucherButton() {
2220
}
2321

2422
@Composable
25-
fun RedeemVoucherButton(
26-
modifier: Modifier = Modifier,
27-
background: Color = MaterialTheme.colorScheme.background,
28-
onClick: () -> Unit,
29-
isEnabled: Boolean
30-
) {
23+
fun RedeemVoucherButton(modifier: Modifier = Modifier, onClick: () -> Unit, isEnabled: Boolean) {
3124
VariantButton(
32-
background = background,
3325
text = stringResource(id = R.string.redeem_voucher),
3426
onClick = onClick,
3527
modifier = modifier,

android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/button/SitePaymentButton.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ private fun PreviewSitePaymentButton() {
1717
AppTheme {
1818
SpacedColumn(
1919
spacing = Dimens.cellVerticalSpacing,
20-
modifier = Modifier.background(color = MaterialTheme.colorScheme.background)
20+
modifier = Modifier.background(color = MaterialTheme.colorScheme.surface)
2121
) {
2222
SitePaymentButton(onClick = {}, isEnabled = true)
2323
SitePaymentButton(onClick = {}, isEnabled = false)

android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/button/SwitchLocationButton.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ fun SwitchLocationButton(
3434
onClick = onClick,
3535
colors =
3636
ButtonDefaults.buttonColors(
37-
containerColor = MaterialTheme.colorScheme.inverseSurface.copy(alpha = Alpha20),
38-
contentColor = MaterialTheme.colorScheme.inverseSurface
37+
containerColor = MaterialTheme.colorScheme.onPrimary.copy(alpha = Alpha20),
38+
contentColor = MaterialTheme.colorScheme.onPrimary
3939
),
4040
modifier = modifier,
4141
text = text,

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

+24-9
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import net.mullvad.mullvadvpn.lib.theme.Dimens
3333
@Composable
3434
private fun PreviewBaseCell() {
3535
AppTheme {
36-
SpacedColumn {
36+
SpacedColumn(modifier = Modifier.background(MaterialTheme.colorScheme.surface)) {
3737
BaseCell(
3838
headlineContent = {
3939
BaseCellTitle(
@@ -102,31 +102,46 @@ internal fun BaseCellTitle(
102102
title: String,
103103
style: TextStyle,
104104
modifier: Modifier = Modifier,
105-
color: Color = MaterialTheme.colorScheme.onPrimary,
106-
textAlign: TextAlign = TextAlign.Start
105+
textAlign: TextAlign = TextAlign.Start,
106+
textColor: Color = MaterialTheme.colorScheme.onPrimary
107107
) {
108108
Text(
109109
text = title,
110110
textAlign = textAlign,
111111
style = style,
112-
color = color,
112+
color = textColor,
113113
overflow = TextOverflow.Ellipsis,
114114
maxLines = 1,
115115
modifier = modifier
116116
)
117117
}
118118

119119
@Composable
120-
fun BaseSubtitleCell(text: String, modifier: Modifier = Modifier) {
121-
BaseSubtitleCell(text = AnnotatedString(text), modifier = modifier)
120+
fun BaseSubtitleCell(
121+
text: String,
122+
modifier: Modifier = Modifier,
123+
style: TextStyle = MaterialTheme.typography.labelMedium,
124+
color: Color
125+
) {
126+
BaseSubtitleCell(
127+
text = AnnotatedString(text),
128+
modifier = modifier,
129+
style = style,
130+
color = color
131+
)
122132
}
123133

124134
@Composable
125-
fun BaseSubtitleCell(text: AnnotatedString, modifier: Modifier = Modifier) {
135+
fun BaseSubtitleCell(
136+
text: AnnotatedString,
137+
modifier: Modifier = Modifier,
138+
style: TextStyle = MaterialTheme.typography.labelMedium,
139+
color: Color
140+
) {
126141
Text(
127142
text = text,
128-
style = MaterialTheme.typography.labelMedium,
129-
color = MaterialTheme.colorScheme.onSecondary,
143+
style = style,
144+
color = color,
130145
modifier =
131146
modifier
132147
.padding(

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ internal fun CheckboxCell(
3232
title: String,
3333
checked: Boolean,
3434
onCheckedChange: (Boolean) -> Unit,
35-
background: Color = MaterialTheme.colorScheme.secondaryContainer,
35+
background: Color = MaterialTheme.colorScheme.surfaceContainerLow,
3636
startPadding: Dp = Dimens.mediumPadding,
3737
endPadding: Dp = Dimens.cellEndPadding,
3838
minHeight: Dp = Dimens.cellHeight
@@ -54,7 +54,7 @@ internal fun CheckboxCell(
5454
Text(
5555
text = title,
5656
style = MaterialTheme.typography.labelLarge,
57-
color = MaterialTheme.colorScheme.onBackground,
57+
color = MaterialTheme.colorScheme.onSurface,
5858
modifier =
5959
Modifier.weight(1f)
6060
.padding(top = Dimens.mediumPadding, bottom = Dimens.mediumPadding)

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

+11-4
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,14 @@ import net.mullvad.mullvadvpn.lib.theme.AppTheme
3131
import net.mullvad.mullvadvpn.lib.theme.Dimens
3232
import net.mullvad.mullvadvpn.lib.theme.color.AlphaInvisible
3333
import net.mullvad.mullvadvpn.lib.theme.color.AlphaVisible
34+
import net.mullvad.mullvadvpn.lib.theme.color.onSelected
3435
import net.mullvad.mullvadvpn.lib.theme.color.selected
3536

3637
@Preview
3738
@Composable
3839
private fun PreviewCustomPortCell() {
3940
AppTheme {
40-
SpacedColumn(Modifier.background(MaterialTheme.colorScheme.background)) {
41+
SpacedColumn(Modifier.background(MaterialTheme.colorScheme.surface)) {
4142
CustomPortCell(title = "Title", isSelected = true, port = Port(444))
4243
CustomPortCell(title = "Title", isSelected = false, port = null)
4344
}
@@ -70,7 +71,7 @@ fun CustomPortCell(
7071
if (isSelected) {
7172
MaterialTheme.colorScheme.selected
7273
} else {
73-
MaterialTheme.colorScheme.secondaryContainer
74+
MaterialTheme.colorScheme.surfaceContainerLow
7475
}
7576
)
7677
.padding(start = Dimens.cellStartPadding)
@@ -79,15 +80,21 @@ fun CustomPortCell(
7980
Icon(
8081
painter = painterResource(id = R.drawable.icon_tick),
8182
contentDescription = null,
82-
tint = MaterialTheme.colorScheme.onPrimary,
83+
tint = MaterialTheme.colorScheme.onSelected,
8384
modifier =
8485
Modifier.padding(end = Dimens.selectableCellTextMargin)
8586
.alpha(if (isSelected) AlphaVisible else AlphaInvisible)
8687
)
8788
BaseCellTitle(
8889
title = title,
8990
style = MaterialTheme.typography.labelLarge,
90-
textAlign = TextAlign.Start
91+
textAlign = TextAlign.Start,
92+
textColor =
93+
if (isSelected) {
94+
MaterialTheme.colorScheme.onSelected
95+
} else {
96+
MaterialTheme.colorScheme.onSurface
97+
}
9198
)
9299
}
93100
Spacer(modifier = Modifier.width(Dimens.verticalSpacer))

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ import androidx.compose.material3.MaterialTheme
66
import androidx.compose.material3.Text
77
import androidx.compose.runtime.Composable
88
import androidx.compose.ui.Modifier
9-
import androidx.compose.ui.graphics.Color
109
import androidx.compose.ui.res.painterResource
1110
import androidx.compose.ui.res.stringResource
1211
import androidx.compose.ui.text.style.TextAlign
1312
import androidx.compose.ui.tooling.preview.Preview
1413
import androidx.compose.ui.unit.dp
1514
import net.mullvad.mullvadvpn.R
1615
import net.mullvad.mullvadvpn.lib.theme.AppTheme
16+
import net.mullvad.mullvadvpn.lib.theme.color.warning
1717

1818
@Preview
1919
@Composable
@@ -40,12 +40,12 @@ fun DnsCell(
4040
Icon(
4141
painter = painterResource(id = R.drawable.icon_alert),
4242
contentDescription = stringResource(id = R.string.confirm_local_dns),
43-
tint = MaterialTheme.colorScheme.errorContainer
43+
tint = MaterialTheme.colorScheme.warning
4444
)
4545
}
4646
},
4747
onCellClicked = { onClick.invoke() },
48-
background = MaterialTheme.colorScheme.secondaryContainer,
48+
background = MaterialTheme.colorScheme.surfaceContainerLow,
4949
startPadding = startPadding,
5050
modifier = modifier
5151
)
@@ -55,7 +55,7 @@ fun DnsCell(
5555
private fun RowScope.DnsTitle(address: String, modifier: Modifier = Modifier) {
5656
Text(
5757
text = address,
58-
color = Color.White,
58+
color = MaterialTheme.colorScheme.onSurface,
5959
style = MaterialTheme.typography.labelLarge,
6060
textAlign = TextAlign.Start,
6161
modifier = modifier.weight(1f)

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ fun ThreeDotCell(
3737
BaseCellTitle(
3838
title = text,
3939
style = textStyle,
40-
color = textColor,
40+
textColor = textColor,
4141
modifier = Modifier.weight(1f, true)
4242
)
4343
},

0 commit comments

Comments
 (0)