diff --git a/F-Droid/src/org/fdroid/fdroid/net/Downloader.java b/F-Droid/src/org/fdroid/fdroid/net/Downloader.java index cf9dfa170..7daea82c4 100644 --- a/F-Droid/src/org/fdroid/fdroid/net/Downloader.java +++ b/F-Droid/src/org/fdroid/fdroid/net/Downloader.java @@ -2,7 +2,6 @@ package org.fdroid.fdroid.net; import android.content.Context; import android.os.Bundle; -import android.support.annotation.NonNull; import android.util.Log; import org.fdroid.fdroid.ProgressListener; @@ -33,29 +32,12 @@ public abstract class Downloader { public abstract InputStream getInputStream() throws IOException; - // The context is required for opening the file to write to. - Downloader(String destFile, @NonNull Context ctx) - throws FileNotFoundException, MalformedURLException { - this(new File(ctx.getFilesDir() + File.separator + destFile)); - } - - // The context is required for opening the file to write to. - Downloader(@NonNull Context ctx) throws IOException { - this(File.createTempFile("dl-", "", ctx.getCacheDir())); - } - Downloader(File destFile) throws FileNotFoundException, MalformedURLException { outputFile = destFile; outputStream = new FileOutputStream(outputFile); } - Downloader(OutputStream output) - throws MalformedURLException { - outputStream = output; - outputFile = null; - } - public void setProgressListener(ProgressListener listener) { setProgressListener(listener, null); } diff --git a/F-Droid/src/org/fdroid/fdroid/net/DownloaderFactory.java b/F-Droid/src/org/fdroid/fdroid/net/DownloaderFactory.java index a6cae1438..bf2223b4b 100644 --- a/F-Droid/src/org/fdroid/fdroid/net/DownloaderFactory.java +++ b/F-Droid/src/org/fdroid/fdroid/net/DownloaderFactory.java @@ -7,12 +7,17 @@ import java.io.IOException; public class DownloaderFactory { + /** + * Downloads to a temporary file, which *you must delete yourself when + * you are done + */ public static Downloader create(String url, Context context) throws IOException { + File destFile = File.createTempFile("dl-", "", context.getCacheDir()); if (isOnionAddress(url)) { - return new TorHttpDownloader(url, context); + return new TorHttpDownloader(url, destFile); } - return new HttpDownloader(url, context); + return new HttpDownloader(url, destFile); } public static Downloader create(String url, File destFile) diff --git a/F-Droid/src/org/fdroid/fdroid/net/HttpDownloader.java b/F-Droid/src/org/fdroid/fdroid/net/HttpDownloader.java index c1a6a3650..1ed22174f 100644 --- a/F-Droid/src/org/fdroid/fdroid/net/HttpDownloader.java +++ b/F-Droid/src/org/fdroid/fdroid/net/HttpDownloader.java @@ -1,6 +1,5 @@ package org.fdroid.fdroid.net; -import android.content.Context; import android.util.Log; import org.fdroid.fdroid.Preferences; @@ -34,16 +33,6 @@ public class HttpDownloader extends Downloader { sourceUrl = new URL(source); } - /** - * Downloads to a temporary file, which *you must delete yourself when - * you are done*. - * @see org.fdroid.fdroid.net.Downloader#getFile() - */ - HttpDownloader(String source, Context ctx) throws IOException { - super(ctx); - sourceUrl = new URL(source); - } - @Override public InputStream getInputStream() throws IOException { setupConnection(); diff --git a/F-Droid/src/org/fdroid/fdroid/net/TorHttpDownloader.java b/F-Droid/src/org/fdroid/fdroid/net/TorHttpDownloader.java index 70848ac66..fc7cd08a8 100644 --- a/F-Droid/src/org/fdroid/fdroid/net/TorHttpDownloader.java +++ b/F-Droid/src/org/fdroid/fdroid/net/TorHttpDownloader.java @@ -1,7 +1,5 @@ package org.fdroid.fdroid.net; -import android.content.Context; - import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; @@ -13,10 +11,6 @@ import java.net.SocketAddress; public class TorHttpDownloader extends HttpDownloader { - TorHttpDownloader(String url, Context ctx) throws IOException { - super(url, ctx); - } - TorHttpDownloader(String url, File destFile) throws FileNotFoundException, MalformedURLException { super(url, destFile);