mirror of
https://github.com/gsantner/dandelion
synced 2024-11-24 21:32:07 +01:00
Let ImageDownloadTask and ProfileFetchTask use NetCipher and remove unused imports
This commit is contained in:
parent
53e65eb756
commit
595a0d7794
3 changed files with 10 additions and 11 deletions
|
@ -28,12 +28,6 @@ import android.util.Log;
|
||||||
|
|
||||||
import com.github.dfa.diaspora_android.App;
|
import com.github.dfa.diaspora_android.App;
|
||||||
|
|
||||||
import org.apache.http.HttpEntity;
|
|
||||||
import org.apache.http.HttpResponse;
|
|
||||||
import org.apache.http.StatusLine;
|
|
||||||
import org.apache.http.client.HttpClient;
|
|
||||||
import org.apache.http.client.methods.HttpGet;
|
|
||||||
import org.apache.http.impl.client.DefaultHttpClient;
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
@ -80,7 +74,7 @@ public class GetPodsService extends Service {
|
||||||
//HttpClient client = new DefaultHttpClient();
|
//HttpClient client = new DefaultHttpClient();
|
||||||
List<String> list = null;
|
List<String> list = null;
|
||||||
try {
|
try {
|
||||||
HttpsURLConnection connection = NetCipher.getHttpsURLConnection("http://podupti.me/api.php?key=4r45tg&format=json");
|
HttpsURLConnection connection = NetCipher.getHttpsURLConnection("https://podupti.me/api.php?key=4r45tg&format=json");
|
||||||
int statusCode = connection.getResponseCode();
|
int statusCode = connection.getResponseCode();
|
||||||
if (statusCode == 200) {
|
if (statusCode == 200) {
|
||||||
InputStream content = connection.getInputStream();
|
InputStream content = connection.getInputStream();
|
||||||
|
@ -91,7 +85,6 @@ public class GetPodsService extends Service {
|
||||||
builder.append(line);
|
builder.append(line);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//TODO Notify User about failure
|
|
||||||
Log.e(TAG, "Failed to download list of pods");
|
Log.e(TAG, "Failed to download list of pods");
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|
|
@ -13,6 +13,8 @@ import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
import info.guardianproject.netcipher.NetCipher;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Gregor Santner (gsantner) on 24.03.16.
|
* Created by Gregor Santner (gsantner) on 24.03.16.
|
||||||
*/
|
*/
|
||||||
|
@ -36,7 +38,8 @@ public class ImageDownloadTask extends AsyncTask<String, Void, Bitmap> {
|
||||||
Bitmap bitmap = null;
|
Bitmap bitmap = null;
|
||||||
FileOutputStream out = null;
|
FileOutputStream out = null;
|
||||||
try {
|
try {
|
||||||
InputStream in = new java.net.URL(url).openStream();
|
//InputStream in = new java.net.URL(url).openStream();
|
||||||
|
InputStream in = NetCipher.getHttpsURLConnection(url).getInputStream();
|
||||||
bitmap = BitmapFactory.decodeStream(in);
|
bitmap = BitmapFactory.decodeStream(in);
|
||||||
|
|
||||||
// Save to file if not null
|
// Save to file if not null
|
||||||
|
|
|
@ -11,9 +11,12 @@ import com.github.dfa.diaspora_android.data.PodUserProfile;
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.net.HttpURLConnection;
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
|
import javax.net.ssl.HttpsURLConnection;
|
||||||
|
|
||||||
|
import info.guardianproject.netcipher.NetCipher;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Gregor Santner (gsantner) on 30.03.16.
|
* Created by Gregor Santner (gsantner) on 30.03.16.
|
||||||
*/
|
*/
|
||||||
|
@ -39,7 +42,7 @@ public class ProfileFetchTask extends AsyncTask<Void, Void, Void> {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
URL url = new URL("https://" + app.getSettings().getPodDomain() + "/stream");
|
URL url = new URL("https://" + app.getSettings().getPodDomain() + "/stream");
|
||||||
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
HttpsURLConnection conn = NetCipher.getHttpsURLConnection(url);
|
||||||
conn.setReadTimeout(10000);
|
conn.setReadTimeout(10000);
|
||||||
conn.setConnectTimeout(15000);
|
conn.setConnectTimeout(15000);
|
||||||
conn.setRequestMethod("GET");
|
conn.setRequestMethod("GET");
|
||||||
|
|
Loading…
Reference in a new issue