mirror of
https://github.com/f-droid/fdroidclient.git
synced 2026-01-28 16:51:26 -05:00
🧹 move some code from downloader to prefs
Moved logic for finding active IPFS gateways from DownloaderFractory to Prefrences.
This commit is contained in:
committed by
Hans-Christoph Steiner
parent
7dc52077f7
commit
71aae140f0
@@ -32,6 +32,7 @@ import android.text.format.DateUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.collection.ArraySet;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
@@ -110,9 +111,9 @@ public final class Preferences implements SharedPreferences.OnSharedPreferenceCh
|
||||
private static final String PREF_UNSTABLE_UPDATES = "unstableUpdates";
|
||||
public static final String PREF_KEEP_INSTALL_HISTORY = "keepInstallHistory";
|
||||
public static final String PREF_SEND_TO_FDROID_METRICS = "sendToFdroidMetrics";
|
||||
private static final String PREF_USE_IPFS_GATEWAYS = "useIpfsGateways";
|
||||
private static final String PREF_IPFSGW_DISABLED_DEFAULTS_LIST = "ipfsGwDisabledDefaultsList";
|
||||
private static final String PREF_IPFSGW_USER_LIST = "ipfsGwUserList";
|
||||
public static final String PREF_USE_IPFS_GATEWAYS = "useIpfsGateways";
|
||||
public static final String PREF_IPFSGW_DISABLED_DEFAULTS_LIST = "ipfsGwDisabledDefaultsList";
|
||||
public static final String PREF_IPFSGW_USER_LIST = "ipfsGwUserList";
|
||||
public static final String PREF_EXPERT = "expert";
|
||||
public static final String PREF_FORCE_OLD_INDEX = "forceOldIndex";
|
||||
public static final String PREF_FORCE_OLD_INSTALLER = "forceOldInstaller";
|
||||
@@ -639,6 +640,20 @@ public final class Preferences implements SharedPreferences.OnSharedPreferenceCh
|
||||
return showAppsWithAntiFeatures;
|
||||
}
|
||||
|
||||
public Set<String> getActiveIpfsGateways() {
|
||||
Set<String> gateways = new ArraySet<>();
|
||||
Set<String> disabledDefaults = getIpfsGwDisabledDefaults();
|
||||
for (String gatewayUrl : DEFAULT_IPFS_GATEWAYS) {
|
||||
if (!disabledDefaults.contains(gatewayUrl)) {
|
||||
gateways.add(gatewayUrl);
|
||||
}
|
||||
}
|
||||
for (String gatewayUrl : getIpfsGwUserList()) {
|
||||
gateways.add(gatewayUrl);
|
||||
}
|
||||
return gateways;
|
||||
}
|
||||
|
||||
public void registerAppsRequiringAntiFeaturesChangeListener(ChangeListener listener) {
|
||||
showAppsRequiringAntiFeaturesListeners.add(listener);
|
||||
}
|
||||
|
||||
@@ -23,9 +23,7 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.Proxy;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import info.guardianproject.netcipher.NetCipher;
|
||||
|
||||
@@ -92,13 +90,7 @@ public class DownloaderFactory extends org.fdroid.download.DownloaderFactory {
|
||||
|
||||
private static List<Mirror> loadIpfsMirrors(Preferences prefs) {
|
||||
List<Mirror> mirrorList = new ArrayList<>();
|
||||
Set<String> disabledDefaultGateways = prefs.getIpfsGwDisabledDefaults();
|
||||
for (String gatewayUrl : Preferences.DEFAULT_IPFS_GATEWAYS) {
|
||||
if (!disabledDefaultGateways.contains(gatewayUrl)) {
|
||||
mirrorList.add(new Mirror(gatewayUrl, null, true));
|
||||
}
|
||||
}
|
||||
for (String gatewayUrl : prefs.getIpfsGwUserList()) {
|
||||
for (String gatewayUrl : prefs.getActiveIpfsGateways()) {
|
||||
mirrorList.add(new Mirror(gatewayUrl, null, true));
|
||||
}
|
||||
return mirrorList;
|
||||
|
||||
Reference in New Issue
Block a user