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

Commit 900d4029 authored by Hasib Prince's avatar Hasib Prince
Browse files

App Lounge: use old list if new download fails

parent 883f7d32
Loading
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -52,9 +52,6 @@ class DownloadManager @Inject constructor(
        if (!directoryFile.exists()) {
            directoryFile.mkdirs()
        }
        if (downloadFile.exists()) {
            downloadFile.delete()
        }
        val request = DownloadManager.Request(Uri.parse(url))
            .setTitle("Downloading...")
            .setDestinationUri(Uri.fromFile(downloadFile))
+3 −1
Original line number Diff line number Diff line
@@ -18,4 +18,6 @@

package foundation.e.apps.api.cleanapk.blockedApps

data class AppWarningInfo(val not_working_apps: List<String>)
import com.google.gson.annotations.SerializedName

data class AppWarningInfo(@SerializedName("not_working_apps") val notWorkingApps: List<String>)
+8 −3
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package foundation.e.apps.api.cleanapk.blockedApps

import com.google.gson.Gson
import foundation.e.apps.api.DownloadManager
import foundation.e.apps.manager.fused.FileManager
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch
import java.io.File
@@ -30,18 +31,20 @@ import javax.inject.Singleton
class BlockedAppRepository @Inject constructor(
    private val downloadManager: DownloadManager,
    private val gson: Gson,
    @Named("cacheDir") private val cacheDir: String,
    @Named("ioCoroutineScope") private val coroutineScope: CoroutineScope
) {

    companion object {
        const val APP_WARNING_LIST_FILE_URL =
        private const val APP_WARNING_LIST_FILE_URL =
            "https://gitlab.e.foundation/e/os/blocklist-app-lounge/-/raw/main/app-lounge-warning-list.json?inline=false"
        private const val WARNING_LIST_FILE_NAME = "app-lounge-warning-list.json"
    }

    private var blockedAppInfoList: AppWarningInfo? = null

    fun getBlockedAppPackages(): List<String> {
        return blockedAppInfoList?.not_working_apps ?: listOf()
        return blockedAppInfoList?.notWorkingApps ?: listOf()
    }

    fun fetchUpdateOfAppWarningList() {
@@ -57,7 +60,9 @@ class BlockedAppRepository @Inject constructor(

    private fun parseBlockedAppDataFromFile(path: String) {
        coroutineScope.launch {
            val downloadedFile = File(path)
            val outputPath = "$cacheDir/warning_list/"
            FileManager.moveFile("$cacheDir/", WARNING_LIST_FILE_NAME, outputPath)
            val downloadedFile = File(outputPath + WARNING_LIST_FILE_NAME)
            val blockedAppInfoJson = String(downloadedFile.inputStream().readBytes())
            blockedAppInfoList = gson.fromJson(blockedAppInfoJson, AppWarningInfo::class.java)
        }
+17 −0
Original line number Diff line number Diff line
<!--
  ~ Apps  Quickly and easily install Android apps onto your device!
  ~ Copyright (C) 2022  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/>.
  -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="20dp"
    android:height="21dp"