Skip to content

Commit

Permalink
Move Content blockers closer to Use custom Dns setting
Browse files Browse the repository at this point in the history
  • Loading branch information
Rawa authored and Pururun committed Nov 6, 2023
1 parent b13c219 commit ae9967e
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,16 @@ class VpnSettingsScreenTest {
)
}

composeTestRule.apply {
onNodeWithText("WireGuard MTU").assertExists()
onNodeWithText("Default").assertExists()
}
composeTestRule.apply { onNodeWithText("Auto-connect").assertExists() }

composeTestRule
.onNodeWithTag(LAZY_LIST_TEST_TAG)
.performScrollToNode(hasTestTag(LAZY_LIST_LAST_ITEM_TEST_TAG))

// Assert
composeTestRule.apply {
onNodeWithText("Use custom DNS server").assertExists()
onNodeWithText("Add a server").assertDoesNotExist()
onNodeWithText("WireGuard MTU").assertExists()
onNodeWithText("Default").assertExists()
}
}

Expand All @@ -81,6 +78,10 @@ class VpnSettingsScreenTest {
)
}

composeTestRule
.onNodeWithTag(LAZY_LIST_TEST_TAG)
.performScrollToNode(hasTestTag(LAZY_LIST_LAST_ITEM_TEST_TAG))

// Assert
composeTestRule.onNodeWithText(VALID_DUMMY_MTU_VALUE).assertExists()
}
Expand All @@ -97,6 +98,10 @@ class VpnSettingsScreenTest {
)
}

composeTestRule
.onNodeWithTag(LAZY_LIST_TEST_TAG)
.performScrollToNode(hasTestTag(LAZY_LIST_LAST_ITEM_TEST_TAG))

// Act
composeTestRule.onNodeWithText("WireGuard MTU").performClick()

Expand Down Expand Up @@ -257,9 +262,9 @@ class VpnSettingsScreenTest {
toastMessagesSharedFlow = MutableSharedFlow<String>().asSharedFlow()
)
}
composeTestRule
.onNodeWithTag(LAZY_LIST_TEST_TAG)
.performScrollToNode(hasTestTag(LAZY_LIST_LAST_ITEM_TEST_TAG))
// composeTestRule
// .onNodeWithTag(LAZY_LIST_TEST_TAG)
// .performScrollToNode(hasTestTag(LAZY_LIST_LAST_ITEM_TEST_TAG))
// Assert
composeTestRule.apply {
onNodeWithText(DUMMY_DNS_ADDRESS).assertExists()
Expand Down Expand Up @@ -386,9 +391,9 @@ class VpnSettingsScreenTest {
toastMessagesSharedFlow = MutableSharedFlow<String>().asSharedFlow()
)
}
composeTestRule
.onNodeWithTag(LAZY_LIST_TEST_TAG)
.performScrollToNode(hasTestTag(LAZY_LIST_LAST_ITEM_TEST_TAG))
// composeTestRule
// .onNodeWithTag(LAZY_LIST_TEST_TAG)
// .performScrollToNode(hasTestTag(LAZY_LIST_LAST_ITEM_TEST_TAG))

// Act
composeTestRule.onNodeWithText("Add a server").performClick()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,12 +293,8 @@ fun VpnSettingsScreen(
onCellClicked = { newValue -> onToggleLocalNetworkSharing(newValue) },
onInfoClicked = { onLocalNetworkSharingInfoClick() }
)
}
item {
Spacer(modifier = Modifier.height(Dimens.cellLabelVerticalPadding))
MtuComposeCell(mtuValue = uiState.mtu, onEditMtu = { onMtuCellClick() })
}
item { MtuSubtitle() }

