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

Verified Commit 73d01602 authored by Saalim Quadri's avatar Saalim Quadri
Browse files

feat: Add preference to handle Installation on metered connections

parent 7c0aeef9
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import foundation.e.apps.data.enums.Type
import foundation.e.apps.data.install.models.AppInstall
import foundation.e.apps.data.parentalcontrol.ContentRatingDao
import foundation.e.apps.data.parentalcontrol.ContentRatingEntity
import foundation.e.apps.data.preference.AppLoungePreference
import foundation.e.apps.install.download.data.DownloadProgressLD
import foundation.e.apps.install.pkg.AppLoungePackageManager
import foundation.e.apps.install.pkg.PwaManager
@@ -61,6 +62,9 @@ class AppManagerImpl @Inject constructor(
    @Inject
    lateinit var contentRatingDao: ContentRatingDao

    @Inject
    lateinit var appLoungePreference: AppLoungePreference

    private val mutex = Mutex()

    override fun createNotificationChannels() {
@@ -230,6 +234,10 @@ class AppManagerImpl @Inject constructor(
            val request = DownloadManager.Request(Uri.parse(it))
                .setTitle(if (count == 1) appInstall.name else context.getString(R.string.additional_file_for, appInstall.name))
                .setDestinationUri(Uri.fromFile(packagePath))
            if (appLoungePreference.installOnlyOnUnmeteredNetwork()) {
                // Set to true by default for Download requests
                request.setAllowedOverMetered(false)
            }
            val requestId = downloadManager.enqueue(request)
            DownloadProgressLD.setDownloadId(requestId)
            appInstall.downloadIdMap[requestId] = false
+4 −0
Original line number Diff line number Diff line
@@ -124,4 +124,8 @@ class AppLoungePreference @Inject constructor(
    fun isOnlyUnmeteredNetworkEnabled(): Boolean {
        return preferenceManager.getBoolean(context.getString(R.string.only_unmetered_network), true)
    }

    fun installOnlyOnUnmeteredNetwork(): Boolean {
        return preferenceManager.getBoolean(context.getString(R.string.install_only_unmetered_network), false)
    }
}
+3 −0
Original line number Diff line number Diff line
@@ -55,6 +55,8 @@
    <string name="preference_update_interval_title" weblate_ctx="settings">Update check interval</string>
    <string name="preference_update_wifi_only_title" weblate_ctx="settings">Only on un-metered networks</string>
    <string name="preference_update_wifi_only_description" weblate_ctx="settings">Update apps automatically only on un-metered networks such as Wi-Fi</string>
    <string name="preference_install_wifi_only_title" weblate_ctx="settings">Install only on un-metered networks</string>
    <string name="preference_install_wifi_only_description" weblate_ctx="settings">Install apps only on un-metered networks such as Wi-Fi</string>
    <string name="preference_update_apps_from_other_stores_title">Update apps installed by other stores</string>
    <string name="preference_update_apps_from_other_stores_description">Update apps installed from other app stores.\nSuch apps will be attempted to be updated from common apps and open source category.</string>
    <string name="preference_update_install_automatically_title" weblate_ctx="settings">Automatically install updates</string>
@@ -170,6 +172,7 @@
    <string name="updateNotify" translatable="false">updateNotify</string>
    <string name="auto_install_enabled" translatable="false">updateInstallAuto</string>
    <string name="only_unmetered_network" translatable="false">updateUnmeteredOnly</string>
    <string name="install_only_unmetered_network" translatable="false">installUnmeteredOnly</string>
    <string name="update_apps_from_other_stores" translatable="false">updateAppsFromOtherStores</string>
    <!-- No Internet Fragment -->
    <string name="no_internet_message">Can\'t connect! Please check your internet connection and try again</string>
+15 −0
Original line number Diff line number Diff line
@@ -89,6 +89,21 @@
            app:iconSpaceReserved="false" />
    </PreferenceCategory>

    <PreferenceCategory
        android:title="@string/install"
        app:allowDividerAbove="false"
        app:allowDividerBelow="true"
        app:iconSpaceReserved="false">

        <CheckBoxPreference
            android:defaultValue="false"
            android:key="@string/install_only_unmetered_network"
            android:summary="@string/preference_install_wifi_only_description"
            android:title="@string/preference_install_wifi_only_title"
            app:singleLineTitle="false"
            app:iconSpaceReserved="false" />
    </PreferenceCategory>

    <PreferenceCategory
        android:title="@string/Show_applications"
        app:iconSpaceReserved="false">