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

Commit 4006a6e7 authored by Hasib Prince's avatar Hasib Prince
Browse files

Merge branch '1305-cursor_window_crash' into 'main'

removed image icon from database

See merge request !310
parents f763809b 2c3fd931
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -78,7 +78,7 @@ class AppLoungeApplication : Application(), Configuration.Provider {
            Telemetry.init(BuildConfig.SENTRY_DSN, this)
            plant(object : Timber.Tree() {
                override fun log(priority: Int, tag: String?, message: String, t: Throwable?) {
                    if (priority < Log.WARN) {
                    if (priority <= Log.WARN) {
                        return
                    }
                    Log.println(priority, tag, message)
+1 −1
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@ import foundation.e.apps.data.database.AppDatabase
import foundation.e.apps.data.fusedDownload.FusedDownloadDAO
import foundation.e.apps.data.fusedDownload.models.FusedDownload

@Database(entities = [FusedDownload::class], version = 3, exportSchema = false)
@Database(entities = [FusedDownload::class], version = 4, exportSchema = false)
@TypeConverters(FusedConverter::class)
abstract class FusedDatabase : RoomDatabase() {
    abstract fun fusedDownloadDao(): FusedDownloadDAO
+19 −2
Original line number Diff line number Diff line
package foundation.e.apps.data.fusedDownload.models

import androidx.room.Entity
import androidx.room.Ignore
import androidx.room.PrimaryKey
import com.aurora.gplayapi.data.models.File
import foundation.e.apps.data.cleanapk.CleanApkRetrofit
import foundation.e.apps.data.enums.Origin
import foundation.e.apps.data.enums.Status
import foundation.e.apps.data.enums.Type
@@ -18,7 +20,7 @@ data class FusedDownload(
    var downloadIdMap: MutableMap<Long, Boolean> = mutableMapOf(),
    val orgStatus: Status = Status.UNAVAILABLE,
    val type: Type = Type.NATIVE,
    val iconByteArray: String = String(),
    val iconImageUrl: String = String(),
    val versionCode: Int = 1,
    val offerType: Int = -1,
    val isFree: Boolean = true,
@@ -26,9 +28,24 @@ data class FusedDownload(
    var files: List<File> = mutableListOf(),
    var signature: String = String()
) {
    fun isAppInstalling() = listOf<Status>(Status.AWAITING, Status.DOWNLOADING, Status.DOWNLOADED, Status.INSTALLING).contains(status)
    @Ignore
    private val installingStatusList = listOf(
        Status.AWAITING,
        Status.DOWNLOADING,
        Status.DOWNLOADED,
        Status.INSTALLING
    )

    fun isAppInstalling() = installingStatusList.contains(status)

    fun isAwaiting() = status == Status.AWAITING

    fun areFilesDownloaded() = downloadIdMap.isNotEmpty() && !downloadIdMap.values.contains(false)

    fun getAppIconUrl(): String {
        if (this.origin == Origin.CLEANAPK) {
            return "${CleanApkRetrofit.ASSET_URL}${this.iconImageUrl}"
        }
        return this.iconImageUrl
    }
}
+2 −2
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ package foundation.e.apps.data.gplay.utils
import com.aurora.gplayapi.data.models.PlayResponse
import com.aurora.gplayapi.network.IHttpClient
import foundation.e.apps.data.login.AuthObject
import foundation.e.apps.utils.CommonUtilsFunctions
import foundation.e.apps.utils.SystemInfoProvider
import foundation.e.apps.utils.eventBus.AppEvent
import foundation.e.apps.utils.eventBus.EventBus
import kotlinx.coroutines.MainScope
@@ -88,7 +88,7 @@ class GPlayHttpClient @Inject constructor(
    override fun postAuth(url: String, body: ByteArray): PlayResponse {
        val requestBody = body.toRequestBody("application/json".toMediaType(), 0, body.size)
        val headers = mapOf(
            "User-Agent" to CommonUtilsFunctions.getAppBuildInfo()
            "User-Agent" to SystemInfoProvider.getAppBuildInfo()
        )
        val request = Request.Builder()
            .headers(headers.toHeaders())
+34 −5
Original line number Diff line number Diff line
@@ -7,7 +7,6 @@ import android.content.Intent
import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.net.Uri
import android.util.Base64
import androidx.core.content.pm.ShortcutInfoCompat
import androidx.core.content.pm.ShortcutManagerCompat
import androidx.core.graphics.drawable.IconCompat
@@ -18,6 +17,10 @@ import foundation.e.apps.data.fused.data.FusedApp
import foundation.e.apps.data.fusedDownload.FusedDownloadRepository
import foundation.e.apps.data.fusedDownload.models.FusedDownload
import kotlinx.coroutines.delay
import timber.log.Timber
import java.io.ByteArrayOutputStream
import java.io.IOException
import java.net.URL
import javax.inject.Inject
import javax.inject.Singleton

@@ -25,7 +28,7 @@ import javax.inject.Singleton
@OpenForTesting
class PWAManagerModule @Inject constructor(
    @ApplicationContext private val context: Context,
    private val fusedDownloadRepository: FusedDownloadRepository
    private val fusedDownloadRepository: FusedDownloadRepository,
) {

    companion object {
@@ -100,9 +103,15 @@ class PWAManagerModule @Inject constructor(
        fusedDownloadRepository.updateDownload(fusedDownload)

        // Get bitmap and byteArray for icon
        val iconByteArray = Base64.decode(fusedDownload.iconByteArray, Base64.DEFAULT)
        val iconBitmap = BitmapFactory.decodeByteArray(iconByteArray, 0, iconByteArray.size)
        val iconBitmap = getIconImageBitmap(fusedDownload.getAppIconUrl())

        if (iconBitmap == null) {
            fusedDownload.status = Status.INSTALLATION_ISSUE
            fusedDownloadRepository.updateDownload(fusedDownload)
            return
        }

        val iconByteArray = iconBitmap.toByteArray()
        val values = ContentValues()
        values.apply {
            put(URL, fusedDownload.downloadURLList[0])
@@ -117,7 +126,27 @@ class PWAManagerModule @Inject constructor(
        }
    }

    private suspend fun publishShortcut(fusedDownload: FusedDownload, bitmap: Bitmap, databaseID: Long) {
    fun getIconImageBitmap(url: String): Bitmap? {
        return try {
            val stream = URL(url).openStream()
            BitmapFactory.decodeStream(stream)
        } catch (e: IOException) {
            Timber.e(e)
            null
        }
    }

    fun Bitmap.toByteArray(): ByteArray {
        val byteArrayOS = ByteArrayOutputStream()
        this.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOS)
        return byteArrayOS.toByteArray()
    }

    private suspend fun publishShortcut(
        fusedDownload: FusedDownload,
        bitmap: Bitmap,
        databaseID: Long
    ) {
        // Update status
        fusedDownload.status = Status.INSTALLING
        fusedDownloadRepository.updateDownload(fusedDownload)
Loading