itemWithDivider {
ExpandableComposeCell(
Expand Down Expand Up @@ -363,7 +359,7 @@ fun VpnSettingsScreen(
)
}

itemWithDivider {
item {
NormalSwitchComposeCell(
title = stringResource(R.string.block_social_media_title),
isToggled = uiState.contentBlockersOptions.blockSocialMedia,
Expand All @@ -389,6 +385,58 @@ fun VpnSettingsScreen(
}
}

item {
HeaderSwitchComposeCell(
title = stringResource(R.string.enable_custom_dns),
isToggled = uiState.isCustomDnsEnabled,
isEnabled = uiState.contentBlockersOptions.isAnyBlockerEnabled().not(),
onCellClicked = { newValue -> onToggleDnsClick(newValue) },
onInfoClicked = { onCustomDnsInfoClick() }
)
}

if (uiState.isCustomDnsEnabled) {
itemsIndexed(uiState.customDnsItems) { index, item ->
DnsCell(
address = item.address,
isUnreachableLocalDnsWarningVisible =
item.isLocal && uiState.isAllowLanEnabled.not(),
onClick = { onDnsClick(index) },
modifier = Modifier.animateItemPlacement()
)
Divider()
}

itemWithDivider {
BaseCell(
onCellClicked = { onDnsClick(null) },
title = {
Text(
text = stringResource(id = R.string.add_a_server),
color = Color.White,
)
},
bodyView = {},
background = MaterialTheme.colorScheme.secondaryContainer,
startPadding = biggerPadding,
)
}
}

item {
CustomDnsCellSubtitle(
isCellClickable = uiState.contentBlockersOptions.isAnyBlockerEnabled().not(),
modifier =
Modifier.background(MaterialTheme.colorScheme.secondary)
.padding(
start = Dimens.cellStartPadding,
top = topPadding,
end = Dimens.cellEndPadding,
bottom = Dimens.cellLabelVerticalPadding,
)
)
}

itemWithDivider {
Spacer(modifier = Modifier.height(Dimens.cellLabelVerticalPadding))
InformationComposeCell(
Expand Down Expand Up @@ -497,61 +545,11 @@ fun VpnSettingsScreen(
mainTestTag = LAZY_LIST_WIREGUARD_CUSTOM_PORT_TEXT_TEST_TAG,
numberTestTag = LAZY_LIST_WIREGUARD_CUSTOM_PORT_NUMBER_TEST_TAG
)
}

item {
Spacer(modifier = Modifier.height(Dimens.cellLabelVerticalPadding))
HeaderSwitchComposeCell(
title = stringResource(R.string.enable_custom_dns),
isToggled = uiState.isCustomDnsEnabled,
isEnabled = uiState.contentBlockersOptions.isAnyBlockerEnabled().not(),
onCellClicked = { newValue -> onToggleDnsClick(newValue) },
onInfoClicked = { onCustomDnsInfoClick() }
)
}

if (uiState.isCustomDnsEnabled) {
itemsIndexed(uiState.customDnsItems) { index, item ->
DnsCell(
address = item.address,
isUnreachableLocalDnsWarningVisible =
item.isLocal && uiState.isAllowLanEnabled.not(),
onClick = { onDnsClick(index) },
modifier = Modifier.animateItemPlacement()
)
Divider()
}

itemWithDivider {
BaseCell(
onCellClicked = { onDnsClick(null) },
title = {
Text(
text = stringResource(id = R.string.add_a_server),
color = Color.White,
)
},
bodyView = {},
background = MaterialTheme.colorScheme.secondaryContainer,
startPadding = biggerPadding,
)
}
}

item {
CustomDnsCellSubtitle(
isCellClickable = uiState.contentBlockersOptions.isAnyBlockerEnabled().not(),
modifier =
Modifier.background(MaterialTheme.colorScheme.secondary)
.testTag(LAZY_LIST_LAST_ITEM_TEST_TAG)
.padding(
start = Dimens.cellStartPadding,
top = topPadding,
end = Dimens.cellEndPadding,
bottom = Dimens.cellLabelVerticalPadding,
)
)
}
item { MtuComposeCell(mtuValue = uiState.mtu, onEditMtu = { onMtuCellClick() }) }
item { MtuSubtitle(modifier = Modifier.testTag(LAZY_LIST_LAST_ITEM_TEST_TAG)) }
}
}
}

0 comments on commit ae9967e

Please sign in to comment.