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

Commit 110522f3 authored by Jonathan Klee's avatar Jonathan Klee
Browse files

remove duplication

parent 1275f171
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -223,6 +223,7 @@ dependencies {
    implementation(project(":auth-data-lib"))
    implementation(project(":parental-control-data"))
    implementation(project(":data"))
    implementation(project(":domain"))
    implementation(project(":ui"))

    // eFoundation libraries
+32 −7
Original line number Diff line number Diff line
@@ -18,7 +18,11 @@

package foundation.e.apps.data.application.mapper

import com.aurora.gplayapi.Constants
import com.aurora.gplayapi.data.models.Artwork
import com.aurora.gplayapi.data.models.ContentRating
import foundation.e.apps.data.application.data.Application
import foundation.e.apps.data.application.data.Ratings
import foundation.e.apps.domain.application.ApplicationDomain

fun ApplicationDomain.toApplication() = Application(
@@ -39,29 +43,50 @@ fun ApplicationDomain.toApplication() = Application(
    other_images_path = otherImagesPath,
    package_name = packageName,
    offer_type = offerType,
    status = status,
    status = foundation.e.apps.data.enums.Status.valueOf(status.name),
    shareUrl = shareUrl,
    originalSize = originalSize,
    appSize = appSize,
    source = source,
    source = foundation.e.apps.data.enums.Source.valueOf(source.name),
    price = price,
    isFree = isFree,
    is_pwa = isPwa,
    pwaPlayerDbId = pwaPlayerDbId,
    url = url,
    type = type,
    type = foundation.e.apps.data.enums.Type.valueOf(type.name),
    privacyScore = privacyScore,
    isPurchased = isPurchased,
    updatedOn = updatedOn,
    numberOfPermission = numberOfPermission,
    numberOfTracker = numberOfTracker,
    filterLevel = filterLevel,
    filterLevel = foundation.e.apps.data.enums.FilterLevel.valueOf(filterLevel.name),
    isGplayReplaced = isGplayReplaced,
    isFDroidApp = isFDroidApp,
    contentRating = contentRating,
    restriction = restriction,
    contentRating = contentRating.toAurora(),
    restriction = restriction.toAurora(),
    antiFeatures = antiFeatures,
    isPlaceHolder = isPlaceHolder,
    ratings = ratings,
    ratings = ratings.toData(),
    isSystemApp = isSystemApp,
)

private fun foundation.e.apps.domain.application.model.Ratings.toData() = Ratings(
    privacyScore = privacyScore,
    usageQualityScore = usageQualityScore,
)

private fun foundation.e.apps.domain.application.model.ContentRating.toAurora() = ContentRating(
    id = id,
    title = title,
    description = description,
    artwork = Artwork(url = artworkUrl),
)

private fun foundation.e.apps.domain.application.model.AppRestriction.toAurora() =
    if (this == foundation.e.apps.domain.application.model.AppRestriction.NOT_RESTRICTED) {
        Constants.Restriction.NOT_RESTRICTED
    } else {
        Constants.Restriction.values()
            .firstOrNull { it != Constants.Restriction.NOT_RESTRICTED }
            ?: Constants.Restriction.NOT_RESTRICTED
    }
+0 −72
Original line number Diff line number Diff line
/*
 * Copyright (C) 2026 e Foundation
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 *
 */

package foundation.e.apps.domain.application

import com.aurora.gplayapi.Constants.Restriction
import com.aurora.gplayapi.data.models.ContentRating
import foundation.e.apps.data.application.data.Ratings
import foundation.e.apps.data.enums.FilterLevel
import foundation.e.apps.data.enums.Source
import foundation.e.apps.data.enums.Status
import foundation.e.apps.data.enums.Type

data class ApplicationDomain(
    val id: String = String(),
    val author: String = String(),
    val category: String = String(),
    val description: String = String(),
    val perms: List<String> = emptyList(),
    val reportId: Long = -1L,
    val packageName: String = String(),
    val name: String = String(),
    val iconImagePath: String = String(),
    val iconUrl: String? = null,
    val otherImagesPath: List<String> = emptyList(),
    val lastModified: String = String(),
    val latestVersionCode: Long = -1,
    val latestVersionNumber: String = String(),
    val latestDownloadedVersion: String = String(),
    val licence: String = String(),
    val source: Source = Source.PLAY_STORE,
    val status: Status = Status.UNAVAILABLE,
    val ratings: Ratings = Ratings(),
    val offerType: Int = -1,
    val isFree: Boolean = true,
    val price: String = String(),
    val isPwa: Boolean = false,
    val url: String = String(),
    val pwaPlayerDbId: Long = -1L,
    val type: Type = Type.NATIVE,
    val originalSize: Long = 0,
    val appSize: String = String(),
    val shareUrl: String = String(),
    val privacyScore: Int = -1,
    val isPurchased: Boolean = false,
    val updatedOn: String = String(),
    val numberOfPermission: Int = 0,
    val numberOfTracker: Int = 0,
    val contentRating: ContentRating = ContentRating(),
    val restriction: Restriction = Restriction.NOT_RESTRICTED,
    val filterLevel: FilterLevel = FilterLevel.UNKNOWN,
    val isGplayReplaced: Boolean = false,
    val isFDroidApp: Boolean = false,
    val antiFeatures: List<Map<String, String>> = emptyList(),
    val isPlaceHolder: Boolean = false,
    val isSystemApp: Boolean = false,
)
+2 −2
Original line number Diff line number Diff line
@@ -47,14 +47,14 @@ import foundation.e.apps.BuildConfig
import foundation.e.apps.R
import foundation.e.apps.contract.ParentalControlContract.COLUMN_LOGIN_TYPE
import foundation.e.apps.data.Constants
import foundation.e.apps.data.enums.User
import foundation.e.apps.data.event.AppEvent
import foundation.e.apps.data.event.EventBus
import foundation.e.apps.data.install.models.AppInstall
import foundation.e.apps.data.install.updates.UpdatesNotifier
import foundation.e.apps.data.login.core.StoreType
import foundation.e.apps.data.system.ParentalControlAuthenticator
import foundation.e.apps.databinding.ActivityMainBinding
import foundation.e.apps.data.enums.User
import foundation.e.apps.data.install.models.AppInstall
import foundation.e.apps.ui.application.subFrags.ApplicationDialogFragment
import foundation.e.apps.ui.error.AppUnavailableDialogDirections
import foundation.e.apps.ui.purchase.AppPurchaseFragmentDirections
+2 −2
Original line number Diff line number Diff line
@@ -232,7 +232,7 @@ class MainActivityViewModel @Inject constructor(
        homeApp: ApplicationDomain,
        alertDialogContext: Context? = null
    ): Boolean {
        if (!homeApp.filterLevel.isUnFiltered()) {
        if (homeApp.filterLevel != foundation.e.apps.domain.enums.FilterLevel.NONE) {
            alertDialogContext?.let { context ->
                AlertDialog.Builder(context).apply {
                    setTitle(R.string.unsupported_app_title)
@@ -336,7 +336,7 @@ class MainActivityViewModel @Inject constructor(
            }
            val status = downloadingItem?.status
                ?: applicationRepository.getFusedAppInstallationStatus(homeApp.toApplication())
            homeApp.copy(status = status)
            homeApp.copy(status = foundation.e.apps.domain.enums.Status.valueOf(status.name))
        }
    }

Loading