Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a238f319 authored by Saalim Quadri's avatar Saalim Quadri Committed by Nishith Khanna
Browse files

fix: source: Remove privacyScore and sourceTag

parent 26e4e2db
Loading
Loading
Loading
Loading
+2 −52
Original line number Diff line number Diff line
@@ -54,7 +54,6 @@ class SearchResultListItemTest {
                        onItemClick = {},
                        onPrimaryActionClick = {},
                        onShowMoreClick = {},
                        onPrivacyClick = {},
                    )
                }
            }
@@ -70,7 +69,6 @@ class SearchResultListItemTest {
    fun metadataAndClicks_areWiredCorrectly() {
        var itemClicks = 0
        var primaryClicks = 0
        var privacyClicks = 0

        composeRule.setContent {
            AppTheme(darkTheme = false) {
@@ -81,11 +79,6 @@ class SearchResultListItemTest {
                            author = "Signal LLC",
                            ratingText = "4.5",
                            showRating = true,
                            sourceTag = "Play Store",
                            showSourceTag = true,
                            privacyScore = "06/10",
                            showPrivacyScore = true,
                            isPrivacyLoading = false,
                            primaryAction = PrimaryActionUiState(
                                label = "Install",
                                enabled = true,
@@ -96,7 +89,6 @@ class SearchResultListItemTest {
                        onItemClick = { itemClicks += 1 },
                        onPrimaryActionClick = { primaryClicks += 1 },
                        onShowMoreClick = {},
                        onPrivacyClick = { privacyClicks += 1 },
                    )
                }
            }
@@ -105,9 +97,7 @@ class SearchResultListItemTest {
        composeRule.onNodeWithText("Signal").assertIsDisplayed()
        composeRule.onNodeWithText("Signal LLC").assertIsDisplayed()
        composeRule.onNodeWithText("4.5").assertIsDisplayed()
        composeRule.onNodeWithText("Play Store").assertIsDisplayed()
        composeRule.onNodeWithText("Install").assertIsDisplayed()
        composeRule.onNodeWithText("06/10").assertIsDisplayed()
        composeRule.onAllNodesWithTag(SearchResultListItemTestTags.SHOW_MORE)
            .assertCountEquals(0)

@@ -115,18 +105,15 @@ class SearchResultListItemTest {
            .performClick()
        composeRule.onNodeWithTag(SearchResultListItemTestTags.PRIMARY_BUTTON)
            .performClick()
        composeRule.onNodeWithTag(SearchResultListItemTestTags.PRIVACY_BADGE)
            .performClick()

        composeRule.runOnIdle {
            assertEquals(1, itemClicks)
            assertEquals(1, primaryClicks)
            assertEquals(1, privacyClicks)
        }
    }

    @Test
    fun hidesRatingAndSourceTag_whenDisabled() {
    fun hidesRating_whenDisabled() {
        composeRule.setContent {
            AppTheme(darkTheme = false) {
                Surface(color = MaterialTheme.colorScheme.background) {
@@ -136,11 +123,6 @@ class SearchResultListItemTest {
                            author = "Anonymous",
                            ratingText = "4.9",
                            showRating = false,
                            sourceTag = "Play Store",
                            showSourceTag = false,
                            privacyScore = "",
                            showPrivacyScore = false,
                            isPrivacyLoading = false,
                            primaryAction = PrimaryActionUiState(
                                label = "Install",
                                enabled = true,
@@ -151,14 +133,12 @@ class SearchResultListItemTest {
                        onItemClick = {},
                        onPrimaryActionClick = {},
                        onShowMoreClick = {},
                        onPrivacyClick = {},
                    )
                }
            }
        }

        composeRule.onAllNodesWithText("4.9").assertCountEquals(0)
        composeRule.onAllNodesWithText("Play Store").assertCountEquals(0)
    }

    @Test
@@ -175,11 +155,6 @@ class SearchResultListItemTest {
                            author = "Author",
                            ratingText = "",
                            showRating = false,
                            sourceTag = "",
                            showSourceTag = false,
                            privacyScore = "",
                            showPrivacyScore = false,
                            isPrivacyLoading = false,
                            primaryAction = PrimaryActionUiState(
                                label = "Install",
                                enabled = true,
@@ -191,7 +166,6 @@ class SearchResultListItemTest {
                        onItemClick = {},
                        onPrimaryActionClick = {},
                        onShowMoreClick = { showMoreClicks += 1 },
                        onPrivacyClick = {},
                    )
                }
            }
@@ -210,7 +184,7 @@ class SearchResultListItemTest {
    }

    @Test
    fun inProgressPrimaryAction_andPrivacyLoading_showSpinners() {
    fun inProgressPrimaryAction_showsSpinner() {
        composeRule.setContent {
            AppTheme(darkTheme = false) {
                Surface(color = MaterialTheme.colorScheme.background) {
@@ -220,11 +194,6 @@ class SearchResultListItemTest {
                            author = "Author",
                            ratingText = "",
                            showRating = false,
                            sourceTag = "",
                            showSourceTag = false,
                            privacyScore = "07/10",
                            showPrivacyScore = true,
                            isPrivacyLoading = true,
                            primaryAction = PrimaryActionUiState(
                                label = "",
                                enabled = true,
@@ -235,7 +204,6 @@ class SearchResultListItemTest {
                        onItemClick = {},
                        onPrimaryActionClick = {},
                        onShowMoreClick = {},
                        onPrivacyClick = {},
                    )
                }
            }
@@ -243,9 +211,6 @@ class SearchResultListItemTest {

        composeRule.onNodeWithTag(SearchResultListItemTestTags.PRIMARY_PROGRESS)
            .assertIsDisplayed()
        composeRule.onNodeWithTag(SearchResultListItemTestTags.PRIVACY_PROGRESS)
            .assertIsDisplayed()
        composeRule.onAllNodesWithText("07/10").assertCountEquals(0)
    }

    private fun sampleApp(name: String) = Application(name = name)
@@ -254,11 +219,6 @@ class SearchResultListItemTest {
        author = "",
        ratingText = "",
        showRating = false,
        sourceTag = "",
        showSourceTag = false,
        privacyScore = "",
        showPrivacyScore = false,
        isPrivacyLoading = false,
        primaryAction = PrimaryActionUiState(
            label = "",
            enabled = false,
@@ -274,21 +234,11 @@ class SearchResultListItemTest {
        author: String,
        ratingText: String,
        showRating: Boolean,
        sourceTag: String,
        showSourceTag: Boolean,
        privacyScore: String,
        showPrivacyScore: Boolean,
        isPrivacyLoading: Boolean,
        primaryAction: PrimaryActionUiState,
    ): SearchResultListItemState = SearchResultListItemState(
        author = author,
        ratingText = ratingText,
        showRating = showRating,
        sourceTag = sourceTag,
        showSourceTag = showSourceTag,
        privacyScore = privacyScore,
        showPrivacyScore = showPrivacyScore,
        isPrivacyLoading = isPrivacyLoading,
        primaryAction = primaryAction,
        iconUrl = null,
        placeholderResId = null,
+3 −110
Original line number Diff line number Diff line
@@ -69,7 +69,6 @@ fun SearchResultListItem(
    onItemClick: (Application) -> Unit,
    onPrimaryActionClick: (Application) -> Unit,
    onShowMoreClick: (Application) -> Unit,
    onPrivacyClick: (Application) -> Unit,
    modifier: Modifier = Modifier,
) {
    if (uiState.isPlaceholder) {
@@ -120,30 +119,15 @@ fun SearchResultListItem(
                overflow = TextOverflow.Ellipsis,
            )

            if (uiState.showRating || uiState.showSourceTag) {
                Row(
                    verticalAlignment = Alignment.CenterVertically,
                    horizontalArrangement = Arrangement.spacedBy(6.dp),
                ) {
            if (uiState.showRating) {
                RatingChip(ratingText = uiState.ratingText)
            }

                    if (uiState.showSourceTag) {
                        SourceTag(text = uiState.sourceTag)
                    }
                }
            }
        }

        PrimaryActionArea(
            uiState = uiState.primaryAction,
            onPrimaryClick = { onPrimaryActionClick(application) },
            onShowMoreClick = { onShowMoreClick(application) },
            privacyScore = uiState.privacyScore,
            showPrivacyScore = uiState.showPrivacyScore,
            isPrivacyLoading = uiState.isPrivacyLoading,
            onPrivacyClick = { onPrivacyClick(application) },
        )
    }
}
@@ -190,75 +174,11 @@ private fun RatingChip(ratingText: String) {
    }
}

@Composable
private fun SourceTag(text: String) {
    Text(
        text = text,
        style = MaterialTheme.typography.labelMedium,
        color = MaterialTheme.colorScheme.onSecondaryContainer,
        modifier = Modifier
            .background(
                color = MaterialTheme.colorScheme.secondaryContainer,
                shape = MaterialTheme.shapes.small,
            )
            .padding(horizontal = 8.dp, vertical = 4.dp),
        maxLines = 1,
        overflow = TextOverflow.Ellipsis,
    )
}

@Composable
private fun PrivacyBadge(
    privacyScore: String,
    isVisible: Boolean,
    isLoading: Boolean,
    onClick: () -> Unit,
) {
    if (!isVisible) {
        return
    } else {
        // proceed to render the badge
    }

    Row(
        verticalAlignment = Alignment.CenterVertically,
        modifier = Modifier
            .testTag(SearchResultListItemTestTags.PRIVACY_BADGE)
            .clickable(onClick = onClick),
    ) {
        Image(
            painter = painterResource(id = R.drawable.ic_lock),
            contentDescription = stringResource(id = R.string.privacy_score),
            modifier = Modifier.size(16.dp),
        )
        Spacer(modifier = Modifier.width(4.dp))
        if (isLoading) {
            CircularProgressIndicator(
                modifier = Modifier
                    .size(16.dp)
                    .testTag(SearchResultListItemTestTags.PRIVACY_PROGRESS),
                strokeWidth = 2.dp,
                color = MaterialTheme.colorScheme.tertiary,
            )
        } else {
            Text(
                text = privacyScore,
                style = MaterialTheme.typography.bodyMedium,
                color = MaterialTheme.colorScheme.onBackground,
            )
        }
    }
}

@Composable
private fun PrimaryActionArea(
    uiState: PrimaryActionUiState,
    onPrimaryClick: () -> Unit,
    onShowMoreClick: () -> Unit,
    privacyScore: String,
    showPrivacyScore: Boolean,
    isPrivacyLoading: Boolean,
    onPrivacyClick: () -> Unit,
) {
    if (uiState.showMore) {
        Text(
@@ -333,16 +253,6 @@ private fun PrimaryActionArea(
        ) {
            buttonContent()
        }

        if (showPrivacyScore) {
            Spacer(modifier = Modifier.height(8.dp))
            PrivacyBadge(
                privacyScore = privacyScore,
                isVisible = true,
                isLoading = isPrivacyLoading,
                onClick = onPrivacyClick,
            )
        }
    }
}

@@ -363,11 +273,6 @@ data class SearchResultListItemState(
    val author: String,
    val ratingText: String,
    val showRating: Boolean,
    val sourceTag: String,
    val showSourceTag: Boolean,
    val privacyScore: String,
    val showPrivacyScore: Boolean,
    val isPrivacyLoading: Boolean,
    val primaryAction: PrimaryActionUiState,
    val iconUrl: String? = null,
    val placeholderResId: Int?,
@@ -390,8 +295,6 @@ internal object SearchResultListItemTestTags {
    const val SHOW_MORE = "search_result_item_show_more"
    const val PRIMARY_BUTTON = "search_result_item_primary_button"
    const val PRIMARY_PROGRESS = "search_result_item_primary_progress"
    const val PRIVACY_BADGE = "search_result_item_privacy_badge"
    const val PRIVACY_PROGRESS = "search_result_item_privacy_progress"
}

// --- Previews ---
@@ -404,8 +307,7 @@ private fun SearchResultListItemPreviewInstall() {
            SearchResultListItem(
                application = sampleApp(name = "iMe: AI Messenger"),
                uiState = sampleState(
                    rating = "4.4",
                    privacy = "06/10",
                    rating = "4.3",
                    primary = PrimaryActionUiState(
                        label = "Install",
                        enabled = true,
@@ -417,7 +319,6 @@ private fun SearchResultListItemPreviewInstall() {
                onItemClick = {},
                onPrimaryActionClick = {},
                onShowMoreClick = {},
                onPrivacyClick = {},
            )
        }
    }
@@ -432,7 +333,6 @@ private fun SearchResultListItemPreviewOpen() {
                application = sampleApp(name = "This is a very long app name"),
                uiState = sampleState(
                    rating = "4.3",
                    privacy = "10/10",
                    primary = PrimaryActionUiState(
                        label = "Open",
                        enabled = true,
@@ -444,7 +344,6 @@ private fun SearchResultListItemPreviewOpen() {
                onItemClick = {},
                onPrimaryActionClick = {},
                onShowMoreClick = {},
                onPrivacyClick = {},
            )
        }
    }
@@ -455,18 +354,12 @@ private fun sampleApp(name: String) = Application(name = name)
@Composable
private fun sampleState(
    rating: String,
    privacy: String,
    primary: PrimaryActionUiState,
): SearchResultListItemState =
    SearchResultListItemState(
        author = "This is a very long author name which can take multiple lines",
        ratingText = rating,
        showRating = true,
        sourceTag = "Open-source", // PNG omits this; kept for legacy data
        showSourceTag = true,
        privacyScore = privacy,
        showPrivacyScore = true,
        isPrivacyLoading = false,
        primaryAction = primary,
        isPlaceholder = false,
        iconUrl = null,
+0 −22
Original line number Diff line number Diff line
@@ -77,7 +77,6 @@ fun SearchResultsContent(
    onResultClick: (Application) -> Unit = {},
    onPrimaryActionClick: (Application, InstallButtonAction) -> Unit = { _, _ -> },
    onShowMoreClick: (Application) -> Unit = {},
    onPrivacyClick: (Application) -> Unit = {},
    installButtonStateProvider: (Application) -> InstallButtonState,
) {
    when {
@@ -98,7 +97,6 @@ fun SearchResultsContent(
                onResultClick = onResultClick,
                onPrimaryActionClick = onPrimaryActionClick,
                onShowMoreClick = onShowMoreClick,
                onPrivacyClick = onPrivacyClick,
                installButtonStateProvider = installButtonStateProvider,
                modifier = modifier.fillMaxSize(),
            )
@@ -162,7 +160,6 @@ fun SearchResultsContent(
                        onResultClick = onResultClick,
                        onPrimaryActionClick = onPrimaryActionClick,
                        onShowMoreClick = onShowMoreClick,
                        onPrivacyClick = onPrivacyClick,
                        installButtonStateProvider = installButtonStateProvider,
                        modifier = Modifier.fillMaxSize(),
                    )
@@ -184,7 +181,6 @@ private fun SearchTabPage(
    onResultClick: (Application) -> Unit,
    onPrimaryActionClick: (Application, InstallButtonAction) -> Unit,
    onShowMoreClick: (Application) -> Unit,
    onPrivacyClick: (Application) -> Unit,
    installButtonStateProvider: (Application) -> InstallButtonState,
    modifier: Modifier = Modifier,
) {
@@ -223,7 +219,6 @@ private fun SearchTabPage(
                onItemClick = onResultClick,
                onPrimaryActionClick = onPrimaryActionClick,
                onShowMoreClick = onShowMoreClick,
                onPrivacyClick = onPrivacyClick,
                installButtonStateProvider = installButtonStateProvider,
                emptyResultsStringResource = emptyResultsStringResource,
                errorTitleStringResource = errorTitleStringResource,
@@ -240,7 +235,6 @@ private fun SearchTabPage(
                onItemClick = onResultClick,
                onPrimaryActionClick = onPrimaryActionClick,
                onShowMoreClick = onShowMoreClick,
                onPrivacyClick = onPrivacyClick,
                installButtonStateProvider = installButtonStateProvider,
                emptyResultsStringResource = emptyResultsStringResource,
                errorTitleStringResource = errorTitleStringResource,
@@ -259,7 +253,6 @@ private fun PagingPlayStoreResultList(
    onItemClick: (Application) -> Unit,
    onPrimaryActionClick: (Application, InstallButtonAction) -> Unit,
    onShowMoreClick: (Application) -> Unit,
    onPrivacyClick: (Application) -> Unit,
    installButtonStateProvider: (Application) -> InstallButtonState,
    emptyResultsStringResource: Int,
    errorTitleStringResource: Int,
@@ -367,7 +360,6 @@ private fun PagingPlayStoreResultList(
                                    )
                                },
                                onShowMoreClick = onShowMoreClick,
                                onPrivacyClick = onPrivacyClick,
                                modifier = Modifier.fillMaxWidth(),
                            )
                        } else {
@@ -406,7 +398,6 @@ private fun PagingSearchResultList(
    onItemClick: (Application) -> Unit,
    onPrimaryActionClick: (Application, InstallButtonAction) -> Unit,
    onShowMoreClick: (Application) -> Unit,
    onPrivacyClick: (Application) -> Unit,
    installButtonStateProvider: (Application) -> InstallButtonState,
    emptyResultsStringResource: Int,
    errorTitleStringResource: Int,
@@ -513,7 +504,6 @@ private fun PagingSearchResultList(
                                    )
                                },
                                onShowMoreClick = onShowMoreClick,
                                onPrivacyClick = onPrivacyClick,
                                modifier = Modifier.fillMaxWidth(),
                            )
                        } else {
@@ -551,11 +541,6 @@ private fun Application.toSearchResultUiState(buttonState: InstallButtonState):
            author = "",
            ratingText = "",
            showRating = false,
            sourceTag = "",
            showSourceTag = false,
            privacyScore = "",
            showPrivacyScore = false,
            isPrivacyLoading = false,
            primaryAction = PrimaryActionUiState(
                label = "",
                enabled = false,
@@ -579,17 +564,10 @@ private fun Application.toSearchResultUiState(buttonState: InstallButtonState):
        else -> stringResource(id = R.string.not_available)
    }

    val sourceTagText = source.toString()

    return SearchResultListItemState(
        author = author.ifBlank { package_name },
        ratingText = ratingText,
        showRating = ratingText.isNotBlank(),
        sourceTag = sourceTagText,
        showSourceTag = false,
        privacyScore = "",
        showPrivacyScore = false, // Privacy scores are disabled on Search per functional spec.
        isPrivacyLoading = false,
        primaryAction = PrimaryActionUiState(
            label = buttonState.label.text
                ?: buttonState.progressPercentText
+0 −6
Original line number Diff line number Diff line
@@ -48,7 +48,6 @@ fun SearchResultListItemPlaceholder(modifier: Modifier = Modifier) {
        onItemClick = {},
        onPrimaryActionClick = {},
        onShowMoreClick = {},
        onPrivacyClick = {},
        modifier = modifier
    )
}
@@ -57,11 +56,6 @@ private fun placeholderState() = SearchResultListItemState(
    author = "",
    ratingText = "",
    showRating = false,
    sourceTag = "",
    showSourceTag = false,
    privacyScore = "",
    showPrivacyScore = false,
    isPrivacyLoading = false,
    primaryAction = PrimaryActionUiState(
        label = "",
        enabled = false,
+0 −2
Original line number Diff line number Diff line
@@ -77,7 +77,6 @@ fun SearchScreen(
    onScrollPositionChange: (SearchTabType, Int, Int) -> Unit = { _, _, _ -> },
    onResultClick: (Application) -> Unit = {},
    onShowMoreClick: (Application) -> Unit = {},
    onPrivacyClick: (Application) -> Unit = {},
    onPrimaryAction: (Application, InstallButtonAction) -> Unit = { _, _ -> },
    installButtonStateProvider: (Application) -> InstallButtonState,
) {
@@ -158,7 +157,6 @@ fun SearchScreen(
                        onResultClick = onResultClick,
                        onPrimaryActionClick = onPrimaryAction,
                        onShowMoreClick = onShowMoreClick,
                        onPrivacyClick = onPrivacyClick,
                        installButtonStateProvider = installButtonStateProvider,
                    )
                }