Add back toggle to enable wifi-only downloads

This commit is contained in:
Rahul Patel
2023-10-17 06:20:17 +05:30
parent 1ce09c5c35
commit 93b8cf3455
5 changed files with 14 additions and 2 deletions

View File

@@ -24,6 +24,7 @@ import com.aurora.Constants
import com.aurora.gplayapi.data.models.App
import com.aurora.gplayapi.data.models.File
import com.aurora.store.util.PathUtil
import com.aurora.store.util.Preferences
import com.google.gson.GsonBuilder
import com.tonyodev.fetch2.EnqueueAction
import com.tonyodev.fetch2.NetworkType
@@ -32,11 +33,13 @@ import com.tonyodev.fetch2core.Extras
import java.lang.reflect.Modifier
private fun Request.attachMetaData(context: Context, app: App) {
val isWifiOnly = Preferences.getBoolean(context, Preferences.PREFERENCE_DOWNLOAD_WIFI_ONLY)
apply {
groupId = app.getGroupId(context)
tag = app.packageName
enqueueAction = EnqueueAction.UPDATE_ACCORDINGLY
networkType = NetworkType.ALL
networkType = if (isWifiOnly) NetworkType.WIFI_ONLY else NetworkType.ALL
}
}

View File

@@ -50,7 +50,7 @@ object Preferences {
const val PREFERENCE_DOWNLOAD_ACTIVE = "PREFERENCE_DOWNLOAD_ACTIVE"
const val PREFERENCE_DOWNLOAD_EXTERNAL = "PREFERENCE_DOWNLOAD_EXTERNAL"
const val PREFERENCE_DOWNLOAD_DIRECTORY = "PREFERENCE_DOWNLOAD_DIRECTORY"
const val PREFERENCE_DOWNLOAD_WIFI = "PREFERENCE_DOWNLOAD_WIFI"
const val PREFERENCE_DOWNLOAD_WIFI_ONLY = "PREFERENCE_DOWNLOAD_WIFI_ONLY"
const val PREFERENCE_TOS_READ = "PREFERENCE_TOS_READ"

View File

@@ -40,6 +40,7 @@ import com.aurora.store.util.Preferences.PREFERENCE_DEFAULT_SELECTED_TAB
import com.aurora.store.util.Preferences.PREFERENCE_DOWNLOAD_ACTIVE
import com.aurora.store.util.Preferences.PREFERENCE_DOWNLOAD_DIRECTORY
import com.aurora.store.util.Preferences.PREFERENCE_DOWNLOAD_EXTERNAL
import com.aurora.store.util.Preferences.PREFERENCE_DOWNLOAD_WIFI_ONLY
import com.aurora.store.util.Preferences.PREFERENCE_FILTER_FDROID
import com.aurora.store.util.Preferences.PREFERENCE_FILTER_GOOGLE
import com.aurora.store.util.Preferences.PREFERENCE_FILTER_SEARCH
@@ -158,6 +159,7 @@ class OnboardingFragment : Fragment(R.layout.fragment_onboarding) {
save(PREFERENCE_DOWNLOAD_ACTIVE, 3)
save(PREFERENCE_DOWNLOAD_EXTERNAL, false)
save(PREFERENCE_DOWNLOAD_DIRECTORY, PathUtil.getExternalPath(requireContext()))
save(PREFERENCE_DOWNLOAD_WIFI_ONLY, false)
/*Network*/
save(PREFERENCE_INSECURE_ANONYMOUS, false)

View File

@@ -215,6 +215,7 @@
<string name="pref_downloader_external">"User external storage"</string>
<string name="pref_downloader_external_desc">External storage is used for downloads, exports, etc.</string>
<string name="pref_downloader_path_title">"Download path"</string>
<string name="pref_downloader_wifi_title">"Download using WiFi only"</string>
<string name="pref_download_directory_error">"Selected path is not writable"</string>
<string name="pref_filter_fdroid_summary">"Removes F-Droid apps from app lists"</string>
<string name="pref_filter_fdroid_title">"Filter F-Droid apps"</string>

View File

@@ -41,6 +41,12 @@
app:summary="@string/pref_install_delete_summary"
app:title="@string/pref_install_delete_title" />
<SwitchPreferenceCompat
app:defaultValue="false"
app:iconSpaceReserved="false"
app:key="PREFERENCE_DOWNLOAD_WIFI_ONLY"
app:title="@string/pref_downloader_wifi_title" />
<SeekBarPreference
android:defaultValue="3"
android:key="PREFERENCE_DOWNLOAD_ACTIVE"