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

Commit c85eb023 authored by Fahim M. Choudhury's avatar Fahim M. Choudhury
Browse files

Merge remote-tracking branch 'origin/v3.7'

parents d79f82b2 69b9ddf9
Loading
Loading
Loading
Loading
Loading
+12 −6
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.onAllNodesWithText
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
import androidx.core.os.ConfigurationCompat
import androidx.paging.LoadState
import androidx.paging.LoadStates
import androidx.paging.PagingData
@@ -53,6 +54,7 @@ import foundation.e.apps.ui.compose.state.InstallButtonAction
import foundation.e.apps.ui.compose.state.InstallButtonState
import foundation.e.apps.ui.compose.theme.AppTheme
import foundation.e.apps.ui.search.v2.SearchTabType
import foundation.e.apps.ui.utils.AppUserRatingFormatter
import java.util.Locale

@RunWith(AndroidJUnit4::class)
@@ -137,13 +139,17 @@ class SearchResultsContentTest {
    fun applicationMapping_setsAuthorRatingAndPrimaryAction() {
        val notAvailable = composeRule.activity.getString(R.string.not_available)
        val openLabel = composeRule.activity.getString(R.string.open)
        val expectedRating = String.format(Locale.getDefault(), "%.1f", 4.4)
        val unexpectedRating = String.format(Locale.getDefault(), "%.1f", 4.9)
        val locale = ConfigurationCompat.getLocales(
            composeRule.activity.resources.configuration
        ).get(0) ?: Locale.getDefault()
        val expectedRating = AppUserRatingFormatter.format(4.4, locale) ?: notAvailable
        val hiddenRating = AppUserRatingFormatter.format(4.9, locale) ?: notAvailable

        renderSearchResults(
            tabs = listOf(SearchTabType.OPEN_SOURCE),
            selectedTab = SearchTabType.OPEN_SOURCE,
            fossPagingData = pagingData(
            tabs = listOf(SearchTabType.COMMON_APPS),
            selectedTab = SearchTabType.COMMON_APPS,
            fossPagingData = PagingData.empty(),
            playStorePagingData = pagingData(
                listOf(
                    Application(
                        name = "Rated App",
@@ -184,7 +190,7 @@ class SearchResultsContentTest {
        composeRule.onNodeWithText(expectedRating).assertIsDisplayed()
        composeRule.onNodeWithText(openLabel).assertIsDisplayed()
        composeRule.onNodeWithText(notAvailable).assertIsDisplayed()
        composeRule.onAllNodesWithText(unexpectedRating).assertCountEquals(0)
        composeRule.onAllNodesWithText(hiddenRating).assertCountEquals(0)
    }

    @Test
+0 −2
Original line number Diff line number Diff line
@@ -37,6 +37,4 @@ object Constants {
        "${BuildConfig.PACKAGE_NAME_PARENTAL_CONTROL}.action.APP_LOUNGE_LOGIN"

    const val REQUEST_GPLAY_LOGIN = "request_gplay_login"

    const val MIN_VALID_RATING = 0.1
}
+0 −1
Original line number Diff line number Diff line
@@ -19,6 +19,5 @@
package foundation.e.apps.data.application.data

data class Ratings(
    val privacyScore: Double = -1.0,
    val usageQualityScore: Double = -1.0
)
+0 −13
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ import android.content.Context
import androidx.lifecycle.LiveData
import dagger.hilt.android.qualifiers.ApplicationContext
import foundation.e.apps.OpenForTesting
import foundation.e.apps.data.Constants.MIN_VALID_RATING
import foundation.e.apps.data.application.data.Application
import foundation.e.apps.data.fdroid.FDroidRepository
import foundation.e.apps.data.install.download.data.DownloadProgress
@@ -171,18 +170,6 @@ class AppManagerWrapper @Inject constructor(
        return percent
    }

    fun handleRatingFormat(rating: Double): String? {
        return if (rating >= MIN_VALID_RATING) {
            if (rating % 1 == 0.0) {
                rating.toInt().toString()
            } else {
                rating.toString()
            }
        } else {
            null
        }
    }

    suspend fun getCalculateProgressWithTotalSize(
        application: Application?,
        progress: DownloadProgress
+0 −4
Original line number Diff line number Diff line
@@ -397,8 +397,4 @@ class MainActivityViewModel @Inject constructor(
    fun launchPwa(homeApp: ApplicationDomain) {
        launchPwa(homeApp.toApplication())
    }

    fun handleRatingFormat(rating: Double): String? {
        return appManagerWrapper.handleRatingFormat(rating)
    }
}
Loading