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

Commit 459c2dd8 authored by Hasib Prince's avatar Hasib Prince
Browse files

App Lounge: handled OBB files

parent f565a8ab
Loading
Loading
Loading
Loading
Loading
+11 −5
Original line number Diff line number Diff line
@@ -24,12 +24,19 @@
    <uses-permission
        android:name="android.permission.DELETE_PACKAGES"
        tools:ignore="ProtectedPermissions" />
    <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
    <uses-permission android:name="android.permission.REQUEST_DELETE_PACKAGES" />
    <uses-permission android:name="android.permission.UPDATE_PACKAGES_WITHOUT_USER_ACTION" />

    <application
        android:name=".AppLoungeApplication"
        android:allowBackup="false"
        android:icon="@mipmap/ic_launcher"
        android:killAfterRestore="false"
        android:label="@string/app_name"
        android:requestLegacyExternalStorage="true"
        android:restoreAnyVersion="true"
        android:restoreNeedsApplication="true"
        android:supportsRtl="true"
        android:theme="@style/Theme.Apps"
        android:usesCleartextTraffic="true">
@@ -65,8 +72,7 @@
        <provider
            android:name="androidx.startup.InitializationProvider"
            android:authorities="${applicationId}.androidx-startup"
            tools:node="remove">
        </provider>
            tools:node="remove" />

        <service android:name=".manager.pkg.PackageInstallerService" />
    </application>
