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

Commit 7c0aeef9 authored by Mohammed Althaf T's avatar Mohammed Althaf T 😊
Browse files

Merge branch '8880-lounge-unmetered' into 'main'

feat: Respect unmetered connections as we should

See merge request !648
parents e25a06f1 2fb59ca6
Loading
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.net.Uri
import dagger.hilt.android.qualifiers.ApplicationContext
import foundation.e.apps.OpenForTesting
import foundation.e.apps.R
import foundation.e.apps.data.preference.AppLoungePreference
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
@@ -46,6 +47,7 @@ class DownloadManager @Inject constructor(
    private val downloadManager: DownloadManager,
    @Named("cacheDir") private val cacheDir: String,
    private val downloadManagerQuery: DownloadManager.Query,
    private val appLoungePreference: AppLoungePreference,
) {
    private val downloadsMaps = HashMap<Long, Boolean>()

@@ -79,6 +81,10 @@ class DownloadManager @Inject constructor(
            val request = DownloadManager.Request(Uri.parse(url))
                .setTitle(context.getString(R.string.downloading))
                .setDestinationUri(Uri.fromFile(downloadFile))
            if (appLoungePreference.isOnlyUnmeteredNetworkEnabled()) {
                // Set to true by default for Download requests
                request.setAllowedOverMetered(false)
            }
            downloadId = downloadManager.enqueue(request)
        } catch (e: java.lang.NullPointerException) {
            Timber.e(e, "Url: $url; downloadFilePath: ${downloadFile.absolutePath}")
+4 −0
Original line number Diff line number Diff line
@@ -120,4 +120,8 @@ class AppLoungePreference @Inject constructor(
            putBoolean(context.getString(R.string.anonymous_update_migration_completed), true)
        }
    }

    fun isOnlyUnmeteredNetworkEnabled(): Boolean {
        return preferenceManager.getBoolean(context.getString(R.string.only_unmetered_network), true)
    }
}
+2 −2
Original line number Diff line number Diff line
@@ -52,7 +52,7 @@ class UpdatesWorker @AssistedInject constructor(

    private var shouldShowNotification = true
    private var automaticInstallEnabled = true
    private var onlyOnUnmeteredNetwork = false
    private var onlyOnUnmeteredNetwork = true
    private var isAutoUpdate = true // indicates it is auto update or user initiated update
    private var retryCount = 0

@@ -245,7 +245,7 @@ class UpdatesWorker @AssistedInject constructor(
            applicationContext.getString(
                R.string.only_unmetered_network
            ),
            false
            true
        )
    }