21
21
import com .javiersantos .whatsappbetaupdater .activity .MainActivity ;
22
22
import com .pnikosis .materialishprogress .ProgressWheel ;
23
23
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
-
29
24
import java .io .BufferedReader ;
30
25
import java .io .File ;
31
26
import java .io .FileOutputStream ;
@@ -230,6 +225,7 @@ protected Integer doInBackground(Void... voids) {
230
225
231
226
try {
232
227
URL url = new URL (downloadUrl );
228
+
233
229
connection = (HttpURLConnection ) url .openConnection ();
234
230
connection .connect ();
235
231
// Getting file lenght
@@ -309,17 +305,18 @@ protected void onCancelled() {
309
305
}
310
306
311
307
public static String getLatestWhatsAppVersion () {
312
- String res = "0.0.0.0" ;
313
308
String source = "" ;
314
309
315
310
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 );
319
312
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" ));
322
318
StringBuilder str = new StringBuilder ();
319
+
323
320
String line ;
324
321
while ((line = reader .readLine ()) != null ) {
325
322
if (line .contains (Config .PATTERN_LATEST_VERSION )) {
@@ -345,13 +342,15 @@ public static String getLatestAppVersion() {
345
342
String source = "" ;
346
343
347
344
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 );
351
346
352
- InputStream in = response .getEntity ().getContent ();
347
+ HttpURLConnection connection = (HttpURLConnection ) url .openConnection ();
348
+ connection .connect ();
349
+
350
+ InputStream in = connection .getInputStream ();
353
351
BufferedReader reader = new BufferedReader (new InputStreamReader (in ));
354
352
StringBuilder str = new StringBuilder ();
353
+
355
354
String line ;
356
355
while ((line = reader .readLine ()) != null ) {
357
356
str .append (line );
0 commit comments