+2 −2
Original line number Diff line number Diff line
@@ -22,10 +22,10 @@ class AppProgressViewModel @Inject constructor(
    ): Pair<Long, Long> {
        fusedApp?.let { app ->
            val appDownload = fusedManagerRepository.getDownloadList()
                .singleOrNull { it.id.contentEquals(app._id) && it.package_name.contentEquals(app.package_name) }
                .singleOrNull { it.id.contentEquals(app._id) && it.packageName.contentEquals(app.package_name) }
                ?: return Pair(1, 0)

            if (!appDownload.id.contentEquals(app._id) || !appDownload.package_name.contentEquals(app.package_name)) {
            if (!appDownload.id.contentEquals(app._id) || !appDownload.packageName.contentEquals(app.package_name)) {
                return@let
            }
            val downloadingMap = progress.totalSizeBytes.filter { item ->
+1 −1
Original line number Diff line number Diff line
@@ -172,7 +172,7 @@ class MainActivity : AppCompatActivity() {

        viewModel.purchaseAppLiveData.observe(this) {
            val action =
                AppPurchaseFragmentDirections.actionGlobalAppPurchaseFragment(it.package_name)
                AppPurchaseFragmentDirections.actionGlobalAppPurchaseFragment(it.packageName)
            findNavController(R.id.fragment).navigate(action)
        }

+15 −22
Original line number Diff line number Diff line
@@ -146,16 +146,13 @@ class MainActivityViewModel @Inject constructor(
            val fusedDownload: FusedDownload
            try {
                val appIcon = imageView?.let { getImageBase64(it) } ?: ""
                val downloadList: List<String>
                downloadList = getAppDownloadLink(app).toMutableList()

                fusedDownload = FusedDownload(
                    app._id,
                    app.origin,
                    app.status,
                    app.name,
                    app.package_name,
                    downloadList,
                    mutableListOf(),
                    mutableMapOf(),
                    app.status,
                    app.type,
@@ -164,6 +161,7 @@ class MainActivityViewModel @Inject constructor(
                    app.offer_type,
                    app.isFree
                )
                updateFusedDownloadWithAppDownloadLink(app, fusedDownload)
            } catch (e: Exception) {
                if (e is ApiException.AppNotPurchased) {
                    handleAppNotPurchased(imageView, app)
@@ -215,14 +213,11 @@ class MainActivityViewModel @Inject constructor(
        authData.value?.let {
            if (!it.isAnonymous) {
                try {
                    fusedDownload.downloadURLList = fusedAPIRepository.getDownloadLink(
                        fusedDownload.id,
                        fusedDownload.package_name,
                        fusedDownload.versionCode,
                        fusedDownload.offerType,
                    fusedAPIRepository.updateFusedDownloadWithDownloadingInfo(
                        it,
                        Origin.GPLAY
                    ).toMutableList()
                        Origin.GPLAY,
                        fusedDownload
                    )
                } catch (e: Exception) {
                    Log.e(TAG, e.stackTraceToString())
                    _errorMessage.value = e
@@ -248,25 +243,23 @@ class MainActivityViewModel @Inject constructor(
        }
    }

    private suspend fun getAppDownloadLink(app: FusedApp): List<String> {
    private suspend fun updateFusedDownloadWithAppDownloadLink(
        app: FusedApp,
        fusedDownload: FusedDownload
    ) {
        val downloadList = mutableListOf<String>()
        authData.value?.let {
            if (app.type == Type.PWA) {
                downloadList.add(app.url)
                fusedDownload.downloadURLList = downloadList
            } else {
                downloadList.addAll(
                    fusedAPIRepository.getDownloadLink(
                        app._id,
                        app.package_name,
                        app.latest_version_code,
                        app.offer_type,
                fusedAPIRepository.updateFusedDownloadWithDownloadingInfo(
                    it,
                        app.origin
                    )
                    app.origin,
                    fusedDownload
                )
            }
        }
        return downloadList
    }

    private fun getImageBase64(imageView: ImageView): String {
+12 −19
Original line number Diff line number Diff line
@@ -25,7 +25,6 @@ import com.aurora.gplayapi.data.models.App
import com.aurora.gplayapi.data.models.Artwork
import com.aurora.gplayapi.data.models.AuthData
import com.aurora.gplayapi.data.models.Category
import com.aurora.gplayapi.data.models.File
import com.aurora.gplayapi.helpers.TopChartsHelper
import dagger.hilt.android.qualifiers.ApplicationContext
import foundation.e.apps.R
@@ -40,6 +39,7 @@ import foundation.e.apps.api.fused.data.FusedHome
import foundation.e.apps.api.fused.data.Ratings
import foundation.e.apps.api.fused.utils.CategoryUtils
import foundation.e.apps.api.gplay.GPlayAPIRepository
import foundation.e.apps.manager.database.fusedDownload.FusedDownload
import foundation.e.apps.manager.pkg.PkgManagerModule
import foundation.e.apps.utils.enums.Origin
import foundation.e.apps.utils.enums.Status
@@ -152,38 +152,31 @@ class FusedAPIImpl @Inject constructor(
        return gPlayAPIRepository.validateAuthData(authData)
    }

    suspend fun getDownloadLink(
        id: String,
        packageName: String,
        versionCode: Int,
        offerType: Int,
    suspend fun updateFusedDownloadWithDownloadingInfo(
        authData: AuthData,
        origin: Origin
    ): List<String> {
        origin: Origin,
        fusedDownload: FusedDownload
    ) {
        val list = mutableListOf<String>()
        when (origin) {
            Origin.CLEANAPK -> {
                val downloadInfo = cleanAPKRepository.getDownloadInfo(id).body()
                val downloadInfo = cleanAPKRepository.getDownloadInfo(fusedDownload.id).body()
                downloadInfo?.download_data?.download_link?.let { list.add(it) }
            }
            Origin.GPLAY -> {
                val downloadList = gPlayAPIRepository.getDownloadInfo(
                    packageName,
                    versionCode,
                    offerType,
                    fusedDownload.packageName,
                    fusedDownload.versionCode,
                    fusedDownload.offerType,
                    authData
                )
                // TODO: DEAL WITH MULTIPLE PACKAGES
                downloadList.forEach {
                    if (it.type == File.FileType.BASE || it.type == File.FileType.SPLIT) {
                        list.add(it.url)
                    }
                }
                fusedDownload.files = downloadList
                list.addAll(downloadList.map { it.url })
            }
            Origin.GITLAB -> {
            }
        }
        return list
        fusedDownload.downloadURLList = list
    }

    suspend fun listApps(category: String, browseUrl: String, authData: AuthData): List<FusedApp>? {
Loading