Skip to content

Commit 45e5c76

Browse files
committed
Remove deprecated HttpClient
1 parent eab9a46 commit 45e5c76

File tree

3 files changed

+14
-17
lines changed

3 files changed

+14
-17
lines changed

app/app.iml

-1
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,5 @@
108108
<orderEntry type="library" exported="" name="material-design-iconic-typeface-2.2.0.1" level="project" />
109109
<orderEntry type="library" exported="" name="support-annotations-23.1.1" level="project" />
110110
<orderEntry type="library" exported="" name="appcompat-v7-23.1.1" level="project" />
111-
<orderEntry type="library" exported="" name="org.apache.http.legacy-android-23" level="project" />
112111
</component>
113112
</module>

app/build.gradle

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ apply plugin: 'com.android.application'
33
android {
44
compileSdkVersion 23
55
buildToolsVersion "23.0.2"
6-
useLibrary 'org.apache.http.legacy'
76

87
defaultConfig {
98
applicationId "com.javiersantos.whatsappbetaupdater"

app/src/main/java/com/javiersantos/whatsappbetaupdater/util/UtilsAsync.java

+14-15
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@
2121
import com.javiersantos.whatsappbetaupdater.activity.MainActivity;
2222
import com.pnikosis.materialishprogress.ProgressWheel;
2323

24-
import org.apache.http.HttpResponse;
25-
import org.apache.http.client.HttpClient;
26-
import org.apache.http.client.methods.HttpGet;
27-
import org.apache.http.impl.client.DefaultHttpClient;
28-
2924
import java.io.BufferedReader;
3025
import java.io.File;
3126
import java.io.FileOutputStream;
@@ -230,6 +225,7 @@ protected Integer doInBackground(Void... voids) {
230225

231226
try {
232227
URL url = new URL(downloadUrl);
228+
233229
connection = (HttpURLConnection) url.openConnection();
234230
connection.connect();
235231
// Getting file lenght
@@ -309,17 +305,18 @@ protected void onCancelled() {
309305
}
310306

311307
public static String getLatestWhatsAppVersion() {
312-
String res = "0.0.0.0";
313308
String source = "";
314309

315310
try {
316-
HttpClient client = new DefaultHttpClient();
317-
HttpGet request = new HttpGet(Config.WHATSAPP_URL_CDN);
318-
HttpResponse response = client.execute(request);
311+
URL url = new URL(Config.WHATSAPP_URL_CDN);
319312

320-
InputStream in = response.getEntity().getContent();
321-
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
313+
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
314+
connection.connect();
315+
316+
InputStream in = connection.getInputStream();
317+
BufferedReader reader = new BufferedReader(new InputStreamReader(in, "UTF-8"));
322318
StringBuilder str = new StringBuilder();
319+
323320
String line;
324321
while((line = reader.readLine()) != null) {
325322
if (line.contains(Config.PATTERN_LATEST_VERSION)) {
@@ -345,13 +342,15 @@ public static String getLatestAppVersion() {
345342
String source = "";
346343

347344
try {
348-
HttpClient client = new DefaultHttpClient();
349-
HttpGet request = new HttpGet(Config.GITHUB_TAGS);
350-
HttpResponse response = client.execute(request);
345+
URL url = new URL(Config.GITHUB_TAGS);
351346

352-
InputStream in = response.getEntity().getContent();
347+
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
348+
connection.connect();
349+
350+
InputStream in = connection.getInputStream();
353351
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
354352
StringBuilder str = new StringBuilder();
353+
355354
String line;
356355
while((line = reader.readLine()) != null) {
357356
str.append(line);

0 commit comments

Comments
 (0)